@porsche-design-system/components-react 4.8.0-rc.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 +9 -0
- 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/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/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
|
|
|
14
14
|
|
|
15
15
|
## [Unreleased]
|
|
16
16
|
|
|
17
|
+
## [4.8.0-rc.1] - 2026-10-01
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- `Knowledge Skill`: patterns and templates – the header, footer, popover and feedback patterns, the landing page and
|
|
22
|
+
the admin panel – with their description, the components they use, and their complete markup and script, together with
|
|
23
|
+
the note that they are vanilla HTML and JavaScript to be converted to your framework
|
|
24
|
+
([#4761](https://github.com/porsche-design-system/porsche-design-system/pull/4761))
|
|
25
|
+
|
|
17
26
|
## [4.8.0-rc.0] - 2026-10-01
|
|
18
27
|
|
|
19
28
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porsche-design-system/components-react",
|
|
3
|
-
"version": "4.8.0-rc.
|
|
3
|
+
"version": "4.8.0-rc.1",
|
|
4
4
|
"description": "Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"porsche",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/porsche-design-system/porsche-design-system"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@porsche-design-system/components-js": "4.8.0-rc.
|
|
24
|
+
"@porsche-design-system/components-js": "4.8.0-rc.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"ag-grid-community": ">= 36.0.0 <37.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pds-audit-deprecations-react
|
|
3
3
|
description: Audit an existing react project for deprecated Porsche Design System (PDS) API usage — components, props, prop values, events, slots, CSS variables, tokens and styling-package aliases. Produces a JSON report and a Markdown report rendered from it, every finding carrying quoted evidence, a concrete fix and a derived confidence. Read-only apart from its two report files.
|
|
4
|
-
compatibility: Requires the pds-knowledge-react skill, which ships alongside this one in @porsche-design-system/components-react@4.8.0-rc.
|
|
4
|
+
compatibility: Requires the pds-knowledge-react skill, which ships alongside this one in @porsche-design-system/components-react@4.8.0-rc.1. The audited project must depend on that exact version.
|
|
5
5
|
disable-model-invocation: true
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -135,7 +135,7 @@ Every finding carries:
|
|
|
135
135
|
- `evidence` — every location where the project **uses** the API, each with a project-relative path, a line number and the source line **quoted verbatim**. The quote is not decoration: it is what lets a reader, or a later fix, confirm the finding against the file instead of trusting it.
|
|
136
136
|
- `anchor` on a location — the line that proves that usage is PDS, with its own path, line and quoted source. The import, the resolved SCSS `@use` **including one injected by build config**, the Tailwind `@theme` import, or the PDS root at the far end of a wrapper chain. Record it whenever it is not the evidence line itself; it is frequently in another file, and it is the only truthful place to put `vite.config.ts` for a stylesheet that names PDS nowhere. Omit it only where the usage anchors itself, as a `--p-` custom property does.
|
|
137
137
|
- `remediation` — a `replacement` with the exact `from` and `to` spelling whenever the index documents an unambiguous one, plus an `instruction` in words. Where the index documents no replacement, say so plainly in the instruction rather than inventing one.
|
|
138
|
-
- `sources` — the knowledge-skill reference the fact came from, as a path relative to that skill’s root, at version `4.8.0-rc.
|
|
138
|
+
- `sources` — the knowledge-skill reference the fact came from, as a path relative to that skill’s root, at version `4.8.0-rc.1`.
|
|
139
139
|
- the index entry’s message as `deprecationMessage`, verbatim, when it has one. Some say an API has no effect anymore; that wording matters to whoever reads the finding, so do not paraphrase it.
|
|
140
140
|
|
|
141
141
|
An evidence `line` is the **usage** — the attribute, tag, custom property or alias reference itself. Never the `import`, `@use` or `@theme` that anchored it, never the wrapper call it arrived through, and never the declaration line of a constant it resolved from — including a key inside an object that is applied to the element as a whole, which is such a declaration and not a usage. For such an object, the evidence line is the element it is applied to. Where a component is reached through a local binding, the evidence line is the reference to the PDS binding, not the render of the local alias. Those lines are real and they matter, which is exactly why the anchor has a field of its own: counted as locations instead, they inflate a finding by however many anchors it happens to have, and occurrence count is a sort key in §8 — so two runs of an unchanged project stop being comparable.
|
|
@@ -13,13 +13,13 @@ Prefer Porsche Design System components and tokens for new UI, even when the use
|
|
|
13
13
|
|
|
14
14
|
## Coverage and fallbacks
|
|
15
15
|
|
|
16
|
-
This skill currently covers components, global stylesheets and theming, tokens, styling integrations, and the deprecated API index. It does not yet include complete getting-started, setup, and installation guidance; the v3-to-v4 migration guide; the changelog; partials;
|
|
16
|
+
This skill currently covers components, global stylesheets and theming, tokens, styling integrations, patterns and templates, and the deprecated API index. It does not yet include complete getting-started, setup, and installation guidance; the v3-to-v4 migration guide; the changelog; partials; the AG Grid theme; or the Storefront’s Must Know and Help sections.
|
|
17
17
|
|
|
18
|
-
Before using documentation outside this skill or the installed package, match it to the installed PDS version. This skill was generated for `4.8.0-rc.
|
|
18
|
+
Before using documentation outside this skill or the installed package, match it to the installed PDS version. This skill was generated for `4.8.0-rc.1`; prefer the [exact-version Porsche Design System Storefront](https://designsystem.porsche.com/v4.8.0-rc.1/). Major-version URLs such as `/v4/` always serve the latest v4 release and may describe APIs or setup introduced after the installed version. Use them only as a fallback and verify relevant details against the installed package.
|
|
19
19
|
|
|
20
|
-
For runnable
|
|
20
|
+
For runnable starter apps per framework, consult the [Porsche Design System examples repository](https://github.com/porsche-design-system/examples), selecting a release tag or commit that matches the installed package instead of assuming its default branch is compatible. For release-specific changes, read `../../CHANGELOG.md`.
|
|
21
21
|
|
|
22
|
-
For exact API facts, inspect the installed typings and metadata first. When readable implementation details are necessary, use the [exact-version component source](https://github.com/porsche-design-system/porsche-design-system/tree/v4.8.0-rc.
|
|
22
|
+
For exact API facts, inspect the installed typings and metadata first. When readable implementation details are necessary, use the [exact-version component source](https://github.com/porsche-design-system/porsche-design-system/tree/v4.8.0-rc.1/packages/components/src/components) under the repository's `packages/components/src/components/<component>` directory. Do not use the default branch, which may represent a newer release.
|
|
23
23
|
|
|
24
24
|
For deployed browser behavior, inspect component requests in the Network panel. Treat these minified, content-hashed CDN artifacts as a debugging fallback; use the exact-version repository source for readable implementation details.
|
|
25
25
|
|
|
@@ -110,7 +110,7 @@ import { PButton, PorscheDesignSystemProvider } from '@porsche-design-system/com
|
|
|
110
110
|
|
|
111
111
|
On the server, the `/ssr` build emits component markup and styles as Declarative Shadow DOM so the browser can create the Shadow DOM before JavaScript runs. In the browser, it initializes like the standard React wrapper. The framework build must replace `process.browser` for its server and client targets and eliminate the unused branch.
|
|
112
112
|
|
|
113
|
-
Framework setup differs. Follow the [Next.js integration guide](https://designsystem.porsche.com/v4.8.0-rc.
|
|
113
|
+
Framework setup differs. Follow the [Next.js integration guide](https://designsystem.porsche.com/v4.8.0-rc.1/developing/next-js/getting-started/) or the [React Router integration guide](https://designsystem.porsche.com/v4.8.0-rc.1/developing/react-router/getting-started/). Remix users should follow the React Router guidance because Remix v2 was upstreamed into React Router.
|
|
114
114
|
|
|
115
115
|
## Stylesheets
|
|
116
116
|
|
|
@@ -135,6 +135,15 @@ Note: the code examples in the component references use PDS Tailwind utility cla
|
|
|
135
135
|
| vanilla-extract | typed tokens and utilities in `*.css.ts` files | [vanilla-extract.md](references/styles/vanilla-extract.md) |
|
|
136
136
|
| Emotion | tokens and utilities in `css`/`styled` styles | [emotion.md](references/styles/emotion.md) |
|
|
137
137
|
|
|
138
|
+
## Patterns and templates
|
|
139
|
+
|
|
140
|
+
Patterns and templates are curated use cases composed of PDS components, each with a defined layout, styling and behaviour – the way the Porsche Design System puts its components together for a recurring task. Patterns cover a single section of a page – a header, a footer, a popover flow, a feedback form – shown in the place it occupies on a real page; templates cover a whole page. They are written in vanilla HTML and JavaScript with the PDS web components and the PDS Tailwind CSS theme. Whatever the framework of a project, they are the reference for how such a pattern is meant to be built – the components, their props, the layout, the styling and the behaviour they show – and only their syntax has to be converted to the framework. Before building a page or one of these sections, open [examples.md](references/examples.md) for the catalog with descriptions and what all examples share, then the reference of the closest example for its complete markup and script.
|
|
141
|
+
|
|
142
|
+
> **Convert to React before use.** The examples are written in vanilla HTML and JavaScript with the PDS web components, not in React. Never copy them verbatim: rebuild them with the components of `@porsche-design-system/components-react` and the conventions of React (see the framework syntax in SKILL.md), and move the behaviour of the script into React state and event handlers. Import the stylesheet entries of that package as well – `@porsche-design-system/components-react/index.css` and `@porsche-design-system/components-react/tailwindcss` instead of the `components-js` ones. Keep the components, props, layout and styling they show: that usage is how the pattern is meant to be built.
|
|
143
|
+
|
|
144
|
+
- **Patterns:** [Feedback: Dialog](references/examples/patterns/feedback/dialog.md), [Feedback: Inline](references/examples/patterns/feedback/inline.md), [Footer](references/examples/patterns/footer.md), [Header: Overlay](references/examples/patterns/header/overlay.md), [Header: Stacked](references/examples/patterns/header/stacked.md), [Popover: Feature tour](references/examples/patterns/popover/feature-tour.md), [Popover: Local market switch](references/examples/patterns/popover/local-market-switch.md), [Popover: Priority navigation](references/examples/patterns/popover/priority-navigation.md)
|
|
145
|
+
- **Templates:** [Admin panel](references/examples/templates/admin-panel.md), [Landing page](references/examples/templates/landing-page.md)
|
|
146
|
+
|
|
138
147
|
## Deprecations
|
|
139
148
|
|
|
140
149
|
Every deprecated API in this version is indexed in [deprecations.md](references/deprecations.md) — components, props, prop values, events, slots, CSS variables and the styling packages’ deprecated aliases, with what to use instead.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deprecated API
|
|
2
2
|
|
|
3
|
-
Every deprecated Porsche Design System API in `4.8.0-rc.
|
|
3
|
+
Every deprecated Porsche Design System API in `4.8.0-rc.1`, indexed by what is deprecated rather than by which component owns it. Use it to check an existing codebase; use the component and styling references to build with the current API.
|
|
4
4
|
|
|
5
5
|
Deprecated APIs still work in this version. Each will be removed in the next major release, so usage is a compatibility risk rather than a present-day defect — except where a message says an API has no effect anymore, which means the behavior is already gone and only the declaration remains.
|
|
6
6
|
|
|
@@ -675,12 +675,12 @@ Derived from the Tailwind theme exposed by `@porsche-design-system/components-re
|
|
|
675
675
|
|
|
676
676
|
## Tokens
|
|
677
677
|
|
|
678
|
-
No deprecations in `4.8.0-rc.
|
|
678
|
+
No deprecations in `4.8.0-rc.1`. Derived from the design-token API exposed by `@porsche-design-system/components-react/tokens`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
679
679
|
|
|
680
680
|
## Icons
|
|
681
681
|
|
|
682
|
-
No deprecations in `4.8.0-rc.
|
|
682
|
+
No deprecations in `4.8.0-rc.1`. Derived from the `p-icon` `name` values exposed by `@porsche-design-system/components-react`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
683
683
|
|
|
684
684
|
## Stylesheets
|
|
685
685
|
|
|
686
|
-
No deprecations in `4.8.0-rc.
|
|
686
|
+
No deprecations in `4.8.0-rc.1`. Derived from the global CSS exposed by `@porsche-design-system/components-react/index.css`, including `@porsche-design-system/components-react/variables.css` and `@porsche-design-system/components-react/color-scheme.css`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Feedback: Dialog
|
|
2
|
+
|
|
3
|
+
A trigger button opens the same rating-and-comment flow inside a dialog, keeping the page uncluttered. It can be launched from any action on the page, which makes it ideal for task-focused or space-constrained contexts where feedback should stay available but out of the way.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-modal`](../../../components/p-modal/p-modal.md), [`p-segmented-control`](../../../components/p-segmented-control/p-segmented-control.md), [`p-text`](../../../components/p-text/p-text.md), [`p-textarea`](../../../components/p-textarea/p-textarea.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
|
+
<main id="main" class="grid-template gap-y-fluid-xl py-fluid-lg">
|
|
15
|
+
<section class="col-wide grid gap-fluid-md">
|
|
16
|
+
<p-heading tag="h1" size="xl">Feedback in a dialog</p-heading>
|
|
17
|
+
<p-text>
|
|
18
|
+
The page asks for permission first: the flow opens in a modal, and closing it returns focus to the button it
|
|
19
|
+
was opened from. The next visit starts fresh, because the reset waits for the closing animation.
|
|
20
|
+
</p-text>
|
|
21
|
+
</section>
|
|
22
|
+
<section
|
|
23
|
+
class="col-extended justify-self-center w-full max-w-prose grid gap-fluid-md justify-items-center"
|
|
24
|
+
aria-label="Feedback"
|
|
25
|
+
>
|
|
26
|
+
<div class="grid gap-static-xs justify-items-center">
|
|
27
|
+
<p-heading tag="h2" size="md" align="center">Your opinion matters</p-heading>
|
|
28
|
+
<p-text color="contrast-medium" align="center">Help us improve this page.</p-text>
|
|
29
|
+
</div>
|
|
30
|
+
<p-button
|
|
31
|
+
id="feedback-trigger"
|
|
32
|
+
type="button"
|
|
33
|
+
variant="secondary"
|
|
34
|
+
icon="none"
|
|
35
|
+
aria="{ 'aria-haspopup': 'dialog' }"
|
|
36
|
+
>
|
|
37
|
+
Give feedback
|
|
38
|
+
</p-button>
|
|
39
|
+
</section>
|
|
40
|
+
</main>
|
|
41
|
+
<p-modal id="feedback-modal" aria="{ 'aria-label': 'Feedback' }">
|
|
42
|
+
<div class="grid gap-fluid-md">
|
|
43
|
+
<p-heading
|
|
44
|
+
id="feedback-question"
|
|
45
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
46
|
+
tag="h2"
|
|
47
|
+
size="md"
|
|
48
|
+
align="center"
|
|
49
|
+
tabindex="-1"
|
|
50
|
+
>
|
|
51
|
+
How satisfied are you with the information shown on this page?
|
|
52
|
+
</p-heading>
|
|
53
|
+
<form id="feedback-form" class="grid gap-fluid-md justify-items-center">
|
|
54
|
+
<div class="w-full grid md:grid-cols-[auto_minmax(320px,1fr)_auto] items-center gap-static-md">
|
|
55
|
+
<p-text
|
|
56
|
+
class="max-sm:hidden row-2 md:row-auto col-1 md:col-auto justify-self-start"
|
|
57
|
+
size="sm"
|
|
58
|
+
align="start"
|
|
59
|
+
color="contrast-medium"
|
|
60
|
+
>
|
|
61
|
+
Very dissatisfied
|
|
62
|
+
</p-text>
|
|
63
|
+
<p-segmented-control
|
|
64
|
+
id="feedback-rating"
|
|
65
|
+
class="row-1 md:row-auto col-span-2 md:col-auto"
|
|
66
|
+
columns="{ base: 1, s: 5 }"
|
|
67
|
+
label="Select your satisfaction from the scale 1 (very dissatisfied) to 5 (very satisfied)"
|
|
68
|
+
hide-label="true"
|
|
69
|
+
>
|
|
70
|
+
<p-segmented-control-item value="1">
|
|
71
|
+
1
|
|
72
|
+
<span class="sm:sr-only">(very dissatisfied)</span>
|
|
73
|
+
</p-segmented-control-item>
|
|
74
|
+
<p-segmented-control-item value="2">
|
|
75
|
+
2
|
|
76
|
+
<span class="sm:sr-only">(dissatisfied)</span>
|
|
77
|
+
</p-segmented-control-item>
|
|
78
|
+
<p-segmented-control-item value="3">
|
|
79
|
+
3
|
|
80
|
+
<span class="sm:sr-only">(neutral)</span>
|
|
81
|
+
</p-segmented-control-item>
|
|
82
|
+
<p-segmented-control-item value="4">
|
|
83
|
+
4
|
|
84
|
+
<span class="sm:sr-only">(satisfied)</span>
|
|
85
|
+
</p-segmented-control-item>
|
|
86
|
+
<p-segmented-control-item value="5">
|
|
87
|
+
5
|
|
88
|
+
<span class="sm:sr-only">(very satisfied)</span>
|
|
89
|
+
</p-segmented-control-item>
|
|
90
|
+
</p-segmented-control>
|
|
91
|
+
<p-text
|
|
92
|
+
class="max-sm:hidden row-2 md:row-auto col-2 md:col-auto justify-self-end"
|
|
93
|
+
size="sm"
|
|
94
|
+
align="end"
|
|
95
|
+
color="contrast-medium"
|
|
96
|
+
>
|
|
97
|
+
Very satisfied
|
|
98
|
+
</p-text>
|
|
99
|
+
</div>
|
|
100
|
+
<p-textarea
|
|
101
|
+
id="feedback-comment"
|
|
102
|
+
class="w-full"
|
|
103
|
+
name="comment"
|
|
104
|
+
label="What two things could we do to make this page better?"
|
|
105
|
+
rows="4"
|
|
106
|
+
hidden
|
|
107
|
+
></p-textarea>
|
|
108
|
+
<p-button id="feedback-submit" type="button" hidden>Submit feedback</p-button>
|
|
109
|
+
</form>
|
|
110
|
+
<div
|
|
111
|
+
id="feedback-thanks"
|
|
112
|
+
class="grid gap-fluid-md justify-items-center"
|
|
113
|
+
aria-live="polite"
|
|
114
|
+
aria-atomic="true"
|
|
115
|
+
hidden
|
|
116
|
+
>
|
|
117
|
+
<p-heading
|
|
118
|
+
id="feedback-thanks-heading"
|
|
119
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
120
|
+
tag="h2"
|
|
121
|
+
size="md"
|
|
122
|
+
align="center"
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
>
|
|
125
|
+
Thank you for your feedback
|
|
126
|
+
</p-heading>
|
|
127
|
+
<p-text align="center">Your feedback helps us continuously improve our page.</p-text>
|
|
128
|
+
<p-button id="feedback-close" type="button" variant="secondary">Close</p-button>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</p-modal>
|
|
132
|
+
<script type="module" src="main.js"></script>
|
|
133
|
+
</body>
|
|
134
|
+
</html>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Script
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
// DO NOT USE IN PRODUCTION!
|
|
141
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
142
|
+
|
|
143
|
+
// Behaviour of the feedback dialog pattern: whether the modal is open. The flow inside it is the script of
|
|
144
|
+
// "FeedbackForm", which also cancels a pending submission and starts over when the modal closes.
|
|
145
|
+
//
|
|
146
|
+
// "p-modal" is used in *controlled* mode – "open" is set from here, which is what lets the flow wait for the
|
|
147
|
+
// closing animation before it resets, instead of snapping back while the dialog is still visible.
|
|
148
|
+
|
|
149
|
+
const trigger = document.getElementById('feedback-trigger');
|
|
150
|
+
const modal = document.getElementById('feedback-modal');
|
|
151
|
+
const closeButton = document.getElementById('feedback-close');
|
|
152
|
+
|
|
153
|
+
const closeModal = () => {
|
|
154
|
+
modal.open = false;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
trigger.addEventListener('click', () => {
|
|
158
|
+
modal.open = true;
|
|
159
|
+
});
|
|
160
|
+
closeButton.addEventListener('click', closeModal);
|
|
161
|
+
modal.addEventListener('dismiss', closeModal);
|
|
162
|
+
|
|
163
|
+
// Behaviour of the feedback flow: which of its two steps – the question or the confirmation – is shown.
|
|
164
|
+
//
|
|
165
|
+
// No data is sent anywhere: the submission is simulated, so the flow can be reviewed end to end.
|
|
166
|
+
|
|
167
|
+
const question = document.getElementById('feedback-question');
|
|
168
|
+
const form = document.getElementById('feedback-form');
|
|
169
|
+
const rating = document.getElementById('feedback-rating');
|
|
170
|
+
const comment = document.getElementById('feedback-comment');
|
|
171
|
+
const submit = document.getElementById('feedback-submit');
|
|
172
|
+
const thanks = document.getElementById('feedback-thanks');
|
|
173
|
+
const thanksHeading = document.getElementById('feedback-thanks-heading');
|
|
174
|
+
|
|
175
|
+
// Handle of the simulated request, so dismissing the modal mid-submission can cancel it.
|
|
176
|
+
let pendingSubmission;
|
|
177
|
+
|
|
178
|
+
const cancelSubmission = () => {
|
|
179
|
+
window.clearTimeout(pendingSubmission);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Choosing a rating reveals the optional free-text field and the submit button.
|
|
183
|
+
rating.addEventListener('change', () => {
|
|
184
|
+
comment.hidden = false;
|
|
185
|
+
submit.hidden = false;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Reveal the confirmation once the "submission" has completed.
|
|
189
|
+
const showConfirmation = () => {
|
|
190
|
+
form.hidden = true;
|
|
191
|
+
question.hidden = true;
|
|
192
|
+
thanks.hidden = false;
|
|
193
|
+
submit.loading = false;
|
|
194
|
+
// Move focus to the confirmation so keyboard and screen reader users are informed.
|
|
195
|
+
thanksHeading.focus();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
submit.addEventListener('click', () => {
|
|
199
|
+
// Simulate a short server round-trip: show a loading spinner while "submitting", then reveal the
|
|
200
|
+
// confirmation. In a real integration the request would happen here.
|
|
201
|
+
submit.loading = true;
|
|
202
|
+
pendingSubmission = window.setTimeout(showConfirmation, 1200);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const startOver = () => {
|
|
206
|
+
cancelSubmission();
|
|
207
|
+
rating.value = '';
|
|
208
|
+
comment.value = '';
|
|
209
|
+
comment.hidden = true;
|
|
210
|
+
submit.loading = false;
|
|
211
|
+
submit.hidden = true;
|
|
212
|
+
thanks.hidden = true;
|
|
213
|
+
question.hidden = false;
|
|
214
|
+
form.hidden = false;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Offered by the flow shown in the page: starting over from the confirmation.
|
|
218
|
+
document.getElementById('feedback-restart')?.addEventListener('click', () => {
|
|
219
|
+
startOver();
|
|
220
|
+
// Return focus to the question so the flow is re-announced and can be repeated from the start.
|
|
221
|
+
question.focus();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Shown in a modal, the flow follows it: a submission still pending when the modal is dismissed is cancelled, and
|
|
225
|
+
// the next open starts fresh. The reset waits for "motionHiddenEnd", which fires once the close animation has
|
|
226
|
+
// finished, so the content does not visibly snap back while the dialog is still on screen.
|
|
227
|
+
const enclosingModal = form.closest('p-modal');
|
|
228
|
+
enclosingModal?.addEventListener('dismiss', cancelSubmission);
|
|
229
|
+
enclosingModal?.addEventListener('motionHiddenEnd', startOver);
|
|
230
|
+
```
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Feedback: Inline
|
|
2
|
+
|
|
3
|
+
The rating sits directly in the page flow, typically at the end of the content, and stays visible at all times. Once feedback is submitted, it shows a confirmation and offers the option to start over and give new feedback.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-segmented-control`](../../../components/p-segmented-control/p-segmented-control.md), [`p-text`](../../../components/p-text/p-text.md), [`p-textarea`](../../../components/p-textarea/p-textarea.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
|
+
<main id="main" class="grid-template gap-y-fluid-xl py-fluid-lg">
|
|
15
|
+
<section class="col-wide grid gap-fluid-md">
|
|
16
|
+
<p-heading tag="h1" size="xl">Inline feedback</p-heading>
|
|
17
|
+
<p-text>
|
|
18
|
+
The feedback sits in the page, below the content it asks about. Choosing a rating reveals the optional
|
|
19
|
+
comment; submitting replaces the form with the confirmation, which offers to start over.
|
|
20
|
+
</p-text>
|
|
21
|
+
</section>
|
|
22
|
+
<section
|
|
23
|
+
class="col-extended justify-self-center w-full max-w-prose grid gap-fluid-md justify-items-center"
|
|
24
|
+
aria-label="Feedback"
|
|
25
|
+
>
|
|
26
|
+
<p-heading
|
|
27
|
+
id="feedback-question"
|
|
28
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
29
|
+
tag="h2"
|
|
30
|
+
size="md"
|
|
31
|
+
align="center"
|
|
32
|
+
tabindex="-1"
|
|
33
|
+
>
|
|
34
|
+
How satisfied are you with the information shown on this page?
|
|
35
|
+
</p-heading>
|
|
36
|
+
<form id="feedback-form" class="grid gap-fluid-md justify-items-center">
|
|
37
|
+
<div class="w-full grid md:grid-cols-[auto_minmax(320px,1fr)_auto] items-center gap-static-md">
|
|
38
|
+
<p-text
|
|
39
|
+
class="max-sm:hidden row-2 md:row-auto col-1 md:col-auto justify-self-start"
|
|
40
|
+
size="sm"
|
|
41
|
+
align="start"
|
|
42
|
+
color="contrast-medium"
|
|
43
|
+
>
|
|
44
|
+
Very dissatisfied
|
|
45
|
+
</p-text>
|
|
46
|
+
<p-segmented-control
|
|
47
|
+
id="feedback-rating"
|
|
48
|
+
class="row-1 md:row-auto col-span-2 md:col-auto"
|
|
49
|
+
columns="{ base: 1, s: 5 }"
|
|
50
|
+
label="Select your satisfaction from the scale 1 (very dissatisfied) to 5 (very satisfied)"
|
|
51
|
+
hide-label="true"
|
|
52
|
+
>
|
|
53
|
+
<p-segmented-control-item value="1">
|
|
54
|
+
1
|
|
55
|
+
<span class="sm:sr-only">(very dissatisfied)</span>
|
|
56
|
+
</p-segmented-control-item>
|
|
57
|
+
<p-segmented-control-item value="2">
|
|
58
|
+
2
|
|
59
|
+
<span class="sm:sr-only">(dissatisfied)</span>
|
|
60
|
+
</p-segmented-control-item>
|
|
61
|
+
<p-segmented-control-item value="3">
|
|
62
|
+
3
|
|
63
|
+
<span class="sm:sr-only">(neutral)</span>
|
|
64
|
+
</p-segmented-control-item>
|
|
65
|
+
<p-segmented-control-item value="4">
|
|
66
|
+
4
|
|
67
|
+
<span class="sm:sr-only">(satisfied)</span>
|
|
68
|
+
</p-segmented-control-item>
|
|
69
|
+
<p-segmented-control-item value="5">
|
|
70
|
+
5
|
|
71
|
+
<span class="sm:sr-only">(very satisfied)</span>
|
|
72
|
+
</p-segmented-control-item>
|
|
73
|
+
</p-segmented-control>
|
|
74
|
+
<p-text
|
|
75
|
+
class="max-sm:hidden row-2 md:row-auto col-2 md:col-auto justify-self-end"
|
|
76
|
+
size="sm"
|
|
77
|
+
align="end"
|
|
78
|
+
color="contrast-medium"
|
|
79
|
+
>
|
|
80
|
+
Very satisfied
|
|
81
|
+
</p-text>
|
|
82
|
+
</div>
|
|
83
|
+
<p-textarea
|
|
84
|
+
id="feedback-comment"
|
|
85
|
+
class="w-full"
|
|
86
|
+
name="comment"
|
|
87
|
+
label="What two things could we do to make this page better?"
|
|
88
|
+
rows="4"
|
|
89
|
+
hidden
|
|
90
|
+
></p-textarea>
|
|
91
|
+
<p-button id="feedback-submit" type="button" hidden>Submit feedback</p-button>
|
|
92
|
+
</form>
|
|
93
|
+
<div
|
|
94
|
+
id="feedback-thanks"
|
|
95
|
+
class="grid gap-fluid-md justify-items-center"
|
|
96
|
+
aria-live="polite"
|
|
97
|
+
aria-atomic="true"
|
|
98
|
+
hidden
|
|
99
|
+
>
|
|
100
|
+
<p-heading
|
|
101
|
+
id="feedback-thanks-heading"
|
|
102
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
103
|
+
tag="h2"
|
|
104
|
+
size="md"
|
|
105
|
+
align="center"
|
|
106
|
+
tabindex="-1"
|
|
107
|
+
>
|
|
108
|
+
Thank you for your feedback
|
|
109
|
+
</p-heading>
|
|
110
|
+
<p-text align="center">Your feedback helps us continuously improve our page.</p-text>
|
|
111
|
+
<p-button id="feedback-restart" type="button" variant="secondary" icon="refresh">Give new feedback</p-button>
|
|
112
|
+
</div>
|
|
113
|
+
</section>
|
|
114
|
+
</main>
|
|
115
|
+
<script type="module" src="main.js"></script>
|
|
116
|
+
</body>
|
|
117
|
+
</html>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Script
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// DO NOT USE IN PRODUCTION!
|
|
124
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
125
|
+
|
|
126
|
+
// Behaviour of the feedback flow: which of its two steps – the question or the confirmation – is shown.
|
|
127
|
+
//
|
|
128
|
+
// No data is sent anywhere: the submission is simulated, so the flow can be reviewed end to end.
|
|
129
|
+
|
|
130
|
+
const question = document.getElementById('feedback-question');
|
|
131
|
+
const form = document.getElementById('feedback-form');
|
|
132
|
+
const rating = document.getElementById('feedback-rating');
|
|
133
|
+
const comment = document.getElementById('feedback-comment');
|
|
134
|
+
const submit = document.getElementById('feedback-submit');
|
|
135
|
+
const thanks = document.getElementById('feedback-thanks');
|
|
136
|
+
const thanksHeading = document.getElementById('feedback-thanks-heading');
|
|
137
|
+
|
|
138
|
+
// Handle of the simulated request, so dismissing the modal mid-submission can cancel it.
|
|
139
|
+
let pendingSubmission;
|
|
140
|
+
|
|
141
|
+
const cancelSubmission = () => {
|
|
142
|
+
window.clearTimeout(pendingSubmission);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Choosing a rating reveals the optional free-text field and the submit button.
|
|
146
|
+
rating.addEventListener('change', () => {
|
|
147
|
+
comment.hidden = false;
|
|
148
|
+
submit.hidden = false;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Reveal the confirmation once the "submission" has completed.
|
|
152
|
+
const showConfirmation = () => {
|
|
153
|
+
form.hidden = true;
|
|
154
|
+
question.hidden = true;
|
|
155
|
+
thanks.hidden = false;
|
|
156
|
+
submit.loading = false;
|
|
157
|
+
// Move focus to the confirmation so keyboard and screen reader users are informed.
|
|
158
|
+
thanksHeading.focus();
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
submit.addEventListener('click', () => {
|
|
162
|
+
// Simulate a short server round-trip: show a loading spinner while "submitting", then reveal the
|
|
163
|
+
// confirmation. In a real integration the request would happen here.
|
|
164
|
+
submit.loading = true;
|
|
165
|
+
pendingSubmission = window.setTimeout(showConfirmation, 1200);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const startOver = () => {
|
|
169
|
+
cancelSubmission();
|
|
170
|
+
rating.value = '';
|
|
171
|
+
comment.value = '';
|
|
172
|
+
comment.hidden = true;
|
|
173
|
+
submit.loading = false;
|
|
174
|
+
submit.hidden = true;
|
|
175
|
+
thanks.hidden = true;
|
|
176
|
+
question.hidden = false;
|
|
177
|
+
form.hidden = false;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Offered by the flow shown in the page: starting over from the confirmation.
|
|
181
|
+
document.getElementById('feedback-restart')?.addEventListener('click', () => {
|
|
182
|
+
startOver();
|
|
183
|
+
// Return focus to the question so the flow is re-announced and can be repeated from the start.
|
|
184
|
+
question.focus();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Shown in a modal, the flow follows it: a submission still pending when the modal is dismissed is cancelled, and
|
|
188
|
+
// the next open starts fresh. The reset waits for "motionHiddenEnd", which fires once the close animation has
|
|
189
|
+
// finished, so the content does not visibly snap back while the dialog is still on screen.
|
|
190
|
+
const enclosingModal = form.closest('p-modal');
|
|
191
|
+
enclosingModal?.addEventListener('dismiss', cancelSubmission);
|
|
192
|
+
enclosingModal?.addEventListener('motionHiddenEnd', startOver);
|
|
193
|
+
```
|