Skip to content

Commit 841f41c

Browse files
committed
Update CSS to defensively avoid inheriting Docker styles
This commit opts us out of Docker's default theme which is designed for MUI, and seems like it may change a fair bit. Instead, we update our Tailwind config to inherit a selection of CSS variables from their theme so we have greater control over changes and can avoid bitrot.
1 parent 8ae1929 commit 841f41c

6 files changed

Lines changed: 47 additions & 4 deletions

File tree

ui/src/components/tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function Tooltip(props: Props) {
3636
{children}
3737
</Primitive.Trigger>
3838
<Primitive.Content
39-
className="tooltip px-2 py-1 bg-[#5e6971] text-white text-center rounded-md max-w-xs"
39+
className="tooltip px-2 py-1 bg-[#5e6971] text-white text-sm text-center rounded-md max-w-xs"
4040
sideOffset={sideOffset}
4141
>
4242
{content}

ui/src/entry.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import NeedsAuthView from "src/views/needs-auth-view"
1414
import OnboardingView from "src/views/onboarding-view"
1515

1616
export default function App() {
17+
useRemoveDockerStyles()
18+
1719
return (
1820
<Tooltip.Provider>
1921
<div className="text-sm h-full">
@@ -107,3 +109,19 @@ const showOnboarding = (state: BackendState, user?: object) => {
107109
}
108110
return false
109111
}
112+
113+
/**
114+
* useRemoveDockerStyles removes the `dockerDesktopTheme` classname that gets
115+
* injected by Docker Desktop. These styles seem like they may change regularly,
116+
* so opting out lets us control our UI better, and only make changes when
117+
* necessary.
118+
*/
119+
function useRemoveDockerStyles() {
120+
useEffect(() => {
121+
const dockerThemeClass = "dockerDesktopTheme"
122+
const $body = document.body;
123+
if ($body && $body.classList.contains(dockerThemeClass)) {
124+
$body.classList.remove(dockerThemeClass)
125+
}
126+
}, [])
127+
}

ui/src/styles.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@
2121
html,
2222
body,
2323
#root {
24-
height: 100%;
24+
@apply font-sans text-base h-full antialiased;
25+
}
26+
27+
body {
28+
/**
29+
* We apply some default values from Docker Desktop's default theme prior to
30+
* version 4.9. This is overriden in the #root declaration below.
31+
*/
32+
@apply bg-[#f4f4f6] dark:bg-[#202c33] text-[rgba(0,0,0,0.87)] dark:text-white p-0;
33+
}
34+
35+
#root {
36+
/**
37+
* We override the body styles here to prevent Docker's theme
38+
* from affecting us.
39+
*/
40+
background-color: var(--dd-color-background);
41+
color: var(--dd-text-color-primary);
42+
padding: var(--dd-page-padding-top, 1.5rem) var(--dd-page-padding-right, 1.5rem) var(--dd-page-padding-bottom, 1.5rem) var(--dd-page-padding-left, 1.5rem);
2543
}
2644
}
2745

ui/src/views/container-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function ContainerView() {
7070
longer be able to access your containers.
7171
</p>
7272
</Dialog>
73-
<header className="flex items-center justify-between py-5">
73+
<header className="flex items-center justify-between pb-5">
7474
<div>
7575
<div className="font-semibold text-xl">Tailscale</div>
7676
<div className="flex items-center text-gray-500 dark:text-gray-400">

ui/src/views/loading-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function LoadingView() {
1212
<div className="w-full h-full flex justify-center">
1313
<div
1414
className={cx(
15-
"rounded-full border-gray-400 dark:border-gray-500 border-4 border-t-transparent dark:border-t-transparent w-12 h-12 animate-spin duration-[1.5s] transition mt-28",
15+
"rounded-full border-gray-600 dark:border-gray-500 border-4 border-t-transparent dark:border-t-transparent w-12 h-12 animate-spin duration-[1.5s] transition mt-28",
1616
{
1717
"opacity-0": !mounted,
1818
"opacity-100": mounted,

ui/tailwind.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ module.exports = {
3434
"docker-gray-200": "#E1E2E6",
3535
"docker-gray-100": "#F9F9FA",
3636

37+
"docker-blue-300": "var(--dd-color-blue-300)",
38+
"docker-blue-500": "var(--dd-color-blue-500)",
39+
"docker-blue-700": "var(--dd-color-blue-700)",
40+
3741
"faded-gray-5": "rgba(31,41,55,0.05)",
3842
"faded-gray-15": "rgba(31,41,55,0.15)",
3943
"faded-gray-25": "rgba(31,41,55,0.25)",
4044
"faded-white-5": "rgba(255,255,255,0.05)",
4145
},
46+
fontFamily: {
47+
sans: ["Open SansVariable", "Open Sans", "-apple-system", "sans-serif"],
48+
},
4249
boxShadow: {
4350
avatar:
4451
"0 0 0 1px rgba(136, 152, 170, 0.1), 0 0 4px 0 rgba(49, 49, 93, 0.15)",

0 commit comments

Comments
 (0)