mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
Merge branch 'master' into 274-textinput-add-warn-prop
This commit is contained in:
commit
451eac7b40
2 changed files with 21 additions and 0 deletions
|
@ -16,6 +16,7 @@ export const Default = () => ({
|
|||
open: boolean("Open (open)", true),
|
||||
passiveModal: boolean("Without footer (passiveModal)", false),
|
||||
danger: boolean("Danger mode (danger)", false),
|
||||
alert: boolean('Alert mode (alert)', false),
|
||||
shouldSubmitOnEnter: boolean(
|
||||
"Enter key to submit (shouldSubmitOnEnter)",
|
||||
false
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
*/
|
||||
export let danger = false;
|
||||
|
||||
/**
|
||||
* Set to `true` to enable alert mode
|
||||
* @type {boolean} [alert=false]
|
||||
*/
|
||||
export let alert = false;
|
||||
|
||||
/**
|
||||
* Set to `true` to use the passive variant
|
||||
* @type {boolean} [passiveModal=false]
|
||||
|
@ -147,8 +153,20 @@
|
|||
|
||||
$: modalLabelId = `bx--modal-header__label--modal-${id}`;
|
||||
$: modalHeadingId = `bx--modal-header__heading--modal-${id}`;
|
||||
$: modalBodyId = `bx--modal-body--${id}`;
|
||||
$: ariaLabel =
|
||||
modalLabel || $$props["aria-label"] || modalAriaLabel || modalHeading;
|
||||
|
||||
let alertDialogProps = {};
|
||||
$: if (alert) {
|
||||
if (passiveModal) {
|
||||
alertDialogProps.role = "alert";
|
||||
}
|
||||
if (!passiveModal) {
|
||||
alertDialogProps.role = "alertdialog";
|
||||
alertDialogProps["aria-describedby"] = modalBodyId;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
@ -182,6 +200,7 @@
|
|||
<div
|
||||
bind:this="{innerModal}"
|
||||
role="dialog"
|
||||
{...alertDialogProps}
|
||||
aria-modal="true"
|
||||
aria-label="{ariaLabel}"
|
||||
class:bx--modal-container="{true}"
|
||||
|
@ -230,6 +249,7 @@
|
|||
{/if}
|
||||
</div>
|
||||
<div
|
||||
id="{modalBodyId}"
|
||||
class:bx--modal-content="{true}"
|
||||
class:bx--modal-content--with-form="{hasForm}"
|
||||
class:bx--modal-scroll-content="{hasScrollingContent}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue