Skip to content
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

feat(dialog): use native HTML dialog element #2078

Merged
merged 58 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
de89a75
feat(dialog): use native `<dialog>` element
adamjohnson Dec 4, 2024
4a5f066
chore(dialog): add changeset
adamjohnson Dec 4, 2024
6832da6
fix(dialog): update color values to use new semantic tokens
adamjohnson Dec 5, 2024
9e1b552
fix(dialog): make surface wrap only dialog/modal
adamjohnson Dec 5, 2024
fb0dfda
docs(dialog): update a11y docs around focus and focus order
adamjohnson Dec 5, 2024
3f8d621
fix(dialog): add `accessible-label` to the `no-headings.html` demo
adamjohnson Dec 5, 2024
236f8c1
fix(dialog): update content in `no-header-content.html` demo
adamjohnson Dec 5, 2024
74ee1a6
fix(dialog): horizontally center dialogs with `variant`/`width` attri…
adamjohnson Dec 5, 2024
bf34916
fix(dialog): position top / modal width variants sizing
adamjohnson Dec 6, 2024
e8ef16a
fix(dialog): add `rh-*` elements to list of focusable selectors.
adamjohnson Dec 6, 2024
21f25fd
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 6, 2024
a3d886d
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 9, 2024
f659249
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 10, 2024
4eff705
fix(dialog): update close button spacing/height/width.
adamjohnson Dec 9, 2024
accb3f6
fix(dialog): re-add `--rh-dialog-close-button-color`
adamjohnson Dec 13, 2024
4ded108
fix(dialog): decrease close button size, fix video modal close button…
adamjohnson Dec 13, 2024
0947d16
fix(dialog): add close button color variable to icon declaration
adamjohnson Dec 13, 2024
e275b6f
fix(dialog): remove `trapFocus();` function
adamjohnson Dec 13, 2024
03fef8d
chore(dialog): update changeset wording about overlay
adamjohnson Dec 13, 2024
d1c59fc
fix(dialog): add `href` to `rh-cta` host
adamjohnson Dec 13, 2024
4dab6fb
fix(dialog): add `href` to `rh-cta` host
adamjohnson Dec 13, 2024
acc962a
docs(dialog): update accessible name wording on a11y page
adamjohnson Dec 13, 2024
48a29a1
docs(dialog): a11y accessible label wording
adamjohnson Dec 13, 2024
cd53da9
docs(dialog): tweak accessible label fallback text wording
adamjohnson Dec 13, 2024
a7ef98b
docs(dialog): spelling fix
adamjohnson Dec 13, 2024
2eb2add
docs(dialog): a11y name jsdoc wording
adamjohnson Dec 13, 2024
fb242b0
fix(dialog): add `href` to CTA host's in all demos
adamjohnson Dec 13, 2024
1399bee
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 13, 2024
0ff425f
docs(dialog): add and improve JSDoc formatting
adamjohnson Dec 16, 2024
c292dbe
refactor(dialog): use IDREF's for styling shadowdom
adamjohnson Dec 16, 2024
303f85f
docs(dialog): a11y focus order and a11y name content
adamjohnson Dec 16, 2024
250a437
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 16, 2024
fde7762
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Dec 17, 2024
3b9e903
fix(dialog): only `sticky` the header when there's enough space
adamjohnson Dec 17, 2024
4993118
fix(dialog): add surface background color to close button
adamjohnson Dec 17, 2024
7ced6d6
fix(dialog): add padding to sticky `#header`
adamjohnson Dec 17, 2024
fea2b29
Merge branch 'feat/dialog/use-native-dialog-element-v2' of github.com…
adamjohnson Dec 17, 2024
0c6b775
fix(dialog): add space to bottom of `#header`
adamjohnson Dec 18, 2024
f7d1fc4
fix(dialog): prevent header space from covering body content
adamjohnson Dec 18, 2024
93fbfd5
docs(dialog): update demo wording
adamjohnson Jan 2, 2025
06c2334
fix(dialog): remove `#onKeyDown` from `disconnectedCallback()`
adamjohnson Jan 2, 2025
b9c4011
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Jan 2, 2025
34d7598
docs(dialog): add extra note on `overlay` depreciation to changeset
adamjohnson Jan 2, 2025
db066c1
fix(dialog): ensure `#body` paragraph spacing is correct
adamjohnson Jan 2, 2025
1848cfa
fix(dialog): remove `closeOnOutsideClick` static
adamjohnson Jan 2, 2025
a994deb
refactor(dialog): remove `@bound` from `onClick()` method
adamjohnson Jan 2, 2025
887682d
fix(dialog): remove outdated tab/shift+tab methods
adamjohnson Jan 2, 2025
4d1ecb5
refactor(dialog): remove `@bound` from public methods
adamjohnson Jan 2, 2025
1d3abdc
fix(dialog): simplify color-palette logic
adamjohnson Jan 3, 2025
541b0ed
Merge branch 'main' into feat/dialog/use-native-dialog-element-v2
adamjohnson Jan 6, 2025
6745875
fix(dialog): allow `sm`/`md`/`lg` variants for video dialogs
adamjohnson Jan 10, 2025
cf140d5
docs(dialog): update images and some content, remove old images
marionnegp Jan 31, 2025
ac98eb2
docs(dialog): fix relative link
marionnegp Jan 31, 2025
fc489aa
refactor(dialog): rename `offset` vars to be private
adamjohnson Feb 6, 2025
267f965
Merge branch 'staging/cubone' into feat/dialog/use-native-dialog-elem…
adamjohnson Feb 6, 2025
bb91af5
fix(dialog): update font family variable fallbacks
adamjohnson Feb 6, 2025
9ebd037
docs(dialog): fix video dialog image and remove old images
marionnegp Feb 7, 2025
6f48698
Merge branch 'staging/cubone' into feat/dialog/use-native-dialog-elem…
bennypowers Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-gifts-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rhds/elements": patch
---

`<rh-dialog>`: Aligned CSS variable naming with privacy conventions by prefixing the undocumented `--offset`, `--offset-top`, and `--offset-right` variables with an underscore, marking them as private (`--_offset`, `--_offset-top`, `--_offset-right`).
21 changes: 21 additions & 0 deletions .changeset/loud-coins-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@rhds/elements": minor
---

`<rh-dialog>`: Dialog now uses the native HTML `<dialog>` element internally.

Note: the `overlay` CSS shadow part is now deprecated in favor of the `--rh-dialog-backdrop-background-color` CSS custom property. It will still work, but you can expect the `overlay` part to be removed in a future version

Before:

```css
rh-dialog::part(overlay) { ... }
```

After:

```css
rh-dialog {
--rh-dialog-backdrop-background-color: ghostwhite;
}
```
4 changes: 1 addition & 3 deletions elements/rh-dialog/demo/color-context.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ <h2 slot="header">Color Context</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec sed
odio dui. Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<rh-cta slot="footer">
<a href="#bar">Learn more</a>
</rh-cta>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>
<rh-button id="context-trigger">Open Dialog</rh-button>
</rh-context-demo>
Expand Down
4 changes: 1 addition & 3 deletions elements/rh-dialog/demo/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ <h2 slot="header">Modal dialog with a header</h2>
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<rh-cta>
<a href="#bar">Learn more</a>
</rh-cta>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>
<rh-button id="trigger">Open</rh-button>
<fieldset>
Expand Down
4 changes: 1 addition & 3 deletions elements/rh-dialog/demo/lots-of-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ <h2 slot="header">Modal with a header with a truly excessive super duper long ti
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec sed
odio dui. Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<rh-cta slot="footer">
<a href="#bar">Learn more</a>
</rh-cta>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>

<script type="module">
Expand Down
8 changes: 3 additions & 5 deletions elements/rh-dialog/demo/no-header-content.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<rh-button id="no-header-content-trigger">Open</rh-button>
<rh-dialog trigger="no-header-content-trigger">
<p>A modal with no slotted header content</p>
<h3>This has no header content</h3>
<h2>This dialog has no slotted header content</h2>
<p>All this content exists in the default slot.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.</p>
<rh-cta id="test-dark-child">
<a href="#">Call-to-action</a>
</rh-cta>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>

<script type="module">
Expand Down
17 changes: 8 additions & 9 deletions elements/rh-dialog/demo/no-headings.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<rh-button id="no-headings-trigger">Open</rh-button>
<rh-dialog trigger="no-headings-trigger">
<p>This modal doesn't have any headings. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.</p>
<rh-cta>
<a href="#">Call-to-action</a>
</rh-cta>
<rh-dialog accessible-label="This dialog's accessible name" trigger="no-headings-trigger">
<p>This dialog uses the <code>accessible-label</code> attribute to define its accessible name for assistive technology.
If the dialog includes a heading, the heading automatically becomes its accessible name—as long as the
<code>accessible-label</code> attribute does not exist. If neither a heading nor the <code>accessible-label</code>
attribute are provided, the dialog's accessible name defaults to the text content of its trigger element.
Learn more about these attributes in the <a href="https://ux.redhat.com/elements/dialog/code/">rh-dialog docs</a>.
</p>
<rh-cta slot="footer" href="#">Call to Action</rh-cta>
</rh-dialog>

<script type="module">
Expand Down
4 changes: 1 addition & 3 deletions elements/rh-dialog/demo/rh-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ <h2 slot="header">Modal dialog with a header</h2>
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<rh-cta>
<a href="#bar">Learn more</a>
</rh-cta>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>

<script type="module">
Expand Down
101 changes: 14 additions & 87 deletions elements/rh-dialog/docs/10-style.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
## Style

A dialog is a floating container on top of a transparent backdrop. The container
requires a backdrop so it can separate itself from the page underneath, this
requires a backdrop so it can separate itself from the page underneath. This
helps users focus on the dialog content.

### Anatomy

<figure>
<uxdot-example width-adjustment="872px">
<img src="../dialog-anatomy.png"
<img src="../dialog-anatomy.svg"
alt="Anatomy of a dialog with lots of annotations pointing to various parts"
width="872"
height="322">
height="295">
</uxdot-example>
<figcaption>
<ol>
Expand All @@ -31,22 +31,10 @@ helps users focus on the dialog content.
A dialog is available in the light theme only.

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-theme-light.png"
<img src="../dialog-theme-light.svg"
alt="Light theme dialog"
width="1000"
height="322">
</uxdot-example>

## Configuration

The dialog container does not have a maximum height, but too much content in the
body text section will cause scrolling.

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-configuration.png"
alt="How a dialog container is constructed showing border radius, region, and scrolling details"
width="1000"
height="640">
height="327">
</uxdot-example>

## Space
Expand All @@ -56,16 +44,16 @@ The amount of space in a dialog reduces as breakpoints get smaller.
### Large breakpoints

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-space-breakpoint-large.png"
<img src="../dialog-space-breakpoint-large.svg"
alt="A dialog container on a large breakpoint with spacing between all elements"
width="1000"
height="322">
height="327">
</uxdot-example>

### Small breakpoints

<uxdot-example width-adjustment="360px" variant="full" alignment="left" no-border>
<img src="../dialog-space-breakpoint-small.png"
<img src="../dialog-space-breakpoint-small.svg"
alt="A dialog container on a small breakpoint with spacing between all elements"
width="360"
height="640">
Expand All @@ -83,93 +71,32 @@ interaction states.

### Hover

Control and inactive page number buttons have the same hover state. Truncation
is not interactive so it has no hover state.

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-interaction-state-hover.png"
<img src="../dialog-interaction-state-hover.svg"
alt="Light theme dialog hover state example"
width="1000"
height="322">
height="327">
</uxdot-example>

<rh-table>
<table>
<thead>
<tr>
<th scope="col" data-label="Property">Property</th>
<th scope="col" data-label="Light theme">Light theme</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Property">Color - close button</td>
<td data-label="Light theme">#151515</td>
</tr>
</tbody>
</table>
</rh-table>


### Focus

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-interaction-state-focus.png"
<img src="../dialog-interaction-state-focus.svg"
alt="Light theme dialog focus state example"
width="1000"
height="322">
height="327">
</uxdot-example>

<rh-table>
<table>
<thead>
<tr>
<th scope="col" data-label="Property">Property</th>
<th scope="col" data-label="Light theme">Light theme</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Property">Color - close button</td>
<td data-label="Light theme">#151515</td>
</tr>
<tr>
<td data-label="Property">Color - focus ring</td>
<td data-label="Light theme">#0066cc</td>
</tr>
</tbody>
</table>
</rh-table>

### Active

<uxdot-example width-adjustment="1000px" variant="full" alignment="left" no-border>
<img src="../dialog-interaction-state-active.png"
<img src="../dialog-interaction-state-active.svg"
alt="Light theme dialog active state example"
width="1000"
height="322">
height="327">
</uxdot-example>

<rh-table>
<table>
<thead>
<tr>
<th scope="col" data-label="Property">Property</th>
<th scope="col" data-label="Light theme">Light theme</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Property">Color - close button</td>
<td data-label="Light theme">#151515</td>
</tr>
<tr>
<td data-label="Property">Color - focus ring</td>
<td data-label="Light theme">#0066cc</td>
</tr>
</tbody>
</table>
</rh-table>



Loading