Skip to content

Commit d825e32

Browse files
Luke Bowermanmdodgelooker
andauthored
Correct Chip, ButtonItem color usage and heights (#1298)
* Correct Chip, ButtonItem color usage and heights * Added ChipButton aria-seleted="false" support Co-authored-by: mdodgelooker <[email protected]>
1 parent 4f7f678 commit d825e32

File tree

25 files changed

+540
-175
lines changed

25 files changed

+540
-175
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Added `xxxxxlarge` to sizes to support updated type ramp.
13+
- `ChipButton` introduced for limited use cases
1214
- `ActionListControlBar` component
1315
- `useActionListSelectManager` hook
14-
- Added `xxxxxlarge` to sizes to support updated type ramp.
1516

1617
### Fixed
1718

@@ -28,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2829
- `DialogHeader` presentation fix for IE11
2930
- `Space` presentation fix for IE11 (also affects consumers)
3031
- `Tree` correct React warning about nested buttons by changing `TreeItem` back to `div` with `role="button`
32+
- `ButtonSet` & `ButtonGroup` heights corrected to stay at `36px`
33+
- `ActionList` updated documentation to include info on control bar behavior
3134

3235
### Changed
3336

@@ -38,7 +41,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3841
- Remove arrow from `Tooltip`, `Popover` and `Menu` by default
3942
- Updates to how we apply colors to `ButtonOutline` and `ButtonTransparent` to be more inline with design spec
4043
- `neutral` intent color is now defaults to `charcoal500`
41-
- `ActionList` updated documentation to include info on control bar behavior
44+
- Correlates use of color for `Chip`, `ButtonToggle` & `ButtonSet`
45+
- Consolidated `inputHeight` location and usage suite-wide
46+
- `InputChipsBase` updated to use styled() wrapped for Chip margin overrides
47+
48+
### Removed
49+
50+
- `Chip` removed most prop support
4251

4352
## [0.9.9] - 2020-08-02
4453

packages/components/src/Button/ButtonGroup.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ export const ButtonGroup = styled(ButtonGroupLayout)`
6767
&[aria-pressed='false']:not(:hover) {
6868
background: ${({ theme }) => theme.colors.background};
6969
}
70-
71-
&[aria-pressed='true'] {
72-
border-color: ${({ theme }) => theme.colors.keyAccent};
73-
}
7470
}
7571
&.wrapping {
7672
margin: -${({ theme }) => theme.space.xxxsmall};

packages/components/src/Button/ButtonItem.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ import {
3030
CompatibleHTMLProps,
3131
space,
3232
SpaceProps,
33-
typography,
34-
TypographyProps,
3533
omitStyledProps,
3634
} from '@looker/design-tokens'
35+
import { inputHeight } from '../Form/Inputs/height'
3736
import { ButtonSetContext } from './ButtonSetContext'
3837

3938
export interface ButtonItemProps
4039
extends SpaceProps,
41-
TypographyProps,
4240
Omit<CompatibleHTMLProps<HTMLButtonElement>, 'type' | 'aria-pressed'> {
4341
value?: string
4442
}
@@ -86,8 +84,6 @@ const ButtonLayout = forwardRef(
8684

8785
ButtonLayout.displayName = 'ButtonLayout'
8886

89-
export const buttonItemHeight = 36
90-
9187
export const ButtonItem = styled(ButtonLayout)`
9288
align-items: center;
9389
background: transparent;
@@ -96,15 +92,19 @@ export const ButtonItem = styled(ButtonLayout)`
9692
cursor: pointer;
9793
display: inline-flex;
9894
font-size: ${({ theme }) => theme.fontSizes.small};
99-
height: ${buttonItemHeight}px;
95+
height: ${inputHeight};
10096
justify-content: center;
10197
margin: 0;
10298
padding: 0 ${({ theme }) => theme.space.small};
10399
transition: background ${({ theme }) => theme.transitions.durationQuick} ease;
104100
user-select: none;
105101
106-
&[aria-pressed='false']:not([disabled]):hover {
107-
background: ${({ theme }) => theme.colors.keySubtle};
102+
${space}
103+
104+
&:active,
105+
&:focus,
106+
&:hover {
107+
background: ${({ theme }) => theme.colors.keyAccent};
108108
}
109109
110110
&:focus {
@@ -114,20 +114,20 @@ export const ButtonItem = styled(ButtonLayout)`
114114
115115
&[disabled] {
116116
color: ${(props) => props.theme.colors.text1};
117+
118+
&:hover {
119+
background: inherit;
120+
}
117121
cursor: default;
118122
}
119123
120124
&[aria-pressed='true'] {
121-
background: ${({ theme }) => theme.colors.keyAccent};
122-
border-color: ${({ theme }) => theme.colors.keyAccent};
125+
background: ${({ theme }) => theme.colors.keySubtle};
123126
color: ${({ theme }) => theme.colors.key};
124-
text-shadow: -0.025ex 0 currentColor, 0.025ex 0 currentColor;
125127
126128
&[disabled] {
129+
background: ${({ theme }) => theme.colors.keySubtle};
127130
color: ${({ theme }) => theme.colors.keyFocus};
128131
}
129132
}
130-
131-
${space}
132-
${typography}
133133
`

packages/components/src/Button/ButtonSet.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ import React, {
3535
} from 'react'
3636
import styled from 'styled-components'
3737
import { CompatibleHTMLProps } from '@looker/design-tokens'
38+
import { inputHeightNumber } from '../Form/Inputs/height'
3839
import { simpleLayoutCSS, SimpleLayoutProps } from '../Layout/utils/simple'
3940
import { useForkedRef } from '../utils'
4041
import { ButtonSetCallback, ButtonSetContext } from './ButtonSetContext'
41-
import { ButtonItem, buttonItemHeight } from './ButtonItem'
42+
import { ButtonItem } from './ButtonItem'
4243

4344
export interface ButtonSetOption {
4445
value: string
@@ -108,7 +109,7 @@ export const ButtonSetLayout = forwardRef(
108109
const firstItem = node.childNodes[0] as HTMLElement
109110
const rowHeight = firstItem
110111
? firstItem.getBoundingClientRect().height
111-
: buttonItemHeight
112+
: inputHeightNumber
112113
if (height >= rowHeight * 2) {
113114
setIsWrapping(true)
114115
} else {

packages/components/src/Button/ButtonToggle.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
import React, { forwardRef, MouseEvent, Ref } from 'react'
2828
import styled from 'styled-components'
29-
import { ButtonItem, buttonItemHeight } from './ButtonItem'
29+
import { inputHeight } from '../Form/Inputs/height'
30+
import { ButtonItem } from './ButtonItem'
3031
import {
3132
ButtonGroupOrToggleBaseProps,
3233
ButtonSet,
@@ -76,7 +77,7 @@ export const ButtonToggle = styled(ButtonToggleLayout)`
7677
7778
${ButtonItem} {
7879
border-left: solid 1px ${({ theme }) => theme.colors.ui2};
79-
height: ${buttonItemHeight}px;
80+
height: calc(${inputHeight} - 2px);
8081
8182
&:last-child {
8283
border-bottom-right-radius: ${({ theme }) => theme.radii.medium};
@@ -106,17 +107,17 @@ export const ButtonToggle = styled(ButtonToggleLayout)`
106107
repeating-linear-gradient(
107108
180deg,
108109
transparent,
109-
transparent 35px,
110-
${({ theme }) => theme.colors.ui2} 35px,
111-
${({ theme }) => theme.colors.ui2} ${buttonItemHeight}px
110+
transparent calc(${inputHeight} - 3px),
111+
${({ theme }) => theme.colors.ui2} calc(${inputHeight} - 3px),
112+
${({ theme }) => theme.colors.ui2} calc(${inputHeight} - 2px)
112113
);
113114
114115
/* prevents items in the last row from growing */
115116
&::after {
116117
border-left: 1px solid ${({ theme }) => theme.colors.ui2};
117118
content: '';
118119
flex-grow: 100;
119-
height: ${buttonItemHeight}px;
120+
height: calc(${inputHeight} - 2px);
120121
}
121122
122123
${ButtonItem} {

packages/components/src/Button/__snapshots__/ButtonGroup.test.tsx.snap

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ exports[`ButtonGroup controlled 1`] = `
3030
user-select: none;
3131
}
3232
33-
.c3[aria-pressed='false']:not([disabled]):hover {
34-
background: #F3F2FF;
33+
.c3:active,
34+
.c3:focus,
35+
.c3:hover {
36+
background: #E8E5FF;
3537
}
3638
3739
.c3:focus {
@@ -44,14 +46,17 @@ exports[`ButtonGroup controlled 1`] = `
4446
cursor: default;
4547
}
4648
49+
.c3[disabled]:hover {
50+
background: inherit;
51+
}
52+
4753
.c3[aria-pressed='true'] {
48-
background: #E8E5FF;
49-
border-color: #E8E5FF;
54+
background: #F3F2FF;
5055
color: #6C43E0;
51-
text-shadow: -0.025ex 0 currentColor,0.025ex 0 currentColor;
5256
}
5357
5458
.c3[aria-pressed='true'][disabled] {
59+
background: #F3F2FF;
5560
color: #9785F2;
5661
}
5762
@@ -85,10 +90,6 @@ exports[`ButtonGroup controlled 1`] = `
8590
background: #FFFFFF;
8691
}
8792
88-
.c1 .c2[aria-pressed='true'] {
89-
border-color: #E8E5FF;
90-
}
91-
9293
.c1.wrapping {
9394
margin: -0.125rem;
9495
}

packages/components/src/Button/__snapshots__/ButtonToggle.test.tsx.snap

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ exports[`ButtonToggle controlled 1`] = `
3030
user-select: none;
3131
}
3232
33-
.c3[aria-pressed='false']:not([disabled]):hover {
34-
background: #F3F2FF;
33+
.c3:active,
34+
.c3:focus,
35+
.c3:hover {
36+
background: #E8E5FF;
3537
}
3638
3739
.c3:focus {
@@ -44,14 +46,17 @@ exports[`ButtonToggle controlled 1`] = `
4446
cursor: default;
4547
}
4648
49+
.c3[disabled]:hover {
50+
background: inherit;
51+
}
52+
4753
.c3[aria-pressed='true'] {
48-
background: #E8E5FF;
49-
border-color: #E8E5FF;
54+
background: #F3F2FF;
5055
color: #6C43E0;
51-
text-shadow: -0.025ex 0 currentColor,0.025ex 0 currentColor;
5256
}
5357
5458
.c3[aria-pressed='true'][disabled] {
59+
background: #F3F2FF;
5560
color: #9785F2;
5661
}
5762
@@ -80,7 +85,7 @@ exports[`ButtonToggle controlled 1`] = `
8085
8186
.c1 .c2 {
8287
border-left: solid 1px #DEE1E5;
83-
height: 36px;
88+
height: calc(36px - 2px);
8489
}
8590
8691
.c1 .c2:last-child {
@@ -98,7 +103,7 @@ exports[`ButtonToggle controlled 1`] = `
98103
}
99104
100105
.c1.wrapping {
101-
background-image: linear-gradient( 0deg,#FFFFFF 0,#FFFFFF 1px,transparent 1px,transparent 100% ),repeating-linear-gradient( 180deg,transparent,transparent 35px,#DEE1E5 35px,#DEE1E5 36px );
106+
background-image: linear-gradient( 0deg,#FFFFFF 0,#FFFFFF 1px,transparent 1px,transparent 100% ),repeating-linear-gradient( 180deg,transparent,transparent calc(36px - 3px),#DEE1E5 calc(36px - 3px),#DEE1E5 calc(36px - 2px) );
102107
}
103108
104109
.c1.wrapping::after {
@@ -108,7 +113,7 @@ exports[`ButtonToggle controlled 1`] = `
108113
-webkit-flex-grow: 100;
109114
-ms-flex-positive: 100;
110115
flex-grow: 100;
111-
height: 36px;
116+
height: calc(36px - 2px);
112117
}
113118
114119
.c1.wrapping .c2 {

0 commit comments

Comments
 (0)