@newhighsco/chipset 6.12.2 → 6.13.2

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.12.2",
4
+ "version": "6.13.2",
5
5
  "author": "New High Score <hello@newhighsco.re>",
6
6
  "license": "ISC",
7
7
  "config": {
@@ -35,8 +35,8 @@
35
35
  "snapshot": "npm-run-all --parallel snapshot:*",
36
36
  "snapshot:chromatic": "chromatic --storybook-build-dir build --auto-accept-changes main --exit-once-uploaded",
37
37
  "lint": "npm-run-all --parallel lint:*",
38
- "lint:js": "eslint --cache --ext .js,.json,.jsx,.mdx .",
39
- "lint:css": "stylelint '**/*.{css,scss}' --cache",
38
+ "lint:js": "eslint --cache --ignore-path .gitignore --ext .js,.json,.jsx,.mdx .",
39
+ "lint:css": "stylelint '**/*.{css,scss}' --cache --ignore-path .gitignore",
40
40
  "format": "npm-run-all --parallel format:*",
41
41
  "format:js": "yarn lint:js --fix",
42
42
  "format:css": "yarn lint:css --fix"
@@ -47,39 +47,40 @@
47
47
  "react-device-detect": "2.1.2"
48
48
  },
49
49
  "devDependencies": {
50
- "@babel/core": "7.15.8",
50
+ "@babel/core": "7.16.0",
51
51
  "@babel/polyfill": "7.12.1",
52
- "@babel/preset-env": "7.15.8",
53
- "@babel/preset-react": "7.14.5",
54
- "@commitlint/cli": "13.2.1",
52
+ "@babel/preset-env": "7.16.0",
53
+ "@babel/preset-react": "7.16.0",
54
+ "@commitlint/cli": "14.1.0",
55
55
  "@fullhuman/postcss-purgecss": "4.0.3",
56
56
  "@newhighsco/browserslist-config": "1.0.3",
57
- "@newhighsco/commitlint-config": "1.0.16",
57
+ "@newhighsco/commitlint-config": "1.0.17",
58
58
  "@newhighsco/editor-config": "1.1.2",
59
- "@newhighsco/eslint-config": "2.3.36",
60
- "@newhighsco/postcss-config": "3.4.10",
59
+ "@newhighsco/eslint-config": "2.3.37",
60
+ "@newhighsco/postcss-config": "3.4.15",
61
61
  "@newhighsco/prettier-config": "2.0.14",
62
- "@newhighsco/release-config": "1.0.73",
63
- "@newhighsco/storybook-preset": "4.3.24",
64
- "@newhighsco/stylelint-config": "2.0.48",
62
+ "@newhighsco/release-config": "1.0.76",
63
+ "@newhighsco/storybook-preset": "4.3.26",
64
+ "@newhighsco/stylelint-config": "3.0.3",
65
65
  "@storybook/react": "6.3.12",
66
66
  "@wojtekmaj/enzyme-adapter-react-17": "0.6.5",
67
67
  "babel-jest": "27.3.1",
68
68
  "babel-loader": "8.2.3",
69
- "chromatic": "6.0.4",
69
+ "chromatic": "6.0.5",
70
70
  "enzyme": "3.11.0",
71
71
  "eslint": "8.1.0",
72
72
  "husky": "7.0.4",
73
73
  "identity-obj-proxy": "3.0.0",
74
74
  "jest": "27.3.1",
75
75
  "npm-run-all": "4.1.5",
76
+ "postcss": "8.3.11",
76
77
  "prettier": "2.4.1",
77
78
  "react": "17.0.2",
78
79
  "react-dom": "17.0.2",
79
80
  "sass-true": "6.0.1",
80
81
  "semantic-release": "18.0.0",
81
- "stylelint": "13.13.1",
82
- "webpack": "5.59.1"
82
+ "stylelint": "14.0.1",
83
+ "webpack": "5.61.0"
83
84
  },
84
85
  "peerDependencies": {
85
86
  "react": "17.0.2",
@@ -1,4 +1,4 @@
1
1
  @use '../../../styles/mixins/grid';
2
2
 
3
- @include grid.initialize();
3
+ @include grid.initialize;
4
4
  @include grid.gutter('gutterless', 0);
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { node, number, shape, string } from 'prop-types'
2
+ import { node, number, oneOfType, shape, string } from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
  import VisuallyHidden from '../VisuallyHidden'
5
5
 
@@ -23,9 +23,9 @@ const Icon = ({ height, width, alt, children, theme }) => {
23
23
  'aria-hidden': 'true'
24
24
  })}
25
25
  style={{
26
- width: width && `${width}px`,
27
- height: height && `${height}px`,
28
- lineHeight: height && `${height}px`
26
+ width,
27
+ height,
28
+ lineHeight: height
29
29
  }}
30
30
  >
31
31
  {alt && <VisuallyHidden>{alt}</VisuallyHidden>}
@@ -36,8 +36,8 @@ const Icon = ({ height, width, alt, children, theme }) => {
36
36
 
37
37
  Icon.displayName = 'Icon'
38
38
  Icon.propTypes = {
39
- height: number,
40
- width: number,
39
+ height: oneOfType([number, string]),
40
+ width: oneOfType([number, string]),
41
41
  alt: string,
42
42
  children: node,
43
43
  theme: shape({ root: string })
@@ -8,7 +8,7 @@
8
8
  .video {
9
9
  background: black;
10
10
 
11
- @include mixins.mq(breakpoints.$tabletLandscape) {
11
+ @include mixins.mq(breakpoints.$tablet-landscape) {
12
12
  display: flex;
13
13
  align-items: center;
14
14
  flex-grow: 1;
@@ -17,7 +17,7 @@
17
17
  }
18
18
 
19
19
  .chat {
20
- @include mixins.mq(breakpoints.$tabletLandscape) {
20
+ @include mixins.mq(breakpoints.$tablet-landscape) {
21
21
  width: 340px;
22
22
  }
23
23
 
@@ -1,6 +1,7 @@
1
- import React, { useState } from 'react'
1
+ import React from 'react'
2
2
  import { array, bool, func, shape, string } from 'prop-types'
3
3
  import classNames from 'classnames'
4
+ import { useToggle } from '../../hooks'
4
5
  import Button from '../Button'
5
6
  import Icon from '../Icon'
6
7
  import List from '../List'
@@ -22,10 +23,10 @@ const Navigation = ({
22
23
  }) => {
23
24
  if (!links.length) return null
24
25
 
25
- const [visible, setVisibility] = useState(!toggle)
26
+ const [visible, setVisibility] = useToggle(!toggle)
26
27
 
27
28
  const toggleVisibility = () => {
28
- setVisibility(!visible)
29
+ setVisibility()
29
30
  onToggle({ visible })
30
31
  }
31
32
 
@@ -0,0 +1,92 @@
1
+ import React from 'react'
2
+ import { bool, node, oneOf, shape, string } from 'prop-types'
3
+ import classNames from 'classnames'
4
+ import { useToggle } from '../../hooks'
5
+ import SmartLink from '../SmartLink'
6
+
7
+ /**
8
+ * Use `Tooltip` to present additional information about a specific element
9
+ */
10
+ const Tooltip = ({
11
+ hidden = true,
12
+ manual = true,
13
+ toggle,
14
+ href,
15
+ target,
16
+ heading,
17
+ children,
18
+ align = 'center',
19
+ valign = 'top',
20
+ disabled,
21
+ theme,
22
+ className
23
+ }) => {
24
+ if (!heading && !children) return null
25
+
26
+ const [visible, setVisibility] = useToggle(!hidden)
27
+
28
+ return (
29
+ <span
30
+ className={classNames(theme?.root, className)}
31
+ {...(!manual && {
32
+ onMouseOver: setVisibility,
33
+ onMouseOut: setVisibility,
34
+ onFocus: setVisibility,
35
+ onBlur: setVisibility,
36
+ onTouchEnd: setVisibility
37
+ })}
38
+ >
39
+ <SmartLink
40
+ className={classNames(theme?.toggle, visible && theme?.toggleActive)}
41
+ href={href}
42
+ target={target}
43
+ disabled={disabled}
44
+ aria-label="Toggle tooltip"
45
+ {...(manual && {
46
+ 'aria-expanded': visible,
47
+ onClick: setVisibility
48
+ })}
49
+ >
50
+ {toggle}
51
+ </SmartLink>
52
+ {(heading || children) && (
53
+ <span
54
+ className={classNames(
55
+ theme?.content,
56
+ align && theme?.[align],
57
+ valign && theme?.[valign]
58
+ )}
59
+ hidden={!visible}
60
+ >
61
+ {heading && <span className={theme?.heading}>{heading}</span>}
62
+ {children && <span className={theme?.copy}>{children}</span>}
63
+ </span>
64
+ )}
65
+ </span>
66
+ )
67
+ }
68
+
69
+ Tooltip.displayName = 'Tooltip'
70
+ Tooltip.propTypes = {
71
+ hidden: bool,
72
+ manual: bool,
73
+ toggle: node,
74
+ href: string,
75
+ target: string,
76
+ heading: node,
77
+ children: node,
78
+ align: oneOf(['left', 'right', 'center']),
79
+ valign: oneOf(['top', 'middle', 'bottom']),
80
+ disabled: bool,
81
+ theme: shape({
82
+ root: string,
83
+ toggle: string,
84
+ toggleActive: string,
85
+ content: string,
86
+ heading: string,
87
+ copy: string
88
+ }),
89
+ className: string
90
+ }
91
+
92
+ export default Tooltip
@@ -0,0 +1,68 @@
1
+ .root {
2
+ display: inline-block;
3
+ position: relative;
4
+ }
5
+
6
+ .toggle {
7
+ cursor: help;
8
+
9
+ &[href],
10
+ &[aria-expanded] {
11
+ cursor: pointer;
12
+ }
13
+ }
14
+
15
+ .content {
16
+ display: block;
17
+ position: absolute;
18
+ z-index: 1;
19
+
20
+ &[hidden] {
21
+ display: none;
22
+ }
23
+
24
+ &.top {
25
+ bottom: 100%;
26
+ }
27
+
28
+ &.bottom {
29
+ top: 100%;
30
+ }
31
+
32
+ &.left {
33
+ left: 0;
34
+ }
35
+
36
+ &.right {
37
+ right: 0;
38
+ }
39
+
40
+ &.center {
41
+ left: 50%;
42
+ transform: translateX(-50%);
43
+ }
44
+
45
+ &.middle {
46
+ top: 50%;
47
+ transform: translateY(-50%);
48
+
49
+ &.left {
50
+ left: auto;
51
+ right: 100%;
52
+ }
53
+
54
+ &.right {
55
+ left: 100%;
56
+ right: auto;
57
+ }
58
+
59
+ &.center {
60
+ transform: translate(-50%, -50%);
61
+ }
62
+ }
63
+ }
64
+
65
+ .heading,
66
+ .copy {
67
+ display: block;
68
+ }
@@ -0,0 +1,11 @@
1
+ import { withTheme } from '../../providers'
2
+ import PureTooltip from './Tooltip'
3
+
4
+ import theme from './Tooltip.module.scss'
5
+
6
+ const { displayName } = PureTooltip
7
+ const Tooltip = withTheme(displayName, theme)(PureTooltip)
8
+
9
+ Tooltip.displayName = displayName
10
+
11
+ export default Tooltip
@@ -1,5 +1,5 @@
1
1
  @use '../../../styles/mixins/visually-hidden' as *;
2
2
 
3
3
  .root {
4
- @include visually-hidden();
4
+ @include visually-hidden;
5
5
  }
@@ -18,4 +18,5 @@ export { default as Prose } from './Prose'
18
18
  export { default as ResponsiveMedia } from './ResponsiveMedia'
19
19
  export { default as SiteContainer } from './SiteContainer'
20
20
  export { default as SmartLink } from './SmartLink'
21
+ export { default as Tooltip } from './Tooltip'
21
22
  export { default as VisuallyHidden } from './VisuallyHidden'
@@ -0,0 +1 @@
1
+ export { useToggle } from './use-toggle'
@@ -0,0 +1,8 @@
1
+ import { useCallback, useState } from 'react'
2
+
3
+ export const useToggle = (initialState = false) => {
4
+ const [state, setState] = useState(initialState)
5
+ const toggle = useCallback(() => setState(state => !state), [])
6
+
7
+ return [state, toggle]
8
+ }
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './utils'
2
2
  export * from './components'
3
+ export * from './hooks'
3
4
  export * from './providers'
@@ -1,28 +1,31 @@
1
1
  @use './functions/strip-unit' as *;
2
2
 
3
3
  $mobile: 320px !default;
4
- $mobileLandscape: 400px !default;
4
+ $mobile-landscape: 400px !default;
5
5
  $tablet: 550px !default;
6
- $tabletLandscape: 800px !default;
6
+ $tablet-landscape: 800px !default;
7
7
  $desktop: 960px !default;
8
- $desktopMedium: 1280px !default;
9
- $desktopLarge: 1600px !default;
8
+ $desktop-medium: 1280px !default;
9
+ $desktop-large: 1600px !default;
10
+
11
+ /* stylelint-disable value-keyword-case */
10
12
  $all: (
11
13
  mobile: $mobile,
12
- mobileLandscape: $mobileLandscape,
14
+ mobileLandscape: $mobile-landscape,
13
15
  tablet: $tablet,
14
- tabletLandscape: $tabletLandscape,
16
+ tabletLandscape: $tablet-landscape,
15
17
  desktop: $desktop,
16
- desktopMedium: $desktopMedium,
17
- desktopLarge: $desktopLarge
18
+ desktopMedium: $desktop-medium,
19
+ desktopLarge: $desktop-large
18
20
  );
21
+ /* stylelint-enable value-keyword-case */
19
22
 
20
23
  :export {
21
24
  mobile: strip-unit($mobile);
22
- mobileLandscape: strip-unit($mobileLandscape);
25
+ mobileLandscape: strip-unit($mobile-landscape);
23
26
  tablet: strip-unit($tablet);
24
- tabletLandscape: strip-unit($tabletLandscape);
27
+ tabletLandscape: strip-unit($tablet-landscape);
25
28
  desktop: strip-unit($desktop);
26
- desktopMedium: strip-unit($desktopMedium);
27
- desktopLarge: strip-unit($desktopLarge);
29
+ desktopMedium: strip-unit($desktop-medium);
30
+ desktopLarge: strip-unit($desktop-large);
28
31
  }
@@ -5,6 +5,7 @@
5
5
  // 2. Prevent adjustments of font size after orientation changes in iOS
6
6
  html {
7
7
  box-sizing: border-box; // 1
8
+ /* stylelint-disable-next-line property-no-vendor-prefix */
8
9
  -webkit-text-size-adjust: 100%; // 2
9
10
  }
10
11
 
@@ -152,6 +153,7 @@ button,
152
153
  [type='button'],
153
154
  [type='reset'],
154
155
  [type='submit'] {
156
+ /* stylelint-disable-next-line property-no-vendor-prefix */
155
157
  -webkit-appearance: button;
156
158
  }
157
159
 
@@ -211,18 +213,21 @@ textarea {
211
213
  // 1. Correct the odd appearance in Chrome and Safari.
212
214
  // 2. Correct the outline style in Safari.
213
215
  [type='search'] {
216
+ /* stylelint-disable-next-line property-no-vendor-prefix */
214
217
  -webkit-appearance: textfield; // 1
215
218
  outline-offset: -2px; // 2
216
219
  }
217
220
 
218
221
  // Remove the inner padding in Chrome and Safari on macOS.
219
222
  [type='search']::-webkit-search-decoration {
223
+ /* stylelint-disable-next-line property-no-vendor-prefix */
220
224
  -webkit-appearance: none;
221
225
  }
222
226
 
223
227
  // 1. Correct the inability to style clickable types in iOS and Safari.
224
228
  // 2. Change font properties to `inherit` in Safari.
225
229
  ::-webkit-file-upload-button {
230
+ /* stylelint-disable-next-line property-no-vendor-prefix */
226
231
  -webkit-appearance: button; // 1
227
232
  font: inherit; // 2
228
233
  }
@@ -2,7 +2,7 @@
2
2
  @use './strip-unit' as *;
3
3
 
4
4
  @function em($px, $base: 16) {
5
- @if ($px == 0) {
5
+ @if $px == 0 {
6
6
  @return 0;
7
7
  }
8
8
 
@@ -2,7 +2,7 @@
2
2
  @use './strip-unit' as *;
3
3
 
4
4
  @function rem($px, $base: 16) {
5
- @if ($px == 0) {
5
+ @if $px == 0 {
6
6
  @return 0;
7
7
  }
8
8
 
@@ -3,7 +3,7 @@
3
3
  $spacing-base-unit: 8 !default;
4
4
 
5
5
  @function spacing($i) {
6
- @if ($i == 0) {
6
+ @if $i == 0 {
7
7
  @return 0;
8
8
  }
9
9
 
@@ -10,7 +10,7 @@
10
10
  ///
11
11
  /// @example scss
12
12
  /// .element {
13
- /// @include ellipsis();
13
+ /// @include ellipsis;
14
14
  /// }
15
15
  ///
16
16
  /// // CSS Output
@@ -1,9 +1,8 @@
1
+ @use 'sass:list';
1
2
  @use 'sass:math';
2
3
  @use 'sass:map';
3
4
 
4
- //
5
5
  // DEFAULT VARIABLES
6
- //
7
6
 
8
7
  // Default count & fraction names
9
8
  $count-names: one two three four five six seven eight nine ten eleven twelve
@@ -11,9 +10,7 @@ $count-names: one two three four five six seven eight nine ten eleven twelve
11
10
  $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
12
11
  eleventh twelfth thirteenth fourteenth fifteenth sixteenth !default;
13
12
 
14
- //
15
13
  // INITIALIZE GRID
16
- //
17
14
 
18
15
  @mixin initialize() {
19
16
  .item {
@@ -24,10 +21,8 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
24
21
  }
25
22
  }
26
23
 
27
- //
28
24
  // GRID UNCOMPRESSED
29
25
  // Workaround for non-compressed HTML (avoid if possible)
30
- //
31
26
 
32
27
  @mixin uncompressed($spacing: -0.25em) {
33
28
  .root.uncompressed {
@@ -39,13 +34,11 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
39
34
  }
40
35
  }
41
36
 
42
- //
43
37
  // GRID GUTTER
44
38
  // Custom namespaced gutter widths
45
- //
46
39
 
47
40
  @mixin gutter($namespace, $grid-modifier--gutter) {
48
- @if ($namespace != '') {
41
+ @if $namespace != '' {
49
42
  $namespace: '.' + $namespace;
50
43
  }
51
44
 
@@ -61,10 +54,8 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
61
54
  /*! purgecss end ignore */
62
55
  }
63
56
 
64
- //
65
57
  // GRID REVERSE
66
58
  // Reverses the rendered layout of the `grid__item`s
67
- //
68
59
 
69
60
  @mixin reverse($namespace: '') {
70
61
  $namespace: _namespace-suffix($namespace, 'reverse');
@@ -83,10 +74,8 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
83
74
  /*! purgecss end ignore */
84
75
  }
85
76
 
86
- //
87
77
  // GRID WIDTHS
88
78
  // Sets up grid width styles
89
- //
90
79
 
91
80
  @mixin widths($namespace, $columns) {
92
81
  $namespace: _namespace-suffix($namespace);
@@ -94,10 +83,8 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
94
83
  @include _grid($namespace, $columns, 'width');
95
84
  }
96
85
 
97
- //
98
86
  // GRID FLEXBOX
99
87
  // Sets up grid flexbox styles
100
- //
101
88
 
102
89
  @mixin flex() {
103
90
  .root.flex {
@@ -106,10 +93,8 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
106
93
  }
107
94
  }
108
95
 
109
- //
110
96
  // GRID VERTICAL ALIGNMENTS
111
97
  // Sets up grid vertical-align styles
112
- //
113
98
 
114
99
  @mixin valign($aligns) {
115
100
  $align-items: (
@@ -136,24 +121,23 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
136
121
  }
137
122
  }
138
123
 
139
- //
140
124
  // INTERNAL MIXINS
141
125
  // These mixins should not be called directly,
142
126
  // instead are used as helpers within other mixins
143
- //
144
127
 
128
+ /* stylelint-disable-next-line scss/at-mixin-pattern */
145
129
  @mixin _grid($namespace, $columns, $property) {
146
- $columns-length: length($columns);
130
+ $columns-length: list.length($columns);
147
131
 
148
132
  @for $i from 1 through $columns-length {
149
- $column: nth($columns, $i);
150
- $grid: nth($fraction-names, $column);
133
+ $column: list.nth($columns, $i);
134
+ $grid: list.nth($fraction-names, $column);
151
135
  $column-count: if($column == 1, 1, $column - 1);
152
136
 
153
137
  @for $j from 1 through $column-count {
154
138
  $plural: if($j == 1, '', 's');
155
139
  $column-width: $j * math.div(100, $column);
156
- $column-name: nth($count-names, $j);
140
+ $column-name: list.nth($count-names, $j);
157
141
 
158
142
  .item#{$namespace}#{$column-name}-#{$grid}#{$plural} {
159
143
  #{$property}: $column-width + 0%;
@@ -162,6 +146,7 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
162
146
  }
163
147
  }
164
148
 
149
+ /* stylelint-disable-next-line scss/at-function-pattern */
165
150
  @function _grid-gutter--item($g) {
166
151
  @if unit($g) == '%' {
167
152
  $scale: math.div(100, 100 + $g);
@@ -172,8 +157,9 @@ $fraction-names: whole half third quarter fifth sixth seventh eighth ninth tenth
172
157
  }
173
158
  }
174
159
 
160
+ /* stylelint-disable-next-line scss/at-function-pattern */
175
161
  @function _namespace-suffix($namespace, $suffix: '') {
176
- @if ($namespace != '') {
162
+ @if $namespace != '' {
177
163
  $namespace: $namespace + '-';
178
164
  }
179
165
 
@@ -1,3 +1,4 @@
1
+ /* stylelint-disable scss/dollar-variable-pattern */
1
2
  @mixin mq($min: false, $max: false, $height: false, $and: false, $media: all) {
2
3
  $_direction: if($height, height, width);
3
4
  $mq: '#{$media} ';
@@ -1,7 +1,8 @@
1
+ @use 'sass:list';
1
2
  @use 'sass:math';
2
3
 
3
4
  @mixin triangle($point: 'up', $size: 1em, $color: '') {
4
- @if ($point == 'up') {
5
+ @if $point == 'up' {
5
6
  @include _triangle-borders(
6
7
  (
7
8
  right: transparent,
@@ -88,13 +89,14 @@
88
89
  }
89
90
  }
90
91
 
92
+ /* stylelint-disable-next-line scss/at-mixin-pattern */
91
93
  @mixin _triangle-borders($sides, $size, $color) {
92
94
  width: 0;
93
95
  height: 0;
94
96
 
95
97
  @each $side in $sides {
96
- $direction: nth($side, 1);
97
- $type: nth($side, 2);
98
+ $direction: list.nth($side, 1);
99
+ $type: list.nth($side, 2);
98
100
 
99
101
  @if $type == filled {
100
102
  border-#{$direction}: $size solid if($color != '', $color, null);