-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
web component Radio and RadioGroup spec #26900
web component Radio and RadioGroup spec #26900
Conversation
📊 Bundle size report🤖 This report was generated against f8d5e364067660db4ab0f161ad288257ff38efa4 |
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: f8d5e364067660db4ab0f161ad288257ff38efa4 (build) |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 82a3673:
|
@@ -0,0 +1,122 @@ | |||
# Radio |
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.
We should couple RadioGroup along with this I think. If the goal is to leverage the FAST implementation, those two go hand in hand since we implement non-native inputs. All the behavior is in RadioGroup as of now.
|
||
| Name | Privacy | Type | Default | Description | | ||
| --------------- | ------- | ------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `readOnly` | public | `boolean` | | When true, the control will be immutable by user interaction. See readonly [HTML attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly) for more information. | |
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.
This is likely getting removed, we can validate, but I think it's the right move: microsoft/fast#6438
@@ -0,0 +1,127 @@ | |||
# Radio Group | |||
|
|||
> RadioGroup lets people select a single option from two or more Radio items. Use RadioGroup to present all available choices if there's enough space. For more than 5 choices, consider using a different component such as Dropdown. |
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.
Dropdown may not exist here, let's update this to not suggest using components we don't have or know will exist :).
|
||
## **Engineering Spec** | ||
|
||
A radio group is a set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time. Some implementations may initialize the set with all buttons in the unchecked state in order to force the user to check one of the buttons before moving past a certain point in the workflow. |
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.
Let's denote that this is a quote from the W3C, without that, it's written in a way where I might mistake that these should be built with buttons, which is inaccurate as the roles are different.
|
||
### Use Case | ||
|
||
Radio group allows the user to be presented with a list of all the options visible which can facilitate the comparison of choice. |
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.
Does this accurately describe use cases?
| `name` | public | `string` | | The name of the radio group. Setting this value will set the name value for all child radio elements. | | ||
| `value` | public | `string` | | The value of the checked radio. | | ||
| `orientation` | public | `horizontal \| vertical` | `horizontal` | The orientation of the group | | ||
| `childItems` | public | `HTMLElement[]` | | The orientation of the group | |
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 childItems
? This looks copied over, but I think this is internals... if you were to pass a property of childItems I don't think it works. IIRC, you slot the items in the default slot.
| `templateChanged` | protected | | | `void` | | | ||
| `stylesChanged` | protected | | | `void` | | |
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.
Do these really exist?
|
||
| Name | Description | | ||
| ----- | --------------------------------- | | ||
| | The default slotted content | |
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.
These aren't default slotted content - this is the default slot which expects radios
|
||
## **Accessibility** | ||
|
||
[W3 Radio Spec](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_radio_role) |
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.
**Property Mapping** | ||
| Fluent UI React 9 | Fluent Web Components 3 | Description of difference | | ||
|-------------------|------------------------ |---------------------------| | ||
| `layout` | `orientation` | React implementation requires user to pass either `"horizontal"` or `"horizontal-stacked"` through `layout` prop. <br /> WC3 implementation requires user to either pass `"vertical"` or "`horizontal"` through `orientation` attribute. |
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.
Curious of @miroslavstastny's thoughts here, but I'm not sure that layout and orientation are necessarily 1:1. I do think that it probably overlaps in terms of use case though with aria-orientation being set/updated with a change to layout. It seems like there are a couple ways we can go here...we can add a layout attribute with these values and do some aliasing to make sure if orientation isn't updated it gets updated with a change to layout, we can have a slightly different implementation where we have a boolean stacked
attribute which would stack the radios (we can choose to apply only to horizontal), or we can do something else.
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 think this is outstanding but everything else seems reasonable to me
**Property Mapping** | ||
| Fluent UI React 9 | Fluent Web Components 3 | Description of difference | | ||
|-------------------|------------------------ |---------------------------| | ||
| `prop label` | default slotted content | React implementation requires user to pass a string through the `label` prop on the Radio component <br /><br /> The web component implementation requires users to pass the label text through the default slotted content |
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.
nit, technically it's not required to pass the text for the label via the default slot; you could pass an aria-label or use aria-labelledby to associate it with an element outside it's slot...but the slot is the primary place where the label would go.
| `nameChanged` | protected | | | `void` | | | ||
| `valueChanged` | protected | | | `void` | | |
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.
just a note that while not enumerated, each attr includes a [attribute]Changed()
callback 👍
…thub.com/microsoft/fluentui into user/brianbrady/web-component-radio-spec
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
* radio spec init * updates radio spec formatting * adds radio group spec * updates radio specs * updates spec * yarn change
Radio
Design Spec
Link to Radio Design Spec in Figma
Engineering Spec
Fluent WC3 Radio is a form associated component that extends from the FAST Radio FAST Radio and is intended to be as close to the Fluent UI React 9 Menu implementation as possible. However, due to the nature of web components there will not be 100% parity between the two.
Use Case
Used anywhere an author might otherwise use an input[type="radio"]. Used to facilitate choice where only one choice is acceptable.
Class:
Radio
Component Name
fluent-radio
Variables
Fields
name
string
disabled
boolean
labelPosition
"after"
"below"
"below"
checked
boolean
false
Methods
templateChanged
void
stylesChanged
void
Events
change
Attributes
name
disabled
label-position
checked
Slots
checked-indicator
Suggested Template
radioTemplate
from FastFoundationAccessibility
W3 Radio Spec
WAI-ARIA Roles, States, and Properties
role
radio
aria-checked
aria-required
aria-disabled
tabindex
0
Preparation
Fluent Web Component v3 v.s Fluent React 9
Component and Slot Mapping
<Radio>
<fluent-radio>
Property Mapping
prop label
label
prop on the Radio componentThe web component implementation requires users to pass the label text through the default slotted content
Radio Group
Design Spec
Link to Radio Design Spec in Figma
Engineering Spec
A radio group is a set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time. Some implementations may initialize the set with all buttons in the unchecked state in order to force the user to check one of the buttons before moving past a certain point in the workflow.
Use Case
Radio group allows the user to be presented with a list of all the options visible which can facilitate the comparison of choice.
Class:
RadioGroup
Component Name
fluent-radio-group
Fields
disabled
boolean
false
name
string
value
string
orientation
horizontal | vertical
horizontal
childItems
HTMLElement[]
Methods
nameChanged
void
valueChanged
void
templateChanged
void
stylesChanged
void
Events
change
Attributes
disabled
named
value
orientation
Slots
Suggested Template
radioGroupTemplate
from FastFoundationAccessibility
W3 Radio Spec
WAI-ARIA Roles, States, and Properties
aria-labelledby
Preparation
Fluent Web Component v3 v.s Fluent React 9
Component and Slot Mapping
<RadioGroup>
<fluent-radio-group>
Property Mapping
layout
orientation
"horizontal"
or"horizontal-stacked"
throughlayout
prop.WC3 implementation requires user to either pass
"vertical"
or "horizontal"
throughorientation
attribute.