mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix(display): improve font selector for long font names (#12100)
* fix(display): improve font selector for long font names - Increase Select width from 200px to 280px - Increase SelectRow container width from 300px to 380px - Add Tooltip to show full font name on hover - Add text-overflow ellipsis for long font names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(DisplaySettings): replace span with div and use CSS class for truncation --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: icarus <eurfelux@gmail.com>
This commit is contained in:
parent
09e58d3756
commit
89a6d817f1
@ -18,7 +18,7 @@ import {
|
|||||||
setSidebarIcons
|
setSidebarIcons
|
||||||
} from '@renderer/store/settings'
|
} from '@renderer/store/settings'
|
||||||
import { ThemeMode } from '@renderer/types'
|
import { ThemeMode } from '@renderer/types'
|
||||||
import { Button, ColorPicker, Segmented, Select, Switch } from 'antd'
|
import { Button, ColorPicker, Segmented, Select, Switch, Tooltip } from 'antd'
|
||||||
import { Minus, Monitor, Moon, Plus, Sun } from 'lucide-react'
|
import { Minus, Monitor, Moon, Plus, Sun } from 'lucide-react'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
@ -196,6 +196,21 @@ const DisplaySettings: FC = () => {
|
|||||||
[t]
|
[t]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const renderFontOption = useCallback(
|
||||||
|
(font: string) => (
|
||||||
|
<Tooltip title={font} placement="left" mouseEnterDelay={0.5}>
|
||||||
|
<div
|
||||||
|
className="truncate"
|
||||||
|
style={{
|
||||||
|
fontFamily: font
|
||||||
|
}}>
|
||||||
|
{font}
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingContainer theme={theme}>
|
<SettingContainer theme={theme}>
|
||||||
<SettingGroup theme={theme}>
|
<SettingGroup theme={theme}>
|
||||||
@ -292,7 +307,7 @@ const DisplaySettings: FC = () => {
|
|||||||
<SettingRowTitle>{t('settings.display.font.global')}</SettingRowTitle>
|
<SettingRowTitle>{t('settings.display.font.global')}</SettingRowTitle>
|
||||||
<SelectRow>
|
<SelectRow>
|
||||||
<Select
|
<Select
|
||||||
style={{ width: 200 }}
|
style={{ width: 280 }}
|
||||||
placeholder={t('settings.display.font.select')}
|
placeholder={t('settings.display.font.select')}
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
@ -303,7 +318,7 @@ const DisplaySettings: FC = () => {
|
|||||||
),
|
),
|
||||||
value: ''
|
value: ''
|
||||||
},
|
},
|
||||||
...fontList.map((font) => ({ label: <span style={{ fontFamily: font }}>{font}</span>, value: font }))
|
...fontList.map((font) => ({ label: renderFontOption(font), value: font }))
|
||||||
]}
|
]}
|
||||||
value={userTheme.userFontFamily || ''}
|
value={userTheme.userFontFamily || ''}
|
||||||
onChange={(font) => handleUserFontChange(font)}
|
onChange={(font) => handleUserFontChange(font)}
|
||||||
@ -324,7 +339,7 @@ const DisplaySettings: FC = () => {
|
|||||||
<SettingRowTitle>{t('settings.display.font.code')}</SettingRowTitle>
|
<SettingRowTitle>{t('settings.display.font.code')}</SettingRowTitle>
|
||||||
<SelectRow>
|
<SelectRow>
|
||||||
<Select
|
<Select
|
||||||
style={{ width: 200 }}
|
style={{ width: 280 }}
|
||||||
placeholder={t('settings.display.font.select')}
|
placeholder={t('settings.display.font.select')}
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
@ -335,7 +350,7 @@ const DisplaySettings: FC = () => {
|
|||||||
),
|
),
|
||||||
value: ''
|
value: ''
|
||||||
},
|
},
|
||||||
...fontList.map((font) => ({ label: <span style={{ fontFamily: font }}>{font}</span>, value: font }))
|
...fontList.map((font) => ({ label: renderFontOption(font), value: font }))
|
||||||
]}
|
]}
|
||||||
value={userTheme.userCodeFontFamily || ''}
|
value={userTheme.userCodeFontFamily || ''}
|
||||||
onChange={(font) => handleUserCodeFontChange(font)}
|
onChange={(font) => handleUserCodeFontChange(font)}
|
||||||
@ -480,7 +495,7 @@ const SelectRow = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
width: 300px;
|
width: 380px;
|
||||||
`
|
`
|
||||||
|
|
||||||
export default DisplaySettings
|
export default DisplaySettings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user