Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

chore(Indicator): use predefined icon set #1120

Merged
merged 22 commits into from
Mar 29, 2019
Merged

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Mar 27, 2019

Fixes #896 Added default icons set for the icons used in the Stardust's component:

  • stardust-close (used in Input and Dropdown)
  • stardust-arrow-down (used in AccordionTitle and Dropdown)
  • stardust-arrow-up (used in Dropdown)
  • stardust-arrow-end (used in AccordionTitle)

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

  • update changelog

BREAKING CHANGES:

Replace Indicator component with Icon and replace the direction prop with name in the following manner:

  • end => stardust-arrow-end
  • bottom => stardust-arrow-down
  • top => stardust-arrow-up

@mnajdova mnajdova changed the title WIP chore(Indicator): use predefined icon set chore(Indicator): use predefined icon set Mar 28, 2019
@@ -12,21 +12,33 @@ const declareSvg = (svgIcon: SvgIconSpec, exportedAs?: string): ThemeProcessedIc
exportedAs,
})

const processedIcons: ThemeIcons = Object.keys(svgIconsAndStyles as {
const getIcon = iconAndMaybeStyles => {
Copy link
Contributor

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 {
Copy link
Contributor

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>

Copy link
Contributor Author

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

[iconName: string]: TeamsProcessedSvgIconSpec
}).reduce<ThemeIcons>((accIcons, iconName) => {
}).reduce<{ [key: string]: ThemeIconSpec }>((accIcons, iconName) => {
Copy link
Contributor

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 ThemeIcons type here and for processedIcons above
  • or remove ThemeIcons and use ObjectOf<ThemeIconSpec> at both places, if you think that this would be more readable

What do you think?

Copy link
Contributor Author

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!

@@ -130,6 +130,10 @@ const iconStyles: ComponentSlotStylesInput<IconProps, IconVariables> = {
...(!rtl && {
transform: `rotate(${rotate}deg)`,
}),
// override base theme default rtl behavior
...(rtl && {
Copy link
Contributor

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)`,
Copy link
Contributor

@kuzhelov kuzhelov Mar 28, 2019

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)`,
}),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, will add it

@codecov
Copy link

codecov bot commented Mar 28, 2019

Codecov Report

Merging #1120 into master will decrease coverage by 0.06%.
The diff coverage is 54.28%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/react/src/index.ts 100% <ø> (ø) ⬆️
...con/svg/ProcessedIcons/icons-triangle-up-small.tsx 100% <ø> (ø) ⬆️
packages/react/src/components/Menu/MenuItem.tsx 61.26% <0%> (-0.35%) ⬇️
packages/react/src/components/Input/Input.tsx 100% <100%> (ø) ⬆️
...mes/teams/components/Icon/svg/icons/triangleUp.tsx 100% <100%> (ø)
packages/react/src/themes/base/index.ts 100% <100%> (ø) ⬆️
...ckages/react/src/themes/base/componentVariables.ts 100% <100%> (ø) ⬆️
packages/react/src/themes/base/componentStyles.ts 100% <100%> (ø) ⬆️
...ges/react/src/themes/base/components/Icon/index.ts 100% <100%> (ø)
...t/src/themes/base/components/Icon/iconVariables.ts 100% <100%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b50927b...d92dd94. Read the comment docs.

@@ -225,5 +222,9 @@ class Menu extends AutoControlledComponent<ReactProps<MenuProps>, MenuState> {
}

Menu.create = createShorthandFactory({ Component: Menu, mappedArrayProp: 'items' })
Menu.slotClassNames = {
Copy link
Contributor

@kuzhelov kuzhelov Mar 29, 2019

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

@@ -11,7 +11,7 @@ const brand = (content: string) => fontIcon(content, '"Font Awesome 5 Brands"')
// Originally generated from:
// 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 } = {
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Member

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...

Copy link
Contributor Author

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 },
Copy link
Member

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?

@@ -225,5 +222,9 @@ class Menu extends AutoControlledComponent<ReactProps<MenuProps>, MenuState> {
}

Menu.create = createShorthandFactory({ Component: Menu, mappedArrayProp: 'items' })
Menu.slotClassNames = {
divider: `${Menu.className}__divider`,
item: `${Menu.className}__item`,
Copy link
Collaborator

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

Copy link
Collaborator

@bmdalex bmdalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog and merge 👍

manajdov added 2 commits March 29, 2019 13:57
# Conflicts:
#	CHANGELOG.md
#	packages/react/src/components/Indicator/Indicator.tsx
@mnajdova mnajdova merged commit adae2df into master Mar 29, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/predefined-icon-set branch March 29, 2019 13:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon|Dropdown: components use an icon as indicator
4 participants