Skip to content

Commit 0355821

Browse files
committed
chore: introduced component specific alpha layers
1 parent e04a56f commit 0355821

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/components/TextField/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ export const TEXT_FIELD_BORDER_RADIUS = 4;
6161
// ============
6262
export const MULTILINE_PADDING_TOP =
6363
ACTIVE_LABEL_FONT_SIZE + TEXT_FIELD_PADDING_VERTICAL;
64+
65+
// ============
66+
// OPACITY
67+
// ============
68+
69+
export const OUTLINE_ALPHA = 0.12;
70+
export const FILLED_CONTAINER_ALPHA = 0.04;

src/components/TextField/outlined/utils.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import color from 'color';
22

3-
import { tokens } from '../../../styles/themes/v3/tokens';
43
import type { InternalTheme } from '../../../types';
4+
import { OUTLINE_ALPHA } from '../constants';
55

66
export const getOutlinedFieldColors = ({
77
theme,
@@ -19,10 +19,7 @@ export const getOutlinedFieldColors = ({
1919
let inactiveOutlineColor = outline;
2020

2121
if (disabled) {
22-
inactiveOutlineColor = color(onSurface)
23-
.alpha(tokens.md.ref.stateOpacity.dragged)
24-
.rgb()
25-
.string();
22+
inactiveOutlineColor = color(onSurface).alpha(OUTLINE_ALPHA).rgb().string();
2623
}
2724

2825
let activeOutlineColor = primary;

src/components/TextField/utils.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import color from 'color';
22

3-
import { tokens } from '../../styles/themes/v3/tokens';
3+
import { FILLED_CONTAINER_ALPHA } from './constants';
44
import type { InternalTheme } from '../../types';
55

66
export const getAccentColors = ({
@@ -80,10 +80,7 @@ export const getFieldBackgroundColor = ({
8080
colors: { onSurface, surfaceContainerHighest },
8181
} = theme;
8282
if (disabled) {
83-
return color(onSurface)
84-
.alpha(tokens.md.ref.stateOpacity.hover)
85-
.rgb()
86-
.string();
83+
return color(onSurface).alpha(FILLED_CONTAINER_ALPHA).rgb().string();
8784
}
8885

8986
return surfaceContainerHighest;

0 commit comments

Comments
 (0)