@khanacademy/wonder-blocks-link 9.1.20 → 9.2.0
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/.turbo/turbo-build$colon$css.log +5 -0
- package/CHANGELOG.md +24 -0
- package/dist/css/vars.css +5 -0
- package/dist/es/index.js +7 -2
- package/dist/index.js +6 -1
- package/dist/theme/default.d.ts +9 -0
- package/dist/theme/index.d.ts +9 -0
- package/dist/theme/thunderblocks.d.ts +9 -0
- package/package.json +16 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
> @khanacademy/wonder-blocks-link@9.2.0 build:css /home/runner/work/wonder-blocks/wonder-blocks/packages/wonder-blocks-link
|
|
3
|
+
> pnpm exec wonder-blocks-tokens .
|
|
4
|
+
|
|
5
|
+
CSS variables generated successfully in: /home/runner/work/wonder-blocks/wonder-blocks/packages/wonder-blocks-link/dist/css
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-link
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4aad557: Add font theming to Link and Breadcrumbs with links
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [4aad557]
|
|
12
|
+
- @khanacademy/wonder-blocks-tokens@12.1.0
|
|
13
|
+
- @khanacademy/wonder-blocks-clickable@7.1.22
|
|
14
|
+
- @khanacademy/wonder-blocks-icon@5.2.16
|
|
15
|
+
- @khanacademy/wonder-blocks-styles@0.2.28
|
|
16
|
+
- @khanacademy/wonder-blocks-typography@4.2.18
|
|
17
|
+
|
|
18
|
+
## 9.1.21
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [1334e74]
|
|
23
|
+
- @khanacademy/wonder-blocks-core@12.4.0
|
|
24
|
+
- @khanacademy/wonder-blocks-clickable@7.1.21
|
|
25
|
+
- @khanacademy/wonder-blocks-icon@5.2.15
|
|
26
|
+
|
|
3
27
|
## 9.1.20
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -4,11 +4,16 @@ import { Link as Link$1, useInRouterContext } from 'react-router-dom-v5-compat';
|
|
|
4
4
|
import { isClientSideUrl, getClickableBehavior } from '@khanacademy/wonder-blocks-clickable';
|
|
5
5
|
import { StyleSheet } from 'aphrodite';
|
|
6
6
|
import { addStyle } from '@khanacademy/wonder-blocks-core';
|
|
7
|
-
import { spacing, semanticColor, color, border } from '@khanacademy/wonder-blocks-tokens';
|
|
7
|
+
import { mapValuesToCssVars, spacing, semanticColor, color, border, font } from '@khanacademy/wonder-blocks-tokens';
|
|
8
|
+
import { focusStyles } from '@khanacademy/wonder-blocks-styles';
|
|
8
9
|
import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
|
|
9
10
|
import externalLinkIcon from '@phosphor-icons/core/bold/arrow-square-out-bold.svg';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
var themeDefault = {root:{font:{family:"inherit",weight:"inherit"}}};
|
|
13
|
+
|
|
14
|
+
var theme = mapValuesToCssVars(themeDefault,"--wb-c-link-");
|
|
15
|
+
|
|
16
|
+
const StyledA=addStyle("a");const StyledLink=addStyle(Link$1);const LinkCore=React.forwardRef(function LinkCore(props,ref){const inRouterContext=useInRouterContext();const{children,skipClientNav,focused,hovered,href,inline=false,light=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,viewTransition,...restProps}=props;const linkStyles=_generateStyles(inline,light);const defaultStyles=[sharedStyles.shared,linkStyles.rest,inline&&linkStyles.restInline,!pressed&&focused&&linkStyles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsx(PhosphorIcon,{icon:externalLinkIcon,size:"small",style:[linkContentStyles.endIcon,linkContentStyles.centered],testId:"external-icon"});let startIconElement;let endIconElement;if(startIcon){startIconElement=React.cloneElement(startIcon,{style:[linkContentStyles.startIcon,linkContentStyles.centered],testId:"start-icon","aria-hidden":"true",...startIcon.props});}if(endIcon){endIconElement=React.cloneElement(endIcon,{style:[linkContentStyles.endIcon,linkContentStyles.centered],testId:"end-icon","aria-hidden":"true",...endIcon.props});}const linkContent=jsxs(Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&isClientSideUrl(href)?jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,children:linkContent}):jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const styles={};const linkContentStyles=StyleSheet.create({startIcon:{marginInlineEnd:spacing.xxxSmall_4},endIcon:{marginInlineStart:spacing.xxxSmall_4},centered:{verticalAlign:"-10%"}});const sharedStyles=StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"}});const states={color:{default:{rest:{foreground:semanticColor.link.rest},hover:{foreground:semanticColor.link.hover},focus:{border:semanticColor.focus.outer},press:{foreground:semanticColor.link.press}},inverse:{rest:{foreground:semanticColor.core.foreground.inverse.strong},hover:{foreground:semanticColor.core.foreground.inverse.strong},focus:{border:semanticColor.core.border.inverse.strong},press:{foreground:color.fadedBlue}}}};const _generateStyles=(inline,light)=>{const buttonType=`${inline.toString()}-${light.toString()}`;if(styles[buttonType]){return styles[buttonType]}const variant=light?states.color.inverse:states.color.default;const focusStyling={...focusStyles.focus[":focus-visible"],borderRadius:border.radius.radius_010,outlineOffset:border.width.medium};const pressStyling={color:variant.press.foreground,textDecoration:"underline currentcolor solid",textUnderlineOffset:font.textDecoration.underlineOffset};const newStyles={rest:{color:variant.rest.foreground,":hover":{textDecoration:"underline currentcolor solid",color:variant.hover.foreground,textUnderlineOffset:font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:font.textDecoration.thickness,textUnderlineOffset:font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling};styles[buttonType]=StyleSheet.create(newStyles);return styles[buttonType]};
|
|
12
17
|
|
|
13
18
|
const Link=React.forwardRef(function Link(props,ref){const{onClick,beforeNav=undefined,safeWithNav,href,skipClientNav,children,tabIndex,onKeyDown,onKeyUp,target=undefined,inline=false,light=false,viewTransition=false,...sharedProps}=props;const inRouterContext=useInRouterContext();const ClickableBehavior=getClickableBehavior(href,skipClientNav,inRouterContext);if(beforeNav){return jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,beforeNav:beforeNav,safeWithNav:safeWithNav,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,children:(state,{...childrenProps})=>{return jsx(LinkCore,{...sharedProps,...state,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,light:light,ref:ref,viewTransition:viewTransition,children:children})}})}else {return jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,safeWithNav:safeWithNav,target:target,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,children:(state,{...childrenProps})=>{return jsx(LinkCore,{...sharedProps,...state,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,light:light,ref:ref,viewTransition:viewTransition,children:children})}})}});
|
|
14
19
|
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var wonderBlocksClickable = require('@khanacademy/wonder-blocks-clickable');
|
|
|
7
7
|
var aphrodite = require('aphrodite');
|
|
8
8
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
9
9
|
var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
|
|
10
|
+
var wonderBlocksStyles = require('@khanacademy/wonder-blocks-styles');
|
|
10
11
|
var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
|
|
11
12
|
var externalLinkIcon = require('@phosphor-icons/core/bold/arrow-square-out-bold.svg');
|
|
12
13
|
|
|
@@ -33,7 +34,11 @@ function _interopNamespace(e) {
|
|
|
33
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
35
|
var externalLinkIcon__default = /*#__PURE__*/_interopDefaultLegacy(externalLinkIcon);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
var themeDefault = {root:{font:{family:"inherit",weight:"inherit"}}};
|
|
38
|
+
|
|
39
|
+
var theme = wonderBlocksTokens.mapValuesToCssVars(themeDefault,"--wb-c-link-");
|
|
40
|
+
|
|
41
|
+
const StyledA=wonderBlocksCore.addStyle("a");const StyledLink=wonderBlocksCore.addStyle(reactRouterDomV5Compat.Link);const LinkCore=React__namespace.forwardRef(function LinkCore(props,ref){const inRouterContext=reactRouterDomV5Compat.useInRouterContext();const{children,skipClientNav,focused,hovered,href,inline=false,light=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,viewTransition,...restProps}=props;const linkStyles=_generateStyles(inline,light);const defaultStyles=[sharedStyles.shared,linkStyles.rest,inline&&linkStyles.restInline,!pressed&&focused&&linkStyles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsxRuntime.jsx(wonderBlocksIcon.PhosphorIcon,{icon:externalLinkIcon__default["default"],size:"small",style:[linkContentStyles.endIcon,linkContentStyles.centered],testId:"external-icon"});let startIconElement;let endIconElement;if(startIcon){startIconElement=React__namespace.cloneElement(startIcon,{style:[linkContentStyles.startIcon,linkContentStyles.centered],testId:"start-icon","aria-hidden":"true",...startIcon.props});}if(endIcon){endIconElement=React__namespace.cloneElement(endIcon,{style:[linkContentStyles.endIcon,linkContentStyles.centered],testId:"end-icon","aria-hidden":"true",...endIcon.props});}const linkContent=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&wonderBlocksClickable.isClientSideUrl(href)?jsxRuntime.jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,children:linkContent}):jsxRuntime.jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const styles={};const linkContentStyles=aphrodite.StyleSheet.create({startIcon:{marginInlineEnd:wonderBlocksTokens.spacing.xxxSmall_4},endIcon:{marginInlineStart:wonderBlocksTokens.spacing.xxxSmall_4},centered:{verticalAlign:"-10%"}});const sharedStyles=aphrodite.StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"}});const states={color:{default:{rest:{foreground:wonderBlocksTokens.semanticColor.link.rest},hover:{foreground:wonderBlocksTokens.semanticColor.link.hover},focus:{border:wonderBlocksTokens.semanticColor.focus.outer},press:{foreground:wonderBlocksTokens.semanticColor.link.press}},inverse:{rest:{foreground:wonderBlocksTokens.semanticColor.core.foreground.inverse.strong},hover:{foreground:wonderBlocksTokens.semanticColor.core.foreground.inverse.strong},focus:{border:wonderBlocksTokens.semanticColor.core.border.inverse.strong},press:{foreground:wonderBlocksTokens.color.fadedBlue}}}};const _generateStyles=(inline,light)=>{const buttonType=`${inline.toString()}-${light.toString()}`;if(styles[buttonType]){return styles[buttonType]}const variant=light?states.color.inverse:states.color.default;const focusStyling={...wonderBlocksStyles.focusStyles.focus[":focus-visible"],borderRadius:wonderBlocksTokens.border.radius.radius_010,outlineOffset:wonderBlocksTokens.border.width.medium};const pressStyling={color:variant.press.foreground,textDecoration:"underline currentcolor solid",textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset};const newStyles={rest:{color:variant.rest.foreground,":hover":{textDecoration:"underline currentcolor solid",color:variant.hover.foreground,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:wonderBlocksTokens.font.textDecoration.thickness,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling};styles[buttonType]=aphrodite.StyleSheet.create(newStyles);return styles[buttonType]};
|
|
37
42
|
|
|
38
43
|
const Link=React__namespace.forwardRef(function Link(props,ref){const{onClick,beforeNav=undefined,safeWithNav,href,skipClientNav,children,tabIndex,onKeyDown,onKeyUp,target=undefined,inline=false,light=false,viewTransition=false,...sharedProps}=props;const inRouterContext=reactRouterDomV5Compat.useInRouterContext();const ClickableBehavior=wonderBlocksClickable.getClickableBehavior(href,skipClientNav,inRouterContext);if(beforeNav){return jsxRuntime.jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,beforeNav:beforeNav,safeWithNav:safeWithNav,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,children:(state,{...childrenProps})=>{return jsxRuntime.jsx(LinkCore,{...sharedProps,...state,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,light:light,ref:ref,viewTransition:viewTransition,children:children})}})}else {return jsxRuntime.jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,safeWithNav:safeWithNav,target:target,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,children:(state,{...childrenProps})=>{return jsxRuntime.jsx(LinkCore,{...sharedProps,...state,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,light:light,ref:ref,viewTransition:viewTransition,children:children})}})}});
|
|
39
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-link",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,13 +9,23 @@
|
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/es/index.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/es/index.js",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./styles.css": "./dist/css/vars.css"
|
|
19
|
+
},
|
|
12
20
|
"author": "",
|
|
13
21
|
"license": "MIT",
|
|
14
22
|
"dependencies": {
|
|
15
|
-
"@khanacademy/wonder-blocks-clickable": "7.1.
|
|
16
|
-
"@khanacademy/wonder-blocks-core": "12.
|
|
17
|
-
"@khanacademy/wonder-blocks-icon": "5.2.
|
|
18
|
-
"@khanacademy/wonder-blocks-tokens": "12.0
|
|
23
|
+
"@khanacademy/wonder-blocks-clickable": "7.1.22",
|
|
24
|
+
"@khanacademy/wonder-blocks-core": "12.4.0",
|
|
25
|
+
"@khanacademy/wonder-blocks-icon": "5.2.16",
|
|
26
|
+
"@khanacademy/wonder-blocks-tokens": "12.1.0",
|
|
27
|
+
"@khanacademy/wonder-blocks-typography": "4.2.18",
|
|
28
|
+
"@khanacademy/wonder-blocks-styles": "0.2.28"
|
|
19
29
|
},
|
|
20
30
|
"peerDependencies": {
|
|
21
31
|
"@phosphor-icons/core": "^2.0.2",
|
|
@@ -29,6 +39,7 @@
|
|
|
29
39
|
"@khanacademy/wb-dev-build-settings": "3.2.0"
|
|
30
40
|
},
|
|
31
41
|
"scripts": {
|
|
42
|
+
"build:css": "pnpm exec wonder-blocks-tokens .",
|
|
32
43
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
44
|
}
|
|
34
45
|
}
|