Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routine maintenance 2023-08 #596

Merged
merged 22 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .storybook/styles/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ Checkbox
.tooltip-trigger {
float: initial;
width: auto;
padding: 0;
border: none;
background: none;
margin-left: 10px;
}
}

Expand Down Expand Up @@ -262,10 +266,8 @@ Input Tooltip
display: inline-block;
height: 18px;
font-size: 12px;
margin-left: 10px;
text-align: center;
line-height: 1.4;
vertical-align: text-top;
width: 18px;
}

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

&:after {
// background-image: asset-url('dropdown.svg');
Expand Down
16 changes: 10 additions & 6 deletions .storybook/styles/components/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
Shared
-----------------------*/
.tabs {
cursor: pointer;
[role="tab"] {
border: none;
cursor: pointer;
background: none;
@include rem(padding, 10px 20px);
height: 100%;
display: inline-block;

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

&:hover {
color: darken($black-base, 100%);
color: $white-base;
background-color: darken($black-base, 5%);
}
}
}
Expand All @@ -19,7 +25,6 @@ Horizontal Tabs
.horizontal-tabs {
li {
display: inline-block;
@include rem(padding, 10px 20px);
border-bottom: 2px solid transparent;

&.active {
Expand All @@ -29,11 +34,10 @@ Horizontal Tabs
}

/*-----------------------
Veritcal Tabs
Vertical Tabs
chawes13 marked this conversation as resolved.
Show resolved Hide resolved
-----------------------*/
.vertical-tabs {
li {
@include rem(padding, 10px 20px);
border-left: 2px solid transparent;

&.active {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Documentation and usage info can be found in [docs.md](docs.md).
- [v6.0.0](migration-guides/v6.0.0.md)
- [v7.0.0](migration-guides/v7.0.0.md)
- [v8.0.0](migration-guides/v8.0.0.md)
- [v9.0.0](migration-guides/v9.0.0.md)

## Contribution

Expand Down
5 changes: 4 additions & 1 deletion docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,8 @@ Omits the following props:
* `tooltip`
* `label`
* `requiredIndicator`
* `errorComponent`
* `labelComponent`

### Parameters

Expand Down Expand Up @@ -1331,7 +1333,8 @@ function Input (props) {
input: { name, value, onBlur, onChange },
type,
...rest
} = omitLabelProps(props)
} = props
const inputProps = omitLabelProps(rest)
return (
...
)
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
'setupFiles': [
'./test/setup.js',
],
Expand Down
20 changes: 20 additions & 0 deletions migration-guides/v9.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# v9.0.0 Migration Guide

This version contains the following breaking changes:

1. The swatch rendered in `ColorPicker` (also used by `ColorInput`) is now a button
2. The tooltip rendered in the default `InputLabel` is now a button
3. The elements with [role="tab"] in `TabBar` switched from anchor tags to buttons

Further explanation of each item is detailed below.

---

## 1. The swatch rendered in `ColorPicker` (also used by `ColorInput`) is now a button
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.

## 2. The tooltip rendered in the default `InputLabel` is now a button
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`.

## 3. The elements with [role="tab"] in `TabBar` switched from anchor tags to buttons
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
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchpadlab/lp-components",
"version": "8.1.0",
"version": "9.0.0",
"engines": {
"node": "^18.12"
},
Expand Down Expand Up @@ -44,7 +44,7 @@
"classnames": "^2.3.1",
"cleave.js": "^1.6.0",
"date-fns": "^2.28.0",
"filter-invalid-dom-props": "^2.1.0",
"filter-invalid-dom-props": "^3.0.1",
"lodash": "^4.17.21",
"prop-types": "^15.8.1",
"react-color": "^2.19.3",
Expand All @@ -58,9 +58,9 @@
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.9",
"@launchpadlab/babel-preset": "^2.1.1",
"@launchpadlab/eslint-config": "^2.7.0",
"@launchpadlab/eslint-config": "^3.0.1",
"@launchpadlab/prettier-config": "^1.0.0",
"@size-limit/preset-small-lib": "^7.0.8",
"@size-limit/preset-small-lib": "^8.2.6",
"@storybook/addon-a11y": "^6.4.22",
"@storybook/addon-actions": "^6.4.22",
"@storybook/addon-links": "^6.4.22",
Expand All @@ -70,27 +70,28 @@
"@storybook/builder-webpack5": "^6.5.14",
"@storybook/manager-webpack5": "^6.5.14",
"@storybook/react": "^6.4.22",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"babel-loader": "^9.1.0",
"bourbon": "^7.2.0",
"bourbon-neat": "^4.0.0",
"core-js": "^3.21.1",
"css-loader": "^6.7.2",
"documentation": "^13.2.5",
"documentation": "^14.0.2",
"enzyme": "^3.2.0",
"eslint": "^7.32.0",
"husky": "^7.0.4",
"jest": "^25.1.0",
"eslint": "^8.46.0",
"husky": "^8.0.3",
"jest": "^29.6.2",
"jest-canvas-mock": "^2.1.1",
"jest-environment-jsdom": "^29.6.2",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"prettier": "^3.0.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"redux": "^4.1.2",
"regenerator-runtime": "^0.13.9",
"sass": "^1.56.1",
"sass-loader": "^13.2.0",
"size-limit": "^7.0.8",
"size-limit": "^8.2.6",
"style-loader": "^3.3.1",
"webpack": "^5.75.0"
},
Expand All @@ -101,8 +102,5 @@
"lint-staged": {
"src/**/*.{js,jsx}": "eslint --fix --max-warnings=0",
"src/**/*.{js,jsx,json,scss}": "prettier --write"
},
"resolutions": {
"jsprim": "^1.3.6"
}
}
65 changes: 40 additions & 25 deletions src/controls/color-picker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import ChromePicker from 'react-color/lib/Chrome'
import OutsideClickHandler from 'react-outside-click-handler'
import { noop, useToggle } from '../utils'

/**
Expand Down Expand Up @@ -35,46 +36,60 @@ const propTypes = {
onOpen: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
active: PropTypes.bool,
containerRef: PropTypes.shape({ current: PropTypes.any }),
}

const defaultProps = {
value: '#000000',
onChange: noop,
onOpen: noop,
onClose: noop,
containerRef: null,
}

function ColorPicker({ active, value, onChange, onOpen, onClose, ...rest }) {
function ColorPicker({
active,
value,
onChange,
onOpen,
onClose,
containerRef,
...rest
}) {
const [expanded, toggleExpanded] = useToggle()
const isExpanded = active === undefined ? expanded : active

return (
<div className="color-picker">
<span
className="swatch"
style={{ background: value || 'black' }}
onClick={() => {
toggleExpanded()
return onOpen()
<OutsideClickHandler
onOutsideClick={(e) => {
if (containerRef && containerRef.current.contains(e.target)) {
bhennes2 marked this conversation as resolved.
Show resolved Hide resolved
return
}
toggleExpanded(false)
return onClose()
}}
/>
{isExpanded && (
<div className="popover">
<div
className="cover"
onClick={() => {
toggleExpanded()
return onClose()
}}
/>
<ChromePicker
color={value}
onChange={({ hex }) => onChange(hex)}
disableAlpha={true}
{...rest}
/>
</div>
)}
>
<button
type="button"
className="swatch"
style={{ background: value || 'black' }}
onClick={() => {
toggleExpanded()
return isExpanded ? onClose() : onOpen()
}}
/>
{isExpanded && (
<div className="popover">
<ChromePicker
color={value}
onChange={({ hex }) => onChange(hex)}
disableAlpha={true}
{...rest}
/>
</div>
)}
</OutsideClickHandler>
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/controls/paginator/page-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ function PageLink({ className, active, onClick, children, ...rest }) {
return (
<li className={classnames(className, { active: active })}>
<a
role="link"
bhennes2 marked this conversation as resolved.
Show resolved Hide resolved
onClick={onClick}
onKeyPress={triggerOnKeys(onClick, ENTER_KEY_CODE)} // keyboard interaction requirement
onKeyDown={triggerOnKeys(onClick, ENTER_KEY_CODE)} // keyboard interaction requirement
bhennes2 marked this conversation as resolved.
Show resolved Hide resolved
aria-current={active ? 'page' : false}
tabIndex="0" // add back to natural tab order (automatically removed without an href)
{...rest}
Expand Down
16 changes: 4 additions & 12 deletions src/controls/tab-bar/tab-bar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {
serializeOptions,
noop,
toLower,
triggerOnKeys,
KeyCodes,
} from '../../utils'
import { serializeOptions, noop, toLower } from '../../utils'
import manageFocus from './focus'

/**
Expand Down Expand Up @@ -87,20 +81,18 @@ function TabBar({
role="presentation"
onKeyDown={(e) => manageFocus(e, { vertical })}
>
<a
<button
bhennes2 marked this conversation as resolved.
Show resolved Hide resolved
type="button"
id={'tab-' + toLower(optionValue)} // allow sections to reference tab using `aria-labelledby`
onClick={() => {
onChange(optionValue)
}}
onKeyPress={triggerOnKeys(() => {
chawes13 marked this conversation as resolved.
Show resolved Hide resolved
onChange(optionValue)
}, [KeyCodes.ENTER, KeyCodes.SPACE])}
tabIndex={isActive ? '0' : '-1'} // remove inactive tabs from tab order (controlled with arrow keys)
role="tab"
aria-selected={isActive}
>
{key}
</a>
</button>
</li>
)
})}
Expand Down
8 changes: 6 additions & 2 deletions src/forms/helpers/dropdown-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ function DropdownSelect({ children, className, selectedValues }) {
return (
<OutsideClickHandler onOutsideClick={() => toggleExpanded(false)}>
<div className="dropdown-select">
<div className="select-input" onClick={() => toggleExpanded()}>
<button
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagged by the jsx-a11y plugin from upgrading lpl's eslint-config

type="button"
className="select-input"
onClick={() => toggleExpanded()}
>
<p>{getLabel(selectedValues)}</p>
</div>
</button>
<div
className={classnames(className, 'options', {
'is-active': expanded,
Expand Down
5 changes: 4 additions & 1 deletion src/forms/helpers/omit-label-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { omit } from '../../utils'
* - `tooltip`
* - `label`
* - `requiredIndicator`
* - `errorComponent`
* - `labelComponent`
Comment on lines +13 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed these were missing from the docs

*
* @name omitLabelProps
* @type Function
Expand Down Expand Up @@ -38,7 +40,8 @@ import { omit } from '../../utils'
* input: { name, value, onBlur, onChange },
* type,
* ...rest
* } = omitLabelProps(props)
* } = props
* const inputProps = omitLabelProps(rest)
* return (
* ...
* )
Expand Down
Loading