Skip to content
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
607fb16
add raw html
micahgodbolt Mar 1, 2023
b6bbff4
add types and update render to use slots
micahgodbolt Mar 2, 2023
7eab6bc
Merge branch 'master' into tag-first-pass
micahgodbolt Mar 6, 2023
fd1b143
init slots and layout setup for tag
micahgodbolt Mar 6, 2023
6843d4c
init pass on Tag button
micahgodbolt Mar 6, 2023
c02029c
fix dep version
micahgodbolt Mar 6, 2023
1345a2e
add icons to package.json
micahgodbolt Mar 7, 2023
01d968e
api update
micahgodbolt Mar 7, 2023
33b2f8b
update tests
micahgodbolt Mar 7, 2023
bc7dff9
Update packages/react-components/react-tags/src/components/Tag/Tag.ty…
micahgodbolt Mar 8, 2023
cb8b4f1
Update packages/react-components/react-tags/src/components/Tag/useTag…
micahgodbolt Mar 8, 2023
ed79cd6
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt Mar 8, 2023
30dcbe1
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt Mar 8, 2023
e0fb356
remove unnecessary named columns
micahgodbolt Mar 8, 2023
d2aff57
Merge branch 'master' into tag-first-pass
micahgodbolt Mar 8, 2023
1248f0a
Update packages/react-components/react-tags/src/components/Tag/useTag…
micahgodbolt Mar 8, 2023
0e2dcfb
Update packages/react-components/react-tags/src/components/TagButton/…
micahgodbolt Mar 8, 2023
fbe5797
bmp react utils to match master
micahgodbolt Mar 15, 2023
8664988
Merge branch 'master' into tag-first-pass
micahgodbolt Mar 15, 2023
1bde3ef
Merge branch 'master' into tag-first-pass
YuanboXue-Amber Apr 27, 2023
9cde259
Update packages/react-components/react-tags/package.json
YuanboXue-Amber Apr 27, 2023
0e2b676
Update api.md
YuanboXue-Amber Apr 27, 2023
57a0ed2
Update test snapshot with react-icon update
YuanboXue-Amber Apr 27, 2023
aa38b3a
add avatar shape to avatar context
YuanboXue-Amber Apr 27, 2023
6c4d5f5
add bundle size tool to Tag
YuanboXue-Amber Apr 27, 2023
8d5745e
add style for spacing
YuanboXue-Amber Apr 27, 2023
6f940d5
Merge remote-tracking branch 'upstream/master' into tag
YuanboXue-Amber Apr 27, 2023
a606ec2
fix after merge
YuanboXue-Amber Apr 27, 2023
756122b
put media in content
YuanboXue-Amber Apr 27, 2023
6bb2bcd
try content as button on tag and it works fine
YuanboXue-Amber Apr 28, 2023
2849eeb
Revert "try content as button on tag and it works fine"
YuanboXue-Amber Apr 28, 2023
2e19dca
TagButton implementation
YuanboXue-Amber Apr 28, 2023
c5b1b4b
add tabster to dependency
YuanboXue-Amber Apr 28, 2023
2cf6e73
TagButton stories
YuanboXue-Amber Apr 28, 2023
2d35934
cleanup TODO and remove debug styles
YuanboXue-Amber Apr 28, 2023
b938f67
add TODO
YuanboXue-Amber Apr 28, 2023
f67a476
change
YuanboXue-Amber Apr 28, 2023
c8d157c
default story cleanup
YuanboXue-Amber Apr 28, 2023
6ada5b5
Merge branch 'master' into tag
YuanboXue-Amber Apr 28, 2023
4d2f0d7
update import from react-avatar to react-components in stories
YuanboXue-Amber Apr 28, 2023
011bc4e
Merge branch 'tag' of https://github.com/YuanboXue-Amber/fluentui int…
YuanboXue-Amber Apr 28, 2023
af6fe3e
fix crud
YuanboXue-Amber Apr 28, 2023
6846a7a
avatar api.md
YuanboXue-Amber Apr 28, 2023
5c267fe
tags api.md
YuanboXue-Amber Apr 28, 2023
4c2908a
fix import
YuanboXue-Amber Apr 28, 2023
211dc74
add bundle icon and update test
YuanboXue-Amber Apr 28, 2023
be0cf25
Hack to build tag in PR docsite
YuanboXue-Amber Apr 28, 2023
d93ded5
add styles suffix
YuanboXue-Amber Apr 28, 2023
e46a4d4
make content slot required
YuanboXue-Amber May 2, 2023
e585b1e
update useTagButton_unstable
YuanboXue-Amber May 2, 2023
cfa336f
use makeStyles for stories
YuanboXue-Amber May 2, 2023
262cee1
remove snapshot test
YuanboXue-Amber May 2, 2023
ef6d386
revert change in useTagButton_unstable
YuanboXue-Amber May 2, 2023
7918b42
change Button into button
YuanboXue-Amber May 2, 2023
9c19d79
reuse styles
YuanboXue-Amber May 2, 2023
cae86d7
fix HC border
YuanboXue-Amber May 2, 2023
3ed9d8c
add makeResetStyle todo
YuanboXue-Amber May 2, 2023
16e9d5e
Merge remote-tracking branch 'upstream/master' into tag
YuanboXue-Amber May 3, 2023
fc477a7
update useTagButton_unstable again
YuanboXue-Amber May 3, 2023
d698160
remove weird stuff from merging
YuanboXue-Amber May 3, 2023
e215320
remove weird stuff from merging
YuanboXue-Amber May 3, 2023
70aff78
add required on tagButton content
YuanboXue-Amber May 3, 2023
0e3d6e8
Merge remote-tracking branch 'upstream/master' into tag
YuanboXue-Amber May 4, 2023
7a4f8ff
Update packages/react-components/react-tags/src/components/Tag/useTag…
YuanboXue-Amber May 4, 2023
7646ef5
fix focus outline
ling1726 May 4, 2023
068f236
simplify focus indicator
YuanboXue-Amber May 4, 2023
901b8ad
use one gridArea for media and icon
YuanboXue-Amber May 4, 2023
cf934ff
Merge branch 'master' into tag
YuanboXue-Amber May 9, 2023
43f1b6d
remove extra { enableOutline: true } after merge master fix
YuanboXue-Amber May 9, 2023
48ddb75
remove temp change that publishes tag in storybook
YuanboXue-Amber May 9, 2023
ba61dc3
cleanup change file
YuanboXue-Amber May 9, 2023
22734e4
Revert "cleanup change file"
YuanboXue-Amber May 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/public-docsite-v9/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript
'../../../packages/react-components/react-migration-v0-v9/stories/**/@(index.stories.@(ts|tsx)|*.stories.mdx)',
'../../../packages/react-components/react-migration-v8-v9/stories/**/@(index.stories.@(ts|tsx)|*.stories.mdx)',
'../../../packages/react-components/react-datepicker-compat/stories/**/@(index.stories.@(ts|tsx)|*.stories.mdx)',
// TODO: remove this before PR merge. Just for the purpose of building PR docsite
'../../../packages/react-components/react-tags/stories/**/@(index.stories.@(ts|tsx)|*.stories.mdx)',
],
staticDirs: ['../public'],
addons: [...rootMain.addons],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add `shape` to AvatarContext",
"packageName": "@fluentui/react-avatar",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const AvatarContextProvider: React_2.Provider<AvatarContextValue | undefi

// @internal (undocumented)
export interface AvatarContextValue {
// (undocumented)
shape?: AvatarShape;
// (undocumented)
size?: AvatarSize;
}
Expand Down Expand Up @@ -131,10 +133,13 @@ export type AvatarProps = Omit<ComponentProps<AvatarSlots>, 'color'> & {
color?: 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;
idForColor?: string | undefined;
name?: string;
shape?: 'circular' | 'square';
shape?: AvatarShape;
size?: AvatarSize;
};

// @public
export type AvatarShape = 'circular' | 'square';

// @public
export type AvatarSize = 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export type AvatarSizes = AvatarSize;
*/
export type AvatarSize = 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128;

/**
* Shape of the avatar
*/
export type AvatarShape = 'circular' | 'square';

export type AvatarSlots = {
root: Slot<'span'>;

Expand Down Expand Up @@ -129,7 +134,7 @@ export type AvatarProps = Omit<ComponentProps<AvatarSlots>, 'color'> & {
* The avatar can have a circular or square shape.
* @default circular
*/
shape?: 'circular' | 'square';
shape?: AvatarShape;

/**
* Size of the avatar in pixels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const DEFAULT_STRINGS = {

export const useAvatar_unstable = (props: AvatarProps, ref: React.Ref<HTMLElement>): AvatarState => {
const { dir } = useFluent();
const { size: contextSize } = useAvatarContext();
const { size: contextSize, shape: contextShape } = useAvatarContext();
const {
name,
size = contextSize ?? (32 as const),
shape = 'circular',
shape = contextShape ?? 'circular',
active = 'unset',
activeAppearance = 'ring',
idForColor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { AvatarSize } from '../components/Avatar/Avatar.types';
import { AvatarSize, AvatarShape } from '../components/Avatar/Avatar.types';

const avatarContext = React.createContext<AvatarContextValue | undefined>(undefined);

Expand All @@ -8,6 +8,7 @@ const avatarContext = React.createContext<AvatarContextValue | undefined>(undefi
*/
export interface AvatarContextValue {
size?: AvatarSize;
shape?: AvatarShape;
}

const avatarContextDefaultValue: AvatarContextValue = {};
Expand Down
12 changes: 10 additions & 2 deletions packages/react-components/react-avatar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ export {
useAvatarStyles_unstable,
useAvatar_unstable,
} from './Avatar';
// eslint-disable-next-line deprecation/deprecation
export type { AvatarNamedColor, AvatarProps, AvatarSlots, AvatarState, AvatarSizes, AvatarSize } from './Avatar';
export type {
AvatarNamedColor,
AvatarProps,
AvatarSlots,
AvatarState,
// eslint-disable-next-line deprecation/deprecation
AvatarSizes,
AvatarSize,
AvatarShape,
} from './Avatar';
export { getInitials, partitionAvatarGroupItems } from './utils/index';
export type { PartitionAvatarGroupItems, PartitionAvatarGroupItemsOptions } from './utils/index';
export {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Tag } from '@fluentui/react-tags';

console.log(Tag);

export default {
name: 'Tag',
};
48 changes: 19 additions & 29 deletions packages/react-components/react-tags/etc/react-tags.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

/// <reference types="react" />

import { Avatar } from '@fluentui/react-avatar';
import { AvatarShape } from '@fluentui/react-avatar';
import { AvatarSize } from '@fluentui/react-avatar';
import { Button } from '@fluentui/react-button';
import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
Expand All @@ -15,10 +17,10 @@ import type { Slot } from '@fluentui/react-utilities';
import type { SlotClassNames } from '@fluentui/react-utilities';

// @public
export const renderTag_unstable: (state: TagState) => JSX.Element;
export const renderTag_unstable: (state: TagState, contextValues: TagContextValues) => JSX.Element;

// @public
export const renderTagButton_unstable: (state: TagButtonState) => JSX.Element;
export const renderTagButton_unstable: (state: TagButtonState, contextValues: TagButtonContextValues) => JSX.Element;

// @public
export const Tag: ForwardRefComponent<TagProps>;
Expand All @@ -30,34 +32,19 @@ export const TagButton: ForwardRefComponent<TagButtonProps>;
export const tagButtonClassNames: SlotClassNames<TagButtonSlots>;

// @public
export type TagButtonProps = ComponentProps<TagButtonSlots> & {
size?: 'extra-small' | 'small' | 'medium';
shape?: 'rounded' | 'circular';
appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline';
disabled?: boolean;
checked?: boolean;
dismissable?: boolean;
};
export type TagButtonProps = TagProps;

// @public (undocumented)
export type TagButtonSlots = {
root: NonNullable<Slot<'div'>>;
contentButton?: Slot<'button'>;
avatar?: Slot<typeof Avatar>;
icon?: Slot<'span'>;
primaryText?: Slot<'span'>;
secondaryText?: Slot<'span'>;
dismissButton?: NonNullable<Slot<'button'>>;
};
export type TagButtonSlots = TagSlots;

// @public
export type TagButtonState = ComponentState<TagButtonSlots> & Required<Pick<TagButtonProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'>>;
export type TagButtonState = TagState;

// @public (undocumented)
export const tagClassNames: SlotClassNames<TagSlots>;

// @public
export type TagProps = ComponentProps<TagSlots> & {
export type TagProps = ComponentProps<Partial<TagSlots>> & {
size?: 'extra-small' | 'small' | 'medium';
shape?: 'rounded' | 'circular';
appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline';
Expand All @@ -69,16 +56,19 @@ export type TagProps = ComponentProps<TagSlots> & {
// @public (undocumented)
export type TagSlots = {
root: NonNullable<Slot<'div'>>;
content?: Slot<'span'>;
avatar?: Slot<typeof Avatar>;
icon?: Slot<'span'>;
primaryText?: Slot<'span'>;
secondaryText?: Slot<'span'>;
dismissButton?: NonNullable<Slot<'button'>>;
media: Slot<'span'>;
content: Slot<'div'>;
icon: Slot<'span'>;
primaryText: Slot<'span'>;
secondaryText: Slot<'span'>;
dismissButton: Slot<typeof Button>;
};

// @public
export type TagState = ComponentState<TagSlots> & Required<Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'>>;
export type TagState = ComponentState<TagSlots> & Required<Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'> & {
avatarSize: AvatarSize | undefined;
avatarShape: AvatarShape | undefined;
}>;

// @public
export const useTag_unstable: (props: TagProps, ref: React_2.Ref<HTMLElement>) => TagState;
Expand Down
3 changes: 3 additions & 0 deletions packages/react-components/react-tags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"license": "MIT",
"scripts": {
"build": "just-scripts build",
"bundle-size": "bundle-size measure",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
Expand All @@ -33,8 +34,10 @@
},
"dependencies": {
"@fluentui/react-avatar": "^9.4.10",
"@fluentui/react-button": "^9.3.10",
"@fluentui/react-icons": "^2.0.196",
"@fluentui/react-jsx-runtime": "9.0.0-alpha.2",
"@fluentui/react-tabster": "^9.6.5",
"@fluentui/react-theme": "^9.1.7",
"@fluentui/react-utilities": "^9.8.0",
"@griffel/react": "^1.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { Tag } from './Tag';
import { isConformant } from '../../testing/isConformant';

const requiredProps = {
avatar: {
name: 'Katri Athokas',
},
media: 'media',
icon: 'i',
primaryText: 'Primary text',
secondaryText: 'Secondary text',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import { useTag_unstable } from './useTag';
import { renderTag_unstable } from './renderTag';
import { useTagStyles_unstable } from './useTagStyles';
import { useTagStyles_unstable } from './useTagStyles.styles';
import type { TagProps } from './Tag.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useTagContextValues_unstable } from '../../utils/useTagContextValues';

/**
* Tag component - TODO: add more docs
Expand All @@ -12,7 +13,7 @@ export const Tag: ForwardRefComponent<TagProps> = React.forwardRef((props, ref)
const state = useTag_unstable(props, ref);

useTagStyles_unstable(state);
return renderTag_unstable(state);
return renderTag_unstable(state, useTagContextValues_unstable(state));
});

Tag.displayName = 'Tag';
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
import { AvatarSize, AvatarShape } from '@fluentui/react-avatar';
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import { Avatar } from '@fluentui/react-avatar';
import { Button } from '@fluentui/react-button';

export type TagContextValues = {
avatar: {
size?: AvatarSize;
shape?: AvatarShape;
};
};

export type TagSlots = {
root: NonNullable<Slot<'div'>>;
content?: Slot<'span'>;
avatar?: Slot<typeof Avatar>;
icon?: Slot<'span'>;
primaryText?: Slot<'span'>;
secondaryText?: Slot<'span'>;
dismissButton?: NonNullable<Slot<'button'>>;

/**
* Slot for an icon or other visual element
*/
media: Slot<'span'>;

/**
* A layout wrapper for the icon slot, the primaryText and secondaryText slots
*/
content: Slot<'div'>;

icon: Slot<'span'>;

/**
* Main text for the Tag. Children of the root slot are automatically rendered here
*/
primaryText: Slot<'span'>;

/**
* Secondary text that describes or complements the main text
*/
secondaryText: Slot<'span'>;

dismissButton: Slot<typeof Button>;
};

/**
* Tag Props
*/
export type TagProps = ComponentProps<TagSlots> & {
export type TagProps = ComponentProps<Partial<TagSlots>> & {
size?: 'extra-small' | 'small' | 'medium';
shape?: 'rounded' | 'circular';
appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline';
Expand All @@ -27,4 +53,9 @@ export type TagProps = ComponentProps<TagSlots> & {
* State used in rendering Tag
*/
export type TagState = ComponentState<TagSlots> &
Required<Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'>>;
Required<
Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'> & {
avatarSize: AvatarSize | undefined;
avatarShape: AvatarShape | undefined;
}
>;
Loading