Skip to content

Commit d447212

Browse files
Fix text input background color (#19190)
* convert podkit colors into css variables to handle dark mode automatically * cleanup --------- Co-authored-by: Filip Troníček <[email protected]>
1 parent f78eff2 commit d447212

File tree

5 files changed

+93
-26
lines changed

5 files changed

+93
-26
lines changed

components/dashboard/src/components/forms/TextInputField.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ export const TextInput: FunctionComponent<TextInputProps> = memo(({ className, o
5858
return (
5959
<input
6060
// 7px top/bottom padding ensures height matches buttons (36px)
61-
className={cn("py-[7px] w-full max-w-lg rounded-lg dark:text-[#A8A29E]", "text-sm", className)}
61+
className={cn(
62+
"py-[7px] w-full max-w-lg rounded-lg",
63+
"text-pk-content-primary",
64+
"bg-pk-surface-primary",
65+
"border-pk-border-base",
66+
"text-sm",
67+
className,
68+
)}
6269
onChange={handleChange}
6370
onBlur={handleBlur}
6471
{...props}

components/dashboard/src/components/podkit/switch/Switch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Switch = React.forwardRef<
2626
// checked state colors
2727
"data-[state=checked]:bg-kumquat-dark",
2828
// unchecked state colors
29-
"data-[state=unchecked]:bg-pk-surface-labels data-[state=unchecked]:dark:bg-pk-surface-labels-dark",
29+
"data-[state=unchecked]:bg-pk-surface-labels",
3030
className,
3131
)}
3232
{...props}
@@ -35,7 +35,7 @@ export const Switch = React.forwardRef<
3535
<SwitchPrimitives.Thumb
3636
className={cn(
3737
"pointer-events-none block h-[16px] w-[16px] rounded-full",
38-
"bg-pk-surface-primary dark:bg-pk-surface-primary-dark drop-shadow ring-0",
38+
"bg-pk-surface-primary drop-shadow ring-0",
3939
// Positioning
4040
"transition-transform data-[state=checked]:translate-x-[17px] data-[state=unchecked]:translate-x-[3px]",
4141
)}

components/dashboard/src/index.css

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,69 @@
99
@tailwind utilities;
1010

1111
@layer base {
12+
/* Setup colors for different themes */
13+
/* Using rgb color channels here to work well w/ tailwind classes */
14+
/* https: //tailwindcss.com/docs/customizing-colors#using-css-variables */
15+
:root {
16+
/* Setup RGB color channel variables */
17+
--black: 22 22 22; /* #161616 */
18+
--white: 255 255 255; /* #FFFFFF */
19+
--gray-900: 18 16 12; /* #12100C */
20+
--gray-850: 21 19 16; /* #151310 */
21+
--gray-800: 35 33 30; /* #23211E */
22+
--gray-750: 44 43 40; /* #2C2B28 */
23+
--gray-700: 81 79 77; /* #514F4D */
24+
--gray-600: 86 84 81; /* #565451 */
25+
--gray-500: 102 101 100; /* #666564 */
26+
--gray-450: 153 151 149; /* #999795 */
27+
--gray-400: 116 115 114; /* #747372 */
28+
--gray-300: 218 218 218; /* #DADADA */
29+
--gray-200: 236 231 229; /* #ECE7E5 */
30+
--gray-100: 245 244 244; /* #F5F4F4 */
31+
--gray-50: 249 249 249; /* #F9F9F9 */
32+
33+
34+
/* Content */
35+
--content-primary: var(--gray-900);
36+
--content-secondary: var(--gray-600);
37+
--content-tertiary: var(--gray-400);
38+
--content-disabled: var(--gray-450);
39+
--content-invert-primary: var(--gray-200);
40+
--content-invert-secondary: var(--gray-300);
41+
42+
/* Surfaces */
43+
--surface-primary: var(--white);
44+
--surface-secondary: var(--gray-50);
45+
--surface-tertiary: var(--gray-100);
46+
--surface-labels: var(--gray-200);
47+
--surface-invert: var(--gray-850);
48+
49+
/* Borders */
50+
--border-base: var(--gray-200);
51+
}
52+
53+
/* Dark mode color adjustments */
54+
:root[class~="dark"] {
55+
/* Content */
56+
--content-primary: var(--gray-200);
57+
--content-secondary: var(--gray-450);
58+
--content-tertiary: var(--gray-500);
59+
--content-disabled: var(--gray-600);
60+
--content-invert-primary: var(--gray-900);
61+
--content-invert-secondary: var(--gray-600);
62+
63+
/* Surfaces */
64+
--surface-primary: var(--gray-850);
65+
--surface-secondary: var(--gray-800);
66+
--surface-tertiary: var(--gray-750);
67+
--surface-labels: var(--gray-700);
68+
--surface-invert: var(--gray-50);
69+
70+
/* Borders */
71+
--border-base: var(--gray-700);
72+
}
73+
74+
1275
html,
1376
body {
1477
@apply h-full;

components/dashboard/src/repositories/detail/variables/ConfigurationVariableList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ export const ConfigurationVariableList = ({ configuration }: Props) => {
6262
</TableHeader>
6363
<TableBody>
6464
{data.map((variable) => (
65-
<ConfigurationVariableItem configurationId={configuration.id} variable={variable} />
65+
<ConfigurationVariableItem
66+
key={variable.id}
67+
configurationId={configuration.id}
68+
variable={variable}
69+
/>
6670
))}
6771
</TableBody>
6872
</Table>

components/dashboard/tailwind.config.js

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// tailwind.config.js
88
const colors = require("tailwindcss/colors");
99

10+
// TODO: Can replace these w/ rgb(var(...)) references so colors are only defined in our main CSS file
1011
const podkitColors = {
1112
black: "#161616",
1213
white: "#FFFFFF",
@@ -52,30 +53,22 @@ module.exports = {
5253
// Podkit colors - eventually we'll only use these colors
5354
// Once migrated, we can remove the colors above and shift this up under theme directly instead of extend
5455
"pk-content": {
55-
primary: podkitColors.gray["900"],
56-
"primary-dark": podkitColors.gray["200"],
57-
secondary: podkitColors.gray["600"],
58-
"secondary-dark": podkitColors.gray["450"],
59-
tertiary: podkitColors.gray["400"],
60-
"tertiary-dark": podkitColors.gray["500"],
61-
disabled: podkitColors.gray["450"],
62-
"disabled-dark": podkitColors.gray["600"],
63-
"invert-primary": podkitColors.gray["200"],
64-
"invert-primary-dark": podkitColors.gray["900"],
65-
"invert-secondary": podkitColors.gray["300"],
66-
"invert-secondary-dark": podkitColors.gray["600"],
56+
primary: "rgb(var(--content-primary) / <alpha-value>)",
57+
secondary: "rgb(var(--content-secondary) / <alpha-value>)",
58+
tertiary: "rgb(var(--content-tertiary) / <alpha-value>)",
59+
disabled: "rgb(var(--content-disabled) / <alpha-value>)",
60+
"invert-primary": "rgb(var(--content-invert-primary) / <alpha-value>)",
61+
"invert-secondary": "rgb(var(--content-invert-secondary) / <alpha-value>)",
6762
},
6863
"pk-surface": {
69-
primary: podkitColors.white,
70-
"primary-dark": podkitColors.gray["850"],
71-
secondary: podkitColors.gray["50"],
72-
"secondary-dark": podkitColors.gray["800"],
73-
tertiary: podkitColors.gray["100"],
74-
"tertiary-dark": podkitColors.gray["750"],
75-
labels: podkitColors.gray["200"],
76-
"labels-dark": podkitColors.gray["700"],
77-
invert: podkitColors.gray["850"],
78-
"invert-dark": podkitColors.gray["50"],
64+
primary: "rgb(var(--surface-primary) / <alpha-value>)",
65+
secondary: "rgb(var(--surface-secondary) / <alpha-value>)",
66+
tertiary: "rgb(var(--surface-tertiary) / <alpha-value>)",
67+
labels: "rgb(var(--surface-labels) / <alpha-value>)",
68+
invert: "rgb(var(--surface-invert) / <alpha-value>)",
69+
},
70+
"pk-border": {
71+
base: "rgb(var(--border-base) / <alpha-value>)",
7972
},
8073
},
8174
container: {

0 commit comments

Comments
 (0)