-
Notifications
You must be signed in to change notification settings - Fork 254
feat(core): selection controller #6402
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
Closed
Closed
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
02db50d
feat(core): init poc selection controller
nikkimk dc92ec0
feat(core): fixed storybook and updated docs
nikkimk 72e363f
feat(tabs): implemented focus group navigation and selection controllers
nikkimk 11b1dbf
chore: added changeset
nikkimk 19f38f5
test(core): added tests for selection controller
nikkimk f9e89ef
chore(rules): updates to stories documentation rules to expand on con…
nikkimk eef6543
fix(core): fixed failing tests for tabs using focus group navigation …
nikkimk 1765662
docs(core): test fixes for selection controller
nikkimk 3c43f1b
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk 19de942
fix(core): fixing another failing a11y test
nikkimk 2cc8a6a
docs(core): fix selection controller stories
nikkimk 82b54c6
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk ae96a75
Merge branch 'nikkimk/poc-selection-controller' of github.com:adobe/s…
nikkimk 032b4ee
fix(core): enforcing a selection with disabled host with radio type
nikkimk 5719c93
revert(global-button): remove accidental CSS reformatting
nikkimk ff795b8
revert(claude): remove accidentally committed settings file
nikkimk 95624e8
docs(css, ai): document process and features of shared style director…
5t3ph 602ebc0
docs(color-handle): accessbility migration-analysis (#6397)
nikkimk b97c3f8
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk 37f3fd8
fix(core): fixing another failing a11y test
nikkimk 6be1608
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk db0bffb
docs(core): fix selection controller stories
nikkimk a3dd2ed
Merge branch 'nikkimk/poc-selection-controller' of github.com:adobe/s…
nikkimk 9f358ff
fix(core): enforcing a selection with disabled host with radio type
nikkimk aafc290
revert(claude): remove accidentally committed settings file
nikkimk 216734b
Merge branch 'nikkimk/poc-selection-controller' of github.com:adobe/s…
nikkimk 7ec56a7
chore(global-button): sync with main
nikkimk 6c41476
Merge branch 'main' of github.com:adobe/spectrum-web-components into …
nikkimk 8ace672
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk d20463d
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk 2870704
fix(core): updated selection controller based on PR feedback
nikkimk b652aa4
fix(tabs): updated tabs based on PR feedback
nikkimk ba5c257
feat(accordion): refactored accordion to use selection controller
nikkimk c692710
feat(core): refactored selection controller with silent, enable inter…
nikkimk 1d7e10b
fix(core): updated based on change handler feedback
nikkimk 2dd846b
fix(core): updated to fix navigation change handler
nikkimk 1b4a071
fix(core): updated selection controller to clear selection when nothi…
nikkimk 40d738b
test(core): added selection and focus group controller tests
nikkimk d7b3312
fix(core): fixed host connected refresh, added force flag, and update…
nikkimk 5e89d6c
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk b6336c2
Merge branch 'nikkimk/poc-selection-controller' of github.com:adobe/s…
nikkimk c37809f
Merge branch 'main' into nikkimk/poc-selection-controller
nikkimk 2e1836d
feat(accordion): allowed accordion to switch to allow multiple via se…
nikkimk eb5a302
fix(core): made selection controller more useful for cases like accor…
nikkimk 6210479
fix(core): performance fixes and updated docs
nikkimk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ Component-specific `.usage.mdx` files are no longer used. Units without a per-un | |
|
|
||
| ### Stories file (`.stories.ts`) | ||
|
|
||
| #### Component / pattern section order | ||
|
|
||
| Required structure with visual separators between sections: | ||
|
|
||
| 1. **Copyright header** (lines 1-11) | ||
|
|
@@ -56,6 +58,22 @@ Required structure with visual separators between sections: | |
| 10. **BEHAVIORS STORIES** - Built-in functionality (if applicable) | ||
| 11. **ACCESSIBILITY STORIES** - A11y demonstration | ||
|
|
||
| #### Controller section order | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Controllers require different documentation, like how to use them with a host, so they should have different rules. |
||
|
|
||
| Controllers do not have `ANATOMY STORIES`, `OPTIONS STORIES`, or `STATES STORIES` sections (no visual DOM surface). The typical controller story file structure is: | ||
|
|
||
| 1. **Copyright header** (lines 1-11) | ||
| 2. **Imports** | ||
| 3. **METADATA** - Meta object with `tags: ['migrated', 'controller']` | ||
| 4. **HELPERS** - Shared utilities (if needed) | ||
| 5. **PLAYGROUND STORY** - tags: `['dev']` | ||
| 6. **OVERVIEW STORY** - tags: `['overview']` | ||
| 7. **USAGE STORIES** _(optional)_ - tags: `['usage']` / `['usage', 'description-only']` with `'section-order'` parameter; JSDoc code examples above each export (see [Usage stories in controllers](#usage-stories-in-controllers)) | ||
| 8. **BEHAVIORS STORIES** - tags: `['behaviors']` | ||
| 9. **ACCESSIBILITY STORIES** - tags: `['a11y']` | ||
|
|
||
| A controller may also include `OPTIONS STORIES` and `STATES STORIES` if it has configurable behaviors with visible differences (e.g., `HoverController` with `disabled` and `manual` states). | ||
|
|
||
| #### Visual separators | ||
|
|
||
| ```typescript | ||
|
|
@@ -318,6 +336,64 @@ Section ordering is hand-authored in each component's per-component MDX file (`< | |
|
|
||
| Do not use a `section-order` parameter on stories. The previous `section-order` workaround is retired now that MDX is the source of truth for documentation layout. | ||
|
|
||
| **Controller exception:** Some existing `core/controllers` stories (notably `selection-controller.stories.ts`) use the `'usage'` tag, `'description-only'` tag, and `'section-order'` parameter on usage-example stories. These are a preserved documentation pattern for controllers that ship inline code examples alongside the story canvas. Do **not** remove these stories or tags to satisfy a lint error. If a lint error occurs on a different story in the same file (e.g. an `'a11y'` story without a `<Canvas>` reference in the MDX), fix only that story. See the [Usage stories in controllers](#usage-stories-in-controllers) section below. | ||
|
|
||
| ## Usage stories in controllers | ||
|
|
||
| Some `core/controllers` stories use a legacy inline-documentation pattern where `'usage'`-tagged exports carry JSDoc code examples. This is distinct from the component pattern (no JSDoc above story exports). Preserve these stories when they exist. | ||
|
|
||
| ### When to use | ||
|
|
||
| Use this pattern **only in `core/controllers`** when the controller's primary audience is engineers integrating it into a component, and inline code snippets alongside a live demo are more useful than prose alone in MDX. | ||
|
|
||
| ### Pattern | ||
|
|
||
| ````typescript | ||
| // ────────────────────────── | ||
| // USAGE STORIES | ||
| // ────────────────────────── | ||
|
|
||
| /** | ||
| * ## Anatomy of a `MyController` | ||
| * | ||
| * Constructor signature, options, and lifecycle description. | ||
| * | ||
| * ```typescript | ||
| * // Example setup code | ||
| * ``` | ||
| */ | ||
| export const Usage: Story = { | ||
| tags: ['usage', 'description-only'], | ||
| parameters: { 'section-order': 0 }, | ||
| }; | ||
|
|
||
| /** | ||
| * ### Single mode example | ||
| * | ||
| * Explanation of when to use this mode. | ||
| * | ||
| * ```typescript | ||
| * // Mode-specific code | ||
| * ``` | ||
| */ | ||
| export const UsageExampleSingle: Story = { | ||
| name: 'Example: single mode', | ||
| tags: ['usage'], | ||
| parameters: { 'section-order': 1 }, | ||
| render: () => html` | ||
| <demo-host></demo-host> | ||
| `, | ||
| }; | ||
| ```` | ||
|
|
||
| ### Rules specific to controller usage stories | ||
|
|
||
| - The JSDoc above each usage story export **is** authored (exception to the no-story-JSDoc rule). | ||
| - `'description-only'` on the header story means it has no canvas — prose only. | ||
| - `'section-order'` controls display order within the Usage section in `DocumentTemplate.mdx`. | ||
| - The demo custom element rendered by usage stories lives in `stories/demo-hosts.ts` alongside the stories file. | ||
| - Do not add `<Canvas of={Stories.UsageExample...} />` to the controller MDX — usage stories render through `DocumentTemplate.mdx` via the `'usage'` tag, not through the hand-authored MDX page. | ||
|
|
||
| ## Tags | ||
|
|
||
| ### Required tags | ||
|
|
@@ -338,7 +414,9 @@ Do not use a `section-order` parameter on stories. The previous `section-order` | |
|
|
||
| - `'upcoming'` - Story demonstrates a feature or variant that is not yet available | ||
|
|
||
| > The previous `'description-only'` tag is retired. Prose-only sections live in the per-component MDX (`<component>.mdx`) as Markdown without a `<Canvas>` reference, not as story exports. | ||
| > The `'description-only'` tag is retired **for components and patterns**. Prose-only sections live in the per-unit MDX as Markdown without a `<Canvas>` reference, not as story exports. | ||
| > | ||
| > **Controller exception:** `'usage'` and `'description-only'` remain valid in `core/controllers` stories for the usage-example pattern. See [Usage stories in controllers](#usage-stories-in-controllers). | ||
|
|
||
| ### Exclusion tags | ||
|
|
||
|
|
@@ -680,10 +758,10 @@ See `asset.stories.ts` for complete examples. | |
|
|
||
| ### ❌ Don't | ||
|
|
||
| - Add JSDoc above any individual story export (Playground, Overview, or any other) | ||
| - Use the `'usage'` tag for new units (deprecated) | ||
| - Use the `'description-only'` tag (retired — prose-only sections live in MDX) | ||
| - Use the `'section-order'` parameter (retired — section order is hand-authored in MDX) | ||
| - Add JSDoc above any individual story export (Playground, Overview, or any other) — **except** usage-example stories in `core/controllers` (see [Usage stories in controllers](#usage-stories-in-controllers)) | ||
| - Use the `'usage'` tag for new **component or pattern** units (deprecated for those genres) | ||
| - Use the `'description-only'` tag for **components or patterns** (retired — prose-only sections live in MDX) | ||
| - Use the `'section-order'` parameter for **components or patterns** (retired — section order is hand-authored in MDX) | ||
| - Use `tags: ['autodocs', 'dev']` on a unit that has a per-unit MDX file (creates a duplicate Docs entry — use `['dev']`) | ||
| - Omit `subtitle` in meta parameters | ||
| - Use placeholder text | ||
|
|
@@ -715,9 +793,9 @@ See `asset.stories.ts` for complete examples. | |
| - [ ] Behaviors: `['behaviors']` tag (if applicable) | ||
| - [ ] Accessibility: `['a11y']` tag (prose lives in MDX) | ||
| - [ ] Static colors: three-story or combined-story pattern with `staticColorsDemo` (if applicable) | ||
| - [ ] No story-level JSDoc comments above any `export const` | ||
| - [ ] No `section-order` parameter on any story | ||
| - [ ] No `description-only` tag on any story | ||
| - [ ] No story-level JSDoc comments above any `export const` (exception: usage-example stories in `core/controllers`) | ||
| - [ ] No `section-order` parameter on any story (exception: usage-example stories in `core/controllers`) | ||
| - [ ] No `description-only` tag on any story (exception: usage-example stories in `core/controllers`) | ||
| - [ ] All stories accessible with meaningful content | ||
| - [ ] Image assets: use `picsum.photos` with static IDs (if applicable) | ||
| - [ ] Per-unit MDX file exists at the unit root and references each section-tagged story via `<Canvas of={Stories.StoryName} />` (see `.ai/rules/stories-documentation.md`) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controllers require different documentation, like how to use them with a host, so they should have different rules.