Skip to content

Commit 4b79afd

Browse files
authored
feat(forms): new light/dark mode colors (#1838)
1 parent d97aa1b commit 4b79afd

40 files changed

+691
-526
lines changed

packages/buttons/src/styled/StyledButton.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,14 @@ const colorStyles = ({
182182

183183
if (isNeutral) {
184184
borderColor = getColor({ theme, variable: 'border.default', ...offset100 });
185-
focusBorderColor = getColor(borderOptions);
185+
hoverBorderColor = getColor(borderOptions);
186+
focusBorderColor = hoverBorderColor;
187+
activeBorderColor = getColor({ ...borderOptions, ...offset100 });
186188
} else {
187189
borderColor = getColor(borderOptions);
190+
hoverBorderColor = getColor({ ...borderOptions, ...offset100 });
191+
activeBorderColor = getColor({ ...borderOptions, ...offset200 });
188192
}
189-
190-
hoverBorderColor = getColor({ ...borderOptions, ...offset100 });
191-
activeBorderColor = getColor({ ...borderOptions, ...offset200 });
192193
}
193194

194195
backgroundVariable = 'background.primaryEmphasis';

packages/forms/demo/fileUpload.stories.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import README from '../README.md';
2424
...commonArgs
2525
}}
2626
argTypes={{
27+
tabIndex: { control: 'number' },
2728
...commonArgTypes
2829
}}
2930
parameters={{

packages/forms/demo/input.stories.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ import README from '../README.md';
2020
placeholder: { control: 'text' },
2121
type: {
2222
control: {
23-
type: 'select',
24-
options: [
25-
'date',
26-
'datetime-local',
27-
'email',
28-
'month',
29-
'number',
30-
'password',
31-
'search',
32-
'tel',
33-
'text',
34-
'time',
35-
'url',
36-
'week'
37-
]
38-
}
23+
type: 'select'
24+
},
25+
options: [
26+
'date',
27+
'datetime-local',
28+
'email',
29+
'month',
30+
'number',
31+
'password',
32+
'search',
33+
'tel',
34+
'text',
35+
'time',
36+
'url',
37+
'week'
38+
]
3939
}
4040
}}
4141
parameters={{

packages/forms/src/elements/FileUpload.spec.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import React from 'react';
9-
import { getColorV8, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9+
import { PALETTE } from '@zendeskgarden/react-theming';
1010
import { rgba } from 'polished';
1111
import { render, renderRtl } from 'garden-test-utils';
1212
import { FileUpload } from './FileUpload';
@@ -34,11 +34,8 @@ describe('FileUpload', () => {
3434
it('renders correct styling when isDragging is active', () => {
3535
const { container } = render(<FileUpload isDragging />);
3636

37-
const activeColor = getColorV8('primaryHue', 800, DEFAULT_THEME);
38-
const activeBackgroundColor = rgba(getColorV8('primaryHue', 600, DEFAULT_THEME) as string, 0.2);
39-
40-
expect(container.firstChild).toHaveStyleRule('color', activeColor);
41-
expect(container.firstChild).toHaveStyleRule('background-color', activeBackgroundColor);
42-
expect(container.firstChild).toHaveStyleRule('border-color', activeColor);
37+
expect(container.firstChild).toHaveStyleRule('color', PALETTE.blue[900]);
38+
expect(container.firstChild).toHaveStyleRule('background-color', rgba(PALETTE.blue[700], 0.16));
39+
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.blue[900]);
4340
});
4441
});

packages/forms/src/elements/Select.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const Select = React.forwardRef<HTMLSelectElement, ISelectProps>(
3838
<StyledSelectWrapper
3939
isCompact={isCompact}
4040
isBare={isBare}
41+
isDisabled={disabled}
4142
validation={validation}
4243
focusInset={focusInset}
4344
>

packages/forms/src/elements/faux-input/components/EndIcon.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ import React from 'react';
99
import { IFauxInputIconProps } from '../../../types';
1010
import { StyledTextMediaFigure } from '../../../styled';
1111

12-
const EndIconComponent = ({ isDisabled, isRotated, ...props }: IFauxInputIconProps) => (
12+
const EndIconComponent = ({
13+
isDisabled,
14+
isFocused,
15+
isHovered,
16+
isRotated,
17+
...props
18+
}: IFauxInputIconProps) => (
1319
<StyledTextMediaFigure
1420
$position="end"
1521
$isDisabled={isDisabled}
22+
$isFocused={isFocused}
23+
$isHovered={isHovered}
1624
$isRotated={isRotated}
1725
{...props}
1826
/>

packages/forms/src/elements/faux-input/components/StartIcon.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ import React from 'react';
99
import { IFauxInputIconProps } from '../../../types';
1010
import { StyledTextMediaFigure } from '../../../styled';
1111

12-
const StartIconComponent = ({ isDisabled, isRotated, ...props }: IFauxInputIconProps) => (
12+
const StartIconComponent = ({
13+
isDisabled,
14+
isFocused,
15+
isHovered,
16+
isRotated,
17+
...props
18+
}: IFauxInputIconProps) => (
1319
<StyledTextMediaFigure
1420
$position="start"
1521
$isDisabled={isDisabled}
22+
$isFocused={isFocused}
23+
$isHovered={isHovered}
1624
$isRotated={isRotated}
1725
{...props}
1826
/>

packages/forms/src/elements/file-list/components/File.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const FileComponent = forwardRef<HTMLDivElement, IFileProps>(
2929
ref={ref}
3030
>
3131
{validationType && (
32-
<StyledFileIcon $isCompact={isCompact}>
32+
<StyledFileIcon $isCompact={isCompact} $validation={validation}>
3333
{isCompact ? fileIconsCompact[validationType] : fileIconsDefault[validationType]}
3434
</StyledFileIcon>
3535
)}

packages/forms/src/elements/tiles/components/Tile.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ const TileComponent = React.forwardRef<HTMLLabelElement, ITilesTileProps>(
2727
}
2828

2929
return (
30-
<StyledTile
31-
ref={ref}
32-
aria-disabled={disabled}
33-
isDisabled={disabled}
34-
isSelected={tilesContext && tilesContext.value === value}
35-
{...props}
36-
>
30+
<StyledTile ref={ref} aria-disabled={disabled} {...props}>
3731
{children}
3832
<StyledTileInput
3933
{...inputProps}

packages/forms/src/styled/checkbox/StyledCheckInput.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,31 @@
66
*/
77

88
import styled, { css, DefaultTheme, ThemeProps } from 'styled-components';
9-
import { getColorV8, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
1010
import { StyledRadioInput } from '../radio/StyledRadioInput';
1111
import { StyledCheckLabel } from './StyledCheckLabel';
1212

1313
const COMPONENT_ID = 'forms.checkbox';
1414

15-
const colorStyles = (props: ThemeProps<DefaultTheme>) => {
16-
const SHADE = 600;
15+
const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
16+
const backgroundOptions = { theme, variable: 'background.primaryEmphasis' };
17+
const borderOptions = { theme, variable: 'border.primaryEmphasis' };
1718

18-
const indeterminateBorderColor = getColorV8('primaryHue', SHADE, props.theme);
19-
const indeterminateBackgroundColor = indeterminateBorderColor;
20-
const indeterminateActiveBorderColor = getColorV8('primaryHue', SHADE + 100, props.theme);
21-
const indeterminateActiveBackgroundColor = indeterminateActiveBorderColor;
22-
const indeterminateDisabledBackgroundColor = getColorV8('neutralHue', SHADE - 400, props.theme);
19+
const indeterminateBackgroundColor = getColor(backgroundOptions);
20+
const indeterminateBorderColor = getColor(borderOptions);
21+
22+
const offset100 = { dark: { offset: -100 }, light: { offset: 100 } };
23+
const offset200 = { dark: { offset: -200 }, light: { offset: 200 } };
24+
25+
const indeterminateHoverBackgroundColor = getColor({ ...backgroundOptions, ...offset100 });
26+
const indeterminateHoverBorderColor = getColor({ ...borderOptions, ...offset100 });
27+
const indeterminateActiveBackgroundColor = getColor({ ...backgroundOptions, ...offset200 });
28+
const indeterminateActiveBorderColor = getColor({ ...borderOptions, ...offset200 });
29+
const indeterminateDisabledBackgroundColor = getColor({
30+
theme,
31+
variable: 'background.disabled',
32+
transparency: theme.opacity[300]
33+
});
2334

2435
return css`
2536
&:indeterminate ~ ${StyledCheckLabel}::before {
@@ -28,6 +39,11 @@ const colorStyles = (props: ThemeProps<DefaultTheme>) => {
2839
}
2940
3041
/* stylelint-disable selector-max-specificity */
42+
&:enabled:indeterminate ~ ${StyledCheckLabel}:hover::before {
43+
border-color: ${indeterminateHoverBorderColor};
44+
background-color: ${indeterminateHoverBackgroundColor};
45+
}
46+
3147
&:enabled:indeterminate ~ ${StyledCheckLabel}:active::before {
3248
border-color: ${indeterminateActiveBorderColor};
3349
background-color: ${indeterminateActiveBackgroundColor};
@@ -51,7 +67,7 @@ export const StyledCheckInput = styled(StyledRadioInput).attrs({
5167
border-radius: ${props => props.theme.borderRadii.md};
5268
}
5369
54-
${props => colorStyles(props)};
70+
${colorStyles};
5571
5672
${props => retrieveComponentStyles(COMPONENT_ID, props)};
5773
`;

0 commit comments

Comments
 (0)