1
- import * as examples from "./examples" ;
2
1
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" ;
18
2
import Site , {
19
3
componentFactory ,
20
4
formChildFromExamplesFactory ,
21
5
FormChildOption ,
22
6
ShellSlot ,
23
7
SiteCategory ,
24
8
SiteCategoryIcon ,
25
- SiteCategoryItem ,
26
- SiteMenu ,
27
- SiteMenuItem ,
28
- SiteProps ,
29
9
SiteTitle ,
30
10
SiteTitleBrand ,
31
11
Theme ,
32
12
} 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" ;
34
25
import ColorPicker , { ColorConfig } from "./color-picker" ;
35
26
import reactHTMLElementExamples from "./components/react-html-element-child-option" ;
36
27
import reactSVGElementExamples from "./components/svg-svg-element-child-option" ;
@@ -39,7 +30,14 @@ import carouselDarkImageContentExamples from "./components/carousel-dark-image-c
39
30
import carouselLightImageContentExamples from "./components/carousel-light-image-content-child-options" ;
40
31
import pivotItemContentExamples from "./components/pivot-item-content-child-options" ;
41
32
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" ;
43
41
44
42
/* tslint:disable-next-line */
45
43
const sketchDesignKit = require ( "./fast-dna-msft-design-kit.sketch" ) ;
@@ -54,6 +52,10 @@ const formChildOptions: FormChildOption[] = [
54
52
pivotItemTabExamples ,
55
53
] . concat ( formChildFromExamplesFactory ( examples ) ) ;
56
54
55
+ const dark : string = "#111111" ;
56
+ const light : string = "#FFFFFF" ;
57
+ const accent : string = "#0078D4" ;
58
+
57
59
const formPlugins : Array < Plugin < PluginProps > > = [
58
60
new AdditionalPropsPlugin ( {
59
61
id : [
@@ -90,6 +92,8 @@ enum ThemeName {
90
92
}
91
93
92
94
export interface AppState extends ColorConfig {
95
+ accentPalette : string [ ] ;
96
+ neutralPalette : string [ ] ;
93
97
theme : ThemeName ;
94
98
direction : Direction ;
95
99
density : DensityOffset ;
@@ -100,12 +104,12 @@ export default class App extends React.Component<{}, AppState> {
100
104
{
101
105
id : ThemeName . light ,
102
106
displayName : ThemeName . light ,
103
- background : DesignSystemDefaults . backgroundColor ,
107
+ background : light ,
104
108
} ,
105
109
{
106
110
id : ThemeName . dark ,
107
111
displayName : ThemeName . dark ,
108
- background : DesignSystemDefaults . foregroundColor ,
112
+ background : dark ,
109
113
} ,
110
114
{ id : ThemeName . custom , displayName : ThemeName . custom } ,
111
115
] ;
@@ -114,10 +118,11 @@ export default class App extends React.Component<{}, AppState> {
114
118
super ( props ) ;
115
119
116
120
this . state = {
121
+ accentColor : accent ,
122
+ accentPalette : this . createColorPalette ( parseColor ( accent ) ) ,
123
+ neutralPalette : this . createColorPalette ( new ColorRGBA64 ( 0.5 , 0.5 , 0.5 , 1 ) ) ,
117
124
direction : Direction . ltr ,
118
- foregroundColor : DesignSystemDefaults . foregroundColor ,
119
125
backgroundColor : DesignSystemDefaults . backgroundColor ,
120
- accentColor : DesignSystemDefaults . brandColor ,
121
126
theme : ThemeName . light ,
122
127
density : DesignSystemDefaults . density ,
123
128
} ;
@@ -172,7 +177,6 @@ export default class App extends React.Component<{}, AppState> {
172
177
onChange = { this . handleDensityUpdate }
173
178
/>
174
179
< ColorPicker
175
- foregroundColor = { this . state . foregroundColor }
176
180
backgroundColor = { this . state . backgroundColor }
177
181
accentColor = { this . state . accentColor }
178
182
onColorUpdate = { this . handleColorUpdate }
@@ -193,10 +197,10 @@ export default class App extends React.Component<{}, AppState> {
193
197
194
198
private generateDesignSystem ( ) : DesignSystem {
195
199
const designSystem : Partial < DesignSystem > = {
200
+ accentPalette : this . state . accentPalette ,
201
+ neutralPalette : this . state . neutralPalette ,
196
202
direction : this . state . direction ,
197
- foregroundColor : this . state . foregroundColor ,
198
203
backgroundColor : this . state . backgroundColor ,
199
- brandColor : this . state . accentColor ,
200
204
density : this . state . density ,
201
205
} ;
202
206
@@ -220,14 +224,7 @@ export default class App extends React.Component<{}, AppState> {
220
224
if ( theme !== ThemeName . custom ) {
221
225
this . setState ( {
222
226
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 ,
231
228
} ) ;
232
229
} else {
233
230
this . setCustomThemeBackground ( this . state . backgroundColor ) ;
@@ -244,16 +241,39 @@ export default class App extends React.Component<{}, AppState> {
244
241
this . setCustomThemeBackground ( config . backgroundColor ) ;
245
242
const updates : Partial < AppState > = { ...config } ;
246
243
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
+ ) ;
252
263
}
253
264
254
265
this . setState ( updates as AppState ) ;
255
266
} ;
256
267
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
+
257
277
private handleDensityUpdate = ( e : React . ChangeEvent < HTMLInputElement > ) : void => {
258
278
this . setState ( {
259
279
density : parseInt ( e . target . value , 10 ) as DensityOffset ,
0 commit comments