-
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
feat(icon): convert icon slots to ShorthandValue<BoxProps> #12489
feat(icon): convert icon slots to ShorthandValue<BoxProps> #12489
Conversation
-updated button props and examples
-fixed inconsistencies
…ents-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com>
…ents-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com>
…ents-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com>
-added Icon suffix in name test
@@ -92,7 +92,8 @@ class DropdownSelectedItem extends UIComponent<WithAsProp<DropdownSelectedItemPr | |||
}; | |||
|
|||
static defaultProps = { | |||
icon: 'close', | |||
// TODO: fix me | |||
icon: <CloseIcon />, |
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.
Will be fixed in a follow up PR to avoid unrelated changes
@@ -69,7 +69,7 @@ const ComponentControls: React.FC<ComponentControlsProps> = props => { | |||
aria-label={toolbarAriaLabel || null} | |||
items={[ | |||
{ | |||
icon: { name: 'code', style: { width: '20px', height: '20px' } }, | |||
icon: <Icon name={'code'} {...{ style: { width: '20px', height: '20px' } }} />, |
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.
Any reason to actually use spread for style instead of direct using the prop/attribute?
icon: <Icon name="code" style={{ width: '20px', height: '20px' }} />,
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 was auto generated by the codemods, which basically remove the name prop and spread the rest of the object on the component.
<Button | ||
as={Link} | ||
content={next.name} | ||
icon={<Icon name="arrow right" />} |
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.
Should it be <ArrowRightIcon />
?
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 a font icon, we don't have mapping for an svg icon
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.
You mean when using icon in the button is font Icon or the arrow left
itself? I got confused because PopupExamplePointing.shorthand.tsx
it was using <ArrowRightIcon />
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.
It is a bit confusion yeah. Basically name="arrow-left"
can be transform to <ArrowLeftIcon />
, but here the name is arrow left
which is a different font icon. Anyway, as it is not in an example we can change it to <ArrowRightIcon />
, but my point was that it is a different icon.
packages/fluentui/react-northstar/src/themes/teams/components/Status/statusStyles.ts
Outdated
Show resolved
Hide resolved
packages/fluentui/react-northstar/src/themes/teams/components/Menu/menuItemStyles.ts
Outdated
Show resolved
Hide resolved
@@ -447,7 +448,8 @@ class Toolbar extends UIComponent<WithAsProp<ToolbarProps>> { | |||
<Ref innerRef={this.overflowItemRef}> | |||
{ToolbarItem.create(overflowItem, { | |||
defaultProps: () => ({ | |||
icon: { name: 'more', outline: true }, | |||
// TODO: ups | |||
icon: <MoreIcon {...{ outline: true }} />, |
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.
Will be fixed after these changes are merged
styles: resolvedStyles.icon, | ||
xSpacing: 'none', |
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 default no need for overriding styles
@@ -105,12 +104,6 @@ const Label: React.FC<WithAsProp<LabelProps>> & FluentComponentStaticProps = pro | |||
rtl: context.rtl, | |||
}); | |||
|
|||
const handleIconOverrides = (predefinedProps: IconProps) => ({ |
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.
No need for this as xSpacing: undefined == 'none' is default
const { clearable, icon } = this.props; | ||
const { value } = this.state; | ||
|
||
if (clearable && (value as string).length !== 0) { | ||
return { name: '' }; |
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.
Yeey
defaultProps: () => | ||
getA11Props('icon', { | ||
styles: resolvedStyles.icon, | ||
xSpacing: !content ? 'none' : iconPosition === 'after' ? 'before' : 'after', |
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.
Moved to styles
# Conflicts: # packages/fluentui/react-northstar/src/components/Alert/Alert.tsx
packages/fluentui/docs/src/prototypes/chatPane/services/messageFactoryMock.tsx
Outdated
Show resolved
Hide resolved
packages/fluentui/docs/src/prototypes/chatPane/services/messageFactoryMock.tsx
Outdated
Show resolved
Hide resolved
…eFactoryMock.tsx Co-Authored-By: Roman Sudarikov <pompomon@users.noreply.github.com>
…eFactoryMock.tsx Co-Authored-By: Roman Sudarikov <pompomon@users.noreply.github.com>
…#12489) * wip * -fixed imports * -added icons * -reverted unintended changes * -reverted unintended changes * -reverted unintended changes * -reverted unintended changes * -fixed imports * -added redPath * -updated icon prop to box shorthand -updated button props and examples * -fixed jest config * -fixed references * -added components tests -fixed inconsistencies * -ts-morphin experiments * -perf experiments * -perf experiments * Update packages/fluentui/react-icons-northstar/test/components/components-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * Update packages/fluentui/react-icons-northstar/test/components/components-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * Update packages/fluentui/react-icons-northstar/test/components/components-test.tsx Co-Authored-By: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * -added packages * -fixed tests * -added Icon suffix * -reverted perf test changes * -removed author from package.json * -changed some icon names to reflect the previous names -added Icon suffix in name test * -removed comments * -fixed names * ts-morphin changes * -more ts-morphin changes * -more ts-morphin changes * -updated styles * -updated menuItemStyles * -fixed renderConfig * -more ts morphin changes * -more ts morphin changes (collection components) * -added as: 'span' in MenuItem * -more changes f+r * -more changes ts-morphin * -more changes ts-morphin * -more changes ts-morphin * -more changes ts-morphin * -more changes ts-morphin * -fixes * -more changes f & r * -more changes f & r * -more changes f & r * -more changes f & r * -more changes f & r * -fixes in status styles * -fixes in components still dependent on icons * -fixes * -fixes * -fixed some styles * -fixed some styles and examples * -test button styles * -added variables * -added variables * -fixed toolbar menu item icon spacing * -removed comment * -fixed tests * Update packages/fluentui/docs/src/prototypes/chatPane/services/messageFactoryMock.tsx Co-Authored-By: Roman Sudarikov <pompomon@users.noreply.github.com> * Update packages/fluentui/docs/src/prototypes/chatPane/services/messageFactoryMock.tsx Co-Authored-By: Roman Sudarikov <pompomon@users.noreply.github.com> * -final fixes * -fixed tests * -fixed tests Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com> Co-authored-by: Roman Sudarikov <pompomon@users.noreply.github.com>
This PR changes all icon slots inside
@fluentui/react-northstar
to be shorthands of Box. All icon shorthands are replaced with icon components from the@fluentui/react-icons-northstar package
.This PR will not remove the Icon comeponent and will not change the Icon docs. Those will be implemented in follow up PRs.
There are few broken screeners mainly because of font -> svg icon changes
TODOs:
BREAKING CHANGES
The icon prop in the following components was changed from
ShorthandValue<IconProps>
toShorthandValue<BoxProps>
:The conversion looks like this:
Codemods prepared for the migration: https://github.com/joschect/ts-morphin-migration/tree/iconbranch
Note:
The codemods works only known component icon props, where the value string or object literal on the components.
Steps for migration:
<Icon ..></Icon> => <Icon ... />
icon=\{[^<]
icon: \{
icon: "(\w+)"
icon: "(\w+)-(\w+)"
icon: "(\w+)-(\w+)-(\w+)"
<Icon.*name