@newhighsco/chipset 6.18.0 → 6.19.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/package.json +9 -9
- package/src/components/CreditLockup/CreditLockup.jsx +5 -3
- package/src/components/Landmark/Landmark.jsx +3 -7
- package/src/components/SmartLink/SmartLink.jsx +18 -13
- package/src/docs/README.mdx +2 -4
- package/src/providers/LinkProvider/LinkProvider.jsx +26 -0
- package/src/providers/LinkProvider/index.js +1 -0
- package/src/providers/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newhighsco/chipset",
|
|
3
3
|
"description": "Shareable, theme-able component library by New High Score",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.19.1",
|
|
5
5
|
"author": "New High Score",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"repository": {
|
|
@@ -42,28 +42,28 @@
|
|
|
42
42
|
"react-device-detect": "2.2.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@babel/core": "7.28.
|
|
46
|
-
"@babel/preset-env": "7.28.
|
|
45
|
+
"@babel/core": "7.28.3",
|
|
46
|
+
"@babel/preset-env": "7.28.3",
|
|
47
47
|
"@babel/preset-react": "7.27.1",
|
|
48
48
|
"@commitlint/cli": "19.8.1",
|
|
49
49
|
"@fullhuman/postcss-purgecss": "7.0.2",
|
|
50
50
|
"@newhighsco/browserslist-config": "2.0.0",
|
|
51
51
|
"@newhighsco/commitlint-config": "1.1.46",
|
|
52
52
|
"@newhighsco/editor-config": "1.2.0",
|
|
53
|
-
"@newhighsco/eslint-config": "4.1.
|
|
54
|
-
"@newhighsco/postcss-config": "3.5.
|
|
53
|
+
"@newhighsco/eslint-config": "4.1.44",
|
|
54
|
+
"@newhighsco/postcss-config": "3.5.343",
|
|
55
55
|
"@newhighsco/prettier-config": "2.1.32",
|
|
56
|
-
"@newhighsco/release-config": "1.4.
|
|
56
|
+
"@newhighsco/release-config": "1.4.7",
|
|
57
57
|
"@newhighsco/storybook-preset": "7.1.1",
|
|
58
58
|
"@newhighsco/stylelint-config": "4.0.17",
|
|
59
59
|
"@omlet/cli": "2.0.0",
|
|
60
60
|
"@storybook/react-webpack5": "8.6.14",
|
|
61
61
|
"@testing-library/dom": "10.4.1",
|
|
62
|
-
"@testing-library/jest-dom": "6.
|
|
62
|
+
"@testing-library/jest-dom": "6.7.0",
|
|
63
63
|
"@testing-library/react": "16.3.0",
|
|
64
64
|
"babel-loader": "10.0.0",
|
|
65
65
|
"chromatic": "13.1.3",
|
|
66
|
-
"concurrently": "9.2.
|
|
66
|
+
"concurrently": "9.2.1",
|
|
67
67
|
"eslint": "8.57.1",
|
|
68
68
|
"husky": "9.1.7",
|
|
69
69
|
"identity-obj-proxy": "3.0.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"semantic-release": "24.2.7",
|
|
79
79
|
"storybook": "8.6.14",
|
|
80
80
|
"stylelint": "16.23.1",
|
|
81
|
-
"webpack": "5.101.
|
|
81
|
+
"webpack": "5.101.3"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"react": "19.1.1",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { oneOf, shape, string } from 'prop-types'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
+
import { classNames } from '../../utils'
|
|
4
5
|
import Icon from '../Icon'
|
|
5
6
|
import SmartLink from '../SmartLink'
|
|
6
7
|
import { ReactComponent as LogoSvg } from './images/logo.svg'
|
|
@@ -13,8 +14,8 @@ const href = 'http://newhighsco.re'
|
|
|
13
14
|
/**
|
|
14
15
|
* The `CreditLockup` provides a link to the New High Score website
|
|
15
16
|
*/
|
|
16
|
-
const CreditLockup = ({ theme, ...rest }) => (
|
|
17
|
-
<span className={theme?.root} {...rest}>
|
|
17
|
+
const CreditLockup = ({ theme, className, ...rest }) => (
|
|
18
|
+
<span className={classNames(theme?.root, className)} {...rest}>
|
|
18
19
|
<SmartLink
|
|
19
20
|
className={theme?.link}
|
|
20
21
|
href={href}
|
|
@@ -38,7 +39,8 @@ CreditLockup.displayName = 'CreditLockup'
|
|
|
38
39
|
CreditLockup.propTypes = {
|
|
39
40
|
align: oneOf(['left', 'right', 'center']),
|
|
40
41
|
dir: oneOf(['ltr', 'rtl']),
|
|
41
|
-
theme: shape({ root: string, link: string, logo: string, text: string })
|
|
42
|
+
theme: shape({ root: string, link: string, logo: string, text: string }),
|
|
43
|
+
className: string
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export default CreditLockup
|
|
@@ -8,13 +8,9 @@ import styles from './Landmark.module.scss'
|
|
|
8
8
|
* Use `Landmark` to create visually hidden anchors
|
|
9
9
|
*/
|
|
10
10
|
const Landmark = ({ children, ...rest }) => (
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
<VisuallyHidden>{children}</VisuallyHidden>
|
|
15
|
-
</a>
|
|
16
|
-
{/* eslint-enable jsx-a11y/anchor-is-valid */}
|
|
17
|
-
</>
|
|
11
|
+
<a className={styles.root} {...rest}>
|
|
12
|
+
<VisuallyHidden>{children}</VisuallyHidden>
|
|
13
|
+
</a>
|
|
18
14
|
)
|
|
19
15
|
|
|
20
16
|
Landmark.propTypes = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { bool, func, node, object, oneOf, oneOfType, string } from 'prop-types'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
+
import { useLink } from '../../providers'
|
|
4
5
|
import { absoluteUrl } from '../../utils'
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -16,8 +17,24 @@ const SmartLink = ({
|
|
|
16
17
|
className,
|
|
17
18
|
...rest
|
|
18
19
|
}) => {
|
|
20
|
+
const renderLink = useLink()
|
|
21
|
+
|
|
19
22
|
if (!children) return null
|
|
20
23
|
|
|
24
|
+
if (!href) {
|
|
25
|
+
return (
|
|
26
|
+
<button
|
|
27
|
+
ref={setRef}
|
|
28
|
+
className={className}
|
|
29
|
+
disabled={disabled}
|
|
30
|
+
type={type}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</button>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
if (disabled) {
|
|
22
39
|
const { role = 'link' } = rest
|
|
23
40
|
|
|
@@ -29,14 +46,6 @@ const SmartLink = ({
|
|
|
29
46
|
)
|
|
30
47
|
}
|
|
31
48
|
|
|
32
|
-
if (!href) {
|
|
33
|
-
return (
|
|
34
|
-
<button ref={setRef} className={className} type={type} {...rest}>
|
|
35
|
-
{children}
|
|
36
|
-
</button>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
49
|
if (absoluteUrl(href)) {
|
|
41
50
|
return (
|
|
42
51
|
<a
|
|
@@ -52,11 +61,7 @@ const SmartLink = ({
|
|
|
52
61
|
)
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
return (
|
|
56
|
-
<a ref={setRef} className={className} href={href} {...rest}>
|
|
57
|
-
{children}
|
|
58
|
-
</a>
|
|
59
|
-
)
|
|
64
|
+
return renderLink({ ref: setRef, className, href, children, ...rest })
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
SmartLink.displayName = 'SmartLink'
|
package/src/docs/README.mdx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, Title
|
|
1
|
+
import { Meta, Title } from '@storybook/blocks'
|
|
2
2
|
|
|
3
3
|
import { ReactComponent as LogoSvg } from '../../.storybook/static/logo.svg'
|
|
4
4
|
import { CreditLockup, Image, SmartLink } from '../../src'
|
|
@@ -27,7 +27,5 @@ Shareable, theme-able component library
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
29
|
<p>
|
|
30
|
-
<
|
|
31
|
-
<CreditLockup />
|
|
32
|
-
</Unstyled>
|
|
30
|
+
<CreditLockup className="sb-unstyled" />
|
|
33
31
|
</p>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { func, node } from 'prop-types'
|
|
2
|
+
import React, { createContext, useContext } from 'react'
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
5
|
+
const LinkContext = createContext(props => <a {...props} />)
|
|
6
|
+
|
|
7
|
+
export const useLink = () => {
|
|
8
|
+
const renderLink = useContext(LinkContext)
|
|
9
|
+
|
|
10
|
+
if (!renderLink) {
|
|
11
|
+
throw new Error("<LinkProvider /> missing 'renderLink'")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return renderLink
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const LinkProvider = ({ children, renderLink }) => {
|
|
18
|
+
return (
|
|
19
|
+
<LinkContext.Provider value={renderLink}>{children}</LinkContext.Provider>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
LinkProvider.propTypes = {
|
|
24
|
+
children: node,
|
|
25
|
+
renderLink: func
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LinkProvider'
|
package/src/providers/index.js
CHANGED