@porsche-design-system/components-react 4.7.0 → 4.8.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -1
- package/cjs/hooks.cjs +1 -5
- package/cjs/lib/components/checkbox.wrapper.cjs +3 -3
- package/cjs/lib/components/input-date.wrapper.cjs +3 -3
- package/cjs/lib/components/input-email.wrapper.cjs +3 -3
- package/cjs/lib/components/input-month.wrapper.cjs +3 -3
- package/cjs/lib/components/input-number.wrapper.cjs +3 -3
- package/cjs/lib/components/input-password.wrapper.cjs +3 -3
- package/cjs/lib/components/input-tel.wrapper.cjs +3 -3
- package/cjs/lib/components/input-text.wrapper.cjs +3 -3
- package/cjs/lib/components/input-time.wrapper.cjs +3 -3
- package/cjs/lib/components/input-url.wrapper.cjs +3 -3
- package/cjs/lib/components/input-week.wrapper.cjs +3 -3
- package/cjs/lib/components/multi-select.wrapper.cjs +3 -3
- package/cjs/lib/components/select.wrapper.cjs +3 -3
- package/cjs/lib/components/switch.wrapper.cjs +3 -3
- package/cjs/lib/components/textarea.wrapper.cjs +3 -3
- package/esm/hooks.d.ts +0 -3
- package/esm/hooks.mjs +2 -5
- package/esm/lib/components/checkbox.wrapper.d.ts +9 -1
- package/esm/lib/components/checkbox.wrapper.mjs +3 -3
- package/esm/lib/components/input-date.wrapper.d.ts +9 -1
- package/esm/lib/components/input-date.wrapper.mjs +3 -3
- package/esm/lib/components/input-email.wrapper.d.ts +9 -1
- package/esm/lib/components/input-email.wrapper.mjs +3 -3
- package/esm/lib/components/input-month.wrapper.d.ts +9 -1
- package/esm/lib/components/input-month.wrapper.mjs +3 -3
- package/esm/lib/components/input-number.wrapper.d.ts +9 -1
- package/esm/lib/components/input-number.wrapper.mjs +3 -3
- package/esm/lib/components/input-password.wrapper.d.ts +9 -1
- package/esm/lib/components/input-password.wrapper.mjs +3 -3
- package/esm/lib/components/input-search.wrapper.d.ts +2 -2
- package/esm/lib/components/input-tel.wrapper.d.ts +9 -1
- package/esm/lib/components/input-tel.wrapper.mjs +3 -3
- package/esm/lib/components/input-text.wrapper.d.ts +9 -1
- package/esm/lib/components/input-text.wrapper.mjs +3 -3
- package/esm/lib/components/input-time.wrapper.d.ts +9 -1
- package/esm/lib/components/input-time.wrapper.mjs +3 -3
- package/esm/lib/components/input-url.wrapper.d.ts +9 -1
- package/esm/lib/components/input-url.wrapper.mjs +3 -3
- package/esm/lib/components/input-week.wrapper.d.ts +9 -1
- package/esm/lib/components/input-week.wrapper.mjs +3 -3
- package/esm/lib/components/link-pure.wrapper.d.ts +2 -2
- package/esm/lib/components/link-tile-product.wrapper.d.ts +2 -2
- package/esm/lib/components/link.wrapper.d.ts +2 -2
- package/esm/lib/components/multi-select.wrapper.d.ts +9 -1
- package/esm/lib/components/multi-select.wrapper.mjs +3 -3
- package/esm/lib/components/select.wrapper.d.ts +9 -1
- package/esm/lib/components/select.wrapper.mjs +3 -3
- package/esm/lib/components/switch.wrapper.d.ts +9 -1
- package/esm/lib/components/switch.wrapper.mjs +3 -3
- package/esm/lib/components/textarea.wrapper.d.ts +9 -1
- package/esm/lib/components/textarea.wrapper.mjs +3 -3
- package/esm/lib/types.d.ts +22 -1
- package/package.json +2 -2
- package/skills/pds-audit-deprecations-react/SKILL.md +2 -2
- package/skills/pds-knowledge-react/SKILL.md +14 -5
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/DynamicSlides.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/FocusOnCenterSlide.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/JumpToSlide.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-checkbox/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-checkbox/p-checkbox.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-date/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-date/p-input-date.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-email/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-email/p-input-email.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-month/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-month/p-input-month.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-number/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-number/p-input-number.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-password/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-password/p-input-password.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-search/p-input-search.md +2 -1
- package/skills/pds-knowledge-react/references/components/p-input-tel/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-tel/p-input-tel.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-text/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-text/p-input-text.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-time/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-time/p-input-time.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-url/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-url/p-input-url.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-week/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-week/p-input-week.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-link/p-link.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-link-pure/p-link-pure.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-link-tile-product/p-link-tile-product.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-multi-select/accessibility.md +22 -0
- package/skills/pds-knowledge-react/references/components/p-multi-select/p-multi-select.md +14 -2
- package/skills/pds-knowledge-react/references/components/p-pin-code/p-pin-code.md +11 -3
- package/skills/pds-knowledge-react/references/components/p-select/accessibility.md +22 -0
- package/skills/pds-knowledge-react/references/components/p-select/p-select.md +14 -2
- package/skills/pds-knowledge-react/references/components/p-switch/accessibility.md +18 -0
- package/skills/pds-knowledge-react/references/components/p-switch/p-switch.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-textarea/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-textarea/p-textarea.md +12 -0
- package/skills/pds-knowledge-react/references/deprecations.md +4 -4
- package/skills/pds-knowledge-react/references/examples/patterns/feedback/dialog.md +230 -0
- package/skills/pds-knowledge-react/references/examples/patterns/feedback/inline.md +193 -0
- package/skills/pds-knowledge-react/references/examples/patterns/footer.md +250 -0
- package/skills/pds-knowledge-react/references/examples/patterns/header/overlay.md +152 -0
- package/skills/pds-knowledge-react/references/examples/patterns/header/stacked.md +122 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/feature-tour.md +243 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/local-market-switch.md +323 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/priority-navigation.md +191 -0
- package/skills/pds-knowledge-react/references/examples/templates/admin-panel.md +397 -0
- package/skills/pds-knowledge-react/references/examples/templates/landing-page.md +529 -0
- package/skills/pds-knowledge-react/references/examples.md +48 -0
- package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +18 -105
- package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +78 -156
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/hooks.cjs +1 -5
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/checkbox.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-date.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-email.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-month.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-number.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-password.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-tel.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-text.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-time.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-url.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-week.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/multi-select.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/select.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/switch.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/textarea.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/checkbox.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.cjs +2 -2
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-date.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-email.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-month.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-number.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-password.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-tel.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-text.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-time.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-url.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-week.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/label.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-pure.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-tile-product.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/multi-select.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pin-code.cjs +2 -3
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/segmented-control-item.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/select.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/stepper-horizontal.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/switch.cjs +1 -2
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs-bar.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/textarea.cjs +1 -1
- package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +18 -105
- package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +78 -150
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/hooks.mjs +2 -5
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/checkbox.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-date.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-email.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-month.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-number.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-password.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-tel.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-text.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-time.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-url.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-week.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/multi-select.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/select.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/switch.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/textarea.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/checkbox.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.mjs +3 -3
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-date.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-email.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-month.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-number.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-password.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-tel.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-text.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-time.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-url.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-week.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/label.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-pure.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-tile-product.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/multi-select.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pin-code.mjs +3 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/segmented-control-item.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/select.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/stepper-horizontal.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/switch.mjs +1 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs-bar.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/textarea.mjs +2 -2
- package/ssr/esm/hooks.d.ts +0 -3
- package/ssr/esm/lib/components/checkbox.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-date.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-email.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-month.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-number.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-password.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-search.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/input-tel.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-text.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-time.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-url.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-week.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/link-pure.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/link-tile-product.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/link.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/multi-select.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/select.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/switch.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/textarea.wrapper.d.ts +9 -1
- package/ssr/esm/lib/dsr-components/label.d.ts +1 -0
- package/ssr/esm/lib/dsr-components/link-pure.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/link-tile-product.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/link.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/stepper-horizontal.d.ts +0 -1
- package/ssr/esm/lib/dsr-components/tabs-bar.d.ts +0 -1
- package/ssr/esm/lib/dsr-components/tabs.d.ts +0 -1
- package/ssr/esm/lib/types.d.ts +22 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Popover: Feature tour
|
|
2
|
+
|
|
3
|
+
On first visit, a sequence of popovers guides the user through the key areas of the interface one step at a time ("Step 2 of 4", Back / Next / Skip), each anchored to the element it describes. Only a single step is open at once.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-button-pure`](../../../components/p-button-pure/p-button-pure.md), [`p-crest`](../../../components/p-crest/p-crest.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-popover`](../../../components/p-popover/p-popover.md), [`p-text`](../../../components/p-text/p-text.md), [`p-wordmark`](../../../components/p-wordmark/p-wordmark.md)
|
|
7
|
+
- **Conventions and stylesheet:** shared by all examples, see [examples.md](../../../examples.md)
|
|
8
|
+
|
|
9
|
+
## Markup
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<body>
|
|
14
|
+
<header class="grid-template border-b border-contrast-lower">
|
|
15
|
+
<div class="col-wide grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] gap-fluid-md items-center min-h-[80px]">
|
|
16
|
+
<div class="flex flex-wrap gap-static-md items-center justify-start">
|
|
17
|
+
<p-popover class="[--p-popover-w:20rem]" open data-tour-step="true">
|
|
18
|
+
<p-button-pure
|
|
19
|
+
slot="button"
|
|
20
|
+
class="p-static-xs -m-static-xs"
|
|
21
|
+
type="button"
|
|
22
|
+
icon="menu-lines"
|
|
23
|
+
hide-label="{ base: true, s: false }"
|
|
24
|
+
>
|
|
25
|
+
Menu
|
|
26
|
+
</p-button-pure>
|
|
27
|
+
<div class="grid gap-static-sm">
|
|
28
|
+
<div class="flex items-center justify-between gap-static-md">
|
|
29
|
+
<p-text size="xs" color="contrast-medium">Step 1 of 4</p-text>
|
|
30
|
+
<p-button-pure
|
|
31
|
+
class="shrink-0 p-static-xs -m-static-xs"
|
|
32
|
+
type="button"
|
|
33
|
+
icon="close"
|
|
34
|
+
hide-label="true"
|
|
35
|
+
data-tour="skip"
|
|
36
|
+
>
|
|
37
|
+
Dismiss tips
|
|
38
|
+
</p-button-pure>
|
|
39
|
+
</div>
|
|
40
|
+
<p-heading tag="h2" size="sm" weight="semibold">Main navigation</p-heading>
|
|
41
|
+
<p-text>Open the menu to explore every section of the site.</p-text>
|
|
42
|
+
<div class="flex gap-static-sm">
|
|
43
|
+
<p-button type="button" compact="true" data-tour="next">Next</p-button>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</p-popover>
|
|
47
|
+
</div>
|
|
48
|
+
<p-crest class="sm:hidden" href="#"></p-crest>
|
|
49
|
+
<p-wordmark class="max-sm:hidden" href="#"></p-wordmark>
|
|
50
|
+
<div class="flex flex-wrap gap-static-md items-center justify-end">
|
|
51
|
+
<p-popover class="[--p-popover-w:20rem]" data-tour-step="true">
|
|
52
|
+
<p-button-pure slot="button" class="p-static-xs -m-static-xs" type="button" icon="search" hide-label="true">
|
|
53
|
+
Search
|
|
54
|
+
</p-button-pure>
|
|
55
|
+
<div class="grid gap-static-sm">
|
|
56
|
+
<div class="flex items-center justify-between gap-static-md">
|
|
57
|
+
<p-text size="xs" color="contrast-medium">Step 2 of 4</p-text>
|
|
58
|
+
<p-button-pure
|
|
59
|
+
class="shrink-0 p-static-xs -m-static-xs"
|
|
60
|
+
type="button"
|
|
61
|
+
icon="close"
|
|
62
|
+
hide-label="true"
|
|
63
|
+
data-tour="skip"
|
|
64
|
+
>
|
|
65
|
+
Dismiss tips
|
|
66
|
+
</p-button-pure>
|
|
67
|
+
</div>
|
|
68
|
+
<p-heading tag="h2" size="sm" weight="semibold">Search</p-heading>
|
|
69
|
+
<p-text>Find models, dealers and content from anywhere on the site.</p-text>
|
|
70
|
+
<div class="flex gap-static-sm">
|
|
71
|
+
<p-button type="button" variant="secondary" compact="true" data-tour="back">Back</p-button>
|
|
72
|
+
<p-button type="button" compact="true" data-tour="next">Next</p-button>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</p-popover>
|
|
76
|
+
<p-popover class="[--p-popover-w:20rem]" data-tour-step="true">
|
|
77
|
+
<p-button-pure slot="button" class="p-static-xs -m-static-xs" type="button" icon="bell" hide-label="true">
|
|
78
|
+
Notifications
|
|
79
|
+
</p-button-pure>
|
|
80
|
+
<div class="grid gap-static-sm">
|
|
81
|
+
<div class="flex items-center justify-between gap-static-md">
|
|
82
|
+
<p-text size="xs" color="contrast-medium">Step 3 of 4</p-text>
|
|
83
|
+
<p-button-pure
|
|
84
|
+
class="shrink-0 p-static-xs -m-static-xs"
|
|
85
|
+
type="button"
|
|
86
|
+
icon="close"
|
|
87
|
+
hide-label="true"
|
|
88
|
+
data-tour="skip"
|
|
89
|
+
>
|
|
90
|
+
Dismiss tips
|
|
91
|
+
</p-button-pure>
|
|
92
|
+
</div>
|
|
93
|
+
<p-heading tag="h2" size="sm" weight="semibold">Notifications</p-heading>
|
|
94
|
+
<p-text>Your latest updates and messages appear right here.</p-text>
|
|
95
|
+
<div class="flex gap-static-sm">
|
|
96
|
+
<p-button type="button" variant="secondary" compact="true" data-tour="back">Back</p-button>
|
|
97
|
+
<p-button type="button" compact="true" data-tour="next">Next</p-button>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</p-popover>
|
|
101
|
+
<p-popover class="[--p-popover-w:20rem]" data-tour-step="true">
|
|
102
|
+
<p-button-pure slot="button" class="p-static-xs -m-static-xs" type="button" icon="user" hide-label="true">
|
|
103
|
+
Your account
|
|
104
|
+
</p-button-pure>
|
|
105
|
+
<div class="grid gap-static-sm">
|
|
106
|
+
<div class="flex items-center justify-between gap-static-md">
|
|
107
|
+
<p-text size="xs" color="contrast-medium">Step 4 of 4</p-text>
|
|
108
|
+
<p-button-pure
|
|
109
|
+
class="shrink-0 p-static-xs -m-static-xs"
|
|
110
|
+
type="button"
|
|
111
|
+
icon="close"
|
|
112
|
+
hide-label="true"
|
|
113
|
+
data-tour="skip"
|
|
114
|
+
>
|
|
115
|
+
Dismiss tips
|
|
116
|
+
</p-button-pure>
|
|
117
|
+
</div>
|
|
118
|
+
<p-heading tag="h2" size="sm" weight="semibold">Your account</p-heading>
|
|
119
|
+
<p-text>Manage your profile, orders and settings from here.</p-text>
|
|
120
|
+
<div class="flex gap-static-sm">
|
|
121
|
+
<p-button type="button" variant="secondary" compact="true" data-tour="back">Back</p-button>
|
|
122
|
+
<p-button type="button" compact="true" data-tour="next">Done</p-button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</p-popover>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</header>
|
|
129
|
+
<main id="main" class="grid-template">
|
|
130
|
+
<section class="col-wide my-fluid-lg grid gap-fluid-md">
|
|
131
|
+
<p-heading tag="h1" size="xl">Feature tour</p-heading>
|
|
132
|
+
<p-text>
|
|
133
|
+
On first visit, a sequence of popovers walks the user through the key areas of the interface, one step at a
|
|
134
|
+
time. Only a single step is open at once.
|
|
135
|
+
</p-text>
|
|
136
|
+
<p-button class="justify-self-start" id="restart-tour" type="button" variant="secondary" icon="refresh">
|
|
137
|
+
Restart tour
|
|
138
|
+
</p-button>
|
|
139
|
+
</section>
|
|
140
|
+
</main>
|
|
141
|
+
<script type="module" src="main.js"></script>
|
|
142
|
+
</body>
|
|
143
|
+
</html>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Script
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
// DO NOT USE IN PRODUCTION!
|
|
150
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
151
|
+
|
|
152
|
+
// Behaviour of the feature tour: exactly one coachmark is open at a time, and the sequence can be walked with the
|
|
153
|
+
// keyboard alone.
|
|
154
|
+
//
|
|
155
|
+
// Every step is used in *controlled* mode, so the open state lives here rather than in the components – that is
|
|
156
|
+
// what makes "open the next one and close the current one" a single, atomic step.
|
|
157
|
+
|
|
158
|
+
const steps = Array.from(document.querySelectorAll('[data-tour-step]'));
|
|
159
|
+
const restartButton = document.getElementById('restart-tour');
|
|
160
|
+
|
|
161
|
+
let current = 0;
|
|
162
|
+
|
|
163
|
+
// The controls of a step are only rendered once its popover is open, so focus is moved two frames later – one for
|
|
164
|
+
// the open state to apply, one for the panel to be laid out.
|
|
165
|
+
const focusAfterRender = (element) => {
|
|
166
|
+
if (!element) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
requestAnimationFrame(() => requestAnimationFrame(() => element.focus()));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/** The affordance a step is anchored to, which is also where focus returns when the tour ends. */
|
|
173
|
+
const getTrigger = (step) => step?.querySelector('[slot="button"]');
|
|
174
|
+
/** The primary action of a step – the natural place to land, so the tour can be continued from the keyboard. */
|
|
175
|
+
const getPrimaryAction = (step) => step?.querySelector('[data-tour="next"]');
|
|
176
|
+
|
|
177
|
+
// Tells keyboard from pointer activation: pressing Enter or Space synthesizes a click with "detail" 0, while
|
|
178
|
+
// mouse and touch report "detail >= 1". Focus is only pulled into the tour for keyboard users, so pointer users
|
|
179
|
+
// are not yanked into the coachmark they just opened.
|
|
180
|
+
const isKeyboardActivation = (event) => event.detail === 0;
|
|
181
|
+
|
|
182
|
+
// An index outside the range (-1) closes every step, which is how the tour ends.
|
|
183
|
+
const showStep = (index, moveFocus = false) => {
|
|
184
|
+
current = index;
|
|
185
|
+
for (const [i, step] of steps.entries()) {
|
|
186
|
+
step.open = i === index;
|
|
187
|
+
}
|
|
188
|
+
// Without this, closing the current popover takes the activated button with it, focus falls back to <body> and
|
|
189
|
+
// the next Tab restarts the tab order at the top of the page.
|
|
190
|
+
if (moveFocus) {
|
|
191
|
+
focusAfterRender(getPrimaryAction(steps[index]));
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Ending the tour returns focus to the affordance the last step pointed at, so the user is left in the header
|
|
196
|
+
// they were just told about instead of at the start of the document.
|
|
197
|
+
const endTour = (moveFocus = false) => {
|
|
198
|
+
const lastTrigger = getTrigger(steps[current]);
|
|
199
|
+
showStep(-1);
|
|
200
|
+
if (moveFocus) {
|
|
201
|
+
lastTrigger?.focus();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// The markup opens the first step; setting every step from here puts them all into controlled mode.
|
|
206
|
+
showStep(0);
|
|
207
|
+
|
|
208
|
+
// One listener for the controls of every step: the click is retargeted to the "p-button"/"p-button-pure" host at
|
|
209
|
+
// the shadow boundary, so the element carrying "data-tour" is what "closest()" finds.
|
|
210
|
+
document.addEventListener('click', (e) => {
|
|
211
|
+
const control = e.target.closest?.('[data-tour]');
|
|
212
|
+
if (!control) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const viaKeyboard = isKeyboardActivation(e);
|
|
217
|
+
|
|
218
|
+
switch (control.getAttribute('data-tour')) {
|
|
219
|
+
case 'next':
|
|
220
|
+
if (current + 1 < steps.length) {
|
|
221
|
+
showStep(current + 1, viaKeyboard);
|
|
222
|
+
} else {
|
|
223
|
+
endTour(viaKeyboard);
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case 'back':
|
|
227
|
+
showStep(Math.max(0, current - 1), viaKeyboard);
|
|
228
|
+
break;
|
|
229
|
+
case 'skip':
|
|
230
|
+
endTour(viaKeyboard);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Escape or a click outside the current step ends the tour. The component restores focus to its own trigger on
|
|
236
|
+
// keyboard dismissal, so nothing is forced here.
|
|
237
|
+
for (const step of steps) {
|
|
238
|
+
step.addEventListener('dismiss', () => endTour());
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// A tour that can only be seen once cannot be reviewed, so this example offers it again.
|
|
242
|
+
restartButton.addEventListener('click', (e) => showStep(0, isKeyboardActivation(e)));
|
|
243
|
+
```
|
package/skills/pds-knowledge-react/references/examples/patterns/popover/local-market-switch.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# Popover: Local market switch
|
|
2
|
+
|
|
3
|
+
On entering the site, a popover anchored to the globe icon in the header suggests switching to the user's local market for correct content and pricing. It is shown on load and can be dismissed via an outside click or the Escape key.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-button-pure`](../../../components/p-button-pure/p-button-pure.md), [`p-crest`](../../../components/p-crest/p-crest.md), [`p-drilldown`](../../../components/p-drilldown/p-drilldown.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-link-pure`](../../../components/p-link-pure/p-link-pure.md), [`p-popover`](../../../components/p-popover/p-popover.md), [`p-sheet`](../../../components/p-sheet/p-sheet.md), [`p-tag`](../../../components/p-tag/p-tag.md), [`p-text`](../../../components/p-text/p-text.md), [`p-wordmark`](../../../components/p-wordmark/p-wordmark.md)
|
|
7
|
+
- **Conventions and stylesheet:** shared by all examples, see [examples.md](../../../examples.md)
|
|
8
|
+
|
|
9
|
+
## Markup
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<body>
|
|
14
|
+
<header
|
|
15
|
+
class="z-1 grid-template absolute inset-x-0 before:absolute before:inset-[0_0_-60px_0] before:-z-1 before:pointer-events-none before:bg-fade-to-b"
|
|
16
|
+
>
|
|
17
|
+
<div class="col-wide grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] gap-fluid-md items-center min-h-[80px]">
|
|
18
|
+
<div class="flex flex-wrap gap-static-md items-center justify-start">
|
|
19
|
+
<nav aria-label="Main">
|
|
20
|
+
<p-button-pure
|
|
21
|
+
id="nav-button"
|
|
22
|
+
class="p-static-xs -m-static-xs scheme-dark"
|
|
23
|
+
type="button"
|
|
24
|
+
icon="menu-lines"
|
|
25
|
+
hide-label="{ base: true, s: false }"
|
|
26
|
+
aria="{ 'aria-haspopup': 'dialog' }"
|
|
27
|
+
>
|
|
28
|
+
Menu
|
|
29
|
+
</p-button-pure>
|
|
30
|
+
<p-drilldown id="nav-drilldown">
|
|
31
|
+
<p-drilldown-item identifier="home" label="Home">
|
|
32
|
+
<p-drilldown-link active><a href="#" aria-current="page">Home overview</a></p-drilldown-link>
|
|
33
|
+
<p-drilldown-link><a href="#">Highlights</a></p-drilldown-link>
|
|
34
|
+
<p-drilldown-item identifier="home-models" label="Models">
|
|
35
|
+
<p-drilldown-link><a href="#">Models overview</a></p-drilldown-link>
|
|
36
|
+
<p-drilldown-link><a href="#">911</a></p-drilldown-link>
|
|
37
|
+
<p-drilldown-link><a href="#">Taycan</a></p-drilldown-link>
|
|
38
|
+
</p-drilldown-item>
|
|
39
|
+
</p-drilldown-item>
|
|
40
|
+
<p-drilldown-item identifier="features" label="Features">
|
|
41
|
+
<p-drilldown-link><a href="#">Features overview</a></p-drilldown-link>
|
|
42
|
+
<p-drilldown-link><a href="#">Design</a></p-drilldown-link>
|
|
43
|
+
<p-drilldown-link><a href="#">Technology</a></p-drilldown-link>
|
|
44
|
+
</p-drilldown-item>
|
|
45
|
+
<p-drilldown-link><a href="#">Contact</a></p-drilldown-link>
|
|
46
|
+
</p-drilldown>
|
|
47
|
+
</nav>
|
|
48
|
+
</div>
|
|
49
|
+
<p-crest class="sm:hidden scheme-dark" href="#"></p-crest>
|
|
50
|
+
<p-wordmark class="max-sm:hidden scheme-dark" href="#"></p-wordmark>
|
|
51
|
+
<div class="flex flex-wrap gap-static-md items-center justify-end">
|
|
52
|
+
<p-popover id="market-popover" class="[--p-popover-w:22rem]">
|
|
53
|
+
<p-button-pure
|
|
54
|
+
id="market-button"
|
|
55
|
+
slot="button"
|
|
56
|
+
class="scheme-dark p-static-xs -m-static-xs"
|
|
57
|
+
type="button"
|
|
58
|
+
icon="globe"
|
|
59
|
+
hide-label="true"
|
|
60
|
+
aria="{ 'aria-expanded': true }"
|
|
61
|
+
>
|
|
62
|
+
Local Market
|
|
63
|
+
</p-button-pure>
|
|
64
|
+
<div class="grid gap-fluid-sm">
|
|
65
|
+
<div class="flex gap-static-md items-start">
|
|
66
|
+
<p-text>Do you want to switch to your local market for correct content and pricing?</p-text>
|
|
67
|
+
<p-button-pure
|
|
68
|
+
id="market-dismiss"
|
|
69
|
+
class="shrink-0 p-static-xs -m-static-xs"
|
|
70
|
+
type="button"
|
|
71
|
+
icon="close"
|
|
72
|
+
hide-label="true"
|
|
73
|
+
>
|
|
74
|
+
Dismiss market popover
|
|
75
|
+
</p-button-pure>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="flex flex-wrap gap-static-sm">
|
|
78
|
+
<p-button type="button" compact="true">Go to Local Market</p-button>
|
|
79
|
+
<p-button type="button" variant="secondary" compact="true">International</p-button>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</p-popover>
|
|
83
|
+
<p-popover
|
|
84
|
+
id="profile-popover"
|
|
85
|
+
class="[--p-popover-w:22rem] [--p-popover-px:var(--spacing-static-lg)] [--p-popover-py:var(--spacing-static-lg)]"
|
|
86
|
+
>
|
|
87
|
+
<p-button-pure
|
|
88
|
+
id="profile-button"
|
|
89
|
+
slot="button"
|
|
90
|
+
class="scheme-dark p-static-xs -m-static-xs"
|
|
91
|
+
type="button"
|
|
92
|
+
icon="user"
|
|
93
|
+
hide-label="true"
|
|
94
|
+
aria="{ 'aria-expanded': false }"
|
|
95
|
+
>
|
|
96
|
+
User
|
|
97
|
+
</p-button-pure>
|
|
98
|
+
<div class="grid gap-fluid-md">
|
|
99
|
+
<p-heading tag="h2" size="md">Welcome, John Doe</p-heading>
|
|
100
|
+
<div class="grid gap-fluid-xs">
|
|
101
|
+
<p-heading tag="h3" size="sm" color="contrast-medium">Services</p-heading>
|
|
102
|
+
<div class="grid gap-static-xs">
|
|
103
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
104
|
+
<a href="#">My Porsche App</a>
|
|
105
|
+
</p-link-pure>
|
|
106
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
107
|
+
<a href="#">
|
|
108
|
+
Messages
|
|
109
|
+
<p-tag class="ms-static-xs" variant="secondary" compact>3</p-tag>
|
|
110
|
+
</a>
|
|
111
|
+
</p-link-pure>
|
|
112
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
113
|
+
<a href="#">Find Connect Services</a>
|
|
114
|
+
</p-link-pure>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="grid gap-fluid-xs">
|
|
118
|
+
<p-heading tag="h3" size="sm" color="contrast-medium">Settings</p-heading>
|
|
119
|
+
<div class="grid gap-static-xs">
|
|
120
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
121
|
+
<a href="#">Profile settings</a>
|
|
122
|
+
</p-link-pure>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<p-button type="button" variant="secondary" icon="none">Logout</p-button>
|
|
126
|
+
</div>
|
|
127
|
+
</p-popover>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</header>
|
|
131
|
+
<main id="main" class="grid-template">
|
|
132
|
+
<section class="scheme-dark z-0 col-full grid grid-cols-subgrid items-end h-[clamp(480px,80vh,1000px)]">
|
|
133
|
+
<video
|
|
134
|
+
id="hero-video"
|
|
135
|
+
class="z-0 col-span-full row-span-full min-w-full w-full min-h-full h-full object-cover object-center"
|
|
136
|
+
poster="/examples/media/mood-porsche-gts.webp"
|
|
137
|
+
loop
|
|
138
|
+
muted
|
|
139
|
+
autoplay
|
|
140
|
+
playsinline
|
|
141
|
+
>
|
|
142
|
+
<source src="/examples/media/mood-porsche-gts.mp4" type="video/mp4" />
|
|
143
|
+
<source src="/examples/media/mood-porsche-gts.webm" type="video/webm" />
|
|
144
|
+
</video>
|
|
145
|
+
<div class="z-1 col-extended row-span-full mb-fluid-lg">
|
|
146
|
+
<p-heading tag="h1" size="3xl">
|
|
147
|
+
<span class="text-md block">Pattern</span>
|
|
148
|
+
Popover
|
|
149
|
+
</p-heading>
|
|
150
|
+
</div>
|
|
151
|
+
<p-button
|
|
152
|
+
class="z-2 col-wide place-self-end row-span-full mb-fluid-lg"
|
|
153
|
+
variant="secondary"
|
|
154
|
+
compact="true"
|
|
155
|
+
hide-label="true"
|
|
156
|
+
icon="pause"
|
|
157
|
+
id="pause-button"
|
|
158
|
+
>
|
|
159
|
+
Pause Video
|
|
160
|
+
</p-button>
|
|
161
|
+
</section>
|
|
162
|
+
</main>
|
|
163
|
+
<p-sheet id="profile-sheet" aria="{ 'aria-label': 'User profile' }">
|
|
164
|
+
<p-heading slot="header" tag="h2" size="lg">Welcome, John Doe</p-heading>
|
|
165
|
+
<div class="grid gap-fluid-md">
|
|
166
|
+
<div class="grid gap-fluid-xs">
|
|
167
|
+
<p-heading tag="h3" size="sm" color="contrast-medium">Services</p-heading>
|
|
168
|
+
<div class="grid gap-static-xs">
|
|
169
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none"><a href="#">My Porsche App</a></p-link-pure>
|
|
170
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
171
|
+
<a href="#">
|
|
172
|
+
Messages
|
|
173
|
+
<p-tag class="ms-static-xs" variant="secondary" compact>3</p-tag>
|
|
174
|
+
</a>
|
|
175
|
+
</p-link-pure>
|
|
176
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none">
|
|
177
|
+
<a href="#">Find Connect Services</a>
|
|
178
|
+
</p-link-pure>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="grid gap-fluid-xs">
|
|
182
|
+
<p-heading tag="h3" size="sm" color="contrast-medium">Settings</p-heading>
|
|
183
|
+
<div class="grid gap-static-xs">
|
|
184
|
+
<p-link-pure class="py-static-xs" stretch="true" icon="none"><a href="#">Profile settings</a></p-link-pure>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<p-button type="button" variant="secondary" icon="none">Logout</p-button>
|
|
188
|
+
</div>
|
|
189
|
+
</p-sheet>
|
|
190
|
+
<script type="module" src="main.js"></script>
|
|
191
|
+
</body>
|
|
192
|
+
</html>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Script
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
// DO NOT USE IN PRODUCTION!
|
|
199
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
200
|
+
|
|
201
|
+
// Behaviour of the header navigation: the menu button opens the drilldown, and the drilldown reports the level
|
|
202
|
+
// the user drilled into.
|
|
203
|
+
|
|
204
|
+
const navButton = document.getElementById('nav-button');
|
|
205
|
+
const navDrilldown = document.getElementById('nav-drilldown');
|
|
206
|
+
|
|
207
|
+
navButton.addEventListener('click', () => {
|
|
208
|
+
navDrilldown.open = true;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Closing is requested by the component (Escape, the close button, a click on the backdrop) – the open state is
|
|
212
|
+
// owned by the page, so it has to be written back.
|
|
213
|
+
navDrilldown.addEventListener('dismiss', (e) => {
|
|
214
|
+
e.target.open = false;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
navDrilldown.addEventListener('update', (e) => {
|
|
218
|
+
e.target.activeIdentifier = e.detail.activeIdentifier;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Behaviour of the hero video: a pause control that follows the actual state of the video.
|
|
222
|
+
|
|
223
|
+
const video = document.getElementById('hero-video');
|
|
224
|
+
const pauseButton = document.getElementById('pause-button');
|
|
225
|
+
|
|
226
|
+
// The button hides its label, so its text content is its accessible name – it has to follow the actual state of
|
|
227
|
+
// the video, not the last click. Deriving it from the media events also covers autoplay being refused by the
|
|
228
|
+
// browser.
|
|
229
|
+
const syncPauseButton = () => {
|
|
230
|
+
pauseButton.textContent = video.paused ? 'Play Video' : 'Pause Video';
|
|
231
|
+
pauseButton.icon = video.paused ? 'play' : 'pause';
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
video.addEventListener('play', syncPauseButton);
|
|
235
|
+
video.addEventListener('pause', syncPauseButton);
|
|
236
|
+
|
|
237
|
+
pauseButton.addEventListener('click', () => {
|
|
238
|
+
video[video.paused ? 'play' : 'pause']();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// WCAG 2.2: an animation that starts on its own must be stoppable – and it must not start at all when the
|
|
242
|
+
// operating system was asked for reduced motion.
|
|
243
|
+
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
244
|
+
video.autoplay = false;
|
|
245
|
+
video.pause();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
syncPauseButton();
|
|
249
|
+
|
|
250
|
+
// Behaviour of the popover pattern: which of the two disclosures of the header is open, and in which container.
|
|
251
|
+
//
|
|
252
|
+
// The navigation and the hero video bring their own behaviour, rendered by the partials they are built from. Only
|
|
253
|
+
// what is specific to this pattern is written here.
|
|
254
|
+
//
|
|
255
|
+
// Both popovers and the sheet are used in *controlled* mode: "open" is set from here, so the page always knows
|
|
256
|
+
// which one is showing and can mirror it onto the "aria-expanded" of the trigger. In uncontrolled mode the
|
|
257
|
+
// component owns that state and the page could not keep the two triggers mutually exclusive.
|
|
258
|
+
|
|
259
|
+
const marketPopover = document.getElementById('market-popover');
|
|
260
|
+
const marketButton = document.getElementById('market-button');
|
|
261
|
+
const marketDismiss = document.getElementById('market-dismiss');
|
|
262
|
+
const profilePopover = document.getElementById('profile-popover');
|
|
263
|
+
const profileSheet = document.getElementById('profile-sheet');
|
|
264
|
+
const profileButton = document.getElementById('profile-button');
|
|
265
|
+
|
|
266
|
+
// A panel anchored to a header icon has no room below "s", so the profile menu is a sheet there and a popover
|
|
267
|
+
// above.
|
|
268
|
+
const desktopQuery = window.matchMedia('(min-width: 480px)');
|
|
269
|
+
|
|
270
|
+
// Keeps a trigger's "aria-expanded" in sync with the disclosure it controls. "hide-label" only hides the label
|
|
271
|
+
// visually, so the button keeps its accessible name and only the state has to be announced.
|
|
272
|
+
const setExpanded = (button, isExpanded) => {
|
|
273
|
+
button.aria = { 'aria-expanded': isExpanded };
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/** The profile menu, in whichever container the current viewport calls for. Closing covers both. */
|
|
277
|
+
const setProfileOpen = (isOpen) => {
|
|
278
|
+
const useSheet = isOpen && !desktopQuery.matches;
|
|
279
|
+
profilePopover.open = isOpen && !useSheet;
|
|
280
|
+
profileSheet.open = useSheet;
|
|
281
|
+
setExpanded(profileButton, isOpen);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const setMarketOpen = (isOpen) => {
|
|
285
|
+
marketPopover.open = isOpen;
|
|
286
|
+
setExpanded(marketButton, isOpen);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// The market switch is the message the page offers on load; the profile menu waits to be asked for.
|
|
290
|
+
setMarketOpen(true);
|
|
291
|
+
setProfileOpen(false);
|
|
292
|
+
|
|
293
|
+
marketButton.addEventListener('click', () => {
|
|
294
|
+
const isOpen = !marketPopover.open;
|
|
295
|
+
setProfileOpen(false);
|
|
296
|
+
setMarketOpen(isOpen);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
marketDismiss.addEventListener('click', (e) => {
|
|
300
|
+
setMarketOpen(false);
|
|
301
|
+
// Return focus to the trigger for keyboard activation only: pressing Enter/Space synthesizes a click with
|
|
302
|
+
// "detail" 0, while pointer clicks report "detail >= 1". Without it the dismissed panel takes the focused
|
|
303
|
+
// button with it and the next Tab restarts at the top of the page.
|
|
304
|
+
if (e.detail === 0) {
|
|
305
|
+
marketButton.focus();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
profileButton.addEventListener('click', () => {
|
|
310
|
+
const isOpen = !(profilePopover.open || profileSheet.open);
|
|
311
|
+
setMarketOpen(false);
|
|
312
|
+
setProfileOpen(isOpen);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Escape, a click outside or focus leaving the panel request a close in controlled mode – the components restore
|
|
316
|
+
// focus to the trigger themselves, so only the state has to be written back.
|
|
317
|
+
marketPopover.addEventListener('dismiss', () => setMarketOpen(false));
|
|
318
|
+
profilePopover.addEventListener('dismiss', () => setProfileOpen(false));
|
|
319
|
+
profileSheet.addEventListener('dismiss', () => setProfileOpen(false));
|
|
320
|
+
|
|
321
|
+
// Crossing the breakpoint moves an open profile menu into the other container instead of closing it.
|
|
322
|
+
desktopQuery.addEventListener('change', () => setProfileOpen(profilePopover.open || profileSheet.open));
|
|
323
|
+
```
|