Skip to content

Commit 42af405

Browse files
committed
breaking: inputBorderFocus -> inputOutlineFocus, feat: add foregroundHover and OutlineFocus for submit/cancel buttons
1 parent c17b008 commit 42af405

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

packages/feedback/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,18 @@ Colors can be customized via the Feedback constructor or by defining CSS variabl
126126
| `submitBackground` | `--submit-background` | `rgba(88, 74, 192, 1)` | `rgba(88, 74, 192, 1)` | Background color for the submit button |
127127
| `submitBackgroundHover` | `--submit-background-hover` | `rgba(108, 95, 199, 1)` | `rgba(108, 95, 199, 1)` | Background color when hovering over the submit button |
128128
| `submitBorder` | `--submit-border` | `rgba(108, 95, 199, 1)` | `rgba(108, 95, 199, 1)` | Border style for the submit button |
129+
| `submitOutlineFocus` | `--submit-outline-focus` | `rgba(108, 95, 199, 1)` | `rgba(108, 95, 199, 1)` | Outline color for the submit button, in the focused state |
129130
| `submitForeground` | `--submit-foreground` | `#ffffff` | `#ffffff` | Foreground color for the submit button |
131+
| `submitForegroundHover` | `--submit-foreground-hover` | `#ffffff` | `#ffffff` | Foreground color for the submit button |
130132
| `cancelBackground` | `--cancel-background` | `transparent` | `transparent` | Background color for the cancel button |
131133
| `cancelBackgroundHover` | `--cancel-background-hover` | `var(--background-hover)` | `var(--background-hover)` | Background color when hovering over the cancel button |
132134
| `cancelBorder` | `--cancel-border` | `var(--border)` | `var(--border)` | Border style for the cancel button |
135+
| `cancelOutlineFocus` | `--cancel-outline-focus` | `var(--input-outline-focus)` | `var(--input-outline-focus)` | Outline color for the cancel button, in the focused state |
133136
| `cancelForeground` | `--cancel-foreground` | `var(--foreground)` | `var(--foreground)` | Foreground color for the cancel button |
134137
| `inputBackground` | `--input-background` | `inherit` | `inherit` | Background color for form inputs |
135138
| `inputForeground` | `--input-foreground` | `inherit` | `inherit` | Foreground color for form inputs |
136139
| `inputBorder` | `--input-border` | `var(--border)` | `var(--border)` | Border styles for form inputs |
137-
| `inputBorderFocus` | `--input-border-focus` | `rgba(108, 95, 199, 1)` | `rgba(108, 95, 199, 1)` | Border styles for form inputs when focused |
140+
| `inputOutlineFocus` | `--input-outline-focus` | `rgba(108, 95, 199, 1)` | `rgba(108, 95, 199, 1)` | Outline color for form inputs when focused |
138141

139142
Here is an example of customizing only the background color for the light theme using the Feedback constructor configuration.
140143
```javascript

packages/feedback/src/constants.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const LIGHT_BACKGROUND = '#ffffff';
22
const INHERIT = 'inherit';
3+
const SUBMIT_COLOR = 'rgba(108, 95, 199, 1)';
34
const LIGHT_THEME = {
45
fontFamily: "'Helvetica Neue', Arial, sans-serif",
56
fontSize: '14px',
@@ -14,19 +15,23 @@ const LIGHT_THEME = {
1415
error: '#df3338',
1516

1617
submitBackground: 'rgba(88, 74, 192, 1)',
17-
submitBackgroundHover: 'rgba(108, 95, 199, 1)',
18-
submitBorder: 'rgba(108, 95, 199, 1)',
18+
submitBackgroundHover: SUBMIT_COLOR,
19+
submitBorder: SUBMIT_COLOR,
20+
submitOutlineFocus: '#29232f',
1921
submitForeground: LIGHT_BACKGROUND,
22+
submitForegroundHover: LIGHT_BACKGROUND,
2023

2124
cancelBackground: 'transparent',
2225
cancelBackgroundHover: 'var(--background-hover)',
2326
cancelBorder: 'var(--border)',
27+
cancelOutlineFocus: 'var(--input-outline-focus)',
2428
cancelForeground: 'var(--foreground)',
29+
cancelForegroundHover: 'var(--foreground)',
2530

2631
inputBackground: INHERIT,
2732
inputForeground: INHERIT,
2833
inputBorder: 'var(--border)',
29-
inputBorderFocus: 'rgba(108, 95, 199, 1)',
34+
inputOutlineFocus: SUBMIT_COLOR,
3035
};
3136

3237
export const DEFAULT_THEME = {

packages/feedback/src/types/index.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,20 @@ export interface FeedbackTheme {
269269
* Border style for the submit button
270270
*/
271271
submitBorder: string;
272+
/**
273+
* Border style for the submit button, in the focued state
274+
*/
275+
submitOutlineFocus: string;
272276
/**
273277
* Foreground color for the submit button
274278
*/
275279
submitForeground: string;
276280

281+
/**
282+
* Foreground color for the submit button, in the hover state
283+
*/
284+
submitForegroundHover: string;
285+
277286
/**
278287
* Background color for the cancel button
279288
*/
@@ -286,10 +295,18 @@ export interface FeedbackTheme {
286295
* Border style for the cancel button
287296
*/
288297
cancelBorder: string;
298+
/**
299+
* Border style for the cancel button, in the focued state
300+
*/
301+
cancelOutlineFocus: string;
289302
/**
290303
* Foreground color for the cancel button
291304
*/
292305
cancelForeground: string;
306+
/**
307+
* Foreground color for the cancel button, in the hover state
308+
*/
309+
cancelForegroundHover: string;
293310

294311
/**
295312
* Background color for form inputs
@@ -306,7 +323,7 @@ export interface FeedbackTheme {
306323
/**
307324
* Border styles for form inputs when focused
308325
*/
309-
inputBorderFocus: string;
326+
inputOutlineFocus: string;
310327
}
311328

312329
export interface FeedbackThemes {

packages/feedback/src/widget/Dialog.css.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ export function createDialogStyles(d: Document): HTMLStyleElement {
122122
padding: 6px 12px;
123123
}
124124
125-
.form__input:focus {
126-
outline: 1px solid transparent;
127-
outline-color: var(--input-border-focus);
125+
.form__input:focus-visible {
126+
outline: 1px auto var(--input-outline-focus);
128127
}
129128
130129
.form__input--textarea {
@@ -159,6 +158,10 @@ export function createDialogStyles(d: Document): HTMLStyleElement {
159158
}
160159
.btn--primary:hover {
161160
background-color: var(--submit-background-hover);
161+
color: var(--submit-foreground-hover);
162+
}
163+
.btn--primary:focus-visible {
164+
outline: 1px auto var(--submit-outline-focus);
162165
}
163166
164167
.btn--default {
@@ -168,6 +171,10 @@ export function createDialogStyles(d: Document): HTMLStyleElement {
168171
}
169172
.btn--default:hover {
170173
background-color: var(--cancel-background-hover);
174+
color: var(--cancel-foreground-hover);
175+
}
176+
.btn--default:focus-visible {
177+
outline: 1px auto var(--cancel-outline-focus);
171178
}
172179
173180
.success-message {

packages/feedback/src/widget/Main.css.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ function getThemedCssVariables(theme: FeedbackTheme): string {
1313
--submit-background: ${theme.submitBackground};
1414
--submit-background-hover: ${theme.submitBackgroundHover};
1515
--submit-border: ${theme.submitBorder};
16+
--submit-outline-focus: ${theme.submitOutlineFocus};
1617
--submit-foreground: ${theme.submitForeground};
18+
--submit-foreground-hover: ${theme.submitForegroundHover};
1719
1820
--cancel-background: ${theme.cancelBackground};
1921
--cancel-background-hover: ${theme.cancelBackgroundHover};
2022
--cancel-border: ${theme.cancelBorder};
23+
--cancel-outline-focus: ${theme.cancelOutlineFocus};
2124
--cancel-foreground: ${theme.cancelForeground};
25+
--cancel-foreground-hover: ${theme.cancelForegroundHover};
2226
2327
--input-background: ${theme.inputBackground};
2428
--input-foreground: ${theme.inputForeground};
2529
--input-border: ${theme.inputBorder};
26-
--input-border-focus: ${theme.inputBorderFocus};
30+
--input-outline-focus: ${theme.inputOutlineFocus};
2731
`;
2832
}
2933

0 commit comments

Comments
 (0)