@khanacademy/wonder-blocks-form 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import {StyleSheet} from "aphrodite";
3
3
 
4
- import Color, {mix, fade} from "@khanacademy/wonder-blocks-color";
4
+ import {mix} from "@khanacademy/wonder-blocks-color";
5
5
  import {addStyle} from "@khanacademy/wonder-blocks-core";
6
6
  import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
7
- import Spacing from "@khanacademy/wonder-blocks-spacing";
7
+ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
8
8
  import checkIcon from "@phosphor-icons/core/bold/check-bold.svg";
9
9
  import minusIcon from "@phosphor-icons/core/bold/minus-bold.svg";
10
10
 
@@ -26,12 +26,12 @@ function mapCheckedToAriaChecked(value: Checked): AriaChecked {
26
26
  }
27
27
  }
28
28
 
29
- const {blue, red, white, offWhite, offBlack16, offBlack32, offBlack50} = Color;
29
+ const {blue, red, white, offWhite, offBlack16, offBlack32, offBlack50} = color;
30
30
 
31
31
  // The checkbox size
32
- const size = Spacing.medium_16;
32
+ const size = spacing.medium_16;
33
33
  // The check icon size
34
- const checkSize = Spacing.small_12;
34
+ const checkSize = spacing.small_12;
35
35
 
36
36
  const StyledInput = addStyle("input");
37
37
 
@@ -153,10 +153,10 @@ const sharedStyles = StyleSheet.create({
153
153
  },
154
154
  });
155
155
 
156
- const fadedBlue = mix(fade(blue, 0.16), white);
157
- const activeBlue = mix(offBlack32, blue);
158
- const fadedRed = mix(fade(red, 0.08), white);
159
- const activeRed = mix(offBlack32, red);
156
+ const fadedBlue = mix(color.fadedBlue16, white);
157
+ const activeBlue = color.activeBlue;
158
+ const fadedRed = mix(color.fadedRed8, white);
159
+ const activeRed = color.activeRed;
160
160
 
161
161
  const colors = {
162
162
  default: {
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
 
3
3
  import {View, addStyle} from "@khanacademy/wonder-blocks-core";
4
4
  import {Strut} from "@khanacademy/wonder-blocks-layout";
5
- import Spacing from "@khanacademy/wonder-blocks-spacing";
5
+ import {spacing} from "@khanacademy/wonder-blocks-tokens";
6
6
  import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
7
7
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
8
8
 
@@ -147,7 +147,7 @@ const CheckboxGroup = React.forwardRef(function CheckboxGroup(
147
147
  <LabelSmall style={styles.error}>{errorMessage}</LabelSmall>
148
148
  )}
149
149
  {(label || description || errorMessage) && (
150
- <Strut size={Spacing.small_12} />
150
+ <Strut size={spacing.small_12} />
151
151
  )}
152
152
 
153
153
  {allChildren.map((child, index) => {
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
2
  import {StyleSheet} from "aphrodite";
3
3
 
4
- import Color from "@khanacademy/wonder-blocks-color";
5
4
  import {View, UniqueIDProvider} from "@khanacademy/wonder-blocks-core";
6
5
  import {Strut} from "@khanacademy/wonder-blocks-layout";
7
- import Spacing from "@khanacademy/wonder-blocks-spacing";
6
+ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
8
7
  import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
9
8
  import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
10
9
  import CheckboxCore from "./checkbox-core";
@@ -147,7 +146,7 @@ type Props = AriaProps & {
147
146
  error={error}
148
147
  ref={ref}
149
148
  />
150
- <Strut size={Spacing.xSmall_8} />
149
+ <Strut size={spacing.xSmall_8} />
151
150
  {label && getLabel(uniqueId)}
152
151
  </View>
153
152
  {description && getDescription(descriptionId)}
@@ -172,13 +171,13 @@ const styles = StyleSheet.create({
172
171
  marginTop: -2,
173
172
  },
174
173
  disabledLabel: {
175
- color: Color.offBlack32,
174
+ color: color.offBlack32,
176
175
  },
177
176
  description: {
178
177
  // 16 for icon + 8 for spacing strut
179
- marginLeft: Spacing.medium_16 + Spacing.xSmall_8,
180
- marginTop: Spacing.xxxSmall_4,
181
- color: Color.offBlack64,
178
+ marginLeft: spacing.medium_16 + spacing.xSmall_8,
179
+ marginTop: spacing.xxxSmall_4,
180
+ color: color.offBlack64,
182
181
  },
183
182
  });
184
183
 
@@ -2,9 +2,8 @@ import * as React from "react";
2
2
  import {StyleSheet} from "aphrodite";
3
3
 
4
4
  import {View, addStyle, StyleType} from "@khanacademy/wonder-blocks-core";
5
- import Color from "@khanacademy/wonder-blocks-color";
6
5
  import {Strut} from "@khanacademy/wonder-blocks-layout";
7
- import Spacing from "@khanacademy/wonder-blocks-spacing";
6
+ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
8
7
  import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
9
8
 
10
9
  type Props = {
@@ -73,7 +72,7 @@ export default class FieldHeading extends React.Component<Props> {
73
72
  {label}
74
73
  {required && requiredIcon}
75
74
  </LabelMedium>
76
- <Strut size={Spacing.xxxSmall_4} />
75
+ <Strut size={spacing.xxxSmall_4} />
77
76
  </React.Fragment>
78
77
  );
79
78
  }
@@ -93,7 +92,7 @@ export default class FieldHeading extends React.Component<Props> {
93
92
  >
94
93
  {description}
95
94
  </LabelSmall>
96
- <Strut size={Spacing.xxxSmall_4} />
95
+ <Strut size={spacing.xxxSmall_4} />
97
96
  </React.Fragment>
98
97
  );
99
98
  }
@@ -107,7 +106,7 @@ export default class FieldHeading extends React.Component<Props> {
107
106
 
108
107
  return (
109
108
  <React.Fragment>
110
- <Strut size={Spacing.small_12} />
109
+ <Strut size={spacing.small_12} />
111
110
  <LabelSmall
112
111
  style={styles.error}
113
112
  role="alert"
@@ -127,7 +126,7 @@ export default class FieldHeading extends React.Component<Props> {
127
126
  <View style={style}>
128
127
  {this.renderLabel()}
129
128
  {this.maybeRenderDescription()}
130
- <Strut size={Spacing.xSmall_8} />
129
+ <Strut size={spacing.xSmall_8} />
131
130
  {field}
132
131
  {this.maybeRenderError()}
133
132
  </View>
@@ -137,15 +136,15 @@ export default class FieldHeading extends React.Component<Props> {
137
136
 
138
137
  const styles = StyleSheet.create({
139
138
  label: {
140
- color: Color.offBlack,
139
+ color: color.offBlack,
141
140
  },
142
141
  description: {
143
- color: Color.offBlack64,
142
+ color: color.offBlack64,
144
143
  },
145
144
  error: {
146
- color: Color.red,
145
+ color: color.red,
147
146
  },
148
147
  required: {
149
- color: Color.red,
148
+ color: color.red,
150
149
  },
151
150
  });
@@ -1,7 +1,6 @@
1
1
  import {StyleSheet} from "aphrodite";
2
2
 
3
- import Color from "@khanacademy/wonder-blocks-color";
4
- import Spacing from "@khanacademy/wonder-blocks-spacing";
3
+ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
5
4
 
6
5
  import type {StyleDeclaration} from "aphrodite";
7
6
 
@@ -17,17 +16,17 @@ const styles: StyleDeclaration = StyleSheet.create({
17
16
  },
18
17
 
19
18
  description: {
20
- marginTop: Spacing.xxxSmall_4,
21
- color: Color.offBlack64,
19
+ marginTop: spacing.xxxSmall_4,
20
+ color: color.offBlack64,
22
21
  },
23
22
 
24
23
  error: {
25
- marginTop: Spacing.xxxSmall_4,
26
- color: Color.red,
24
+ marginTop: spacing.xxxSmall_4,
25
+ color: color.red,
27
26
  },
28
27
 
29
28
  defaultLineGap: {
30
- marginTop: Spacing.xSmall_8,
29
+ marginTop: spacing.xSmall_8,
31
30
  },
32
31
  });
33
32
 
@@ -1,12 +1,13 @@
1
1
  import * as React from "react";
2
2
  import {StyleSheet} from "aphrodite";
3
3
 
4
- import Color, {mix, fade} from "@khanacademy/wonder-blocks-color";
4
+ import {mix} from "@khanacademy/wonder-blocks-color";
5
+ import {color} from "@khanacademy/wonder-blocks-tokens";
5
6
  import {addStyle} from "@khanacademy/wonder-blocks-core";
6
7
 
7
8
  import type {ChoiceCoreProps, Checked} from "../util/types";
8
9
 
9
- const {blue, red, white, offWhite, offBlack16, offBlack32, offBlack50} = Color;
10
+ const {blue, red, white, offWhite, offBlack16, offBlack32, offBlack50} = color;
10
11
 
11
12
  const StyledInput = addStyle("input");
12
13
 
@@ -90,20 +91,18 @@ const sharedStyles = StyleSheet.create({
90
91
  borderWidth: 1,
91
92
  },
92
93
  });
93
- const fadedBlue = mix(fade(blue, 0.16), white);
94
- const activeBlue = mix(offBlack32, blue);
95
- const fadedRed = mix(fade(red, 0.08), white);
96
- const activeRed = mix(offBlack32, red);
94
+ const fadedBlue = mix(color.fadedBlue16, white);
95
+ const fadedRed = mix(color.fadedRed8, white);
97
96
  const colors = {
98
97
  default: {
99
98
  faded: fadedBlue,
100
99
  base: blue,
101
- active: activeBlue,
100
+ active: color.activeBlue,
102
101
  },
103
102
  error: {
104
103
  faded: fadedRed,
105
104
  base: red,
106
- active: activeRed,
105
+ active: color.activeRed,
107
106
  },
108
107
  } as const;
109
108
  const styles: Record<string, any> = {};
@@ -160,7 +159,7 @@ const _generateStyles = (checked: Checked, error: boolean) => {
160
159
 
161
160
  ":active": {
162
161
  backgroundColor: palette.faded,
163
- borderColor: error ? activeRed : blue,
162
+ borderColor: error ? color.activeRed : blue,
164
163
  borderWidth: 2,
165
164
  },
166
165
  },
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
 
3
3
  import {View, addStyle} from "@khanacademy/wonder-blocks-core";
4
4
  import {Strut} from "@khanacademy/wonder-blocks-layout";
5
- import Spacing from "@khanacademy/wonder-blocks-spacing";
5
+ import {spacing} from "@khanacademy/wonder-blocks-tokens";
6
6
  import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
7
7
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
8
8
 
@@ -132,7 +132,7 @@ const RadioGroup = React.forwardRef(function RadioGroup(
132
132
  <LabelSmall style={styles.error}>{errorMessage}</LabelSmall>
133
133
  )}
134
134
  {(label || description || errorMessage) && (
135
- <Strut size={Spacing.small_12} />
135
+ <Strut size={spacing.small_12} />
136
136
  )}
137
137
 
138
138
  {allChildren.map((child, index) => {
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
  import {StyleSheet} from "aphrodite";
3
3
 
4
- import Color, {mix, fade} from "@khanacademy/wonder-blocks-color";
4
+ import {mix} from "@khanacademy/wonder-blocks-color";
5
5
  import {addStyle} from "@khanacademy/wonder-blocks-core";
6
- import Spacing from "@khanacademy/wonder-blocks-spacing";
6
+ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
7
7
  import {styles as typographyStyles} from "@khanacademy/wonder-blocks-typography";
8
8
 
9
9
  import type {StyleType, AriaProps} from "@khanacademy/wonder-blocks-core";
@@ -296,48 +296,48 @@ const styles = StyleSheet.create({
296
296
  height: 40,
297
297
  borderRadius: 4,
298
298
  boxSizing: "border-box",
299
- paddingLeft: Spacing.medium_16,
299
+ paddingLeft: spacing.medium_16,
300
300
  margin: 0,
301
301
  outline: "none",
302
302
  boxShadow: "none",
303
303
  },
304
304
  default: {
305
- background: Color.white,
306
- border: `1px solid ${Color.offBlack16}`,
307
- color: Color.offBlack,
305
+ background: color.white,
306
+ border: `1px solid ${color.offBlack16}`,
307
+ color: color.offBlack,
308
308
  "::placeholder": {
309
- color: Color.offBlack64,
309
+ color: color.offBlack64,
310
310
  },
311
311
  },
312
312
  error: {
313
- background: `${mix(fade(Color.red, 0.06), Color.white)}`,
314
- border: `1px solid ${Color.red}`,
315
- color: Color.offBlack,
313
+ background: `${mix(color.fadedRed8, color.white)}`,
314
+ border: `1px solid ${color.red}`,
315
+ color: color.offBlack,
316
316
  "::placeholder": {
317
- color: Color.offBlack64,
317
+ color: color.offBlack64,
318
318
  },
319
319
  },
320
320
  disabled: {
321
- background: Color.offWhite,
322
- border: `1px solid ${Color.offBlack16}`,
323
- color: Color.offBlack64,
321
+ background: color.offWhite,
322
+ border: `1px solid ${color.offBlack16}`,
323
+ color: color.offBlack64,
324
324
  "::placeholder": {
325
- color: Color.offBlack32,
325
+ color: color.offBlack32,
326
326
  },
327
327
  },
328
328
  focused: {
329
- background: Color.white,
330
- border: `1px solid ${Color.blue}`,
331
- color: Color.offBlack,
329
+ background: color.white,
330
+ border: `1px solid ${color.blue}`,
331
+ color: color.offBlack,
332
332
  "::placeholder": {
333
- color: Color.offBlack64,
333
+ color: color.offBlack64,
334
334
  },
335
335
  },
336
336
  defaultLight: {
337
- boxShadow: `0px 0px 0px 1px ${Color.blue}, 0px 0px 0px 2px ${Color.white}`,
337
+ boxShadow: `0px 0px 0px 1px ${color.blue}, 0px 0px 0px 2px ${color.white}`,
338
338
  },
339
339
  errorLight: {
340
- boxShadow: `0px 0px 0px 1px ${Color.red}, 0px 0px 0px 2px ${Color.white}`,
340
+ boxShadow: `0px 0px 0px 1px ${color.red}, 0px 0px 0px 2px ${color.white}`,
341
341
  },
342
342
  });
343
343
 
@@ -14,7 +14,7 @@
14
14
  {"path": "../wonder-blocks-icon/tsconfig-build.json"},
15
15
  {"path": "../wonder-blocks-layout/tsconfig-build.json"},
16
16
  {"path": "../wonder-blocks-link/tsconfig-build.json"},
17
- {"path": "../wonder-blocks-spacing/tsconfig-build.json"},
17
+ {"path": "../wonder-blocks-tokens/tsconfig-build.json"},
18
18
  {"path": "../wonder-blocks-typography/tsconfig-build.json"},
19
19
  ]
20
20
  }