Skip to content

Commit f5146b3

Browse files
authored
Routine maintenance 2023-08 (#596)
* Run yarn upgrade * Update non-breaking majors * Update eslint * Upgrade size-limit * Update jest * Update yarn.lock * Address prop type errors * Add alt for decorative image * Use button instead of link * Update tab-bar tests * Update paginator a11y linting * Use a button! * Address color picker issues * Address input label * Add missing type * Add migration guide * Fix input-label tests * Ignore mocks in prod builds * Add publish GH action * Upgrade latest lint-staged * Take recent upgrades * Style tooltip trigger more globally
1 parent 087154c commit f5146b3

31 files changed

+4982
-5909
lines changed

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish
2+
run-name: ${{ github.actor }} published a new release
3+
on:
4+
release:
5+
types: [published]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out latest code
11+
uses: actions/checkout@v3
12+
- name: Set up node
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: '18.x'
16+
registry-url: 'https://registry.npmjs.org'
17+
scope: '@launchpadlab'
18+
- name: Install dependencies
19+
run: HUSKY=0 yarn --frozen-lockfile
20+
- name: Publish package on NPM
21+
run: npm publish
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.storybook/styles/components/_forms.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,15 @@ Checkbox
159159
display: inline-block;
160160
width: calc(100% - 32px);
161161
}
162+
}
162163

163-
.tooltip-trigger {
164-
float: initial;
165-
width: auto;
166-
}
164+
.tooltip-trigger {
165+
float: initial;
166+
width: auto;
167+
padding: 0;
168+
border: none;
169+
background: none;
170+
margin-left: 10px;
167171
}
168172

169173
input[type='checkbox'] {
@@ -262,10 +266,8 @@ Input Tooltip
262266
display: inline-block;
263267
height: 18px;
264268
font-size: 12px;
265-
margin-left: 10px;
266269
text-align: center;
267270
line-height: 1.4;
268-
vertical-align: text-top;
269271
width: 18px;
270272
}
271273

@@ -443,6 +445,8 @@ Custom Dropdown Select
443445
@include font-type($primary-sans-serif, normal, 400);
444446
@include s-base;
445447
@include rem(padding, 7px 13px);
448+
width: 100%;
449+
text-align: left;
446450

447451
&:after {
448452
// background-image: asset-url('dropdown.svg');

.storybook/styles/components/_tabs.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
Shared
33
-----------------------*/
44
.tabs {
5-
cursor: pointer;
5+
[role="tab"] {
6+
border: none;
7+
cursor: pointer;
8+
background: none;
9+
@include rem(padding, 10px 20px);
10+
height: 100%;
11+
display: inline-block;
612

7-
li {
813
transition: all 0.3s ease-in-out;
914

1015
&:hover {
11-
color: darken($black-base, 100%);
16+
color: $white-base;
17+
background-color: darken($black-base, 5%);
1218
}
1319
}
1420
}
@@ -19,7 +25,6 @@ Horizontal Tabs
1925
.horizontal-tabs {
2026
li {
2127
display: inline-block;
22-
@include rem(padding, 10px 20px);
2328
border-bottom: 2px solid transparent;
2429

2530
&.active {
@@ -29,11 +34,10 @@ Horizontal Tabs
2934
}
3035

3136
/*-----------------------
32-
Veritcal Tabs
37+
Vertical Tabs
3338
-----------------------*/
3439
.vertical-tabs {
3540
li {
36-
@include rem(padding, 10px 20px);
3741
border-left: 2px solid transparent;
3842

3943
&.active {

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Documentation and usage info can be found in [docs.md](docs.md).
2828
- [v6.0.0](migration-guides/v6.0.0.md)
2929
- [v7.0.0](migration-guides/v7.0.0.md)
3030
- [v8.0.0](migration-guides/v8.0.0.md)
31+
- [v9.0.0](migration-guides/v9.0.0.md)
3132

3233
## Contribution
3334

docs.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,8 @@ Omits the following props:
13021302
* `tooltip`
13031303
* `label`
13041304
* `requiredIndicator`
1305+
* `errorComponent`
1306+
* `labelComponent`
13051307

13061308
### Parameters
13071309

@@ -1331,7 +1333,8 @@ function Input (props) {
13311333
input: { name, value, onBlur, onChange },
13321334
type,
13331335
...rest
1334-
} = omitLabelProps(props)
1336+
} = props
1337+
const inputProps = omitLabelProps(rest)
13351338
return (
13361339
...
13371340
)

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
testEnvironment: 'jsdom',
23
'setupFiles': [
34
'./test/setup.js',
45
],

migration-guides/v9.0.0.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# v9.0.0 Migration Guide
2+
3+
This version contains the following breaking changes:
4+
5+
1. The swatch rendered in `ColorPicker` (also used by `ColorInput`) is now a button
6+
2. The tooltip rendered in the default `InputLabel` is now a button
7+
3. The elements with [role="tab"] in `TabBar` switched from anchor tags to buttons
8+
9+
Further explanation of each item is detailed below.
10+
11+
---
12+
13+
## 1. The swatch rendered in `ColorPicker` (also used by `ColorInput`) is now a button
14+
This change _might_ affect styling. Review to see if you have any rules targeting `.swatch` or `.cover`. In the case of the latter, this element is no longer being used (in preference to a third-party outside click library) and the styling rules should be able to be safely removed.
15+
16+
## 2. The tooltip rendered in the default `InputLabel` is now a button
17+
This change will likely affect styling **if** you are using the `tooltip` prop on any inputs that don't already have a custom `labelComponent` defined. To preserve appropriate focus styling, move the `margin-left` styling from `.tooltip-trigger:after` to `.tooltip-trigger`. You will likely also need to strip the user agent's default button styling on `.tooltip-trigger`.
18+
19+
## 3. The elements with [role="tab"] in `TabBar` switched from anchor tags to buttons
20+
This change _might_ affect styling. Review styling rules to see if there are any rules specifically targeting `a` elements. If so, replace those rules with a target of `[role="tab"]`. This is more resilient

package.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@launchpadlab/lp-components",
3-
"version": "8.1.0",
3+
"version": "9.0.0",
44
"engines": {
55
"node": "^18.12"
66
},
@@ -18,8 +18,8 @@
1818
"scripts": {
1919
"start": "yarn && yarn build:development",
2020
"build": "yarn build:cjs && yarn build:esm && yarn build:styles",
21-
"build:cjs": "babel src --out-dir lib",
22-
"build:esm": "BABEL_ENV=esm babel src --out-dir esm",
21+
"build:cjs": "babel src --out-dir lib --ignore src/**/__mocks__/**/*.js",
22+
"build:esm": "BABEL_ENV=esm babel src --out-dir esm --ignore src/**/__mocks__/**/*.js",
2323
"build:styles": "cp -r src/styles lib/styles && sass src/styles:lib/styles",
2424
"build:development": "BABEL_ENV=esm babel src --watch --out-dir esm",
2525
"clean": "rm -rf lib esm",
@@ -44,7 +44,7 @@
4444
"classnames": "^2.3.1",
4545
"cleave.js": "^1.6.0",
4646
"date-fns": "^2.28.0",
47-
"filter-invalid-dom-props": "^2.1.0",
47+
"filter-invalid-dom-props": "^3.0.1",
4848
"lodash": "^4.17.21",
4949
"prop-types": "^15.8.1",
5050
"react-color": "^2.19.3",
@@ -58,9 +58,9 @@
5858
"@babel/cli": "^7.17.6",
5959
"@babel/core": "^7.17.9",
6060
"@launchpadlab/babel-preset": "^2.1.1",
61-
"@launchpadlab/eslint-config": "^2.7.0",
61+
"@launchpadlab/eslint-config": "^3.0.1",
6262
"@launchpadlab/prettier-config": "^1.0.0",
63-
"@size-limit/preset-small-lib": "^7.0.8",
63+
"@size-limit/preset-small-lib": "^8.2.6",
6464
"@storybook/addon-a11y": "^6.4.22",
6565
"@storybook/addon-actions": "^6.4.22",
6666
"@storybook/addon-links": "^6.4.22",
@@ -70,27 +70,28 @@
7070
"@storybook/builder-webpack5": "^6.5.14",
7171
"@storybook/manager-webpack5": "^6.5.14",
7272
"@storybook/react": "^6.4.22",
73-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
73+
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
7474
"babel-loader": "^9.1.0",
7575
"bourbon": "^7.2.0",
7676
"bourbon-neat": "^4.0.0",
7777
"core-js": "^3.21.1",
7878
"css-loader": "^6.7.2",
79-
"documentation": "^13.2.5",
79+
"documentation": "^14.0.2",
8080
"enzyme": "^3.2.0",
81-
"eslint": "^7.32.0",
82-
"husky": "^7.0.4",
83-
"jest": "^25.1.0",
81+
"eslint": "^8.46.0",
82+
"husky": "^8.0.3",
83+
"jest": "^29.6.2",
8484
"jest-canvas-mock": "^2.1.1",
85-
"lint-staged": "^13.0.3",
86-
"prettier": "^2.7.1",
85+
"jest-environment-jsdom": "^29.6.2",
86+
"lint-staged": "^14.0.1",
87+
"prettier": "^3.0.0",
8788
"react": "^17.0.0",
8889
"react-dom": "^17.0.0",
8990
"redux": "^4.1.2",
90-
"regenerator-runtime": "^0.13.9",
91+
"regenerator-runtime": "^0.14.0",
9192
"sass": "^1.56.1",
9293
"sass-loader": "^13.2.0",
93-
"size-limit": "^7.0.8",
94+
"size-limit": "^8.2.6",
9495
"style-loader": "^3.3.1",
9596
"webpack": "^5.75.0"
9697
},
@@ -101,8 +102,5 @@
101102
"lint-staged": {
102103
"src/**/*.{js,jsx}": "eslint --fix --max-warnings=0",
103104
"src/**/*.{js,jsx,json,scss}": "prettier --write"
104-
},
105-
"resolutions": {
106-
"jsprim": "^1.3.6"
107105
}
108106
}

src/controls/color-picker.js

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import ChromePicker from 'react-color/lib/Chrome'
4+
import OutsideClickHandler from 'react-outside-click-handler'
45
import { noop, useToggle } from '../utils'
56

67
/**
@@ -35,46 +36,60 @@ const propTypes = {
3536
onOpen: PropTypes.func.isRequired,
3637
onClose: PropTypes.func.isRequired,
3738
active: PropTypes.bool,
39+
containerRef: PropTypes.shape({ current: PropTypes.any }),
3840
}
3941

4042
const defaultProps = {
4143
value: '#000000',
4244
onChange: noop,
4345
onOpen: noop,
4446
onClose: noop,
47+
containerRef: null,
4548
}
4649

47-
function ColorPicker({ active, value, onChange, onOpen, onClose, ...rest }) {
50+
function ColorPicker({
51+
active,
52+
value,
53+
onChange,
54+
onOpen,
55+
onClose,
56+
containerRef,
57+
...rest
58+
}) {
4859
const [expanded, toggleExpanded] = useToggle()
4960
const isExpanded = active === undefined ? expanded : active
5061

5162
return (
5263
<div className="color-picker">
53-
<span
54-
className="swatch"
55-
style={{ background: value || 'black' }}
56-
onClick={() => {
57-
toggleExpanded()
58-
return onOpen()
64+
<OutsideClickHandler
65+
onOutsideClick={(e) => {
66+
if (containerRef && containerRef.current.contains(e.target)) {
67+
return
68+
}
69+
toggleExpanded(false)
70+
return onClose()
5971
}}
60-
/>
61-
{isExpanded && (
62-
<div className="popover">
63-
<div
64-
className="cover"
65-
onClick={() => {
66-
toggleExpanded()
67-
return onClose()
68-
}}
69-
/>
70-
<ChromePicker
71-
color={value}
72-
onChange={({ hex }) => onChange(hex)}
73-
disableAlpha={true}
74-
{...rest}
75-
/>
76-
</div>
77-
)}
72+
>
73+
<button
74+
type="button"
75+
className="swatch"
76+
style={{ background: value || 'black' }}
77+
onClick={() => {
78+
toggleExpanded()
79+
return isExpanded ? onClose() : onOpen()
80+
}}
81+
/>
82+
{isExpanded && (
83+
<div className="popover">
84+
<ChromePicker
85+
color={value}
86+
onChange={({ hex }) => onChange(hex)}
87+
disableAlpha={true}
88+
{...rest}
89+
/>
90+
</div>
91+
)}
92+
</OutsideClickHandler>
7893
</div>
7994
)
8095
}

src/controls/paginator/page-link.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ function PageLink({ className, active, onClick, children, ...rest }) {
2222
return (
2323
<li className={classnames(className, { active: active })}>
2424
<a
25+
role="link"
2526
onClick={onClick}
26-
onKeyPress={triggerOnKeys(onClick, ENTER_KEY_CODE)} // keyboard interaction requirement
27+
onKeyDown={triggerOnKeys(onClick, ENTER_KEY_CODE)} // keyboard interaction requirement
2728
aria-current={active ? 'page' : false}
2829
tabIndex="0" // add back to natural tab order (automatically removed without an href)
2930
{...rest}

src/controls/tab-bar/tab-bar.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import classnames from 'classnames'
4-
import {
5-
serializeOptions,
6-
noop,
7-
toLower,
8-
triggerOnKeys,
9-
KeyCodes,
10-
} from '../../utils'
4+
import { serializeOptions, noop, toLower } from '../../utils'
115
import manageFocus from './focus'
126

137
/**
@@ -87,20 +81,18 @@ function TabBar({
8781
role="presentation"
8882
onKeyDown={(e) => manageFocus(e, { vertical })}
8983
>
90-
<a
84+
<button
85+
type="button"
9186
id={'tab-' + toLower(optionValue)} // allow sections to reference tab using `aria-labelledby`
9287
onClick={() => {
9388
onChange(optionValue)
9489
}}
95-
onKeyPress={triggerOnKeys(() => {
96-
onChange(optionValue)
97-
}, [KeyCodes.ENTER, KeyCodes.SPACE])}
9890
tabIndex={isActive ? '0' : '-1'} // remove inactive tabs from tab order (controlled with arrow keys)
9991
role="tab"
10092
aria-selected={isActive}
10193
>
10294
{key}
103-
</a>
95+
</button>
10496
</li>
10597
)
10698
})}

0 commit comments

Comments
 (0)