Skip to content

Commit d85e515

Browse files
committed
Dark UI for react-select
1 parent 94375bb commit d85e515

File tree

8 files changed

+67
-16
lines changed

8 files changed

+67
-16
lines changed

frontend/src/App.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
:root {
2+
color-scheme: light dark;
3+
}
4+
5+
.light {
6+
color-scheme: light;
7+
}
8+
.dark {
9+
color-scheme: dark;
10+
}
11+
112
.modal-backdrop {
213
--tblr-backdrop-opacity: 0.8 !important;
314
}
@@ -12,3 +23,45 @@
1223
.ml-1 {
1324
margin-left: 0.25rem;
1425
}
26+
27+
.react-select-container {
28+
.react-select__control {
29+
color: var(--tblr-body-color);
30+
background-color: var(--tblr-bg-forms);
31+
border: var(--tblr-border-width) solid var(--tblr-border-color);
32+
33+
.react-select__input {
34+
color: var(--tblr-body-color) !important;
35+
}
36+
37+
.react-select__single-value {
38+
color: var(--tblr-body-color);
39+
}
40+
41+
.react-select__multi-value {
42+
border: 1px solid var(--tblr-border-color);
43+
background-color: var(--tblr-bg-surface-tertiary);
44+
color: var(--tblr-secondary) !important;
45+
46+
.react-select__multi-value__label {
47+
color: var(--tblr-secondary) !important;
48+
}
49+
}
50+
}
51+
52+
.react-select__menu {
53+
background-color: var(--tblr-bg-forms);
54+
55+
.react-select__option {
56+
background: rgba(var(--tblr-primary-rgb), .04);
57+
color: inherit !important;
58+
&.react-select__option--is-focused {
59+
background: rgba(var(--tblr-primary-rgb), .1);
60+
}
61+
62+
&.react-select__option--is-focused.react-select__option--is-selected {
63+
background: rgba(var(--tblr-primary-rgb), .2);
64+
}
65+
}
66+
}
67+
}

frontend/src/components/Form/DNSProviderFields.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function DNSProviderFields() {
4646
DNS Provider
4747
</label>
4848
<Select
49+
className="react-select-container"
50+
classNamePrefix="react-select"
4951
name={field.name}
5052
id="dnsProvider"
5153
closeMenuOnSelect={true}

frontend/src/components/Form/DomainNamesField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export function DomainNamesField({
9191
{intl.formatMessage({ id: label })}
9292
</label>
9393
<CreatableSelect
94+
className="react-select-container"
95+
classNamePrefix="react-select"
9496
name={field.name}
9597
id={id}
9698
closeMenuOnSelect={true}

frontend/src/components/Form/SSLCertificateField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export function SSLCertificateField({
103103
{isError ? <div className="invalid-feedback">{`${error}`}</div> : null}
104104
{!isLoading && !isError ? (
105105
<Select
106+
className="react-select-container"
107+
classNamePrefix="react-select"
106108
defaultValue={options[0]}
107109
options={options}
108110
components={{ Option }}

frontend/src/components/Form/SSLOptionsFields.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function SSLOptionsFields() {
107107

108108
<Field name="letsencryptEmail">
109109
{({ field }: any) => (
110-
<div className="row mt-5">
110+
<div className="mt-5">
111111
<label htmlFor="letsencryptEmail" className="form-label">
112112
Email Address for Let's Encrypt
113113
</label>

frontend/src/components/LocalePicker.module.css

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
.darkBtn {
2-
color: var(--tblr-light) !important;
3-
&:hover {
4-
border: var(--tblr-btn-border-width) solid transparent !important;
5-
background: color-mix(in srgb, var(--tblr-btn-hover-bg) 10%, transparent) !important;
6-
}
7-
}
1+
.btn {
2+
color: light-dark(var(--tblr-dark), var(--tblr-light)) !important;
83

9-
.lightBtn {
10-
color: var(--tblr-dark) !important;
114
&:hover {
125
border: var(--tblr-btn-border-width) solid transparent !important;
136
background: color-mix(in srgb, var(--tblr-btn-hover-bg) 10%, transparent) !important;

frontend/src/components/LocalePicker.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ function LocalePicker() {
1515
location.reload();
1616
};
1717

18-
const classes = ["btn", "dropdown-toggle", "btn-sm"];
19-
let cns = cn(...classes, "btn-ghost-light", styles.lightBtn);
20-
if (getTheme() === "dark") {
21-
cns = cn(...classes, "btn-ghost-dark", styles.darkBtn);
22-
}
18+
const classes = ["btn", "dropdown-toggle", "btn-sm", styles.btn];
19+
const cns = cn(...classes, getTheme() === "dark" ? "btn-ghost-dark" : "btn-ghost-light");
2320

2421
return (
2522
<div className="dropdown">

frontend/src/context/ThemeContext.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
4040

4141
useEffect(() => {
4242
document.body.dataset.theme = theme;
43+
document.body.classList.remove(theme === Light ? Dark : Light);
44+
document.body.classList.add(theme);
4345
localStorage.setItem(StorageKey, theme);
4446
}, [theme]);
4547

@@ -53,7 +55,7 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
5355

5456
const getTheme = () => {
5557
return theme;
56-
}
58+
};
5759

5860
document.documentElement.setAttribute("data-bs-theme", theme);
5961
return <ThemeContext.Provider value={{ theme, toggleTheme, setTheme, getTheme }}>{children}</ThemeContext.Provider>;

0 commit comments

Comments
 (0)