@khanacademy/wonder-blocks-pill 3.1.25 → 3.1.27

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,23 @@
1
1
  # @khanacademy/wonder-blocks-pill
2
2
 
3
+ ## 3.1.27
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d71614: Update use of tokens (semantic colors, sizing, border) and use new typography components.
8
+ This is to better support the thunderblocks theme!
9
+
10
+ ## 3.1.26
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [de9435a]
15
+ - Updated dependencies [f50aafc]
16
+ - @khanacademy/wonder-blocks-tokens@11.2.1
17
+ - @khanacademy/wonder-blocks-clickable@7.1.12
18
+ - @khanacademy/wonder-blocks-link@9.1.12
19
+ - @khanacademy/wonder-blocks-typography@4.2.8
20
+
3
21
  ## 3.1.25
4
22
 
5
23
  ### Patch Changes
@@ -10,8 +10,11 @@ export type PillSize = "small" | "medium" | "large";
10
10
  *
11
11
  * **Note:** Before using the `Pill` component, please see if a component from the
12
12
  * [Badge Package](/?path=/docs/packages-badge-overview--docs&globals=theme:default)
13
- * can be used instead. For example, prefer using the `StatusBadge` component
14
- * instead of a `Pill` to indicate a status.
13
+ * can be used instead.
14
+ *
15
+ * For example, prefer using the `StatusBadge` component instead of a `Pill` to
16
+ * indicate a status. Or, use the `Badge` component instead of a `Pill` with
17
+ * `kind="neutral"`.
15
18
  *
16
19
  * ### Usage
17
20
  *
package/dist/es/index.js CHANGED
@@ -3,9 +3,10 @@ import * as React from 'react';
3
3
  import { StyleSheet } from 'aphrodite';
4
4
  import Clickable from '@khanacademy/wonder-blocks-clickable';
5
5
  import { View } from '@khanacademy/wonder-blocks-core';
6
- import { LabelXSmall, Body, LabelSmall } from '@khanacademy/wonder-blocks-typography';
7
- import * as tokens from '@khanacademy/wonder-blocks-tokens';
6
+ import { BodyText } from '@khanacademy/wonder-blocks-typography';
7
+ import { sizing, border, semanticColor, color } from '@khanacademy/wonder-blocks-tokens';
8
+ import { focusStyles } from '@khanacademy/wonder-blocks-styles';
8
9
 
9
- const{semanticColor}=tokens;const PillInner=props=>{const{children,size}=props;if(typeof children!=="string"){return children}if(size==="small"){return jsx(LabelXSmall,{children:props.children})}if(size==="large"){return jsx(Body,{children:children})}return jsx(LabelSmall,{children:children})};const Pill=React.forwardRef(function Pill(props,ref){const{id,children,kind="neutral",size="medium",role,onClick,style,tabIndex,testId,...ariaProps}=props;let wrapperSizeStyle;switch(size){case"small":wrapperSizeStyle=pillStyles.wrapperSmall;break;case"large":wrapperSizeStyle=pillStyles.wrapperLarge;break;default:wrapperSizeStyle=pillStyles.wrapperMedium;}const colorStyles=_generateColorStyles(!!onClick,kind);const defaultStyles=[pillStyles.wrapper,colorStyles.pill,wrapperSizeStyle];if(onClick){return jsx(Clickable,{id:id,role:role,onClick:onClick,style:[defaultStyles,colorStyles.clickableWrapper,style],testId:testId,ref:ref,tabIndex:tabIndex,...ariaProps,children:()=>jsx(PillInner,{size:size,children:children})})}return jsx(View,{id:id,role:role,style:[defaultStyles,style],testId:testId,ref:ref,...ariaProps,children:jsx(PillInner,{size:size,children:children})})});const pillStyles=StyleSheet.create({wrapper:{display:"inline-flex",width:"fit-content"},wrapperSmall:{paddingLeft:tokens.spacing.xSmall_8,paddingRight:tokens.spacing.xSmall_8,borderRadius:tokens.border.radius.radius_040,height:20},wrapperMedium:{paddingLeft:tokens.spacing.xSmall_8,paddingRight:tokens.spacing.xSmall_8,borderRadius:tokens.border.radius.radius_040,height:tokens.spacing.large_24},wrapperLarge:{paddingLeft:tokens.spacing.small_12,paddingRight:tokens.spacing.small_12,paddingTop:tokens.spacing.xxSmall_6,paddingBottom:tokens.spacing.xxSmall_6,borderRadius:tokens.sizing.size_240,height:tokens.spacing.xLarge_32}});const styles={};const _generateColorStyles=(clickable,kind)=>{const pillType=`${kind}-${clickable.toString()}`;if(styles[pillType]){return styles[pillType]}let backgroundColor;switch(kind){case"accent":backgroundColor=semanticColor.status.notice.foreground;break;case"info":backgroundColor=semanticColor.status.notice.background;break;case"success":backgroundColor=semanticColor.status.success.background;break;case"warning":backgroundColor=semanticColor.status.warning.background;break;case"critical":backgroundColor=semanticColor.status.critical.background;break;case"transparent":backgroundColor="transparent";break;case"neutral":default:backgroundColor=semanticColor.status.neutral.background;}const pressColor=kind==="transparent"||kind==="neutral"?tokens.color.offBlack16:kind==="accent"?tokens.color.activeBlue:`color-mix(in srgb, ${tokens.color.offBlack32}, ${backgroundColor})`;const textColor=kind==="accent"?semanticColor.text.inverse:semanticColor.text.primary;const theme={default:{border:kind==="transparent"?`1px solid ${semanticColor.core.border.neutral.subtle}`:"none",background:backgroundColor,foreground:textColor},focus:{border:semanticColor.focus.outer},hover:{border:semanticColor.core.border.instructive.default},press:{border:semanticColor.core.border.instructive.strong,background:pressColor}};const colorStyles={pill:{backgroundColor:theme.default.background,outline:theme.default.border,color:theme.default.foreground,alignItems:"center",justifyContent:"center"},clickableWrapper:{outline:theme.default.border,":hover":{outline:`2px solid ${theme.hover.border}`,outlineOffset:tokens.spacing.xxxxSmall_2},":active":{backgroundColor:theme.press.background,outline:`2px solid ${theme.press.border}`,outlineOffset:tokens.spacing.xxxxSmall_2},":focus-visible":{outline:`2px solid ${theme.focus.border}`,outlineOffset:tokens.spacing.xxxxSmall_2}}};styles[pillType]=StyleSheet.create(colorStyles);return styles[pillType]};
10
+ const PillInner=props=>{const{children,size}=props;if(typeof children!=="string"){return children}if(size==="small"){return jsx(BodyText,{size:"xsmall",tag:"span",children:props.children})}if(size==="large"){return jsx(BodyText,{tag:"span",children:children})}return jsx(BodyText,{size:"small",tag:"span",children:children})};const Pill=React.forwardRef(function Pill(props,ref){const{id,children,kind="neutral",size="medium",role,onClick,style,tabIndex,testId,...ariaProps}=props;let wrapperSizeStyle;switch(size){case"small":wrapperSizeStyle=pillStyles.wrapperSmall;break;case"large":wrapperSizeStyle=pillStyles.wrapperLarge;break;default:wrapperSizeStyle=pillStyles.wrapperMedium;}const colorStyles=_generateColorStyles(!!onClick,kind);const defaultStyles=[pillStyles.wrapper,colorStyles.pill,wrapperSizeStyle];if(onClick){return jsx(Clickable,{id:id,role:role,onClick:onClick,style:[defaultStyles,colorStyles.clickableWrapper,style],testId:testId,ref:ref,tabIndex:tabIndex,...ariaProps,children:()=>jsx(PillInner,{size:size,children:children})})}return jsx(View,{id:id,role:role,style:[defaultStyles,style],testId:testId,ref:ref,...ariaProps,children:jsx(PillInner,{size:size,children:children})})});const pillStyles=StyleSheet.create({wrapper:{display:"inline-flex",width:"fit-content"},wrapperSmall:{paddingInline:sizing.size_080,borderRadius:border.radius.radius_040,height:sizing.size_200},wrapperMedium:{paddingInline:sizing.size_080,borderRadius:border.radius.radius_040,height:sizing.size_240},wrapperLarge:{paddingInline:sizing.size_120,paddingBlock:sizing.size_060,borderRadius:border.radius.radius_240,height:sizing.size_320}});const styles={};const _generateColorStyles=(clickable,kind)=>{const pillType=`${kind}-${clickable.toString()}`;if(styles[pillType]){return styles[pillType]}let backgroundColor;let textColor;switch(kind){case"accent":backgroundColor=semanticColor.core.background.instructive.default;textColor=semanticColor.core.foreground.inverse.strong;break;case"info":backgroundColor=semanticColor.feedback.info.subtle.background;textColor=semanticColor.feedback.info.subtle.text;break;case"success":backgroundColor=semanticColor.feedback.success.subtle.background;textColor=semanticColor.feedback.success.subtle.text;break;case"warning":backgroundColor=semanticColor.feedback.warning.subtle.background;textColor=semanticColor.feedback.warning.subtle.text;break;case"critical":backgroundColor=semanticColor.feedback.critical.subtle.background;textColor=semanticColor.feedback.critical.subtle.text;break;case"transparent":backgroundColor=semanticColor.core.transparent;textColor=semanticColor.core.foreground.neutral.strong;break;case"neutral":default:backgroundColor=semanticColor.status.neutral.background;textColor=semanticColor.core.foreground.neutral.strong;}const pressColor=kind==="transparent"||kind==="neutral"?color.offBlack16:kind==="accent"?semanticColor.core.background.instructive.strong:`color-mix(in srgb, ${color.offBlack32}, ${backgroundColor})`;const theme={default:{border:kind==="transparent"?`${border.width.thin} solid ${semanticColor.core.border.neutral.subtle}`:"none",background:backgroundColor,foreground:textColor},hover:{border:semanticColor.core.border.instructive.default},press:{border:semanticColor.core.border.instructive.strong,background:pressColor}};const colorStyles={pill:{backgroundColor:theme.default.background,outline:theme.default.border,color:theme.default.foreground,alignItems:"center",justifyContent:"center"},clickableWrapper:{outline:theme.default.border,":hover":{outline:`${border.width.medium} solid ${theme.hover.border}`,outlineOffset:sizing.size_020},":active":{backgroundColor:theme.press.background,outline:`${border.width.medium} solid ${theme.press.border}`,outlineOffset:sizing.size_020},...focusStyles.focus}};styles[pillType]=StyleSheet.create(colorStyles);return styles[pillType]};
10
11
 
11
12
  export { Pill as default };
package/dist/index.js CHANGED
@@ -6,7 +6,8 @@ var aphrodite = require('aphrodite');
6
6
  var Clickable = require('@khanacademy/wonder-blocks-clickable');
7
7
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
8
8
  var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
9
- var tokens = require('@khanacademy/wonder-blocks-tokens');
9
+ var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
10
+ var wonderBlocksStyles = require('@khanacademy/wonder-blocks-styles');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
13
 
@@ -30,8 +31,7 @@ function _interopNamespace(e) {
30
31
 
31
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
33
  var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
33
- var tokens__namespace = /*#__PURE__*/_interopNamespace(tokens);
34
34
 
35
- const{semanticColor}=tokens__namespace;const PillInner=props=>{const{children,size}=props;if(typeof children!=="string"){return children}if(size==="small"){return jsxRuntime.jsx(wonderBlocksTypography.LabelXSmall,{children:props.children})}if(size==="large"){return jsxRuntime.jsx(wonderBlocksTypography.Body,{children:children})}return jsxRuntime.jsx(wonderBlocksTypography.LabelSmall,{children:children})};const Pill=React__namespace.forwardRef(function Pill(props,ref){const{id,children,kind="neutral",size="medium",role,onClick,style,tabIndex,testId,...ariaProps}=props;let wrapperSizeStyle;switch(size){case"small":wrapperSizeStyle=pillStyles.wrapperSmall;break;case"large":wrapperSizeStyle=pillStyles.wrapperLarge;break;default:wrapperSizeStyle=pillStyles.wrapperMedium;}const colorStyles=_generateColorStyles(!!onClick,kind);const defaultStyles=[pillStyles.wrapper,colorStyles.pill,wrapperSizeStyle];if(onClick){return jsxRuntime.jsx(Clickable__default["default"],{id:id,role:role,onClick:onClick,style:[defaultStyles,colorStyles.clickableWrapper,style],testId:testId,ref:ref,tabIndex:tabIndex,...ariaProps,children:()=>jsxRuntime.jsx(PillInner,{size:size,children:children})})}return jsxRuntime.jsx(wonderBlocksCore.View,{id:id,role:role,style:[defaultStyles,style],testId:testId,ref:ref,...ariaProps,children:jsxRuntime.jsx(PillInner,{size:size,children:children})})});const pillStyles=aphrodite.StyleSheet.create({wrapper:{display:"inline-flex",width:"fit-content"},wrapperSmall:{paddingLeft:tokens__namespace.spacing.xSmall_8,paddingRight:tokens__namespace.spacing.xSmall_8,borderRadius:tokens__namespace.border.radius.radius_040,height:20},wrapperMedium:{paddingLeft:tokens__namespace.spacing.xSmall_8,paddingRight:tokens__namespace.spacing.xSmall_8,borderRadius:tokens__namespace.border.radius.radius_040,height:tokens__namespace.spacing.large_24},wrapperLarge:{paddingLeft:tokens__namespace.spacing.small_12,paddingRight:tokens__namespace.spacing.small_12,paddingTop:tokens__namespace.spacing.xxSmall_6,paddingBottom:tokens__namespace.spacing.xxSmall_6,borderRadius:tokens__namespace.sizing.size_240,height:tokens__namespace.spacing.xLarge_32}});const styles={};const _generateColorStyles=(clickable,kind)=>{const pillType=`${kind}-${clickable.toString()}`;if(styles[pillType]){return styles[pillType]}let backgroundColor;switch(kind){case"accent":backgroundColor=semanticColor.status.notice.foreground;break;case"info":backgroundColor=semanticColor.status.notice.background;break;case"success":backgroundColor=semanticColor.status.success.background;break;case"warning":backgroundColor=semanticColor.status.warning.background;break;case"critical":backgroundColor=semanticColor.status.critical.background;break;case"transparent":backgroundColor="transparent";break;case"neutral":default:backgroundColor=semanticColor.status.neutral.background;}const pressColor=kind==="transparent"||kind==="neutral"?tokens__namespace.color.offBlack16:kind==="accent"?tokens__namespace.color.activeBlue:`color-mix(in srgb, ${tokens__namespace.color.offBlack32}, ${backgroundColor})`;const textColor=kind==="accent"?semanticColor.text.inverse:semanticColor.text.primary;const theme={default:{border:kind==="transparent"?`1px solid ${semanticColor.core.border.neutral.subtle}`:"none",background:backgroundColor,foreground:textColor},focus:{border:semanticColor.focus.outer},hover:{border:semanticColor.core.border.instructive.default},press:{border:semanticColor.core.border.instructive.strong,background:pressColor}};const colorStyles={pill:{backgroundColor:theme.default.background,outline:theme.default.border,color:theme.default.foreground,alignItems:"center",justifyContent:"center"},clickableWrapper:{outline:theme.default.border,":hover":{outline:`2px solid ${theme.hover.border}`,outlineOffset:tokens__namespace.spacing.xxxxSmall_2},":active":{backgroundColor:theme.press.background,outline:`2px solid ${theme.press.border}`,outlineOffset:tokens__namespace.spacing.xxxxSmall_2},":focus-visible":{outline:`2px solid ${theme.focus.border}`,outlineOffset:tokens__namespace.spacing.xxxxSmall_2}}};styles[pillType]=aphrodite.StyleSheet.create(colorStyles);return styles[pillType]};
35
+ const PillInner=props=>{const{children,size}=props;if(typeof children!=="string"){return children}if(size==="small"){return jsxRuntime.jsx(wonderBlocksTypography.BodyText,{size:"xsmall",tag:"span",children:props.children})}if(size==="large"){return jsxRuntime.jsx(wonderBlocksTypography.BodyText,{tag:"span",children:children})}return jsxRuntime.jsx(wonderBlocksTypography.BodyText,{size:"small",tag:"span",children:children})};const Pill=React__namespace.forwardRef(function Pill(props,ref){const{id,children,kind="neutral",size="medium",role,onClick,style,tabIndex,testId,...ariaProps}=props;let wrapperSizeStyle;switch(size){case"small":wrapperSizeStyle=pillStyles.wrapperSmall;break;case"large":wrapperSizeStyle=pillStyles.wrapperLarge;break;default:wrapperSizeStyle=pillStyles.wrapperMedium;}const colorStyles=_generateColorStyles(!!onClick,kind);const defaultStyles=[pillStyles.wrapper,colorStyles.pill,wrapperSizeStyle];if(onClick){return jsxRuntime.jsx(Clickable__default["default"],{id:id,role:role,onClick:onClick,style:[defaultStyles,colorStyles.clickableWrapper,style],testId:testId,ref:ref,tabIndex:tabIndex,...ariaProps,children:()=>jsxRuntime.jsx(PillInner,{size:size,children:children})})}return jsxRuntime.jsx(wonderBlocksCore.View,{id:id,role:role,style:[defaultStyles,style],testId:testId,ref:ref,...ariaProps,children:jsxRuntime.jsx(PillInner,{size:size,children:children})})});const pillStyles=aphrodite.StyleSheet.create({wrapper:{display:"inline-flex",width:"fit-content"},wrapperSmall:{paddingInline:wonderBlocksTokens.sizing.size_080,borderRadius:wonderBlocksTokens.border.radius.radius_040,height:wonderBlocksTokens.sizing.size_200},wrapperMedium:{paddingInline:wonderBlocksTokens.sizing.size_080,borderRadius:wonderBlocksTokens.border.radius.radius_040,height:wonderBlocksTokens.sizing.size_240},wrapperLarge:{paddingInline:wonderBlocksTokens.sizing.size_120,paddingBlock:wonderBlocksTokens.sizing.size_060,borderRadius:wonderBlocksTokens.border.radius.radius_240,height:wonderBlocksTokens.sizing.size_320}});const styles={};const _generateColorStyles=(clickable,kind)=>{const pillType=`${kind}-${clickable.toString()}`;if(styles[pillType]){return styles[pillType]}let backgroundColor;let textColor;switch(kind){case"accent":backgroundColor=wonderBlocksTokens.semanticColor.core.background.instructive.default;textColor=wonderBlocksTokens.semanticColor.core.foreground.inverse.strong;break;case"info":backgroundColor=wonderBlocksTokens.semanticColor.feedback.info.subtle.background;textColor=wonderBlocksTokens.semanticColor.feedback.info.subtle.text;break;case"success":backgroundColor=wonderBlocksTokens.semanticColor.feedback.success.subtle.background;textColor=wonderBlocksTokens.semanticColor.feedback.success.subtle.text;break;case"warning":backgroundColor=wonderBlocksTokens.semanticColor.feedback.warning.subtle.background;textColor=wonderBlocksTokens.semanticColor.feedback.warning.subtle.text;break;case"critical":backgroundColor=wonderBlocksTokens.semanticColor.feedback.critical.subtle.background;textColor=wonderBlocksTokens.semanticColor.feedback.critical.subtle.text;break;case"transparent":backgroundColor=wonderBlocksTokens.semanticColor.core.transparent;textColor=wonderBlocksTokens.semanticColor.core.foreground.neutral.strong;break;case"neutral":default:backgroundColor=wonderBlocksTokens.semanticColor.status.neutral.background;textColor=wonderBlocksTokens.semanticColor.core.foreground.neutral.strong;}const pressColor=kind==="transparent"||kind==="neutral"?wonderBlocksTokens.color.offBlack16:kind==="accent"?wonderBlocksTokens.semanticColor.core.background.instructive.strong:`color-mix(in srgb, ${wonderBlocksTokens.color.offBlack32}, ${backgroundColor})`;const theme={default:{border:kind==="transparent"?`${wonderBlocksTokens.border.width.thin} solid ${wonderBlocksTokens.semanticColor.core.border.neutral.subtle}`:"none",background:backgroundColor,foreground:textColor},hover:{border:wonderBlocksTokens.semanticColor.core.border.instructive.default},press:{border:wonderBlocksTokens.semanticColor.core.border.instructive.strong,background:pressColor}};const colorStyles={pill:{backgroundColor:theme.default.background,outline:theme.default.border,color:theme.default.foreground,alignItems:"center",justifyContent:"center"},clickableWrapper:{outline:theme.default.border,":hover":{outline:`${wonderBlocksTokens.border.width.medium} solid ${theme.hover.border}`,outlineOffset:wonderBlocksTokens.sizing.size_020},":active":{backgroundColor:theme.press.background,outline:`${wonderBlocksTokens.border.width.medium} solid ${theme.press.border}`,outlineOffset:wonderBlocksTokens.sizing.size_020},...wonderBlocksStyles.focusStyles.focus}};styles[pillType]=aphrodite.StyleSheet.create(colorStyles);return styles[pillType]};
36
36
 
37
37
  module.exports = Pill;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-pill",
3
- "version": "3.1.25",
3
+ "version": "3.1.27",
4
4
  "design": "v1",
5
5
  "description": "Pill components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -13,11 +13,12 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@khanacademy/wonder-blocks-clickable": "7.1.11",
17
16
  "@khanacademy/wonder-blocks-core": "12.3.0",
18
- "@khanacademy/wonder-blocks-link": "9.1.11",
19
- "@khanacademy/wonder-blocks-tokens": "11.2.0",
20
- "@khanacademy/wonder-blocks-typography": "4.2.7"
17
+ "@khanacademy/wonder-blocks-link": "9.1.12",
18
+ "@khanacademy/wonder-blocks-styles": "0.2.19",
19
+ "@khanacademy/wonder-blocks-typography": "4.2.8",
20
+ "@khanacademy/wonder-blocks-clickable": "7.1.12",
21
+ "@khanacademy/wonder-blocks-tokens": "11.2.1"
21
22
  },
22
23
  "peerDependencies": {
23
24
  "aphrodite": "^1.2.5",