Skip to content

Commit e55929d

Browse files
nicholasricechrisdholt
authored andcommitted
feat: remove deprecated design-system values (#1567)
* remove deprecated design system values * removing deprecated design-system values and updating dev-site to work with changes * rename outlinePatternOutlineWidth to outlineWidth * fix button and input BREAKING CHANGE: removes/renames design system values
1 parent 134b23c commit e55929d

File tree

12 files changed

+103
-114
lines changed

12 files changed

+103
-114
lines changed

packages/fast-components-react-msft/app/app.tsx

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
1-
import * as examples from "./examples";
21
import { ComponentStyles, CSSRules } from "@microsoft/fast-jss-manager";
3-
import manageJss, { DesignSystemProvider } from "@microsoft/fast-jss-manager-react";
4-
import {
5-
DensityOffset,
6-
DesignSystem,
7-
DesignSystemDefaults,
8-
} from "@microsoft/fast-components-styles-msft";
9-
import { Plugin, PluginProps } from "@microsoft/fast-tooling-react";
10-
import {
11-
HypertextClassNameContract,
12-
ManagedClasses,
13-
} from "@microsoft/fast-components-class-name-contracts-base";
14-
import { glyphBuildingblocks } from "@microsoft/fast-glyphs-msft";
15-
import React from "react";
16-
import { Direction } from "@microsoft/fast-web-utilities";
17-
import AdditionalPropsPlugin from "./utilities/additional-props.plugin";
182
import Site, {
193
componentFactory,
204
formChildFromExamplesFactory,
215
FormChildOption,
226
ShellSlot,
237
SiteCategory,
248
SiteCategoryIcon,
25-
SiteCategoryItem,
26-
SiteMenu,
27-
SiteMenuItem,
28-
SiteProps,
299
SiteTitle,
3010
SiteTitleBrand,
3111
Theme,
3212
} from "@microsoft/fast-development-site-react";
33-
import { Hypertext } from "../src/hypertext";
13+
import {
14+
DensityOffset,
15+
DesignSystem,
16+
DesignSystemDefaults,
17+
} from "@microsoft/fast-components-styles-msft";
18+
import { Plugin, PluginProps } from "@microsoft/fast-tooling-react";
19+
import { HypertextClassNameContract } from "@microsoft/fast-components-class-name-contracts-base";
20+
import { glyphBuildingblocks } from "@microsoft/fast-glyphs-msft";
21+
import React from "react";
22+
import { Direction } from "@microsoft/fast-web-utilities";
23+
import AdditionalPropsPlugin from "./utilities/additional-props.plugin";
24+
import * as examples from "./examples";
3425
import ColorPicker, { ColorConfig } from "./color-picker";
3526
import reactHTMLElementExamples from "./components/react-html-element-child-option";
3627
import reactSVGElementExamples from "./components/svg-svg-element-child-option";
@@ -39,7 +30,14 @@ import carouselDarkImageContentExamples from "./components/carousel-dark-image-c
3930
import carouselLightImageContentExamples from "./components/carousel-light-image-content-child-options";
4031
import pivotItemContentExamples from "./components/pivot-item-content-child-options";
4132
import pivotItemTabExamples from "./components/pivot-item-tab-child-options";
42-
import { Label } from "../src/label";
33+
import {
34+
ColorHSL,
35+
ColorPalette,
36+
ColorRGBA64,
37+
hslToRGB,
38+
parseColor,
39+
rgbToHSL,
40+
} from "@microsoft/fast-colors";
4341

4442
/* tslint:disable-next-line */
4543
const sketchDesignKit = require("./fast-dna-msft-design-kit.sketch");
@@ -54,6 +52,10 @@ const formChildOptions: FormChildOption[] = [
5452
pivotItemTabExamples,
5553
].concat(formChildFromExamplesFactory(examples));
5654

55+
const dark: string = "#111111";
56+
const light: string = "#FFFFFF";
57+
const accent: string = "#0078D4";
58+
5759
const formPlugins: Array<Plugin<PluginProps>> = [
5860
new AdditionalPropsPlugin({
5961
id: [
@@ -90,6 +92,8 @@ enum ThemeName {
9092
}
9193

9294
export interface AppState extends ColorConfig {
95+
accentPalette: string[];
96+
neutralPalette: string[];
9397
theme: ThemeName;
9498
direction: Direction;
9599
density: DensityOffset;
@@ -100,12 +104,12 @@ export default class App extends React.Component<{}, AppState> {
100104
{
101105
id: ThemeName.light,
102106
displayName: ThemeName.light,
103-
background: DesignSystemDefaults.backgroundColor,
107+
background: light,
104108
},
105109
{
106110
id: ThemeName.dark,
107111
displayName: ThemeName.dark,
108-
background: DesignSystemDefaults.foregroundColor,
112+
background: dark,
109113
},
110114
{ id: ThemeName.custom, displayName: ThemeName.custom },
111115
];
@@ -114,10 +118,11 @@ export default class App extends React.Component<{}, AppState> {
114118
super(props);
115119

116120
this.state = {
121+
accentColor: accent,
122+
accentPalette: this.createColorPalette(parseColor(accent)),
123+
neutralPalette: this.createColorPalette(new ColorRGBA64(0.5, 0.5, 0.5, 1)),
117124
direction: Direction.ltr,
118-
foregroundColor: DesignSystemDefaults.foregroundColor,
119125
backgroundColor: DesignSystemDefaults.backgroundColor,
120-
accentColor: DesignSystemDefaults.brandColor,
121126
theme: ThemeName.light,
122127
density: DesignSystemDefaults.density,
123128
};
@@ -172,7 +177,6 @@ export default class App extends React.Component<{}, AppState> {
172177
onChange={this.handleDensityUpdate}
173178
/>
174179
<ColorPicker
175-
foregroundColor={this.state.foregroundColor}
176180
backgroundColor={this.state.backgroundColor}
177181
accentColor={this.state.accentColor}
178182
onColorUpdate={this.handleColorUpdate}
@@ -193,10 +197,10 @@ export default class App extends React.Component<{}, AppState> {
193197

194198
private generateDesignSystem(): DesignSystem {
195199
const designSystem: Partial<DesignSystem> = {
200+
accentPalette: this.state.accentPalette,
201+
neutralPalette: this.state.neutralPalette,
196202
direction: this.state.direction,
197-
foregroundColor: this.state.foregroundColor,
198203
backgroundColor: this.state.backgroundColor,
199-
brandColor: this.state.accentColor,
200204
density: this.state.density,
201205
};
202206

@@ -220,14 +224,7 @@ export default class App extends React.Component<{}, AppState> {
220224
if (theme !== ThemeName.custom) {
221225
this.setState({
222226
theme,
223-
foregroundColor:
224-
theme === ThemeName.dark
225-
? DesignSystemDefaults.backgroundColor
226-
: DesignSystemDefaults.foregroundColor,
227-
backgroundColor:
228-
theme === ThemeName.dark
229-
? DesignSystemDefaults.foregroundColor
230-
: DesignSystemDefaults.backgroundColor,
227+
backgroundColor: theme === ThemeName.dark ? dark : light,
231228
});
232229
} else {
233230
this.setCustomThemeBackground(this.state.backgroundColor);
@@ -244,16 +241,39 @@ export default class App extends React.Component<{}, AppState> {
244241
this.setCustomThemeBackground(config.backgroundColor);
245242
const updates: Partial<AppState> = { ...config };
246243

247-
if (
248-
config.backgroundColor !== this.state.backgroundColor ||
249-
config.foregroundColor !== this.state.foregroundColor
250-
) {
251-
updates.theme = ThemeName.custom;
244+
if (config.backgroundColor !== this.state.backgroundColor) {
245+
if (this.state.theme !== ThemeName.custom) {
246+
updates.theme = ThemeName.custom;
247+
}
248+
249+
const color: ColorRGBA64 = parseColor(config.backgroundColor);
250+
const hslColor: ColorHSL = rgbToHSL(color);
251+
const augmentedHSLColor: ColorHSL = ColorHSL.fromObject({
252+
h: hslColor.h,
253+
s: hslColor.s,
254+
l: 0.5,
255+
});
256+
updates.neutralPalette = this.createColorPalette(hslToRGB(augmentedHSLColor));
257+
}
258+
259+
if (config.accentColor !== this.state.accentColor) {
260+
updates.accentPalette = this.createColorPalette(
261+
parseColor(config.accentColor)
262+
);
252263
}
253264

254265
this.setState(updates as AppState);
255266
};
256267

268+
private createColorPalette(baseColor: ColorRGBA64): string[] {
269+
return new ColorPalette({
270+
baseColor,
271+
steps: 63,
272+
clipLight: 0,
273+
clipDark: 0,
274+
}).palette.map((color: ColorRGBA64): string => color.toStringHexRGB());
275+
}
276+
257277
private handleDensityUpdate = (e: React.ChangeEvent<HTMLInputElement>): void => {
258278
this.setState({
259279
density: parseInt(e.target.value, 10) as DensityOffset,

packages/fast-components-react-msft/app/color-picker.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import manageJss, {
66
import { DesignSystem } from "@microsoft/fast-components-styles-msft";
77

88
export interface ColorConfig {
9-
foregroundColor: string;
109
backgroundColor: string;
1110
accentColor: string;
1211
}
@@ -61,12 +60,6 @@ class ColorPicker extends React.Component<
6160
public render(): JSX.Element {
6261
return (
6362
<div className={this.props.managedClasses.colorPicker}>
64-
{this.createColorInput(
65-
"foreground",
66-
this.props.foregroundColor,
67-
"foregroundInput",
68-
this.foregroundRef
69-
)}
7063
{this.createColorInput(
7164
"background",
7265
this.props.backgroundColor,
@@ -118,11 +111,9 @@ class ColorPicker extends React.Component<
118111
private handleColorPickerChange = (e: React.FormEvent<HTMLInputElement>): void => {
119112
const value: string = e.currentTarget.value;
120113
const updatedColorKey: keyof ColorConfig =
121-
e.currentTarget === this.foregroundRef.current
122-
? "foregroundColor"
123-
: e.currentTarget === this.backgroundRef.current
124-
? "backgroundColor"
125-
: "accentColor";
114+
e.currentTarget === this.backgroundRef.current
115+
? "backgroundColor"
116+
: "accentColor";
126117

127118
if (typeof this.props.onColorUpdate === "function") {
128119
this.props.onColorUpdate(

packages/fast-components-react-msft/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@babel/core": "^7.0.0",
7777
"@babel/preset-env": "^7.1.0",
7878
"@babel/preset-react": "^7.0.0",
79+
"@microsoft/fast-colors": "^3.2.0",
7980
"@microsoft/fast-components-class-name-contracts-base": "^3.10.0",
8081
"@microsoft/fast-development-site-react": "^3.4.5",
8182
"@microsoft/fast-jss-manager": "^3.0.13",
@@ -109,8 +110,8 @@
109110
"tslint": "^5.9.1",
110111
"tslint-config-prettier": "^1.15.0",
111112
"tslint-loader": "^3.6.0",
112-
"typescript": "^3.0.1",
113113
"tv4": "^1.3.0",
114+
"typescript": "^3.0.1",
114115
"utility-types": "^2.1.0",
115116
"webpack": "^4.1.0",
116117
"webpack-bundle-analyzer": "^2.13.1",

packages/fast-components-styles-msft/src/button/index.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,25 @@ const styles: ComponentStyles<ButtonClassNameContract, DesignSystem> = (
143143
},
144144
button__outline: {
145145
background: neutralFillStealthRest,
146-
border: `${toPx(
147-
designSystem.outlinePatternOutlineWidth
148-
)} solid ${neutralOutlineRest(designSystem)}`,
149-
padding: `0 ${horizontalSpacing(designSystem.outlinePatternOutlineWidth)(
146+
border: `${toPx(designSystem.outlineWidth)} solid ${neutralOutlineRest(
150147
designSystem
151148
)}`,
149+
padding: `0 ${horizontalSpacing(designSystem.outlineWidth)(designSystem)}`,
152150
"&:hover:enabled": {
153151
background: neutralFillStealthHover,
154-
border: `${toPx(
155-
designSystem.outlinePatternOutlineWidth
156-
)} solid ${neutralOutlineHover(designSystem)}`,
152+
border: `${toPx(designSystem.outlineWidth)} solid ${neutralOutlineHover(
153+
designSystem
154+
)}`,
157155
},
158156
"&:active:enabled": {
159157
background: neutralFillStealthActive,
160-
border: `${toPx(
161-
designSystem.outlinePatternOutlineWidth
162-
)} solid ${neutralOutlineActive(designSystem)}`,
158+
border: `${toPx(designSystem.outlineWidth)} solid ${neutralOutlineActive(
159+
designSystem
160+
)}`,
163161
},
164162
...applyFocusVisible<DesignSystem>({
165163
boxShadow: `0 0 0 ${toPx(
166-
designSystem.focusOutlineWidth -
167-
designSystem.outlinePatternOutlineWidth
164+
designSystem.focusOutlineWidth - designSystem.outlineWidth
168165
)} ${neutralFocus(designSystem)} inset`,
169166
borderColor: neutralFocus,
170167
}),

packages/fast-components-styles-msft/src/carousel/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const styles: ComponentStyles<CarouselClassNameContract, DesignSystem> = (
107107
fill: neutralForegroundRest((): string => black),
108108
background: neutralFillStealthRest((): string => black),
109109
border: `${toPx(
110-
designSystem.outlinePatternOutlineWidth
110+
designSystem.outlineWidth
111111
)} solid ${neutralOutlineRest((): string => black)}`,
112112
},
113113
"& span::before": {
@@ -141,7 +141,7 @@ const styles: ComponentStyles<CarouselClassNameContract, DesignSystem> = (
141141
fill: neutralForegroundRest((): string => white),
142142
background: neutralFillStealthRest((): string => white),
143143
border: `${toPx(
144-
designSystem.outlinePatternOutlineWidth
144+
designSystem.outlineWidth
145145
)} solid ${neutralOutlineRest((): string => white)}`,
146146
},
147147
"& span::before": {

packages/fast-components-styles-msft/src/checkbox/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ const styles: ComponentStyles<CheckboxClassNameContract, DesignSystem> = (
7676
zIndex: "1",
7777
background: neutralFillInputRest,
7878
transition: "all 0.2s ease-in-out",
79-
border: `${toPx(
80-
designSystem.outlinePatternOutlineWidth
81-
)} solid ${neutralOutlineRest(designSystem)}`,
79+
border: `${toPx(designSystem.outlineWidth)} solid ${neutralOutlineRest(
80+
designSystem
81+
)}`,
8282
"&:hover": {
8383
background: neutralFillInputHover,
8484
borderColor: neutralOutlineHover,

packages/fast-components-styles-msft/src/design-system/index.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ export interface DesignSystem {
2323
*/
2424
accentPalette: Palette;
2525

26-
/**
27-
* The brand color used as color accents.
28-
* @deprecated
29-
*/
30-
brandColor: string;
31-
3226
/**
3327
* A number between 0 and 100 that represents the contrast scale value.
3428
*/
@@ -59,12 +53,6 @@ export interface DesignSystem {
5953
*/
6054
direction: Direction;
6155

62-
/**
63-
* The value typically used for foreground elements, such as text.
64-
* @deprecated
65-
*/
66-
foregroundColor: string;
67-
6856
/**
6957
* The corner default radius applied to controls.
7058
*/
@@ -73,7 +61,7 @@ export interface DesignSystem {
7361
/**
7462
* The width of the outline in pixels applied to outline components.
7563
*/
76-
outlinePatternOutlineWidth?: number;
64+
outlineWidth?: number;
7765

7866
/**
7967
* The width of the outline for focus state in pixels.
@@ -162,10 +150,9 @@ const designSystemDefaults: DesignSystem = {
162150
baseHorizontalSpacingMultiplier: 3,
163151
direction: Direction.ltr,
164152
cornerRadius: 2,
165-
outlinePatternOutlineWidth: 1,
166153
focusOutlineWidth: 2,
167154
disabledOpacity: 0.3,
168-
155+
outlineWidth: 1,
169156
neutralPalette: createColorPalette(new ColorRGBA64(0.5, 0.5, 0.5, 1)),
170157
accentPalette: createColorPalette(parseColorHexRGB("#0078D4")),
171158

@@ -204,10 +191,6 @@ const designSystemDefaults: DesignSystem = {
204191
neutralOutlineRestDelta: 12,
205192
neutralOutlineHoverDelta: 24,
206193
neutralOutlineActiveDelta: 18,
207-
208-
// @deprecated
209-
foregroundColor: "#111",
210-
brandColor: "#0078D4",
211194
};
212195

213196
/**

packages/fast-components-styles-msft/src/flipper/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const styles: ComponentStyles<FlipperClassNameContract, DesignSystem> = (
4646
content: "''",
4747
opacity: "0.8",
4848
background: neutralFillStealthRest,
49-
border: `${toPx(
50-
designSystem.outlinePatternOutlineWidth
51-
)} solid ${neutralOutlineRest(designSystem)}`,
49+
border: `${toPx(designSystem.outlineWidth)} solid ${neutralOutlineRest(
50+
designSystem
51+
)}`,
5252
borderRadius: "50%",
5353
position: "absolute",
5454
top: "0",

0 commit comments

Comments
 (0)