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

Commit

Permalink
fix(Text): refactor variables to match size prop (#762)
Browse files Browse the repository at this point in the history
* fix(Text): refactor variables to match size prop

* fix keys warning

* fix size value

* add sizes for Teams theme

* add entry

* revert teams theme change

* add separate lineHeight variables
  • Loading branch information
layershifter authored Jan 24, 2019
1 parent 178e6fa commit d767a49
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### BREAKING CHANGES
- Update variable names in themes, add missing sizes @layershifter ([#762](https://github.com/stardust-ui/react/pull/762))

<!--------------------------------[ v0.18.0 ]------------------------------- -->
## [v0.18.0](https://github.com/stardust-ui/react/tree/v0.18.0) (2019-01-24)
[Compare changes](https://github.com/stardust-ui/react/compare/v0.17.0...v0.18.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const TextExampleColor = () => (
<ProviderConsumer
render={({ siteVariables: { emphasisColors, naturalColors } }) =>
_.keys({ ...emphasisColors, ...naturalColors }).map(color => (
<>
<Text key={color} color={color} content={_.startCase(color)} />
<React.Fragment key={color}>
<Text color={color} content={_.startCase(color)} />
<br />
</>
</React.Fragment>
))
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ const TextExampleColor = () => (
<ProviderConsumer
render={({ siteVariables: { emphasisColors, naturalColors } }) =>
_.keys({ ...emphasisColors, ...naturalColors }).map(color => (
<>
<Text key={color} color={color}>
{_.startCase(color)}
</Text>
<React.Fragment key={color}>
<Text color={color}>{_.startCase(color)}</Text>
<br />
</>
</React.Fragment>
))
}
/>
Expand Down
16 changes: 12 additions & 4 deletions src/themes/base/components/Text/textStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export default {
fontWeight: v.fontWeightBold,
}),

...(size === 'smallest' && {
fontSize: v.fontSizeSmallest,
lineHeight: v.fontLineHeightSmallest,
}),
...(size === 'smaller' && {
fontSize: v.fontSizeExtraSmall,
lineHeight: v.fontLineHeightExtraSmall,
fontSize: v.fontSizeSmaller,
lineHeight: v.fontLineHeightSmaller,
}),
...(size === 'small' && {
fontSize: v.fontSizeSmall,
Expand All @@ -70,8 +74,12 @@ export default {
lineHeight: v.fontLineHeightLarge,
}),
...(size === 'larger' && {
fontSize: v.fontSizeExtraLarge,
lineHeight: v.fontLineHeightExtraLarge,
fontSize: v.fontSizeLarger,
lineHeight: v.fontLineHeightLarger,
}),
...(size === 'largest' && {
fontSize: v.fontSizeLargest,
lineHeight: v.fontLineHeightLargest,
}),
}
},
Expand Down
30 changes: 20 additions & 10 deletions src/themes/base/components/Text/textVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ export interface TextVariables {
errorColor: string
successColor: string

fontSizeExtraSmall: string
fontSizeSmallest: string
fontSizeSmaller: string
fontSizeSmall: string
fontSizeMedium: string
fontSizeLarge: string
fontSizeExtraLarge: string
fontSizeLarger: string
fontSizeLargest: string

fontLineHeightExtraSmall: number
fontLineHeightSmallest: number
fontLineHeightSmaller: number
fontLineHeightSmall: number
fontLineHeightMedium: number
fontLineHeightLarge: number
fontLineHeightExtraLarge: number
fontLineHeightLarger: number
fontLineHeightLargest: number

fontWeightLight: number
fontWeightSemilight: number
Expand All @@ -47,20 +51,26 @@ export default (siteVariables): TextVariables => {
errorColor: siteVariables.colors.red[500],
successColor: siteVariables.colors.green[500],

fontSizeExtraSmall: siteVariables.fontSizes.smaller,
fontLineHeightExtraSmall: siteVariables.lineHeightExtraSmall,
fontSizeSmallest: siteVariables.fontSizes.smallest,
fontLineHeightSmallest: siteVariables.lineHeightSmallest,

fontSizeSmaller: siteVariables.fontSizes.smaller,
fontLineHeightSmaller: siteVariables.lineHeightSmaller,

fontSizeSmall: siteVariables.fontSizes.small,
fontLineHeightSmall: siteVariables.lineHeightSmall,

fontSizeMedium: siteVariables.fontSizes.medium,
fontLineHeightMedium: siteVariables.lineHeightBase,
fontLineHeightMedium: siteVariables.lineHeightMedium,

fontSizeLarge: siteVariables.fontSizes.large,
fontLineHeightLarge: siteVariables.lineHeightSmall,
fontLineHeightLarge: siteVariables.lineHeightLarge,

fontSizeLarger: siteVariables.fontSizes.larger,
fontLineHeightLarger: siteVariables.lineHeightLarger,

fontSizeExtraLarge: siteVariables.fontSizes.larger,
fontLineHeightExtraLarge: siteVariables.lineHeightSmall,
fontSizeLargest: siteVariables.fontSizes.largest,
fontLineHeightLargest: siteVariables.lineHeightLargest,

fontWeightLight: siteVariables.fontWeightLight,
fontWeightSemilight: siteVariables.fontWeightSemilight,
Expand Down
10 changes: 8 additions & 2 deletions src/themes/base/siteVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export { colors, contextualColors, emphasisColors, naturalColors, colorScheme }
// FONT SIZES
//
export const fontSizes = {
smallest: '0.8rem',
smaller: '1rem',
small: '1.2rem',
medium: '1.4rem',
large: '1.8rem',
larger: '2.4rem',
largest: '3rem',
}

//
Expand All @@ -27,6 +29,10 @@ export const fontWeightBold = 700
//
// LINE HEIGHTS
//
export const lineHeightBase = 1.4286
export const lineHeightSmallest = 1.2
export const lineHeightSmaller = 1.2
export const lineHeightSmall = 1.3333
export const lineHeightExtraSmall = 1.2
export const lineHeightMedium = 1.4286
export const lineHeightLarge = 1.3333
export const lineHeightLarger = 1.3333
export const lineHeightLargest = 1.3333
2 changes: 1 addition & 1 deletion src/themes/teams/components/Menu/menuVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ export default (siteVars: any): MenuVariables => {

disabledColor: siteVars.gray06,

lineHeightBase: siteVars.lineHeightBase,
lineHeightBase: siteVars.lineHeightMedium,
}
}
8 changes: 5 additions & 3 deletions src/themes/teams/siteVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ export const fontWeightBold = 700
//
// LINE HEIGHTS
//
export const lineHeightBase = 1.4286
export const lineHeightSmaller = 1.2
export const lineHeightSmall = 1.3333
export const lineHeightExtraSmall = 1.2
export const lineHeightMedium = 1.4286
export const lineHeightLarge = 1.3333
export const lineHeightLarger = 1.3333

//
// SEMANTIC ASSIGNMENTS
Expand All @@ -97,4 +99,4 @@ export const bodyFontFamily =
export const bodyFontSize = '1.4rem'
export const bodyBackground = white
export const bodyColor = black
export const bodyLineHeight = lineHeightBase
export const bodyLineHeight = lineHeightMedium

0 comments on commit d767a49

Please sign in to comment.