|
| 1 | +import ThemeColorPicker from './BrandingSettingItems/ThemeColorPicker'; |
| 2 | +import SettingList, { SettingGroup } from './SettingList'; |
| 3 | +import { BAIButton } from 'backend.ai-ui'; |
| 4 | +import { useTranslation } from 'react-i18next'; |
| 5 | +import { useBAISettingUserState } from 'src/hooks/useBAISetting'; |
| 6 | + |
| 7 | +interface BrandingSettingListProps {} |
| 8 | + |
| 9 | +const BrandingSettingList: React.FC<BrandingSettingListProps> = () => { |
| 10 | + const { t } = useTranslation(); |
| 11 | + |
| 12 | + const [, setUserCustomThemeConfig] = useBAISettingUserState( |
| 13 | + 'custom_theme_config', |
| 14 | + ); |
| 15 | + |
| 16 | + const settingGroups: Array<SettingGroup> = [ |
| 17 | + { |
| 18 | + 'data-testid': 'group-theme-customization', |
| 19 | + title: t('userSettings.Theme'), |
| 20 | + titleExtra: ( |
| 21 | + <BAIButton size="small">{t('userSettings.theme.Preview')}</BAIButton> |
| 22 | + ), |
| 23 | + settingItems: [ |
| 24 | + { |
| 25 | + type: 'custom', |
| 26 | + title: t('userSettings.theme.PrimaryColor'), |
| 27 | + description: t('userSettings.theme.PrimaryColorDesc'), |
| 28 | + children: <ThemeColorPicker tokenName="token.colorPrimary" />, |
| 29 | + // for reset feature |
| 30 | + defaultValue: {}, |
| 31 | + setValue: setUserCustomThemeConfig, |
| 32 | + }, |
| 33 | + { |
| 34 | + type: 'custom', |
| 35 | + title: t('userSettings.theme.HeaderBg'), |
| 36 | + description: t('userSettings.theme.HeaderBgDesc'), |
| 37 | + children: <ThemeColorPicker tokenName="components.Layout.headerBg" />, |
| 38 | + defaultValue: {}, |
| 39 | + setValue: setUserCustomThemeConfig, |
| 40 | + }, |
| 41 | + { |
| 42 | + type: 'custom', |
| 43 | + title: t('userSettings.theme.LinkColor'), |
| 44 | + description: t('userSettings.theme.LinkColorDesc'), |
| 45 | + children: <ThemeColorPicker tokenName="token.colorLink" />, |
| 46 | + defaultValue: {}, |
| 47 | + setValue: setUserCustomThemeConfig, |
| 48 | + }, |
| 49 | + { |
| 50 | + type: 'custom', |
| 51 | + title: t('userSettings.theme.InfoColor'), |
| 52 | + description: t('userSettings.theme.InfoColorDesc'), |
| 53 | + children: <ThemeColorPicker tokenName="token.colorInfo" />, |
| 54 | + defaultValue: {}, |
| 55 | + setValue: setUserCustomThemeConfig, |
| 56 | + }, |
| 57 | + { |
| 58 | + type: 'custom', |
| 59 | + title: t('userSettings.theme.ErrorColor'), |
| 60 | + description: t('userSettings.theme.ErrorColorDesc'), |
| 61 | + children: <ThemeColorPicker tokenName="token.colorError" />, |
| 62 | + defaultValue: {}, |
| 63 | + setValue: setUserCustomThemeConfig, |
| 64 | + }, |
| 65 | + { |
| 66 | + type: 'custom', |
| 67 | + title: t('userSettings.theme.SuccessColor'), |
| 68 | + description: t('userSettings.theme.SuccessColorDesc'), |
| 69 | + children: <ThemeColorPicker tokenName="token.colorSuccess" />, |
| 70 | + defaultValue: {}, |
| 71 | + setValue: setUserCustomThemeConfig, |
| 72 | + }, |
| 73 | + { |
| 74 | + type: 'custom', |
| 75 | + title: t('userSettings.theme.TextColor'), |
| 76 | + description: t('userSettings.theme.TextColorDesc'), |
| 77 | + children: <ThemeColorPicker tokenName="token.colorText" />, |
| 78 | + defaultValue: {}, |
| 79 | + setValue: setUserCustomThemeConfig, |
| 80 | + }, |
| 81 | + ], |
| 82 | + }, |
| 83 | + ]; |
| 84 | + |
| 85 | + return <SettingList settingGroups={settingGroups} showSearchBar />; |
| 86 | +}; |
| 87 | + |
| 88 | +export default BrandingSettingList; |
0 commit comments