chore: adjust custom font family style (#8040)

close AF-1302 AF-1301
This commit is contained in:
JimmFly 2024-09-02 15:11:58 +00:00
parent 2e37ee0e33
commit 130e6ab4a3
No known key found for this signature in database
GPG Key ID: 126E0320FEB0D05C
4 changed files with 38 additions and 22 deletions

View File

@ -173,7 +173,7 @@ const FontMenuItems = ({ onSelect }: { onSelect: (font: string) => void }) => {
{isLoading ? ( {isLoading ? (
<Loading /> <Loading />
) : ( ) : (
<Scrollable.Root style={{ height: '200px' }}> <Scrollable.Root style={{ height: '330px' }}>
<Scrollable.Viewport> <Scrollable.Viewport>
{result.length > 0 ? ( {result.length > 0 ? (
<Virtuoso <Virtuoso
@ -191,7 +191,7 @@ const FontMenuItems = ({ onSelect }: { onSelect: (font: string) => void }) => {
)} )}
/> />
) : ( ) : (
<div>No results found.</div> <div className={styles.notFound}>No results found.</div>
)} )}
</Scrollable.Viewport> </Scrollable.Viewport>
<Scrollable.Scrollbar /> <Scrollable.Scrollbar />
@ -218,20 +218,24 @@ const FontMenuItem = ({
const selected = currentFont === font.fullName; const selected = currentFont === font.fullName;
return ( return (
<MenuItem key={font.fullName} onSelect={handleFontSelect}> <div style={{ marginTop: '4px' }}>
<div className={styles.fontItemContainer}> <MenuItem key={font.fullName} onSelect={handleFontSelect}>
<div className={styles.fontItem}> <div className={styles.fontItemContainer}>
<div className={styles.fontLabel} style={{ fontFamily }}> <div className={styles.fontItem}>
{font.fullName} <div className={styles.fontLabel} style={{ fontFamily }}>
{font.fullName}
</div>
<div className={clsx(styles.fontLabel, 'secondary')}>
{font.fullName}
</div>
</div> </div>
<div className={clsx(styles.fontLabel, 'secondary')}>
{font.fullName}
</div>
</div>
{selected && <DoneIcon fontSize={20} className={styles.selectedIcon} />} {selected && (
</div> <DoneIcon fontSize={20} className={styles.selectedIcon} />
</MenuItem> )}
</div>
</MenuItem>
</div>
); );
}; };
@ -263,7 +267,7 @@ const CustomFontFamilySettings = () => {
items={<FontMenuItems onSelect={onCustomFontFamilyChange} />} items={<FontMenuItems onSelect={onCustomFontFamilyChange} />}
contentOptions={{ contentOptions={{
align: 'end', align: 'end',
style: { width: '250px' }, style: { width: '250px', height: '380px' },
}} }}
> >
<MenuTrigger className={styles.menuTrigger} style={{ fontFamily }}> <MenuTrigger className={styles.menuTrigger} style={{ fontFamily }}>

View File

@ -4,7 +4,6 @@ import { useI18n } from '@affine/i18n';
import { Edgeless } from './edgeless'; import { Edgeless } from './edgeless';
import { General } from './general'; import { General } from './general';
import { Page } from './page'; import { Page } from './page';
import { Preferences } from './preferences';
export const EditorSettings = () => { export const EditorSettings = () => {
const t = useI18n(); const t = useI18n();
@ -18,7 +17,9 @@ export const EditorSettings = () => {
<General /> <General />
<Page /> <Page />
<Edgeless /> <Edgeless />
<Preferences />
{/* // TODO(@EYHN): implement export and import
<Preferences /> */}
</> </>
); );
}; };

View File

@ -76,7 +76,6 @@ export const searchIcon = style({
export const fontItemContainer = style({ export const fontItemContainer = style({
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',
fontSize: cssVar('fontXs'),
alignItems: 'center', alignItems: 'center',
overflow: 'hidden', overflow: 'hidden',
width: '100%', width: '100%',
@ -90,14 +89,21 @@ export const fontItem = style({
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
}); });
export const fontLabel = style({ export const fontLabel = style({
color: cssVarV2('text/secondary'), display: 'inline-flex',
alignItems: 'center',
color: cssVarV2('text/primary'),
width: '100%', width: '100%',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
overflow: 'hidden', overflow: 'hidden',
fontSize: cssVar('fontSm'),
lineHeight: 'normal',
height: '22px',
selectors: { selectors: {
'&.secondary': { '&.secondary': {
color: cssVarV2('text/secondary'), color: cssVarV2('text/secondary'),
fontSize: cssVar('fontXs'),
height: '20px',
}, },
}, },
}); });
@ -105,3 +111,8 @@ export const selectedIcon = style({
color: cssVarV2('button/primary'), color: cssVarV2('button/primary'),
marginLeft: '8px', marginLeft: '8px',
}); });
export const notFound = style({
color: cssVarV2('text/secondary'),
fontSize: cssVar('fontXs'),
padding: '4px',
});

View File

@ -2,10 +2,10 @@ import { UserFeatureService } from '@affine/core/modules/cloud/services/user-fea
import { useI18n } from '@affine/i18n'; import { useI18n } from '@affine/i18n';
import { import {
AppearanceIcon, AppearanceIcon,
BlocksuiteIcon,
ExperimentIcon, ExperimentIcon,
InformationIcon, InformationIcon,
KeyboardIcon, KeyboardIcon,
PenIcon,
} from '@blocksuite/icons/rc'; } from '@blocksuite/icons/rc';
import { import {
FeatureFlagService, FeatureFlagService,
@ -84,8 +84,8 @@ export const useGeneralSettingList = (): GeneralSettingList => {
// add editor settings to second position // add editor settings to second position
settings.splice(1, 0, { settings.splice(1, 0, {
key: 'editor', key: 'editor',
title: t['com.affine.settings.editorSettings.title'](), title: t['com.affine.settings.editorSettings'](),
icon: BlocksuiteIcon, icon: PenIcon,
testId: 'editor-panel-trigger', testId: 'editor-panel-trigger',
}); });
} }