-
Notifications
You must be signed in to change notification settings - Fork 51
chore(Indicator): use predefined icon set #1120
Conversation
| }) | ||
|
|
||
| const processedIcons: ThemeIcons = Object.keys(svgIconsAndStyles as { | ||
| const getIcon = iconAndMaybeStyles => { |
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.
given that it was decided to extract this method, it would be beneficial if we will specify types for the args and return value (actually, the return value type may be the most beneficial piece)
| : (iconAndMaybeStyles as SvgIconSpec) | ||
| } | ||
|
|
||
| const processedIcons: { [key: string]: ThemeIconSpec } = Object.keys(svgIconsAndStyles as { |
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 may use ObjectOf<ThemeIconSpec>
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 use ThemeIcons here as well
| const processedIcons: { [key: string]: ThemeIconSpec } = Object.keys(svgIconsAndStyles as { | ||
| [iconName: string]: TeamsProcessedSvgIconSpec | ||
| }).reduce<ThemeIcons>((accIcons, iconName) => { | ||
| }).reduce<{ [key: string]: ThemeIconSpec }>((accIcons, iconName) => { |
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 can use ThemeIcons at both places where we have { [key: string]: ThemeIconSpec } now - there is no need to use dictionary type. I would suggest to do one of the following:
- use
ThemeIconstype here and forprocessedIconsabove - or remove
ThemeIconsand useObjectOf<ThemeIconSpec>at both places, if you think that this would be more readable
What do you think?
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.
Yep totally agree, at the first implementation the new names were required that is why I was changing these typings, but yes as they are optional now, I can use the same type. Good catch!
packages/react/src/themes/base/components/Icon/fontAwesomeIconStyles.ts
Outdated
Show resolved
Hide resolved
| transform: `rotate(${rotate}deg)`, | ||
| }), | ||
| // override base theme default rtl behavior | ||
| ...(rtl && { |
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.
intent of this and the previous object expansion expressions could be provided in a simpler way:
transfrom: rtl ? 'unset' : `rotate(${rotate}deg)`| getBorderedStyles(v.borderColor || getIconColor(color, v))), | ||
|
|
||
| ...(rtl && { | ||
| transform: `scaleX(-1) rotate(${-1 * rotate}deg)`, |
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 to be sure - seems like rotate prop's value won't have any effect in case if rtl mode is disabled, will it? miss the following style lines from the original file:
...(!rtl && {
transform: `rotate(${rotate}deg)`,
}),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.
yep, will add it
-fixed input test
-fixed input test
Codecov Report
@@ Coverage Diff @@
## master #1120 +/- ##
==========================================
- Coverage 82.09% 82.02% -0.07%
==========================================
Files 724 727 +3
Lines 8661 8670 +9
Branches 1169 1166 -3
==========================================
+ Hits 7110 7112 +2
- Misses 1534 1542 +8
+ Partials 17 16 -1
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| Menu.create = createShorthandFactory({ Component: Menu, mappedArrayProp: 'items' }) | ||
| Menu.slotClassNames = { |
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.
lets follow the same approach that is introduced for other components (i.e. use the dedicated static field for now) - given that the problem with cyclic dependencies was solved in other way. We might want to reconsider the way slotClassNames are introduced later
| // https://github.com/Semantic-Org/Semantic-UI-CSS/blob/master/components/icon.css | ||
| // Corrections were made to duplicate icon names and incorrectly mapped alternates | ||
| const fontAwesomeIcons: ThemeIcons = { | ||
| const fontAwesomeIcons: { [key: string]: ThemeIconSpec } = { |
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.
may we use ThemeIcons type here as well?
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.
Yep, changed
| const modifiedSizes = { | ||
| large: { | ||
| x: 24, | ||
| xx: 28, |
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'm not sure that this is part of base theme...
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 that back to the teams theme. The base theme now is always creating icon with fontSize of 16px
|
|
||
| const iconStyles: ComponentSlotStylesInput<IconProps, IconVariables> = { | ||
| root: ({ | ||
| props: { name, size, bordered, circular, xSpacing, rotate }, |
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.
As we use p. instead?
| Menu.create = createShorthandFactory({ Component: Menu, mappedArrayProp: 'items' }) | ||
| Menu.slotClassNames = { | ||
| divider: `${Menu.className}__divider`, | ||
| item: `${Menu.className}__item`, |
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.
fyi @layershifter @sophieH29 this will fix your issue
bmdalex
left a comment
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.
changelog and merge 👍
# Conflicts: # CHANGELOG.md # packages/react/src/components/Indicator/Indicator.tsx
Fixes #896 Added default icons set for the icons used in the Stardust's component:
It's considered theme's responsibility to implement the rtl behavior of the icons. These icons are added in the base theme as well, by using font awesome icons.
TODO
BREAKING CHANGES:
Replace
Indicatorcomponent withIconand replace thedirectionprop withnamein the following manner:end=>stardust-arrow-endbottom=>stardust-arrow-downtop=>stardust-arrow-up