-
Notifications
You must be signed in to change notification settings - Fork 684
Updates on Sites page #18558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 6.x
Are you sure you want to change the base?
Updates on Sites page #18558
Changes from 13 commits
4c853f9
8870c05
8bc92c9
f57df1f
6ca856d
842a367
e0ba8c3
c4b6669
fe84f7e
5102b38
0a952b1
cccc78a
92ab155
bfd3650
5b62a15
58f2069
e5d3b3a
9eff3a0
bc7342d
4bfa1fc
7bae29c
11d449b
62b35f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import type {Meta, StoryObj} from '@storybook/web-components-vite'; | ||
| import {expect} from 'storybook/test'; | ||
|
|
||
| import {html} from 'lit'; | ||
|
|
||
| import './modal.js'; | ||
|
|
||
| // More on how to set up stories at: https://storybook.js.org/docs/writing-stories | ||
| const meta = { | ||
| title: 'Components/Modal', | ||
| component: 'craft-modal', | ||
| args: {}, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| render: function (args) { | ||
| return html` | ||
| <craft-modal> | ||
| <craft-button slot="invoker">Open Modal</craft-button> | ||
| <div slot="content"> | ||
| This is the body content | ||
| <craft-button | ||
| @click="${(event: Event) => | ||
| event.target?.dispatchEvent( | ||
| new Event('close-overlay', {bubbles: true}) | ||
| )}" | ||
| >Close</craft-button | ||
| > | ||
| </div> | ||
| </craft-modal> | ||
| `; | ||
| }, | ||
| } satisfies Meta<any>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<any>; | ||
|
|
||
| // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
| export const Default: Story = { | ||
| args: {}, | ||
| play: async ({canvas, userEvent}) => { | ||
| const openBtn = canvas.getByShadowText(/Open Modal/i); | ||
| const closeBtn = canvas.getByText(/Close/i); | ||
| await userEvent.click(openBtn); | ||
|
|
||
| const modal = canvas.getByShadowRole('dialog'); | ||
| await expect(modal).toHaveClass('overlays__overlay'); | ||
| await userEvent.click(closeBtn); | ||
| await expect(modal).not.toHaveClass('overlays__overlay'); | ||
| await expect(openBtn).toHaveFocus(); | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import {css} from 'lit'; | ||
|
|
||
| export default css` | ||
| ::slotted([slot='content']) { | ||
| display: block; | ||
| background-color: white; | ||
| border-radius: var(--c-modal-radius); | ||
| border-width: var(--c-modal-border-width); | ||
| border-style: var(--c-modal-border-style); | ||
| border-color: var(--c-modal-border-color); | ||
gcamacho079 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| `; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import type {CSSResultGroup, PropertyValues} from 'lit'; | ||
| import {html, LitElement} from 'lit'; | ||
| import {property} from 'lit/decorators.js'; | ||
| import {OverlayMixin, withModalDialogConfig} from '@lion/ui/overlays.js'; | ||
| import styles from './modal.styles'; | ||
|
|
||
| /** | ||
| * @summary Modal that extends the LionDialog web component | ||
| */ | ||
| export default class CraftModal extends OverlayMixin(LitElement) { | ||
| @property({type: String}) | ||
| name: string; | ||
gcamacho079 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // @ts-ignore | ||
| _defineOverlayConfig() { | ||
| return { | ||
| ...withModalDialogConfig(), | ||
| }; | ||
| } | ||
|
|
||
| static override get styles(): CSSResultGroup { | ||
| return [super.styles ?? [], styles]; | ||
| } | ||
|
|
||
| /** | ||
| * Applies an aria-label to the content node with the name property. | ||
| */ | ||
| __setAccessibleName() { | ||
| const contentNode = this._overlayContentNode; | ||
|
|
||
| if (contentNode) { | ||
| if (!this.name) return; | ||
| contentNode.setAttribute('aria-label', this.name); | ||
| } | ||
| } | ||
|
|
||
| override firstUpdated(c: PropertyValues<this>) { | ||
| super.firstUpdated(c); | ||
|
|
||
| if (c.has('name')) { | ||
| this.__setAccessibleName(); | ||
| } | ||
| } | ||
|
|
||
| override updated(c: PropertyValues<this>) { | ||
gcamacho079 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| super.updated(c); | ||
|
|
||
| if (c.has('name')) { | ||
| this.__setAccessibleName(); | ||
| } | ||
| } | ||
|
|
||
| override render() { | ||
| return html` | ||
| <slot name="invoker"></slot> | ||
| <div id="overlay-content-node-wrapper"> | ||
| <slot name="content"></slot> | ||
| </div> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| if (!customElements.get('craft-modal')) { | ||
| customElements.define('craft-modal', CraftModal); | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'craft-modal': CraftModal; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,7 @@ export {default as CraftPopover} from './components/popover/popover.js'; | |||||
| export {default as CraftNavList} from './components/nav-list/nav-list.js'; | ||||||
| export {default as CraftNavItem} from './components/nav-item/nav-item.js'; | ||||||
| export {default as CraftDrawer} from './components/drawer/drawer.js'; | ||||||
| export {default as CraftDialog} from './components/dialog/dialog.js'; | ||||||
| export {default as CraftModal} from '@src/components/modal/modal.js'; | ||||||
|
||||||
| export {default as CraftModal} from '@src/components/modal/modal.js'; | |
| export {default as CraftModal} from './components/modal/modal.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CraftActionMenuno longer closes when a menu item is clicked (the previousclicklisteners that dispatchedclose-overlaywere removed). IfwithDropdownConfig()doesn’t hide on inside clicks, this is a UX regression across all menus. Consider restoring click-to-close behavior via event delegation on_overlayContentNode(or an overlay config option) so selecting an action consistently closes the menu.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently a work-in-progress. 👍🏼 Trying to think through the best way to handle this while maintaining the “trigger stack” so we don’t have to manually manage focus when a modal is closed and the trigger element can’t be found.