-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(react-checkbox): add motion to Checkbox #35380
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
marcosmoura
wants to merge
7
commits into
microsoft:master
Choose a base branch
from
marcosmoura:feat/react-checkbox/add-motion
base: master
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
32095e4
feat(react-checkbox): add motion to Checkbox
marcosmoura f0131c7
Merge branch 'master' into feat/react-checkbox/add-motion
marcosmoura 5549c0b
fix: generate API files
marcosmoura 429b3de
Merge branch 'master' into feat/react-checkbox/add-motion
marcosmoura 1d780bc
test: fix e2e list tests after checkbox upgrades
marcosmoura bf04703
fix: generate snapshots
marcosmoura 3e64496
fix: remove div
marcosmoura 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-checkbox-efe8019d-5ed0-4eec-ae6d-674f97612c48.json
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,7 @@ | ||
| { | ||
| "type": "minor", | ||
| "comment": "feat: add motion to Checkbox", | ||
| "packageName": "@fluentui/react-checkbox", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -12,13 +12,7 @@ import { | |
| slot, | ||
| } from '@fluentui/react-utilities'; | ||
| import { CheckboxProps, CheckboxState } from './Checkbox.types'; | ||
| import { | ||
| Checkmark12Filled, | ||
| Checkmark16Filled, | ||
| Square12Filled, | ||
| Square16Filled, | ||
| CircleFilled, | ||
| } from '@fluentui/react-icons'; | ||
| import { Checkmark12Filled, Checkmark16Filled } from '@fluentui/react-icons'; | ||
| import { Label } from '@fluentui/react-label'; | ||
| import { useFocusWithin } from '@fluentui/react-tabster'; | ||
|
|
||
|
|
@@ -54,15 +48,10 @@ export const useCheckbox_unstable = (props: CheckboxProps, ref: React.Ref<HTMLIn | |
| const mixed = checked === 'mixed'; | ||
| const id = useId('checkbox-', nativeProps.primary.id); | ||
|
|
||
| let checkmarkIcon; | ||
| if (mixed) { | ||
| if (shape === 'circular') { | ||
| checkmarkIcon = <CircleFilled />; | ||
| } else { | ||
| checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />; | ||
| } | ||
| } else if (checked) { | ||
| checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />; | ||
| let checkmarkIcon: React.ElementType = 'span'; | ||
|
|
||
| if (!mixed) { | ||
| checkmarkIcon = size === 'large' ? Checkmark16Filled : Checkmark12Filled; | ||
| } | ||
|
|
||
| const state: CheckboxState = { | ||
|
|
@@ -75,6 +64,7 @@ export const useCheckbox_unstable = (props: CheckboxProps, ref: React.Ref<HTMLIn | |
| root: 'span', | ||
| input: 'input', | ||
| indicator: 'div', | ||
| checkmarkIcon, | ||
| label: Label, | ||
| }, | ||
| root: slot.always(props.root, { | ||
|
|
@@ -107,10 +97,13 @@ export const useCheckbox_unstable = (props: CheckboxProps, ref: React.Ref<HTMLIn | |
| renderByDefault: true, | ||
| defaultProps: { | ||
| 'aria-hidden': true, | ||
| children: checkmarkIcon, | ||
| }, | ||
| elementType: 'div', | ||
| }), | ||
| checkmarkIcon: slot.optional(props.checkmarkIcon, { | ||
|
Contributor
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. I maybe missing something, but what's the main idea behind having this as a separate slot? |
||
| renderByDefault: true, | ||
| elementType: 'svg', | ||
| }), | ||
| }; | ||
|
|
||
| state.input.onChange = useEventCallback(ev => { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.