-
-
Notifications
You must be signed in to change notification settings - Fork 889
[components] Refactor some components to match closely RAC implementation. #8061
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
Open
sneridagh
wants to merge
11
commits into
seven
Choose a base branch
from
componentsrefactor
base: seven
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
750052f
Added local AGENTS.md to @plone/components
sneridagh bd077e7
More rules
sneridagh 427de9a
Refactor Menu component to be more RAC-like, and do not reinvent the …
sneridagh e572685
Add RAC MCP to the party
sneridagh 181de0b
Refining
sneridagh aa10379
Select
sneridagh d9ff38e
Merge branch 'seven' into componentsrefactor
sneridagh e889f77
Cross-Model review fixes
sneridagh 80f6676
Fix DTS errors
sneridagh bce0799
Fix TS in @plone/components
sneridagh d6f971f
Better Menu typing
sneridagh 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [mcp_servers.react-aria] | ||
| command = "npx" | ||
| args = ["@react-aria/mcp@latest"] |
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file applies only to `packages/components` and its subdirectories. | ||
|
|
||
| ## What This Package Is | ||
|
|
||
| - `@plone/components` is a thin wrapper layer around `react-aria-components`. | ||
| - Components should be usable out of the box in Seven and in Volto. | ||
| - Keep components presentational and lightweight. Avoid adding app-specific behavior, data logic, or i18n machinery here. | ||
|
|
||
| ## Component Model | ||
|
|
||
| - Prefer staying very close to the underlying React Aria Components API. | ||
| - Do not reinvent component behavior that RAC already provides. | ||
| - Add Plone value mainly through packaging, small ergonomic wrappers, and styling. | ||
| - Some components, such as `Breadcrumbs`, are intentionally adapted for Seven/Volto and REST API use cases. In those cases, the wrapper props and helpers may shape data for that environment, but the underlying RAC behavior should remain intact. | ||
| - Even adapted components should still behave like thin proxies: keep forwarding supported props through to the underlying RAC component so upstream RAC documentation and expectations continue to apply. | ||
|
|
||
| ## Two Flavours | ||
|
|
||
| - Components may exist in two flavours: | ||
| - basic: CSS-styled components | ||
| - Quanta styles for a few CSS-styled components in `src/styles/quanta/`: CSS assets for Quanta-styled output | ||
| - Quanta components: the Tailwind-styled React components, named with the `.quanta.tsx` suffix | ||
| - Both flavours live under the same component folder in `src/components/<ComponentName>/`. | ||
| - Basic components are exported from `src/index.ts`. | ||
| - Tailwind Quanta components are exported from `src/quanta/index.ts` and are the real Quanta component implementation. | ||
| - Keep tree-shaking in mind when adding exports or shared helpers. | ||
|
|
||
| ## Styles | ||
|
|
||
| - Built CSS lives under `src/styles`. | ||
| - Basic component styles live in `src/styles/basic/`, usually one CSS file per component, and are bundled from `src/styles/basic/main.css`. | ||
| - `src/styles/quanta/` contains CSS-based Quanta style definitions and is bundled from `src/styles/quanta/main.css`. | ||
| - Do not confuse `src/styles/quanta/` with the Tailwind Quanta component implementation. The Tailwind components are the `.quanta.tsx` files in `src/components`. | ||
| - Other `src/styles` folders are for shared assets such as static files and fonts. | ||
| - When adding or renaming a styled component, make sure the corresponding style entry is wired into the appropriate `main.css`. | ||
|
|
||
| ## Stories | ||
|
|
||
| - Every public component should have a Storybook story. | ||
| - Keep stories colocated with the component in the same folder. | ||
| - If both basic and Quanta variants are public, prefer stories for both. | ||
|
|
||
| ## Icons | ||
|
|
||
| - Raw SVG icons live in `src/icons`. | ||
| - Ready-to-use React icon components live in `src/components/icons`. | ||
| - When adding an SVG icon, also add its React component counterpart and export it from the relevant index when needed. | ||
| - Keep SVG and React component names aligned. | ||
|
|
||
| ## Editing Rules | ||
|
|
||
| - Keep changes minimal and package-local. | ||
| - Prefer extending existing component folders and patterns over introducing new abstractions. | ||
| - If adding a new public component, check all relevant pieces: | ||
| - component file | ||
| - optional `.quanta.tsx` variant | ||
| - stories | ||
| - styles | ||
| - exports | ||
| - tests when behavior is non-trivial | ||
|
|
||
| ## Validation | ||
|
|
||
| - Prefer targeted checks from this package: | ||
| - `pnpm --filter @plone/components test --run` | ||
| - `pnpm --filter @plone/components lint` | ||
| - `pnpm --filter @plone/components build` | ||
| - Run `pnpm --filter @plone/components eslint:fix` after editing component code. This package uses formatting/lint tooling that reorders Tailwind utilities, so apply it before finishing changes. |
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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Quanta Menu API cleanup | ||
|
|
||
| The Quanta `Menu` component was refactored to behave as a thin wrapper around `react-aria-components` instead of exposing a custom data-driven API. | ||
|
|
||
| ## Removed | ||
|
|
||
| - The custom `menuItems` prop. | ||
| - The bundled trigger API based on `button`, `onPress`, and `placement` props on `Menu`. | ||
| - The internal item schema used to describe menu entries with fields such as `label`, `description`, `keyboard`, `icon`, `separator`, `section`, `header`, and nested `children`. | ||
| - Automatic rendering of sections and separators from that custom schema. | ||
| - Automatic rendering of text slots, icons, keyboard shortcuts, and similar item content from custom item objects. | ||
| - The custom `title` prop on `MenuSection`. | ||
|
|
||
| ## Added | ||
|
|
||
| - RAC-aligned Quanta primitives: | ||
| - `Menu` | ||
| - `MenuItem` | ||
| - `MenuTrigger` | ||
| - `SubmenuTrigger` | ||
| - `MenuSection` | ||
| - `MenuSeparator` | ||
|
|
||
| ## Migration | ||
|
|
||
| Consumers should now compose Quanta menus using the standard `react-aria-components` structure: | ||
|
|
||
| - Wrap menus with `MenuTrigger` instead of passing trigger props to `Menu`. | ||
| - Pass `MenuItem`, `MenuSection`, and `MenuSeparator` as children instead of a `menuItems` array. | ||
| - Use `Header` inside `MenuSection`, or `aria-label` when there is no visible header, instead of a custom `title` prop. | ||
| - Render icons, descriptions, labels, keyboard shortcuts, and links explicitly in `MenuItem` children using RAC patterns and slots. | ||
|
|
||
| This removes opinionated behavior from Quanta `Menu` and makes the component API match upstream RAC usage more closely. | ||
|
|
||
| The same alignment was also applied to the basic `Menu` component so both basic and Quanta flavours now follow the same RAC composition model. | ||
|
|
||
| @sneridagh |
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
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
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.
What is this for?
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.
I have the RAC starter locally, for agents consume it as reference. I used also RAC MCP on this one.
I need to polish it stil... I haven't made a thorough review yet.