Skip to content

Commit

Permalink
feat(modal): add dialog part & add customCss option in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Leotheluck authored and dpellier committed Jul 29, 2024
1 parent 13411ae commit 7c625e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class OdsModal {
<dialog class='ods-modal__dialog'
ref={ (el) => this.modalDialog = el as HTMLDialogElement }
onClick={ (event) => this.handleBackdropClick(event) }
part='dialog'
>
<div class='ods-modal__backdrop'></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A Modal component is used to overlay with important content the main view of a s

# Style customization

You can update the modal's content by directly updating the slot elements.
You can update the modal's content by directly updating the slot elements. You can also update it using the `::part(dialog)`.

Custom modal css:

Expand Down
27 changes: 21 additions & 6 deletions packages/storybook/stories/components/modal/modal.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ export const Demo: StoryObj = {
${unsafeHTML(args.actions)}
</ods-modal>
<style>
.modal-demo .my-text::part(text) {
margin: 0 0 1rem 0;
}
.modal-demo ods-button::part(button) {
margin-top: 1rem;
}
${unsafeHTML(args.customCss)}
</style>
`,
argTypes: orderControls({
Expand Down Expand Up @@ -69,6 +64,14 @@ export const Demo: StoryObj = {
},
control: 'text',
},
customCss: {
table: {
category: CONTROL_CATEGORY.design,
defaultValue: { summary: 'ø' },
},
control: 'text',
description: 'Set a custom style properties. Example: "ods-modal::part(dialog) { border: 1px red solid; }"',
}
}),
args: {
isOpen: true,
Expand All @@ -80,6 +83,13 @@ export const Demo: StoryObj = {
actions:
`<ods-button label="Migration guide" slot="actions" variant="outline" icon="upload"></ods-button>
<ods-button label="Documentation" slot="actions" icon="book"></ods-button>`,
customCss:
`.modal-demo .my-text::part(text) {
margin: 0 0 1rem 0;
}
.modal-demo ods-button::part(button) {
margin-top: 1rem;
}`
},
};

Expand Down Expand Up @@ -149,6 +159,11 @@ export const CustomCSS: StoryObj = {
.modal-custom-css .my-text {
color: red;
}
.modal-custom-css::part(dialog) {
border: .5rem red solid;
height: 90%;
}
</style>
`,
};
Expand Down

0 comments on commit 7c625e7

Please sign in to comment.