Skip to content

Commit e01831c

Browse files
authored
fix: forced colors mode for button and text-field (#8927)
1 parent 28d50bf commit e01831c

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

packages/button/src/vaadin-button-base.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,23 @@ export const buttonStyles = css`
8181
8282
@media (forced-colors: active) {
8383
:host {
84-
border: 1px solid;
84+
--vaadin-button-border-width: 1px;
85+
--vaadin-button-background: ButtonFace;
86+
--vaadin-button-text-color: ButtonText;
87+
}
88+
89+
:host([theme~='primary']) {
90+
forced-color-adjust: none;
91+
--vaadin-button-background: CanvasText;
92+
--vaadin-button-text-color: Canvas;
93+
--vaadin-icon-color: Canvas;
94+
}
95+
96+
:host([disabled]) {
97+
--vaadin-button-background: transparent !important;
98+
--vaadin-button-border-color: GrayText !important;
99+
--vaadin-button-text-color: GrayText !important;
100+
opacity: 1;
85101
}
86102
}
87103
}

packages/component-base/src/style-props.js

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ addGlobalThemeStyles(
4343
--_vaadin-icon-cross: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>');
4444
--_vaadin-icon-warn: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>');
4545
}
46+
47+
@media (forced-colors: active) {
48+
html {
49+
--_vaadin-background: Canvas;
50+
51+
--_vaadin-border-color: CanvasText;
52+
--_vaadin-border-color-strong: CanvasText;
53+
54+
--_vaadin-color-subtle: CanvasText;
55+
--_vaadin-color: CanvasText;
56+
--_vaadin-color-strong: CanvasText;
57+
58+
--vaadin-icon-color: CanvasText;
59+
}
60+
}
4661
}
4762
`,
4863
);

packages/field-base/src/styles/field-shared-styles.js

+6
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,10 @@ export const fieldShared = css`
8080
:host([theme~='helper-above-field']) {
8181
--vaadin-input-field-helper-order: -1;
8282
}
83+
84+
@media (forced-colors: active) {
85+
[part='error-message']::before {
86+
background: CanvasText;
87+
}
88+
}
8389
`;

packages/input-container/src/vaadin-input-container-styles.js

+13
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,17 @@ export const inputContainerStyles = css`
100100
);
101101
--vaadin-input-field-border-color: transparent;
102102
}
103+
104+
@media (forced-colors: active) {
105+
:host {
106+
--vaadin-input-field-background: Field;
107+
--vaadin-input-field-value-color: FieldText;
108+
--vaadin-input-field-placeholder-color: GrayText;
109+
}
110+
111+
:host([disabled]) {
112+
--vaadin-input-field-value-color: GrayText;
113+
--vaadin-icon-color: GrayText;
114+
}
115+
}
103116
`;

0 commit comments

Comments
 (0)