mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
style: add text overflow style for collections (#3292)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -200,7 +200,7 @@ export const Header = forwardRef<
|
|||||||
data-testid="editor-header-items"
|
data-testid="editor-header-items"
|
||||||
data-is-edgeless={mode === 'edgeless'}
|
data-is-edgeless={mode === 'edgeless'}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
<div className={styles.headerLeftSide}>
|
||||||
{!open && <SidebarSwitch />}
|
{!open && <SidebarSwitch />}
|
||||||
{props.leftSlot}
|
{props.leftSlot}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -83,13 +83,23 @@ export const titleWrapper = style({
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
});
|
});
|
||||||
|
export const headerLeftSide = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '150px',
|
||||||
|
'@media': {
|
||||||
|
'(max-width: 900px)': {
|
||||||
|
width: 'auto',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
export const headerRightSide = style({
|
export const headerRightSide = style({
|
||||||
height: '100%',
|
height: '100%',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
gap: '12px',
|
gap: '12px',
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
|
justifyContent: 'flex-end',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const browserWarning = style({
|
export const browserWarning = style({
|
||||||
@@ -153,7 +163,6 @@ export const allPageListTitleWrapper = style({
|
|||||||
fontSize: 'var(--affine-font-base)',
|
fontSize: 'var(--affine-font-base)',
|
||||||
color: 'var(--affine-text-primary-color)',
|
color: 'var(--affine-text-primary-color)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
'::after': {
|
'::after': {
|
||||||
content: '""',
|
content: '""',
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Tooltip } from '@affine/component';
|
||||||
import { EditCollectionModel } from '@affine/component/page-list';
|
import { EditCollectionModel } from '@affine/component/page-list';
|
||||||
import type { PropertiesMeta } from '@affine/env/filter';
|
import type { PropertiesMeta } from '@affine/env/filter';
|
||||||
import type { GetPageInfoById } from '@affine/env/page-info';
|
import type { GetPageInfoById } from '@affine/env/page-info';
|
||||||
@@ -102,9 +103,21 @@ export const CollectionBar = ({
|
|||||||
width: 20,
|
width: 20,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div style={{ marginRight: 10 }}>
|
<Tooltip
|
||||||
{setting.currentCollection.name}
|
content={setting.currentCollection.name}
|
||||||
</div>
|
pointerEnterDelay={1500}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginRight: 10,
|
||||||
|
maxWidth: 200,
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{setting.currentCollection.name}
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
{actions.map(action => {
|
{actions.map(action => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { globalStyle, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const menuTitleStyle = style({
|
export const menuTitleStyle = style({
|
||||||
marginLeft: '12px',
|
marginLeft: '12px',
|
||||||
@@ -20,6 +20,8 @@ export const viewButton = style({
|
|||||||
padding: '4px 8px',
|
padding: '4px 8px',
|
||||||
fontSize: 'var(--affine-font-xs)',
|
fontSize: 'var(--affine-font-xs)',
|
||||||
background: 'var(--affine-white)',
|
background: 'var(--affine-white)',
|
||||||
|
maxWidth: '200px',
|
||||||
|
overflow: 'hidden',
|
||||||
color: 'var(--affine-text-secondary-color)',
|
color: 'var(--affine-text-secondary-color)',
|
||||||
border: '1px solid var(--affine-border-color)',
|
border: '1px solid var(--affine-border-color)',
|
||||||
transition: 'margin-left 0.2s ease-in-out',
|
transition: 'margin-left 0.2s ease-in-out',
|
||||||
@@ -28,6 +30,20 @@ export const viewButton = style({
|
|||||||
background: 'var(--affine-hover-color)',
|
background: 'var(--affine-hover-color)',
|
||||||
},
|
},
|
||||||
marginRight: '20px',
|
marginRight: '20px',
|
||||||
|
'@media': {
|
||||||
|
'(max-width: 1200px)': {
|
||||||
|
maxWidth: '100px',
|
||||||
|
},
|
||||||
|
'(max-width: 900px)': {
|
||||||
|
maxWidth: '150px',
|
||||||
|
marginRight: '10px',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
globalStyle(`${viewButton} > span`, {
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
});
|
});
|
||||||
export const viewMenu = style({});
|
export const viewMenu = style({});
|
||||||
export const viewOption = style({
|
export const viewOption = style({
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { useAtom } from 'jotai';
|
|||||||
import type { MouseEvent, ReactNode } from 'react';
|
import type { MouseEvent, ReactNode } from 'react';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { Button, MenuItem } from '../../..';
|
import { Button, MenuItem, Tooltip } from '../../..';
|
||||||
import Menu from '../../../ui/menu/menu';
|
import Menu from '../../../ui/menu/menu';
|
||||||
import { appSidebarOpenAtom } from '../../app-sidebar';
|
import { appSidebarOpenAtom } from '../../app-sidebar';
|
||||||
import { CreateFilterMenu } from '../filter/vars';
|
import { CreateFilterMenu } from '../filter/vars';
|
||||||
@@ -80,39 +80,53 @@ const CollectionOption = ({
|
|||||||
key={collection.id}
|
key={collection.id}
|
||||||
className={styles.viewMenu}
|
className={styles.viewMenu}
|
||||||
>
|
>
|
||||||
<div
|
<Tooltip
|
||||||
style={{
|
content={collection.name}
|
||||||
display: 'flex',
|
placement="right"
|
||||||
alignItems: 'center',
|
pointerEnterDelay={1500}
|
||||||
justifyContent: 'space-between',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div>{collection.name}</div>
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{actions.map((v, i) => {
|
<div
|
||||||
const onClick = (e: MouseEvent<HTMLDivElement>) => {
|
style={{
|
||||||
e.stopPropagation();
|
maxWidth: '150px',
|
||||||
v.click();
|
overflow: 'hidden',
|
||||||
};
|
textOverflow: 'ellipsis',
|
||||||
return (
|
}}
|
||||||
<div
|
>
|
||||||
data-testid={`collection-select-option-${v.name}`}
|
{collection.name}
|
||||||
key={i}
|
</div>
|
||||||
onClick={onClick}
|
<div
|
||||||
style={{ marginLeft: i === 0 ? 28 : undefined }}
|
style={{
|
||||||
className={clsx(styles.viewOption, v.className)}
|
display: 'flex',
|
||||||
>
|
alignItems: 'center',
|
||||||
{v.icon}
|
}}
|
||||||
</div>
|
>
|
||||||
);
|
{actions.map((v, i) => {
|
||||||
})}
|
const onClick = (e: MouseEvent<HTMLDivElement>) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
v.click();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-testid={`collection-select-option-${v.name}`}
|
||||||
|
key={i}
|
||||||
|
onClick={onClick}
|
||||||
|
style={{ marginLeft: i === 0 ? 28 : undefined }}
|
||||||
|
className={clsx(styles.viewOption, v.className)}
|
||||||
|
>
|
||||||
|
{v.icon}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Tooltip>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -155,7 +169,6 @@ export const CollectionList = ({
|
|||||||
[styles.filterButtonCollapse]: !open,
|
[styles.filterButtonCollapse]: !open,
|
||||||
})}
|
})}
|
||||||
style={{
|
style={{
|
||||||
marginLeft: 4,
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}}
|
}}
|
||||||
@@ -199,7 +212,12 @@ export const CollectionList = ({
|
|||||||
hoverColor="var(--affine-icon-color)"
|
hoverColor="var(--affine-icon-color)"
|
||||||
data-testid="collection-select"
|
data-testid="collection-select"
|
||||||
>
|
>
|
||||||
{setting.currentCollection.name}
|
<Tooltip
|
||||||
|
content={setting.currentCollection.name}
|
||||||
|
pointerEnterDelay={1500}
|
||||||
|
>
|
||||||
|
<>{setting.currentCollection.name}</>
|
||||||
|
</Tooltip>
|
||||||
</Button>
|
</Button>
|
||||||
</Menu>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const Popper = ({
|
|||||||
defaultVisible = false,
|
defaultVisible = false,
|
||||||
visible: propsVisible,
|
visible: propsVisible,
|
||||||
trigger = 'hover',
|
trigger = 'hover',
|
||||||
pointerEnterDelay = 100,
|
pointerEnterDelay = 500,
|
||||||
pointerLeaveDelay = 100,
|
pointerLeaveDelay = 100,
|
||||||
onVisibleChange,
|
onVisibleChange,
|
||||||
popoverStyle,
|
popoverStyle,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const StyledTooltip = styled(StyledPopperContainer)(() => {
|
|||||||
fontSize: 'var(--affine-font-sm)',
|
fontSize: 'var(--affine-font-sm)',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
marginBottom: '12px',
|
marginBottom: '12px',
|
||||||
|
overflowWrap: 'break-word',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user