refactor: update styles and theme handling in Sidebar and MessageHeader components

- Removed box-shadow from container styles for a cleaner look.
- Adjusted color variables for better contrast and consistency across themes.
- Enhanced Sidebar component to utilize theme context for icon styling.
- Modified MessageHeader to change font size and apply a specific font family for better readability.
This commit is contained in:
kangfenmao 2025-03-18 13:11:40 +08:00
parent 495656ec9d
commit 6870390b9f
4 changed files with 28 additions and 21 deletions

View File

@ -3,5 +3,4 @@
border-top: 0.5px solid var(--color-border); border-top: 0.5px solid var(--color-border);
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-left: 0.5px solid var(--color-border); border-left: 0.5px solid var(--color-border);
box-shadow: -2px 0px 20px -4px rgba(0, 0, 0, 0.06);
} }

View File

@ -10,7 +10,7 @@
--color-white-soft: rgba(255, 255, 255, 0.8); --color-white-soft: rgba(255, 255, 255, 0.8);
--color-white-mute: rgba(255, 255, 255, 0.94); --color-white-mute: rgba(255, 255, 255, 0.94);
--color-black: #151515; --color-black: #181818;
--color-black-soft: #222222; --color-black-soft: #222222;
--color-black-mute: #333333; --color-black-mute: #333333;
@ -35,9 +35,9 @@
--color-text: var(--color-text-1); --color-text: var(--color-text-1);
--color-icon: #ffffff99; --color-icon: #ffffff99;
--color-icon-white: #ffffff; --color-icon-white: #ffffff;
--color-border: #ffffff22; --color-border: #ffffff15;
--color-border-soft: #ffffff11; --color-border-soft: #ffffff10;
--color-border-mute: #ffffff11; --color-border-mute: #ffffff05;
--color-error: #f44336; --color-error: #f44336;
--color-link: #1677ff; --color-link: #1677ff;
--color-code-background: #323232; --color-code-background: #323232;
@ -50,8 +50,8 @@
--color-reference-text: #ffffff; --color-reference-text: #ffffff;
--color-reference-background: #0b0e12; --color-reference-background: #0b0e12;
--navbar-background-mac: rgba(30, 30, 30, 0.6); --navbar-background-mac: rgba(20, 20, 20, 0.6);
--navbar-background: rgba(30, 30, 30); --navbar-background: rgba(40, 40, 40);
--navbar-height: 40px; --navbar-height: 40px;
--sidebar-width: 50px; --sidebar-width: 50px;
@ -100,9 +100,9 @@ body[theme-mode='light'] {
--color-text: var(--color-text-1); --color-text: var(--color-text-1);
--color-icon: #00000099; --color-icon: #00000099;
--color-icon-white: #000000; --color-icon-white: #000000;
--color-border: #00000028; --color-border: #00000015;
--color-border-soft: #00000020; --color-border-soft: #00000010;
--color-border-mute: #00000010; --color-border-mute: #00000005;
--color-error: #f44336; --color-error: #f44336;
--color-link: #1677ff; --color-link: #1677ff;
--color-code-background: #e3e3e3; --color-code-background: #e3e3e3;
@ -116,7 +116,7 @@ body[theme-mode='light'] {
--color-reference-background: #f1f7ff; --color-reference-background: #f1f7ff;
--navbar-background-mac: rgba(255, 255, 255, 0.6); --navbar-background-mac: rgba(255, 255, 255, 0.6);
--navbar-background: rgba(255, 255, 255); --navbar-background: rgba(244, 244, 244);
--chat-background: #f3f3f3; --chat-background: #f3f3f3;
--chat-background-user: #95ec69; --chat-background-user: #95ec69;
@ -151,8 +151,9 @@ body {
font-size: 14px; font-size: 14px;
line-height: 1.6; line-height: 1.6;
overflow: hidden; overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', font-family:
'Helvetica Neue', sans-serif; -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue',
sans-serif;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;

View File

@ -86,13 +86,14 @@ const Sidebar: FC = () => {
<Menus> <Menus>
<Tooltip title={t('docs.title')} mouseEnterDelay={0.8} placement="right"> <Tooltip title={t('docs.title')} mouseEnterDelay={0.8} placement="right">
<Icon <Icon
theme={theme}
onClick={onOpenDocs} onClick={onOpenDocs}
className={minappShow && MinApp.app?.url === 'https://docs.cherry-ai.com/' ? 'active' : ''}> className={minappShow && MinApp.app?.url === 'https://docs.cherry-ai.com/' ? 'active' : ''}>
<QuestionCircleOutlined /> <QuestionCircleOutlined />
</Icon> </Icon>
</Tooltip> </Tooltip>
<Tooltip title={t('settings.theme.title')} mouseEnterDelay={0.8} placement="right"> <Tooltip title={t('settings.theme.title')} mouseEnterDelay={0.8} placement="right">
<Icon onClick={() => toggleTheme()}> <Icon theme={theme} onClick={() => toggleTheme()}>
{theme === 'dark' ? ( {theme === 'dark' ? (
<i className="iconfont icon-theme icon-dark1" /> <i className="iconfont icon-theme icon-dark1" />
) : ( ) : (
@ -107,7 +108,7 @@ const Sidebar: FC = () => {
await modelGenerating() await modelGenerating()
await to('/settings/provider') await to('/settings/provider')
}}> }}>
<Icon className={pathname.startsWith('/settings') && !minappShow ? 'active' : ''}> <Icon theme={theme} className={pathname.startsWith('/settings') && !minappShow ? 'active' : ''}>
<i className="iconfont icon-setting" /> <i className="iconfont icon-setting" />
</Icon> </Icon>
</StyledLink> </StyledLink>
@ -123,6 +124,7 @@ const MainMenus: FC = () => {
const { sidebarIcons } = useSettings() const { sidebarIcons } = useSettings()
const { minappShow } = useRuntime() const { minappShow } = useRuntime()
const navigate = useNavigate() const navigate = useNavigate()
const { theme } = useTheme()
const isRoute = (path: string): string => (pathname === path && !minappShow ? 'active' : '') const isRoute = (path: string): string => (pathname === path && !minappShow ? 'active' : '')
const isRoutes = (path: string): string => (pathname.startsWith(path) && !minappShow ? 'active' : '') const isRoutes = (path: string): string => (pathname.startsWith(path) && !minappShow ? 'active' : '')
@ -159,7 +161,9 @@ const MainMenus: FC = () => {
await modelGenerating() await modelGenerating()
navigate(path) navigate(path)
}}> }}>
<Icon className={isActive}>{iconMap[icon]}</Icon> <Icon theme={theme} className={isActive}>
{iconMap[icon]}
</Icon>
</StyledLink> </StyledLink>
</Tooltip> </Tooltip>
) )
@ -170,6 +174,7 @@ const PinnedApps: FC = () => {
const { pinned, updatePinnedMinapps } = useMinapps() const { pinned, updatePinnedMinapps } = useMinapps()
const { t } = useTranslation() const { t } = useTranslation()
const { minappShow } = useRuntime() const { minappShow } = useRuntime()
const { theme } = useTheme()
return ( return (
<DragableList list={pinned} onUpdate={updatePinnedMinapps} listStyle={{ marginBottom: 5 }}> <DragableList list={pinned} onUpdate={updatePinnedMinapps} listStyle={{ marginBottom: 5 }}>
@ -189,7 +194,7 @@ const PinnedApps: FC = () => {
<Tooltip key={app.id} title={app.name} mouseEnterDelay={0.8} placement="right"> <Tooltip key={app.id} title={app.name} mouseEnterDelay={0.8} placement="right">
<StyledLink> <StyledLink>
<Dropdown menu={{ items: menuItems }} trigger={['contextMenu']}> <Dropdown menu={{ items: menuItems }} trigger={['contextMenu']}>
<Icon onClick={() => MinApp.start(app)} className={isActive ? 'active' : ''}> <Icon theme={theme} onClick={() => MinApp.start(app)} className={isActive ? 'active' : ''}>
<MinAppIcon size={20} app={app} style={{ borderRadius: 6 }} /> <MinAppIcon size={20} app={app} style={{ borderRadius: 6 }} />
</Icon> </Icon>
</Dropdown> </Dropdown>
@ -255,7 +260,7 @@ const Menus = styled.div`
gap: 5px; gap: 5px;
` `
const Icon = styled.div` const Icon = styled.div<{ theme: string }>`
width: 35px; width: 35px;
height: 35px; height: 35px;
display: flex; display: flex;
@ -274,7 +279,8 @@ const Icon = styled.div`
font-size: 17px; font-size: 17px;
} }
&:hover { &:hover {
background-color: var(--color-hover); background-color: ${({ theme }) => (theme === 'dark' ? 'var(--color-black)' : 'var(--color-white)')};
opacity: 0.8;
cursor: pointer; cursor: pointer;
.iconfont, .iconfont,
.anticon { .anticon {
@ -282,7 +288,7 @@ const Icon = styled.div`
} }
} }
&.active { &.active {
background-color: var(--color-active); background-color: ${({ theme }) => (theme === 'dark' ? 'var(--color-black)' : 'var(--color-white)')};
border: 0.5px solid var(--color-border); border: 0.5px solid var(--color-border);
.iconfont, .iconfont,
.anticon { .anticon {

View File

@ -148,8 +148,9 @@ const UserName = styled.div<{ isBubbleStyle?: boolean; theme?: string }>`
` `
const MessageTime = styled.div` const MessageTime = styled.div`
font-size: 12px; font-size: 10px;
color: var(--color-text-3); color: var(--color-text-3);
font-family: 'Ubuntu';
` `
export default MessageHeader export default MessageHeader