-
-
Notifications
You must be signed in to change notification settings - Fork 833
Refactored ButtonsWidget and AlignWidget. New blockWidth, blockAlignment and size widgets based on ButtonsWidget.
#7555
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
077544f
New ButtonsWidget
sneridagh 832c7dc
AlignmentWidget refactor, and new BlockWidth, Size, BlockAlignment
sneridagh 57e1c77
locales
sneridagh 168d1d4
Docs, test fixes, changelog
sneridagh 42414e5
Wire docs
sneridagh 1ca2899
Changelog
sneridagh 2c78dd3
Merge branch 'main' into widgetsGalore
avoinea 97fe68d
Move to use RAC radio buttons instead
sneridagh cd63b44
Apply suggestions from code review
sneridagh 8c9338c
Improved paragraph mentioning the Buttons widget
sneridagh eeae8de
Changelog
sneridagh 592d27d
Fix tests
sneridagh 408a23c
Apply suggestions from code review
sneridagh d6fb437
Merge branch 'main' into widgetsGalore
sneridagh dccc44e
Refactored removing the ugly useEffect that was needed before using RAC.
sneridagh 0e60cdc
Merge branch 'main' into widgetsGalore
sneridagh d11cea6
Remove memoizations
sneridagh 3038b1b
Fix tests
sneridagh 0d61ee6
Load @plone/components CSS only for CMSUI views
sneridagh d3c47c0
Fix tests
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
| --- | ||
| myst: | ||
| html_meta: | ||
| "description": "Volto reference guides" | ||
| "property=og:description": "Volto reference guides" | ||
| "property=og:title": "Volto reference guides" | ||
| "keywords": "Volto, user interface, frontend, Plone, reference guides" | ||
| --- | ||
|
|
||
| # Reference guides | ||
|
|
||
| This section of the documentation contains reference guides for various aspects of Volto. | ||
|
|
||
| ```{toctree} | ||
| :maxdepth: 1 | ||
|
|
||
| widgets | ||
| ``` | ||
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,124 @@ | ||
| --- | ||
| myst: | ||
| html_meta: | ||
| "description": "Volto widgets" | ||
| "property=og:description": "Volto widgets" | ||
| "property=og:title": "Volto widgets" | ||
| "keywords": "Plone, Volto, widgets" | ||
| --- | ||
|
|
||
| # Widgets | ||
|
|
||
| This chapter describes the set of widgets available in Volto. | ||
|
|
||
| ## `ButtonsWidget` | ||
|
|
||
| `ButtonsWidget` is a helper component for building widgets that have a list of buttons which can be toggled, allowing the selection of a single value only. | ||
| It's a minimal, extensible base widget used by other widgets. | ||
| It renders a set of mutually exclusive toggle buttons, and functions similarly to a radio input. | ||
|
|
||
| With `ButtonsWidget`, you can do the following things. | ||
|
|
||
| - Supply a configurable list of actions, including strings or style definitions. | ||
| - Customize a per-action icon and label via the `actionsInfoMap` prop. | ||
| - Filter out default actions with the `filterActions` prop. | ||
| - Provide default and current values via `default` and `value` props. | ||
| - Pass `disabled` or `isDisabled` props to prevent interaction. | ||
|
|
||
| The following code example demonstrates the complete options for `ButtonsWidget`. | ||
|
|
||
| ```ts | ||
| type ActionInfo = [React.ReactElement<any>, string] | [string, string]; | ||
|
|
||
| type ActionValue = string | Record<`--${string}`, string>; | ||
|
|
||
| export type ButtonsWidgetProps = { | ||
| /** | ||
| * Unique identifier for the widget. | ||
| */ | ||
| id: string; | ||
|
|
||
| /** | ||
| * Callback function to handle changes. | ||
| */ | ||
| onChange: (id: string, value: ActionValue) => void; | ||
|
|
||
| /** | ||
| * List of actions available for the widget. | ||
| */ | ||
| actions?: Array<StyleDefinition | string>; | ||
|
|
||
| /** | ||
| * Map containing additional the information (icon and i18n string) for each action. | ||
| */ | ||
| actionsInfoMap?: Record<string, ActionInfo>; | ||
|
|
||
| /** | ||
| * List of actions to be filtered out. In case that we don't want the default ones | ||
| * we can filter them out. | ||
| */ | ||
| filterActions?: string[]; | ||
|
|
||
| /** | ||
| * Current value of the widget. | ||
| */ | ||
| value?: ActionValue; | ||
|
|
||
| /** | ||
| * Default value of the widget. | ||
| */ | ||
| default?: ActionValue; | ||
|
|
||
| /** | ||
| * Indicates if the widget is disabled. | ||
| */ | ||
| disabled?: boolean; | ||
|
|
||
| /** | ||
| * Indicates if the widget is disabled (alternative flag for compatibility reasons). | ||
| */ | ||
| isDisabled?: boolean; | ||
| }; | ||
| ``` | ||
|
|
||
| ## `blockWidth` | ||
|
|
||
| `blockWidth` is a widget to select a width from the defined `config.blocks.widths`. | ||
| It's based on the `ButtonsWidget`, so the actions and the styles to be applied are configurable. | ||
|
|
||
| ````{card} | ||
| ```{image} ../_static/blockWidth.png | ||
| :alt: blockWidth | ||
| :target: ../_static/blockWidth.png | ||
| ``` | ||
| +++ | ||
| _`blockWidth`_ | ||
| ```` | ||
|
|
||
| ## `blockAlignment` | ||
|
|
||
| `blockAlignment` is a widget to select the block alignment, one of either `left`, `right`, or `center`. | ||
| It's based on the `ButtonsWidget`, so the actions and the styles to be applied are configurable. | ||
|
|
||
| ````{card} | ||
| ```{image} ../_static/blockAlignment.png | ||
| :alt: blockAlignment | ||
| :target: ../_static/blockAlignment.png | ||
| ``` | ||
| +++ | ||
| _`blockAlignment`_ | ||
| ```` | ||
|
|
||
| ## `size` | ||
|
|
||
| `size` is a widget to select the block size from a default list of values, one of either `small`, `medium`, or `large`. | ||
| It's based on the `ButtonsWidget`, so the actions and the styles to be applied are configurable. | ||
|
|
||
| ````{card} | ||
| ```{image} ../_static/size.png | ||
| :alt: size | ||
| :target: ../_static/size.png | ||
| ``` | ||
| +++ | ||
| _`size`_ | ||
| ```` |
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 @@ | ||
| Added `Radio` component to basic set of components, proxied from RAC. @sneridagh |
3 changes: 1 addition & 2 deletions
3
packages/components/src/components/RadioGroup/RadioGroup.stories.tsx
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
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 @@ | ||
| Added new widgets config typings. @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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.