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

Commit de45998

Browse files
authored
feat(Label): added black and white colors for the color prop (#855)
* -added black color * -remove console log * -improved typings for the complex color values * -replaced hex values with theme's colors * -updated changelog * -fixed changelog * -fixed changelog entry * -addressing PR comments * -updated black to be `#000` * -updated for the siteVariables black color -added Breaking change entry in changelog * Update packages/react/src/themes/teams/colors.ts Co-Authored-By: mnajdova <mnajdova@gmail.com> * -added import statements
1 parent 0f431ed commit de45998

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## [Unreleased]
1919

20+
### BREAKING CHANGES
21+
- Changed site variables' `colors.black` to be `#000` instead of `grey[900](#252424)` in Teams theme @mnajdova ([#855](https://github.com/stardust-ui/react/pull/855))
22+
2023
### Features
2124
- Add single search flavor for `Dropdown` component @Bugaa92 ([#839](https://github.com/stardust-ui/react/pull/839))
2225
- Add multiple selection flavor for `Dropdown` component @Bugaa92 ([#845](https://github.com/stardust-ui/react/pull/845))
26+
- Add `black` and `white` options for the `color` prop of the `Label` component @mnajdova ([#855](https://github.com/stardust-ui/react/pull/855))
2327

2428
<!--------------------------------[ v0.20.0 ]------------------------------- -->
2529
## [v0.20.0](https://github.com/stardust-ui/react/tree/v0.20.0) (2019-02-06)

packages/react/src/components/Label/Label.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ import Image from '../Image/Image'
2020
import Layout from '../Layout/Layout'
2121
import { Accessibility } from '../../lib/accessibility/types'
2222
import { ReactProps, ShorthandValue } from '../../types'
23-
import { ComplexColorPropType } from '../../lib/commonPropInterfaces'
23+
import {
24+
ComplexColorPropType,
25+
ColorValuesWithPrimitiveColors,
26+
} from '../../lib/commonPropInterfaces'
2427

2528
export interface LabelProps
2629
extends UIComponentProps,
2730
ChildrenComponentProps,
2831
ContentComponentProps,
29-
ColorComponentProps<ComplexColorPropType> {
32+
ColorComponentProps<ComplexColorPropType<ColorValuesWithPrimitiveColors>> {
3033
accessibility?: Accessibility
3134

3235
/** A Label can be circular. */

packages/react/src/lib/commonPropInterfaces.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ export type ColorValue =
4141
| 'yellow'
4242
| string
4343

44-
export type ComplexColorPropType =
44+
export type ColorValuesWithPrimitiveColors = ColorValue | 'black' | 'white'
45+
46+
export type ComplexColorPropType<TColorValue = ColorValue> =
4547
| {
46-
foreground?: ColorValue
47-
background?: ColorValue
48-
border?: ColorValue
49-
shadow?: ColorValue
48+
foreground?: TColorValue
49+
background?: TColorValue
50+
border?: TColorValue
51+
shadow?: TColorValue
5052
}
51-
| ColorValue
53+
| TColorValue
5254

5355
export interface ColorComponentProps<TColor = ColorValue> {
5456
/** A component can have a color. */

packages/react/src/themes/teams/colors.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
EmphasisColors,
77
NaturalColors,
88
ColorSchemeMapping,
9+
PrimitiveColors,
10+
ColorScheme,
911
} from '../types'
1012

1113
export const emphasisColors: EmphasisColors = {
@@ -163,13 +165,28 @@ export const colors: ColorPalette = {
163165
...contextualColors,
164166

165167
// Primitive colors
166-
black: naturalColors.grey[900],
168+
black: '#000',
167169
white: naturalColors.grey[50],
168170
}
169171

170-
export const colorScheme: ColorSchemeMapping = _.mapValues(
171-
emphasisAndNaturalColors,
172-
(colorVariants, colorName) => {
172+
const primitiveColorsScheme: Record<keyof PrimitiveColors, ColorScheme> = {
173+
black: {
174+
foreground: colors.white,
175+
border: colors.white,
176+
shadow: colors.white,
177+
background: colors.black,
178+
},
179+
white: {
180+
foreground: colors.black,
181+
border: colors.black,
182+
shadow: colors.black,
183+
background: colors.white,
184+
},
185+
}
186+
187+
export const colorScheme: ColorSchemeMapping = {
188+
...primitiveColorsScheme,
189+
..._.mapValues(emphasisAndNaturalColors, (colorVariants, colorName) => {
173190
const foreground = isLightBackground(colorName) ? colors.black : colorVariants[50]
174191

175192
return {
@@ -184,5 +201,5 @@ export const colorScheme: ColorSchemeMapping = _.mapValues(
184201
background: colors.grey[100],
185202
},
186203
}
187-
},
188-
)
204+
}),
205+
}

packages/react/src/themes/teams/siteVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const htmlFontSize = '10px' // what 1rem represents
1111
//
1212
export { colors, contextualColors, emphasisColors, naturalColors, colorScheme } from './colors'
1313

14-
export const black = colors.black
14+
export const black = colors.grey[900]
1515
export const gray02 = '#484644'
1616
export const gray03 = '#605E5C'
1717
export const gray04 = '#979593'

0 commit comments

Comments
 (0)