-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Tag/TagButton init component setup #27102
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
YuanboXue-Amber
merged 23 commits into
microsoft:master
from
micahgodbolt:tag-first-pass
Apr 27, 2023
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
607fb16
add raw html
micahgodbolt b6bbff4
add types and update render to use slots
micahgodbolt 7eab6bc
Merge branch 'master' into tag-first-pass
micahgodbolt fd1b143
init slots and layout setup for tag
micahgodbolt 6843d4c
init pass on Tag button
micahgodbolt c02029c
fix dep version
micahgodbolt 1345a2e
add icons to package.json
micahgodbolt 01d968e
api update
micahgodbolt 33b2f8b
update tests
micahgodbolt bc7dff9
Update packages/react-components/react-tags/src/components/Tag/Tag.ty…
micahgodbolt cb8b4f1
Update packages/react-components/react-tags/src/components/Tag/useTag…
micahgodbolt ed79cd6
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt 30dcbe1
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt e0fb356
remove unnecessary named columns
micahgodbolt d2aff57
Merge branch 'master' into tag-first-pass
micahgodbolt 1248f0a
Update packages/react-components/react-tags/src/components/Tag/useTag…
micahgodbolt 0e2dcfb
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt fbe5797
bmp react utils to match master
micahgodbolt 8664988
Merge branch 'master' into tag-first-pass
micahgodbolt 1bde3ef
Merge branch 'master' into tag-first-pass
YuanboXue-Amber 9cde259
Update packages/react-components/react-tags/package.json
YuanboXue-Amber 0e2b676
Update api.md
YuanboXue-Amber 57a0ed2
Update test snapshot with react-icon update
YuanboXue-Amber 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
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
23 changes: 18 additions & 5 deletions
23
packages/react-components/react-tags/src/components/Tag/Tag.types.ts
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 |
|---|---|---|
| @@ -1,17 +1,30 @@ | ||
| import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities'; | ||
| import { Avatar } from '@fluentui/react-avatar'; | ||
|
|
||
| export type TagSlots = { | ||
| root: Slot<'div'>; | ||
| root: NonNullable<Slot<'div'>>; | ||
| content?: Slot<'span'>; | ||
| avatar?: Slot<typeof Avatar>; | ||
| icon?: Slot<'span'>; | ||
| primaryText?: Slot<'span'>; | ||
| secondaryText?: Slot<'span'>; | ||
| dismissButton?: NonNullable<Slot<'button'>>; | ||
micahgodbolt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| /** | ||
| * Tag Props | ||
| */ | ||
| export type TagProps = ComponentProps<TagSlots> & {}; | ||
| export type TagProps = ComponentProps<TagSlots> & { | ||
| size?: 'extra-small' | 'small' | 'medium'; | ||
| shape?: 'rounded' | 'circular'; | ||
| appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline'; | ||
| disabled?: boolean; | ||
| checked?: boolean; | ||
| dismissable?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * State used in rendering Tag | ||
| */ | ||
| export type TagState = ComponentState<TagSlots>; | ||
| // TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from TagProps. | ||
| // & Required<Pick<TagProps, 'propName'>> | ||
| export type TagState = ComponentState<TagSlots> & | ||
| Required<Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | '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
28 changes: 0 additions & 28 deletions
28
packages/react-components/react-tags/src/components/Tag/useTag.ts
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
packages/react-components/react-tags/src/components/Tag/useTag.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import * as React from 'react'; | ||
| import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities'; | ||
| import { Dismiss16Filled } from '@fluentui/react-icons'; | ||
| import { Avatar } from '@fluentui/react-avatar'; | ||
| import type { TagProps, TagState } from './Tag.types'; | ||
|
|
||
| /** | ||
| * Create the state required to render Tag. | ||
| * | ||
| * The returned state can be modified with hooks such as useTagStyles_unstable, | ||
| * before being passed to renderTag_unstable. | ||
| * | ||
| * @param props - props from this instance of Tag | ||
| * @param ref - reference to root HTMLElement of Tag | ||
| */ | ||
| export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLElement>): TagState => { | ||
| const { | ||
| checked = false, | ||
| disabled = false, | ||
| dismissable = false, | ||
| shape = 'rounded', | ||
| size = 'medium', | ||
| appearance = 'filled-lighter', | ||
| } = props; | ||
|
|
||
| return { | ||
| components: { | ||
| root: 'div', | ||
| content: 'span', | ||
| avatar: Avatar, | ||
| icon: 'span', | ||
| primaryText: 'span', | ||
| secondaryText: 'span', | ||
| dismissButton: 'button', | ||
| }, | ||
| checked, | ||
| disabled, | ||
| dismissable, | ||
| shape, | ||
| size, | ||
| appearance, | ||
| root: getNativeElementProps('div', { | ||
| ref, | ||
| ...props, | ||
| }), | ||
| content: resolveShorthand(props.content, { required: true }), | ||
| avatar: resolveShorthand(props.avatar), | ||
| icon: resolveShorthand(props.icon), | ||
| primaryText: resolveShorthand(props.primaryText), | ||
| secondaryText: resolveShorthand(props.secondaryText), | ||
| dismissButton: resolveShorthand(props.dismissButton, { | ||
| required: true, | ||
| defaultProps: { | ||
| disabled, | ||
| type: 'button', | ||
| children: <Dismiss16Filled />, | ||
| }, | ||
| }), | ||
| }; | ||
| }; |
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.