@khanacademy/wonder-blocks-link 3.8.17 → 3.9.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @khanacademy/wonder-blocks-link
2
2
 
3
+ ## 3.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 91cb727c: Remove file extensions from imports
8
+ - 91cb727c: Merge disjoint prop types since the codemod doesn't handle these properly.
9
+ - Updated dependencies [91cb727c]
10
+ - Updated dependencies [91cb727c]
11
+ - Updated dependencies [91cb727c]
12
+ - @khanacademy/wonder-blocks-clickable@2.4.5
13
+ - @khanacademy/wonder-blocks-color@1.2.1
14
+ - @khanacademy/wonder-blocks-core@4.7.0
15
+
16
+ ## 3.9.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 4fa99654: Add inline variant and update styles
21
+
22
+ ### Patch Changes
23
+
24
+ - 48aceaad: Updated hover and outline styles.
25
+
3
26
  ## 3.8.17
4
27
 
5
28
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -8,7 +8,7 @@ import { Link as Link$1 } from 'react-router-dom';
8
8
  import { addStyle } from '@khanacademy/wonder-blocks-core';
9
9
  import Color, { mix, fade } from '@khanacademy/wonder-blocks-color';
10
10
 
11
- const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "kind", "light", "visitable", "pressed", "style", "testId", "waiting"];
11
+ const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "inline", "kind", "light", "visitable", "pressed", "style", "testId", "waiting"];
12
12
  const StyledAnchor = addStyle("a");
13
13
  const StyledLink = addStyle(Link$1);
14
14
  class LinkCore extends React.Component {
@@ -20,6 +20,7 @@ class LinkCore extends React.Component {
20
20
  focused,
21
21
  hovered,
22
22
  href,
23
+ inline,
23
24
  kind,
24
25
  light,
25
26
  visitable,
@@ -29,9 +30,10 @@ class LinkCore extends React.Component {
29
30
  } = _this$props,
30
31
  restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
31
32
 
32
- const linkStyles = _generateStyles(kind, light, visitable);
33
+ const linkStyles = _generateStyles(inline, kind, light, visitable);
33
34
 
34
- const defaultStyles = [sharedStyles.shared, !(hovered || focused || pressed) && linkStyles.default, pressed ? linkStyles.active : (hovered || focused) && linkStyles.focus];
35
+ const restingStyles = inline ? linkStyles.restingInline : linkStyles.resting;
36
+ const defaultStyles = [sharedStyles.shared, !(hovered || focused || pressed) && restingStyles, pressed && linkStyles.active, !pressed && hovered && linkStyles.hover, !pressed && focused && linkStyles.focus];
35
37
 
36
38
  const commonProps = _extends({
37
39
  "data-test-id": testId,
@@ -55,12 +57,15 @@ const sharedStyles = StyleSheet.create({
55
57
  shared: {
56
58
  cursor: "pointer",
57
59
  textDecoration: "none",
58
- outline: "none"
60
+ outline: "none",
61
+ display: "inline-flex",
62
+ fontSize: 16,
63
+ lineHeight: "22px"
59
64
  }
60
65
  });
61
66
 
62
- const _generateStyles = (kind, light, visitable) => {
63
- const buttonType = kind + light.toString() + visitable.toString();
67
+ const _generateStyles = (inline, kind, light, visitable) => {
68
+ const buttonType = `${kind}-${inline.toString()}-${light.toString()}-${visitable.toString()}`;
64
69
 
65
70
  if (styles[buttonType]) {
66
71
  return styles[buttonType];
@@ -70,42 +75,62 @@ const _generateStyles = (kind, light, visitable) => {
70
75
  throw new Error("Secondary Light links are not supported");
71
76
  }
72
77
 
73
- if (visitable && (kind !== "primary" || kind === "primary" && light)) {
74
- throw new Error("Only primary (not light) link is visitable");
78
+ if (visitable && kind !== "primary") {
79
+ throw new Error("Only primary link is visitable");
75
80
  }
76
81
 
77
82
  const {
78
83
  blue,
84
+ pink,
79
85
  purple,
80
86
  white,
81
87
  offBlack,
82
- offBlack32
88
+ offBlack32,
89
+ offBlack64
83
90
  } = Color;
84
91
  const linkPurple = mix(fade(offBlack, 0.08), purple);
85
- const defaultTextColor = kind === "primary" ? light ? white : blue : offBlack;
86
- const focusColor = light ? white : blue;
87
- const activeColor = light ? mix(fade(blue, 0.32), white) : mix(offBlack32, blue);
92
+ const fadedBlue = mix(fade(blue, 0.32), white);
93
+ const activeLightVisited = mix(fade(white, 0.32), pink);
94
+ const activeDefaultPrimary = mix(offBlack32, blue);
95
+ const primaryDefaultTextColor = light ? white : blue;
96
+ const secondaryDefaultTextColor = inline ? offBlack : offBlack64;
97
+ const defaultTextColor = kind === "primary" ? primaryDefaultTextColor : secondaryDefaultTextColor;
98
+ const primaryActiveColor = light ? fadedBlue : activeDefaultPrimary;
99
+ const secondaryActiveColor = inline ? activeDefaultPrimary : offBlack;
100
+ const activeColor = kind === "primary" ? primaryActiveColor : secondaryActiveColor;
88
101
  const defaultVisited = visitable ? {
89
102
  ":visited": {
90
- color: linkPurple
103
+ color: light ? pink : linkPurple
91
104
  }
92
105
  } : Object.freeze({});
93
106
  const activeVisited = visitable ? {
94
107
  ":visited": {
95
- color: mix(offBlack32, linkPurple)
108
+ color: light ? activeLightVisited : mix(offBlack32, linkPurple)
96
109
  }
97
110
  } : Object.freeze({});
98
111
  const newStyles = {
99
- default: _extends({
112
+ resting: _extends({
100
113
  color: defaultTextColor
101
114
  }, defaultVisited),
115
+ restingInline: _extends({
116
+ color: defaultTextColor,
117
+ textDecoration: "underline currentcolor solid 1px",
118
+ textUnderlineOffset: 4
119
+ }, defaultVisited),
120
+ hover: _extends({
121
+ textDecoration: "underline currentcolor dashed 2px",
122
+ color: defaultTextColor,
123
+ textUnderlineOffset: 4
124
+ }, defaultVisited),
102
125
  focus: _extends({
103
- textDecoration: "underline currentcolor solid",
104
- color: focusColor
126
+ color: defaultTextColor,
127
+ outline: `1px solid ${light ? white : blue}`,
128
+ borderRadius: 3
105
129
  }, defaultVisited),
106
130
  active: _extends({
107
131
  color: activeColor,
108
- textDecoration: "underline currentcolor solid"
132
+ textDecoration: "underline currentcolor solid 1px",
133
+ textUnderlineOffset: 4
109
134
  }, activeVisited)
110
135
  };
111
136
  styles[buttonType] = StyleSheet.create(newStyles);
@@ -181,6 +206,7 @@ class Link extends React.Component {
181
206
 
182
207
  }
183
208
  Link.defaultProps = {
209
+ inline: false,
184
210
  kind: "primary",
185
211
  light: false,
186
212
  visitable: false
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(
35
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
36
  var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
37
37
 
38
- const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "kind", "light", "visitable", "pressed", "style", "testId", "waiting"];
38
+ const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "inline", "kind", "light", "visitable", "pressed", "style", "testId", "waiting"];
39
39
  const StyledAnchor = wonderBlocksCore.addStyle("a");
40
40
  const StyledLink = wonderBlocksCore.addStyle(reactRouterDom.Link);
41
41
  class LinkCore extends React__namespace.Component {
@@ -47,6 +47,7 @@ class LinkCore extends React__namespace.Component {
47
47
  focused,
48
48
  hovered,
49
49
  href,
50
+ inline,
50
51
  kind,
51
52
  light,
52
53
  visitable,
@@ -56,9 +57,10 @@ class LinkCore extends React__namespace.Component {
56
57
  } = _this$props,
57
58
  restProps = _objectWithoutPropertiesLoose__default["default"](_this$props, _excluded$1);
58
59
 
59
- const linkStyles = _generateStyles(kind, light, visitable);
60
+ const linkStyles = _generateStyles(inline, kind, light, visitable);
60
61
 
61
- const defaultStyles = [sharedStyles.shared, !(hovered || focused || pressed) && linkStyles.default, pressed ? linkStyles.active : (hovered || focused) && linkStyles.focus];
62
+ const restingStyles = inline ? linkStyles.restingInline : linkStyles.resting;
63
+ const defaultStyles = [sharedStyles.shared, !(hovered || focused || pressed) && restingStyles, pressed && linkStyles.active, !pressed && hovered && linkStyles.hover, !pressed && focused && linkStyles.focus];
62
64
 
63
65
  const commonProps = _extends__default["default"]({
64
66
  "data-test-id": testId,
@@ -82,12 +84,15 @@ const sharedStyles = aphrodite.StyleSheet.create({
82
84
  shared: {
83
85
  cursor: "pointer",
84
86
  textDecoration: "none",
85
- outline: "none"
87
+ outline: "none",
88
+ display: "inline-flex",
89
+ fontSize: 16,
90
+ lineHeight: "22px"
86
91
  }
87
92
  });
88
93
 
89
- const _generateStyles = (kind, light, visitable) => {
90
- const buttonType = kind + light.toString() + visitable.toString();
94
+ const _generateStyles = (inline, kind, light, visitable) => {
95
+ const buttonType = `${kind}-${inline.toString()}-${light.toString()}-${visitable.toString()}`;
91
96
 
92
97
  if (styles[buttonType]) {
93
98
  return styles[buttonType];
@@ -97,42 +102,62 @@ const _generateStyles = (kind, light, visitable) => {
97
102
  throw new Error("Secondary Light links are not supported");
98
103
  }
99
104
 
100
- if (visitable && (kind !== "primary" || kind === "primary" && light)) {
101
- throw new Error("Only primary (not light) link is visitable");
105
+ if (visitable && kind !== "primary") {
106
+ throw new Error("Only primary link is visitable");
102
107
  }
103
108
 
104
109
  const {
105
110
  blue,
111
+ pink,
106
112
  purple,
107
113
  white,
108
114
  offBlack,
109
- offBlack32
115
+ offBlack32,
116
+ offBlack64
110
117
  } = Color__default["default"];
111
118
  const linkPurple = Color.mix(Color.fade(offBlack, 0.08), purple);
112
- const defaultTextColor = kind === "primary" ? light ? white : blue : offBlack;
113
- const focusColor = light ? white : blue;
114
- const activeColor = light ? Color.mix(Color.fade(blue, 0.32), white) : Color.mix(offBlack32, blue);
119
+ const fadedBlue = Color.mix(Color.fade(blue, 0.32), white);
120
+ const activeLightVisited = Color.mix(Color.fade(white, 0.32), pink);
121
+ const activeDefaultPrimary = Color.mix(offBlack32, blue);
122
+ const primaryDefaultTextColor = light ? white : blue;
123
+ const secondaryDefaultTextColor = inline ? offBlack : offBlack64;
124
+ const defaultTextColor = kind === "primary" ? primaryDefaultTextColor : secondaryDefaultTextColor;
125
+ const primaryActiveColor = light ? fadedBlue : activeDefaultPrimary;
126
+ const secondaryActiveColor = inline ? activeDefaultPrimary : offBlack;
127
+ const activeColor = kind === "primary" ? primaryActiveColor : secondaryActiveColor;
115
128
  const defaultVisited = visitable ? {
116
129
  ":visited": {
117
- color: linkPurple
130
+ color: light ? pink : linkPurple
118
131
  }
119
132
  } : Object.freeze({});
120
133
  const activeVisited = visitable ? {
121
134
  ":visited": {
122
- color: Color.mix(offBlack32, linkPurple)
135
+ color: light ? activeLightVisited : Color.mix(offBlack32, linkPurple)
123
136
  }
124
137
  } : Object.freeze({});
125
138
  const newStyles = {
126
- default: _extends__default["default"]({
139
+ resting: _extends__default["default"]({
127
140
  color: defaultTextColor
128
141
  }, defaultVisited),
142
+ restingInline: _extends__default["default"]({
143
+ color: defaultTextColor,
144
+ textDecoration: "underline currentcolor solid 1px",
145
+ textUnderlineOffset: 4
146
+ }, defaultVisited),
147
+ hover: _extends__default["default"]({
148
+ textDecoration: "underline currentcolor dashed 2px",
149
+ color: defaultTextColor,
150
+ textUnderlineOffset: 4
151
+ }, defaultVisited),
129
152
  focus: _extends__default["default"]({
130
- textDecoration: "underline currentcolor solid",
131
- color: focusColor
153
+ color: defaultTextColor,
154
+ outline: `1px solid ${light ? white : blue}`,
155
+ borderRadius: 3
132
156
  }, defaultVisited),
133
157
  active: _extends__default["default"]({
134
158
  color: activeColor,
135
- textDecoration: "underline currentcolor solid"
159
+ textDecoration: "underline currentcolor solid 1px",
160
+ textUnderlineOffset: 4
136
161
  }, activeVisited)
137
162
  };
138
163
  styles[buttonType] = aphrodite.StyleSheet.create(newStyles);
@@ -208,6 +233,7 @@ class Link extends React__namespace.Component {
208
233
 
209
234
  }
210
235
  Link.defaultProps = {
236
+ inline: false,
211
237
  kind: "primary",
212
238
  light: false,
213
239
  visitable: false
@@ -1,2 +1,2 @@
1
1
  // @flow
2
- export * from "../src/index.js";
2
+ export * from "../src/index";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-link",
3
- "version": "3.8.17",
3
+ "version": "3.9.1",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,9 +16,9 @@
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^2.4.4",
20
- "@khanacademy/wonder-blocks-color": "^1.2.0",
21
- "@khanacademy/wonder-blocks-core": "^4.6.2"
19
+ "@khanacademy/wonder-blocks-clickable": "^2.4.5",
20
+ "@khanacademy/wonder-blocks-color": "^1.2.1",
21
+ "@khanacademy/wonder-blocks-core": "^4.7.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "aphrodite": "^1.2.5",
@@ -27,6 +27,6 @@
27
27
  "react-router-dom": "5.3.0"
28
28
  },
29
29
  "devDependencies": {
30
- "wb-dev-build-settings": "^0.7.0"
30
+ "wb-dev-build-settings": "^0.7.1"
31
31
  }
32
32
  }