@khanacademy/wonder-blocks-icon-button 8.0.1 → 9.0.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-icon-button
2
2
 
3
+ ## 9.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e8ccf60: Update `borderRadius` styles to use new `border.radius` tokens
8
+ - Updated dependencies [e8ccf60]
9
+ - Updated dependencies [e8ccf60]
10
+ - @khanacademy/wonder-blocks-styles@0.2.3
11
+ - @khanacademy/wonder-blocks-tokens@7.0.0
12
+ - @khanacademy/wonder-blocks-clickable@7.0.1
13
+
14
+ ## 9.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - 38c926c: Upgrade WB to using react-router-dom-v5-compat.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [38c926c]
23
+ - @khanacademy/wonder-blocks-clickable@7.0.0
24
+ - @khanacademy/wonder-blocks-core@12.2.1
25
+
3
26
  ## 8.0.1
4
27
 
5
28
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { Link } from "react-router-dom";
2
+ import { Link } from "react-router-dom-v5-compat";
3
3
  import type { SharedProps } from "./icon-button";
4
4
  type Props = SharedProps & {
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { PhosphorIconAsset } from "@khanacademy/wonder-blocks-icon";
3
3
  import type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
4
- import { Link } from "react-router-dom";
4
+ import { Link } from "react-router-dom-v5-compat";
5
5
  export type IconButtonSize = "xsmall" | "small" | "medium" | "large";
6
6
  export type IconButtonActionType = "progressive" | "destructive" | "neutral";
7
7
  export type SharedProps = Partial<Omit<AriaProps, "aria-disabled">> & {
package/dist/es/index.js CHANGED
@@ -2,8 +2,7 @@ import _extends from '@babel/runtime/helpers/extends';
2
2
  import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
3
3
  import * as React from 'react';
4
4
  import { StyleSheet } from 'aphrodite';
5
- import { Link } from 'react-router-dom';
6
- import { __RouterContext } from 'react-router';
5
+ import { Link, useInRouterContext } from 'react-router-dom-v5-compat';
7
6
  import { addStyle } from '@khanacademy/wonder-blocks-core';
8
7
  import { isClientSideUrl } from '@khanacademy/wonder-blocks-clickable';
9
8
  import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
@@ -56,7 +55,7 @@ const theme = {
56
55
  }
57
56
  },
58
57
  radius: {
59
- default: border.radius.medium_4
58
+ default: border.radius.radius_040
60
59
  }
61
60
  }
62
61
  };
@@ -117,36 +116,34 @@ const IconButtonCore = React.forwardRef(function IconButtonCore(props, ref) {
117
116
  theme,
118
117
  themeName
119
118
  } = useScopedTheme(IconButtonThemeContext);
120
- const renderInner = router => {
121
- const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
122
- const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
123
- const child = React.createElement(IconChooser, {
124
- size: size,
125
- icon: icon
126
- });
127
- const commonProps = _extends({
128
- "data-testid": testId,
129
- style: [defaultStyle, style]
130
- }, restProps);
131
- if (href && !disabled) {
132
- return router && !skipClientNav && isClientSideUrl(href) ? React.createElement(StyledLink, _extends({}, commonProps, {
133
- to: href,
134
- ref: ref
135
- }), child) : React.createElement(StyledA, _extends({}, commonProps, {
136
- href: href,
137
- ref: ref
138
- }), child);
139
- } else {
140
- return React.createElement(StyledButton, _extends({
141
- type: type
142
- }, commonProps, {
143
- onClick: disabled ? undefined : restProps.onClick,
144
- "aria-disabled": disabled,
145
- ref: ref
146
- }), child);
147
- }
148
- };
149
- return React.createElement(__RouterContext.Consumer, null, router => renderInner(router));
119
+ const inRouterContext = useInRouterContext();
120
+ const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
121
+ const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
122
+ const child = React.createElement(IconChooser, {
123
+ size: size,
124
+ icon: icon
125
+ });
126
+ const commonProps = _extends({
127
+ "data-testid": testId,
128
+ style: [defaultStyle, style]
129
+ }, restProps);
130
+ if (href && !disabled) {
131
+ return inRouterContext && !skipClientNav && isClientSideUrl(href) ? React.createElement(StyledLink, _extends({}, commonProps, {
132
+ to: href,
133
+ ref: ref
134
+ }), child) : React.createElement(StyledA, _extends({}, commonProps, {
135
+ href: href,
136
+ ref: ref
137
+ }), child);
138
+ } else {
139
+ return React.createElement(StyledButton, _extends({
140
+ type: type
141
+ }, commonProps, {
142
+ onClick: disabled ? undefined : restProps.onClick,
143
+ "aria-disabled": disabled,
144
+ ref: ref
145
+ }), child);
146
+ }
150
147
  });
151
148
  const sharedStyles = StyleSheet.create({
152
149
  shared: {
package/dist/index.js CHANGED
@@ -4,8 +4,7 @@ var _extends = require('@babel/runtime/helpers/extends');
4
4
  var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
5
5
  var React = require('react');
6
6
  var aphrodite = require('aphrodite');
7
- var reactRouterDom = require('react-router-dom');
8
- var reactRouter = require('react-router');
7
+ var reactRouterDomV5Compat = require('react-router-dom-v5-compat');
9
8
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
10
9
  var wonderBlocksClickable = require('@khanacademy/wonder-blocks-clickable');
11
10
  var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
@@ -82,7 +81,7 @@ const theme = {
82
81
  }
83
82
  },
84
83
  radius: {
85
- default: wonderBlocksTokens.border.radius.medium_4
84
+ default: wonderBlocksTokens.border.radius.radius_040
86
85
  }
87
86
  }
88
87
  };
@@ -124,7 +123,7 @@ function IconChooser({
124
123
  }
125
124
  const StyledA = wonderBlocksCore.addStyle("a");
126
125
  const StyledButton = wonderBlocksCore.addStyle("button");
127
- const StyledLink = wonderBlocksCore.addStyle(reactRouterDom.Link);
126
+ const StyledLink = wonderBlocksCore.addStyle(reactRouterDomV5Compat.Link);
128
127
  const IconButtonCore = React__namespace.forwardRef(function IconButtonCore(props, ref) {
129
128
  const {
130
129
  actionType,
@@ -143,36 +142,34 @@ const IconButtonCore = React__namespace.forwardRef(function IconButtonCore(props
143
142
  theme,
144
143
  themeName
145
144
  } = wonderBlocksTheming.useScopedTheme(IconButtonThemeContext);
146
- const renderInner = router => {
147
- const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
148
- const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
149
- const child = React__namespace.createElement(IconChooser, {
150
- size: size,
151
- icon: icon
152
- });
153
- const commonProps = _extends__default["default"]({
154
- "data-testid": testId,
155
- style: [defaultStyle, style]
156
- }, restProps);
157
- if (href && !disabled) {
158
- return router && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink, _extends__default["default"]({}, commonProps, {
159
- to: href,
160
- ref: ref
161
- }), child) : React__namespace.createElement(StyledA, _extends__default["default"]({}, commonProps, {
162
- href: href,
163
- ref: ref
164
- }), child);
165
- } else {
166
- return React__namespace.createElement(StyledButton, _extends__default["default"]({
167
- type: type
168
- }, commonProps, {
169
- onClick: disabled ? undefined : restProps.onClick,
170
- "aria-disabled": disabled,
171
- ref: ref
172
- }), child);
173
- }
174
- };
175
- return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderInner(router));
145
+ const inRouterContext = reactRouterDomV5Compat.useInRouterContext();
146
+ const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
147
+ const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
148
+ const child = React__namespace.createElement(IconChooser, {
149
+ size: size,
150
+ icon: icon
151
+ });
152
+ const commonProps = _extends__default["default"]({
153
+ "data-testid": testId,
154
+ style: [defaultStyle, style]
155
+ }, restProps);
156
+ if (href && !disabled) {
157
+ return inRouterContext && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink, _extends__default["default"]({}, commonProps, {
158
+ to: href,
159
+ ref: ref
160
+ }), child) : React__namespace.createElement(StyledA, _extends__default["default"]({}, commonProps, {
161
+ href: href,
162
+ ref: ref
163
+ }), child);
164
+ } else {
165
+ return React__namespace.createElement(StyledButton, _extends__default["default"]({
166
+ type: type
167
+ }, commonProps, {
168
+ onClick: disabled ? undefined : restProps.onClick,
169
+ "aria-disabled": disabled,
170
+ ref: ref
171
+ }), child);
172
+ }
176
173
  });
177
174
  const sharedStyles = aphrodite.StyleSheet.create({
178
175
  shared: {
@@ -199,7 +199,7 @@ declare const theme: {
199
199
  };
200
200
  };
201
201
  radius: {
202
- default: number;
202
+ default: string;
203
203
  };
204
204
  };
205
205
  };
@@ -209,7 +209,7 @@ export declare const IconButtonThemeContext: React.Context<{
209
209
  };
210
210
  };
211
211
  radius: {
212
- default: number;
212
+ default: string;
213
213
  };
214
214
  };
215
215
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-icon-button",
3
- "version": "8.0.1",
3
+ "version": "9.0.1",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,18 +13,19 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@babel/runtime": "^7.24.5",
16
- "@khanacademy/wonder-blocks-clickable": "6.1.6",
16
+ "@khanacademy/wonder-blocks-clickable": "7.0.1",
17
17
  "@khanacademy/wonder-blocks-core": "12.2.1",
18
18
  "@khanacademy/wonder-blocks-icon": "5.1.3",
19
- "@khanacademy/wonder-blocks-styles": "0.2.2",
19
+ "@khanacademy/wonder-blocks-styles": "0.2.3",
20
20
  "@khanacademy/wonder-blocks-theming": "3.2.1",
21
- "@khanacademy/wonder-blocks-tokens": "6.0.0"
21
+ "@khanacademy/wonder-blocks-tokens": "7.0.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "aphrodite": "^1.2.5",
25
25
  "react": "18.2.0",
26
26
  "react-router": "5.3.4",
27
- "react-router-dom": "5.3.4"
27
+ "react-router-dom": "5.3.4",
28
+ "react-router-dom-v5-compat": "^6.30.0"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@khanacademy/wb-dev-build-settings": "2.1.1"