Skip to content

Commit cb39d35

Browse files
chore: themes language support and refactor
1 parent 9a3fb8b commit cb39d35

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

packages/constants/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export * from "./swr";
1414
export * from "./user";
1515
export * from "./workspace";
1616
export * from "./stickies";
17+
export * from "./themes";
1718
export * from "./profile";
1819
export * from "./workspace-drafts";
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
export const THEMES = ["light", "dark", "light-contrast", "dark-contrast", "custom"];
1+
export const THEMES = [
2+
"light",
3+
"dark",
4+
"light-contrast",
5+
"dark-contrast",
6+
"custom",
7+
];
28

39
export interface I_THEME_OPTION {
410
key: string;
511
value: string;
6-
label: string;
12+
i18n_label: string;
713
type: string;
814
icon: {
915
border: string;
@@ -16,7 +22,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
1622
{
1723
key: "system_preference",
1824
value: "system",
19-
label: "System preference",
25+
i18n_label: "System preference",
2026
type: "light",
2127
icon: {
2228
border: "#DEE2E6",
@@ -27,7 +33,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
2733
{
2834
key: "light",
2935
value: "light",
30-
label: "Light",
36+
i18n_label: "Light",
3137
type: "light",
3238
icon: {
3339
border: "#DEE2E6",
@@ -38,7 +44,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
3844
{
3945
key: "dark",
4046
value: "dark",
41-
label: "Dark",
47+
i18n_label: "Dark",
4248
type: "dark",
4349
icon: {
4450
border: "#2E3234",
@@ -49,7 +55,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
4955
{
5056
key: "light_contrast",
5157
value: "light-contrast",
52-
label: "Light high contrast",
58+
i18n_label: "Light high contrast",
5359
type: "light",
5460
icon: {
5561
border: "#000000",
@@ -60,7 +66,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
6066
{
6167
key: "dark_contrast",
6268
value: "dark-contrast",
63-
label: "Dark high contrast",
69+
i18n_label: "Dark high contrast",
6470
type: "dark",
6571
icon: {
6672
border: "#FFFFFF",
@@ -71,7 +77,7 @@ export const THEME_OPTIONS: I_THEME_OPTION[] = [
7177
{
7278
key: "custom",
7379
value: "custom",
74-
label: "Custom theme",
80+
i18n_label: "Custom theme",
7581
type: "light",
7682
icon: {
7783
border: "#FFC9C9",

packages/i18n/src/locales/en/translations.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,5 +960,28 @@
960960
}
961961
}
962962
}
963+
},
964+
965+
"themes": {
966+
"theme_options": {
967+
"system_preference": {
968+
"label": "System preference"
969+
},
970+
"light": {
971+
"label": "Light"
972+
},
973+
"dark": {
974+
"label": "Dark"
975+
},
976+
"light_contrast": {
977+
"label": "Light high contrast"
978+
},
979+
"dark_contrast": {
980+
"label": "Dark high contrast"
981+
},
982+
"custom": {
983+
"label": "Custom theme"
984+
}
985+
}
963986
}
964987
}

web/app/profile/appearance/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import { useEffect, useState } from "react";
44
import { observer } from "mobx-react";
55
import { useTheme } from "next-themes";
6+
// plane imports
7+
import { I_THEME_OPTION, THEME_OPTIONS } from "@plane/constants";
68
import { useTranslation } from "@plane/i18n";
79
import { IUserTheme } from "@plane/types";
810
import { setPromiseToast } from "@plane/ui";
@@ -11,7 +13,6 @@ import { LogoSpinner } from "@/components/common";
1113
import { CustomThemeSelector, ThemeSwitch, PageHead } from "@/components/core";
1214
import { ProfileSettingContentHeader, ProfileSettingContentWrapper } from "@/components/profile";
1315
// constants
14-
import { I_THEME_OPTION, THEME_OPTIONS } from "@/constants/themes";
1516
// helpers
1617
import { applyTheme, unsetCustomCssVariables } from "@/helpers/theme.helper";
1718
// hooks

web/core/components/command-palette/actions/theme-actions.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { Command } from "cmdk";
55
import { observer } from "mobx-react";
66
import { useTheme } from "next-themes";
77
import { Settings } from "lucide-react";
8+
// plane imports
9+
import { THEME_OPTIONS } from "@plane/constants";
10+
import { useTranslation } from "@plane/i18n";
811
import { TOAST_TYPE, setToast } from "@plane/ui";
9-
// constants
10-
import { THEME_OPTIONS } from "@/constants/themes";
1112
// hooks
1213
import { useUserProfile } from "@/hooks/store";
1314

@@ -20,6 +21,7 @@ export const CommandPaletteThemeActions: FC<Props> = observer((props) => {
2021
const { setTheme } = useTheme();
2122
// hooks
2223
const { updateUserTheme } = useUserProfile();
24+
const { t } = useTranslation();
2325
// states
2426
const [mounted, setMounted] = useState(false);
2527

@@ -53,7 +55,7 @@ export const CommandPaletteThemeActions: FC<Props> = observer((props) => {
5355
>
5456
<div className="flex items-center gap-2 text-custom-text-200">
5557
<Settings className="h-4 w-4 text-custom-text-200" />
56-
{theme.label}
58+
{t(theme.i18n_label)}
5759
</div>
5860
</Command.Item>
5961
))}

web/core/components/core/theme/theme-switch.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"use client";
22

33
import { FC } from "react";
4+
// plane imports
5+
import { I_THEME_OPTION, THEME_OPTIONS } from "@plane/constants";
46
import { useTranslation } from "@plane/i18n";
57
// constants
68
import { CustomSelect } from "@plane/ui";
7-
import { THEME_OPTIONS, I_THEME_OPTION } from "@/constants/themes";
89
// ui
910

1011
type Props = {

0 commit comments

Comments
 (0)