Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Dark mode day 4 patch (#64996)

Nick Fitzpatrick1fed0f701cdc
diff --git a/e2e/test/scenarios/i18n/i18n.cy.spec.ts b/e2e/test/scenarios/i18n/i18n.cy.spec.ts
index 1d46d34251b..548300f9bcf 100644
--- a/e2e/test/scenarios/i18n/i18n.cy.spec.ts
+++ b/e2e/test/scenarios/i18n/i18n.cy.spec.ts
@@ -46,7 +46,7 @@ describe("Pages accessible within one click from the homepage should work in pop
const selectLocale = (localeName: string) => {
cy.visit("/account/profile");
- cy.findByTestId("user-locale-select").findByTestId("select-button").click();
+ cy.findByTestId("user-locale-select").findByRole("textbox").click();
H.popover().within(() => cy.findByText(localeName).click());
cy.get("[type=submit]").click();
diff --git a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
index c9505e36454..c7b6362194a 100644
--- a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
@@ -120,8 +120,8 @@ describe("user > settings", () => {
cy.visit("/account/profile");
- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Use site default").click();
+ cy.findByTestId("user-locale-select").findByRole("textbox").click();
+
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
H.popover().within(() => cy.findByText("Indonesian").click());
@@ -253,19 +253,18 @@ describe("user > settings", () => {
it("should toggle through light and dark mode when clicking on the label or icon", () => {
cy.visit("/account/profile");
- cy.findByRole("img", { name: /sun/ }).click();
+ cy.findByDisplayValue("Light").click();
+ H.popover().findByText("Dark").click();
assertDarkMode();
- cy.findByRole("img", { name: /moon/ }).click();
+ cy.findByDisplayValue("Dark").click();
+ H.popover().findByText("Light").click();
assertLightMode();
- H.main()
- .findByText(/Toggle between light and dark/)
- .click();
- assertDarkMode();
-
+ //Need to take focus off the inpout
+ H.navigationSidebar().findByRole("link", { name: /Home/ }).click();
cy.realPress([metaKey, "Shift", "L"]);
- assertLightMode();
+ assertDarkMode();
});
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/FlexContainer/FlexContainer.module.css b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/FlexContainer/FlexContainer.module.css
index 25322bc002c..ab650a4fec1 100644
--- a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/FlexContainer/FlexContainer.module.css
+++ b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/FlexContainer/FlexContainer.module.css
@@ -67,7 +67,7 @@
.flexContainer:hover .resizeHandle {
opacity: 1;
- background-color: var(--mb-color-text-secondary-inverse);
+ background-color: var(--mb-color-text-secondary);
}
.flexContainer.resizing {
diff --git a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/ResizeNode/ResizeNode.module.css b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/ResizeNode/ResizeNode.module.css
index 8a62d8856c9..4563092b22a 100644
--- a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/ResizeNode/ResizeNode.module.css
+++ b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/ResizeNode/ResizeNode.module.css
@@ -25,7 +25,7 @@
}
.dragHandle {
- background-color: var(--mb-color-text-secondary-inverse);
+ background-color: var(--mb-color-text-secondary);
height: 0.25rem;
width: 4rem;
cursor: row-resize;
diff --git a/frontend/src/metabase/account/profile/components/UserProfileForm/UserProfileForm.tsx b/frontend/src/metabase/account/profile/components/UserProfileForm/UserProfileForm.tsx
index 5fd3fec5179..131b19bf786 100644
--- a/frontend/src/metabase/account/profile/components/UserProfileForm/UserProfileForm.tsx
+++ b/frontend/src/metabase/account/profile/components/UserProfileForm/UserProfileForm.tsx
@@ -3,15 +3,18 @@ import { t } from "ttag";
import _ from "underscore";
import * as Yup from "yup";
-import { ColorSchemeToggle } from "metabase/common/components/ColorSchemeToggle";
+import { ColorSchemeSelect } from "metabase/common/components/ColorScheme";
import { CommunityLocalizationNotice } from "metabase/common/components/CommunityLocalizationNotice";
-import FormErrorMessage from "metabase/common/components/FormErrorMessage";
-import FormInput from "metabase/common/components/FormInput";
-import FormSelect from "metabase/common/components/FormSelect";
-import FormSubmitButton from "metabase/common/components/FormSubmitButton";
-import { Form, FormProvider } from "metabase/forms";
+import {
+ Form,
+ FormErrorMessage,
+ FormProvider,
+ FormSelect,
+ FormSubmitButton,
+ FormTextInput,
+} from "metabase/forms";
import * as Errors from "metabase/lib/errors";
-import { Box, Flex, Text } from "metabase/ui";
+import { Box, Text } from "metabase/ui";
import type { LocaleData, User } from "metabase-types/api";
import type { UserProfileData } from "../../types";
@@ -42,7 +45,12 @@ const UserProfileForm = ({
const schema = isSsoUser ? SSO_PROFILE_SCHEMA : LOCAL_PROFILE_SCHEMA;
const initialValues = useMemo(() => {
- return schema.cast(user, { stripUnknown: true });
+ const values = schema.cast(user, { stripUnknown: true });
+
+ if (values.locale === null) {
+ values.locale = "";
+ }
+ return values;
}, [user, schema]);
const localeOptions = useMemo(() => {
@@ -50,7 +58,11 @@ const UserProfileForm = ({
}, [locales]);
const handleSubmit = useCallback(
- (values: UserProfileData) => onSubmit(user, values),
+ (values: UserProfileData) =>
+ onSubmit(user, {
+ ...values,
+ locale: values.locale === "" ? null : values.locale,
+ }),
[user, onSubmit],
);
@@ -67,37 +79,45 @@ const UserProfileForm = ({
<Form disabled={!dirty}>
{!isSsoUser && (
<>
- <FormInput
+ <FormTextInput
name="first_name"
- title={t`First name`}
+ label={t`First name`}
placeholder={t`Johnny`}
nullable
+ mb="md"
/>
- <FormInput
+ <FormTextInput
name="last_name"
- title={t`Last name`}
+ label={t`Last name`}
placeholder={t`Appleseed`}
nullable
+ mb="md"
/>
- <FormInput
+ <FormTextInput
name="email"
type="email"
- title={t`Email`}
+ label={t`Email`}
placeholder="[email protected]"
+ mb="md"
/>
</>
)}
<div data-testid="user-locale-select">
<FormSelect
name="locale"
- title={t`Language`}
- options={localeOptions}
+ label={t`Language`}
+ data={localeOptions}
description={
<CommunityLocalizationNotice isAdminView={false} />
}
+ mb="md"
/>
</div>
- <FormSubmitButton title={t`Update`} disabled={!dirty} primary />
+ <FormSubmitButton
+ label={t`Update`}
+ disabled={!dirty}
+ variant="primary"
+ />
<FormErrorMessage />
</Form>
)}
@@ -108,28 +128,21 @@ const UserProfileForm = ({
const getLocaleOptions = (locales: LocaleData[] | null) => {
const options = _.chain(locales ?? [["en", "English"]])
- .map(([value, name]) => ({ name, value }))
- .sortBy(({ name }) => name)
+ .map(([value, label]) => ({ label, value }))
+ .sortBy(({ label }) => label)
.value();
- return [{ name: t`Use site default`, value: null }, ...options];
+ return [{ label: t`Use site default`, value: "" }, ...options];
};
const ColorSchemeSwitcher = () => {
- const toggleId = "color-switcher-toggle";
return (
- <Box mb="lg">
- {/* this font doesn't match because the old form component is at 12.3px 🙄 */}
- <Text mt="xs" fw="bold" c="text-medium">
+ <Box mb="md">
+ <Text mt="xs" fw="bold">
{t`Theme`}
</Text>
- <Flex align="center" gap="sm" pt="sm">
- <ColorSchemeToggle id={toggleId} />
- <label style={{ cursor: "pointer" }} htmlFor={toggleId}>
- <Text>{t`Toggle between light and dark color schemes`}</Text>
- </label>
- </Flex>
+ <ColorSchemeSelect />
</Box>
);
};
diff --git a/frontend/src/metabase/common/components/ColorScheme/ColorSchemeSelect.tsx b/frontend/src/metabase/common/components/ColorScheme/ColorSchemeSelect.tsx
new file mode 100644
index 00000000000..8cbbcce15cd
--- /dev/null
+++ b/frontend/src/metabase/common/components/ColorScheme/ColorSchemeSelect.tsx
@@ -0,0 +1,23 @@
+import { t } from "ttag";
+
+import { Select, type SelectProps } from "metabase/ui";
+import { useColorScheme } from "metabase/ui/components/theme/ColorSchemeProvider";
+
+export function ColorSchemeSelect(
+ props: Omit<SelectProps, "data"> & { id?: string },
+) {
+ const { colorScheme, setColorScheme } = useColorScheme();
+
+ return (
+ <Select
+ {...props}
+ value={colorScheme}
+ data={[
+ { value: "auto", label: t`Use system default` },
+ { value: "dark", label: t`Dark` },
+ { value: "light", label: t`Light` },
+ ]}
+ onChange={(val) => setColorScheme(val)}
+ />
+ );
+}
diff --git a/frontend/src/metabase/common/components/ColorSchemeToggle/ColorSchemeToggle.tsx b/frontend/src/metabase/common/components/ColorScheme/ColorSchemeToggle.tsx
similarity index 100%
rename from frontend/src/metabase/common/components/ColorSchemeToggle/ColorSchemeToggle.tsx
rename to frontend/src/metabase/common/components/ColorScheme/ColorSchemeToggle.tsx
diff --git a/frontend/src/metabase/common/components/ColorSchemeToggle/index.ts b/frontend/src/metabase/common/components/ColorScheme/index.ts
similarity index 50%
rename from frontend/src/metabase/common/components/ColorSchemeToggle/index.ts
rename to frontend/src/metabase/common/components/ColorScheme/index.ts
index 608a01574e7..46b9442e5ad 100644
--- a/frontend/src/metabase/common/components/ColorSchemeToggle/index.ts
+++ b/frontend/src/metabase/common/components/ColorScheme/index.ts
@@ -1 +1,2 @@
+export * from "./ColorSchemeSelect";
export * from "./ColorSchemeToggle";
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/NightModeToggleButton.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/NightModeToggleButton.tsx
index e22dffe0df5..c6175f801c5 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/NightModeToggleButton.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/NightModeToggleButton.tsx
@@ -1,4 +1,4 @@
-import { ColorSchemeToggle } from "metabase/common/components/ColorSchemeToggle";
+import { ColorSchemeToggle } from "metabase/common/components/ColorScheme";
export const NightModeToggleButton = () => {
return <ColorSchemeToggle variant="viewHeader" />;
diff --git a/frontend/src/metabase/palette/components/Palette.module.css b/frontend/src/metabase/palette/components/Palette.module.css
index 2b914d65531..13dd63bf55b 100644
--- a/frontend/src/metabase/palette/components/Palette.module.css
+++ b/frontend/src/metabase/palette/components/Palette.module.css
@@ -10,6 +10,7 @@
color: var(--mb-color-text-dark);
line-height: 1rem;
outline: none;
+ background-color: transparent;
}
.iconContainer {
diff --git a/frontend/src/metabase/palette/components/Palette.tsx b/frontend/src/metabase/palette/components/Palette.tsx
index 27af41f0609..bb9ca34d6fb 100644
--- a/frontend/src/metabase/palette/components/Palette.tsx
+++ b/frontend/src/metabase/palette/components/Palette.tsx
@@ -108,7 +108,14 @@ export const PaletteCard = forwardRef<
return (
<Overlay zIndex={500} backgroundOpacity={0.5} {...props}>
<Center>
- <Card ref={ref} w="640px" mt="10vh" p="0" data-testid="command-palette">
+ <Card
+ ref={ref}
+ w="640px"
+ mt="10vh"
+ p="0"
+ data-testid="command-palette"
+ bd="1px solid var(--mb-color-border)"
+ >
{children}
</Card>
</Center>
diff --git a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditor.tsx b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditor.tsx
index f2d765b2c02..c4166601580 100644
--- a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditor.tsx
+++ b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditor.tsx
@@ -89,7 +89,7 @@ export const MetricEditor = forwardRef<HTMLDivElement, MetricEditorProps>(
};
return (
- <Flex h="100%" direction="column" bg="white" ref={ref}>
+ <Flex h="100%" direction="column" bg="bg-white" ref={ref}>
<MetricEditorHeader
question={question}
isDirty={isDirty}