@newhighsco/chipset 6.19.1 → 6.21.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/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.19.1",
4
+ "version": "6.21.0",
5
5
  "author": "New High Score",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -51,15 +51,16 @@
51
51
  "@newhighsco/commitlint-config": "1.1.46",
52
52
  "@newhighsco/editor-config": "1.2.0",
53
53
  "@newhighsco/eslint-config": "4.1.44",
54
- "@newhighsco/postcss-config": "3.5.343",
54
+ "@newhighsco/postcss-config": "3.5.345",
55
55
  "@newhighsco/prettier-config": "2.1.32",
56
56
  "@newhighsco/release-config": "1.4.7",
57
- "@newhighsco/storybook-preset": "7.1.1",
57
+ "@newhighsco/storybook-preset": "7.1.2",
58
58
  "@newhighsco/stylelint-config": "4.0.17",
59
+ "@newhighsco/svgr-config": "1.0.0",
59
60
  "@omlet/cli": "2.0.0",
60
61
  "@storybook/react-webpack5": "8.6.14",
61
62
  "@testing-library/dom": "10.4.1",
62
- "@testing-library/jest-dom": "6.7.0",
63
+ "@testing-library/jest-dom": "6.8.0",
63
64
  "@testing-library/react": "16.3.0",
64
65
  "babel-loader": "10.0.0",
65
66
  "chromatic": "13.1.3",
@@ -67,8 +68,8 @@
67
68
  "eslint": "8.57.1",
68
69
  "husky": "9.1.7",
69
70
  "identity-obj-proxy": "3.0.0",
70
- "jest": "30.0.5",
71
- "jest-environment-jsdom": "30.0.5",
71
+ "jest": "30.1.1",
72
+ "jest-environment-jsdom": "30.1.1",
72
73
  "jest-junit": "16.0.0",
73
74
  "postcss": "8.5.6",
74
75
  "prettier": "3.6.2",
@@ -1,38 +1,30 @@
1
- import { node, number, oneOfType, shape, string } from 'prop-types'
2
- import React from 'react'
1
+ import { node, number, object, oneOfType, shape, string } from 'prop-types'
2
+ import { Children, cloneElement } from 'react'
3
3
 
4
4
  import { classNames } from '../../utils'
5
- import VisuallyHidden from '../VisuallyHidden'
6
5
 
7
6
  /**
8
7
  * Use `Icon` to wrap SVGs
9
8
  */
10
- const Icon = ({ height, width, alt, children, theme }) => {
9
+ const Icon = ({
10
+ width,
11
+ height,
12
+ alt,
13
+ children,
14
+ theme,
15
+ className,
16
+ style,
17
+ ...rest
18
+ }) => {
11
19
  if (!children) return null
12
20
 
13
- return (
14
- <span
15
- className={classNames(
16
- theme?.root,
17
- (width ?? height) && theme?.customSize
18
- )}
19
- {...(alt && {
20
- role: 'img',
21
- 'aria-label': alt
22
- })}
23
- {...(!alt && {
24
- 'aria-hidden': 'true'
25
- })}
26
- style={{
27
- width,
28
- height,
29
- lineHeight: height
30
- }}
31
- >
32
- {alt && <VisuallyHidden>{alt}</VisuallyHidden>}
33
- {children}
34
- </span>
35
- )
21
+ return cloneElement(Children.only(children), {
22
+ className: classNames(theme?.root, className),
23
+ ...(alt && { role: 'img', title: alt }),
24
+ ...(!alt && { 'aria-hidden': true }),
25
+ style: { ...style, width, height },
26
+ ...rest
27
+ })
36
28
  }
37
29
 
38
30
  Icon.displayName = 'Icon'
@@ -41,7 +33,9 @@ Icon.propTypes = {
41
33
  width: oneOfType([number, string]),
42
34
  alt: string,
43
35
  children: node,
44
- theme: shape({ root: string })
36
+ theme: shape({ root: string }),
37
+ className: string,
38
+ style: object
45
39
  }
46
40
 
47
41
  export default Icon
@@ -1,18 +1,8 @@
1
1
  .root {
2
2
  display: inline-block;
3
3
  fill: currentColor;
4
- vertical-align: middle;
5
4
  font-style: normal;
5
+ height: auto;
6
+ vertical-align: middle;
6
7
  width: 1em;
7
-
8
- svg {
9
- vertical-align: top;
10
- height: auto;
11
- }
12
- }
13
-
14
- .customSize {
15
- svg {
16
- width: inherit;
17
- }
18
8
  }
@@ -1,6 +1,9 @@
1
1
  import classnames from 'classnames/dedupe'
2
2
 
3
- export const classNames = (...args) =>
4
- classnames(...args)
3
+ export const classNames = (...args) => {
4
+ const names = classnames(...args)
5
5
  .replace(undefined, '')
6
6
  .trim()
7
+
8
+ return names.length ? names : undefined
9
+ }