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

feat(themes): add FontAwesome theme #1337

Merged
merged 26 commits into from
May 20, 2019
Merged

feat(themes): add FontAwesome theme #1337

merged 26 commits into from
May 20, 2019

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented May 14, 2019

BREAKING CHANGES

FontAwesome icons is not a part of Teams theme more consider to use SVG icons.


FontAwesome styles were extracted to a separate theme which can be merged with the base for example.

import { mergeThemes, themes } from '@stardust-ui/react'

const myTheme = mergeThemes(themes.base, themes.fontAwesome)

Adds separate roots for font and SVG icons, so styles can be configured independently now without conditions in styles:

root: () => {} // will be applied to both types
fontRoot: () => {} // will be applied only for font icons
svgRoot: () => {} // will be applied only for SVG icons

@codecov
Copy link

codecov bot commented May 14, 2019

Codecov Report

Merging #1337 into master will increase coverage by 0.19%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1337      +/-   ##
==========================================
+ Coverage    72.2%   72.39%   +0.19%     
==========================================
  Files         769      770       +1     
  Lines        5777     5749      -28     
  Branches     1688     1680       -8     
==========================================
- Hits         4171     4162       -9     
+ Misses       1600     1581      -19     
  Partials        6        6
Impacted Files Coverage Δ
...t/src/themes/base/components/Icon/iconVariables.ts 0% <ø> (ø) ⬆️
packages/react/src/themes/teams/index.tsx 90.9% <ø> (ø)
...eams/components/RadioGroup/radioGroupItemStyles.ts 18.18% <ø> (ø) ⬆️
...c/themes/font-awesome/components/Icon/iconNames.ts 100% <ø> (ø)
.../src/themes/teams/components/Icon/iconVariables.ts 0% <0%> (ø) ⬆️
...eact/src/themes/base/components/Icon/iconStyles.ts 17.39% <0%> (-2.61%) ⬇️
...react/src/components/RadioGroup/RadioGroupItem.tsx 100% <100%> (ø) ⬆️
packages/react/src/components/Icon/Icon.tsx 100% <100%> (+33.33%) ⬆️
...react/src/themes/base/components/Icon/iconNames.ts 75% <100%> (ø)
...teams/components/Icon/svg/icons/stardustCircle.tsx 100% <100%> (ø)
... and 4 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 f0635e4...3ec7f3d. Read the comment docs.

@layershifter layershifter marked this pull request as ready for review May 16, 2019 14:05
@@ -20,7 +20,7 @@ class App extends React.Component<any, ThemeContextData> {
<ThemeContext.Provider value={this.state}>
<Provider
as={React.Fragment}
theme={mergeThemes(themes[themeName], {
theme={mergeThemes(themes.fontAwesome, themes[themeName], {
Copy link
Member Author

Choose a reason for hiding this comment

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

We're using FA on docs, but we don't to have this theme in any other even in base

@@ -540,6 +540,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
render={this.renderElement}
renderHtml={showCode}
resolver={importResolver}
themeName={themeName}
Copy link
Member Author

Choose a reason for hiding this comment

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

This will allow us to access themeName in example components

@@ -18,7 +18,7 @@ const AvatarExampleImageCustomizationShorthand = () => (
// This example does not react to the avatar size variable
// and otherwise produces bad results when border is applied compared to "normal" image
<Icon
name="user"
name="lock"
Copy link
Member Author

Choose a reason for hiding this comment

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

Teams theme doesn't have this icon and font icons will not be supported inside of it

Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confuse here. We are changing only this icon because Teams' theme doesn't support font icons? What about all other examples like: 'chess rook', 'book' etc. Are we planning to move all examples for now to reflect the Teams' theme icon names?

Copy link
Member Author

@layershifter layershifter May 17, 2019

Choose a reason for hiding this comment

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

We are changing only this icon because Teams' theme doesn't support font icons?

This slot in attachment requires an additional styling for font icons that is not present, so yes.

styles: {
...(isSvgIcon ? styles.svgRoot : styles.fontRoot),
...styles.root,
},
Copy link
Member Author

@layershifter layershifter May 16, 2019

Choose a reason for hiding this comment

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

I have to use styles to avoid collisions in generated classes names... The other option is to use generateCSS() directly, but I will need to get renderer from somewhere

color: v.disabledColor,
}),
}),
fontRoot: ({ props: p, variables: v, theme: t }): ICSSInJSStyle => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Now we have separate roots for SVG and font icons that allows to apply overrides without conditions

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that we have two things separated 👍

mediumSize: string
largeSize: string
largerSize: string
largestSize: string
Copy link
Member Author

Choose a reason for hiding this comment

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

Size values where moved to variables

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure that these size values are general enough for base theme...

Copy link
Member Author

Choose a reason for hiding this comment

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

Base theme should support size prop properly and we should avoid nesting in variables. Do you have better proposal? 🐱

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we should have variables and use this, I was saying about the size values (which now reflect the Teams theme) If you think these values are general and should be defined as this, then I am okay

@layershifter layershifter added 🧰 fix Introduces fix for broken behavior. 🚀 ready for review and removed 🚧 WIP labels May 16, 2019
export default {
icons,
componentStyles,
} as ThemeInput
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not expose this theme to the users? Everything is breaking if I choose this one on the Icon's docs. I don't see any benefit for the clients to explore this theme..


const iconStyles: ComponentSlotStylesInput<IconProps, IconVariables> = {
fontRoot: (): ICSSInJSStyle => ({
fontWeight: 900, // required for the fontAwesome to render
Copy link
Contributor

Choose a reason for hiding this comment

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

It's great that the only required override is actually related to the font awesome icons. I would really like the same thing to be applicable for svgs :)

@@ -64,6 +64,7 @@ const radioStyles: ComponentSlotStylesInput<
// overrides from icon styles
backgroundColor: 'transparent',
boxShadow: 'none',
boxSizing: 'border-box',
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be applied by default?? We are using only svg icons and they already have border-box

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on offline discussion we decided to add a new icon and use it.

return {
display: 'inline-block',
backgroundColor: v.backgroundColor,
boxSizing: 'border-box',
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for specifying boxSizing: 'border-box'. Teams theme users only svg icons, and there is no prev definition of 'content-box' (it is for font icons in base theme, not svg)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 fix Introduces fix for broken behavior. 🚀 ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants