Skip to content

Commit 715f23b

Browse files
committed
feat(password): migrate to semantic colors
1 parent 3268c02 commit 715f23b

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

src/components/Password/Password.tsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { forwardRef, useState } from 'react';
22
import styled from 'styled-components';
33

4-
import { compose, MarginProps, margin, width, WidthProps } from 'styled-system';
5-
import { EyeOpenIcon, EyeClosedIcon } from '../../icons';
4+
import { compose, margin, MarginProps, width, WidthProps } from 'styled-system';
5+
import { EyeClosedIcon, EyeOpenIcon } from '../../icons';
66
import { InnerInput as Input } from '../Input/InnerInput';
77
import { InputProps } from '../Input/InputProps';
88
import { InputWrapperProps } from '../Input/InputWrapper';
99
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
10-
import { Colors } from '../../essentials/Colors/Colors';
1110
import { useGeneratedId } from '../../utils/hooks/useGeneratedId';
11+
import { getSemanticValue } from '../../utils/cssVariables';
1212
import { ToggleButton } from './ToggleButton';
1313
import { TOGGLE_MODE_BUTTON_WIDTH } from './constants';
1414
import { extractWidthProps, extractWrapperMarginProps } from '../../utils/extractProps';
@@ -51,10 +51,24 @@ const defaultAriaStrings = {
5151
};
5252

5353
const iconColors = {
54-
regular: { color: Colors.AUTHENTIC_BLUE_550, hover: Colors.AUTHENTIC_BLUE_900 },
55-
inverted: { color: Colors.AUTHENTIC_BLUE_200, hover: Colors.AUTHENTIC_BLUE_50 }
54+
regular: {
55+
color: getSemanticValue('icon-secondary-default'),
56+
hover: getSemanticValue('icon-secondary-hover')
57+
},
58+
inverted: {
59+
color: getSemanticValue('icon-secondary-inverted'),
60+
hover: getSemanticValue('icon-secondary-hoverInverted')
61+
}
5662
};
5763

64+
// allow component level CSS variables to be passed via `style` prop
65+
declare module 'csstype' {
66+
interface Properties {
67+
'--wave-c-password-color'?: string;
68+
'--wave-c-password-color-hover'?: string;
69+
}
70+
}
71+
5872
const Password = forwardRef<HTMLDivElement, PasswordProps>(
5973
(
6074
{
@@ -105,9 +119,8 @@ const Password = forwardRef<HTMLDivElement, PasswordProps>(
105119
aria-controls={inputId}
106120
aria-label={isHidden ? aria.showPasswordButton : aria.hidePasswordButton}
107121
style={{
108-
// https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
109-
['--color' as never]: color,
110-
['--hover-color' as never]: hover
122+
'--wave-c-password-color': color,
123+
'--wave-c-password-color-hover': hover
111124
}}
112125
>
113126
{isHidden ? <EyeOpenIcon /> : <EyeClosedIcon />}

src/components/Password/ToggleButton.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ const ToggleButton = styled.button<Pick<InputProps, 'size' | 'variant'>>`
3737
${inputType};
3838
3939
svg path {
40-
fill: var(--color);
40+
fill: var(--wave-c-password-color);
4141
}
4242
4343
&:hover svg path {
44-
fill: var(--hover-color);
44+
fill: var(--wave-c-password-color-hover);
4545
}
4646
`;
4747

src/essentials/Colors/Colors.ts

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export const SemanticColors = {
115115
secondary: {
116116
default: Colors.blue.primary[550],
117117
inverted: Colors.blue.primary[200],
118+
hover: Colors.blue.primary[900],
119+
hoverInverted: Colors.blue.primary[50],
118120
},
119121
tertiary: {
120122
default: Colors.blue.primary[350],

src/essentials/Colors/RedesignedColors.ts

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export const SemanticColors = {
113113
secondary: {
114114
default: Colors.blue.primary[350],
115115
inverted: Colors.blue.primary[50],
116+
hover: Colors.blue.primary[900],
117+
hoverInverted: Colors.white,
116118
},
117119
tertiary: {
118120
default: Colors.blue.primary[350],

src/essentials/Colors/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export interface SemanticColorsSchema {
6565
secondary: {
6666
default: Color,
6767
inverted: Color,
68+
hover: Color,
69+
hoverInverted: Color,
6870
},
6971
tertiary: {
7072
default: Color,

0 commit comments

Comments
 (0)