Files
AFFiNE-Mirror/packages/frontend/component/src/ui/dnd/drop-indicator.css.ts
T
EYHN 24e0c5797c refactor(core): doc property (#8465)
doc property upgraded to use orm.

The visibility of the property are simplified to three types: `always show`, `always hide`, `hide when empty`, and the default is `always show`.

![CleanShot 2024-10-14 at 15 34 52](https://github.com/user-attachments/assets/748b8b80-061f-4d6a-8579-52e59df717c2)

Added a sidebar view to manage properties
![CleanShot 2024-10-14 at 15 35 58](https://github.com/user-attachments/assets/bffa9b1a-a1a5-4708-b2e8-4963120f3af9)

new property ui in workspace settings
![CleanShot 2024-10-14 at 15 36 44](https://github.com/user-attachments/assets/572d8dcc-9b3d-462a-9bcc-5f5fa8e622da)

Property lists can be collapsed
![CleanShot 2024-10-14 at 15 37 59](https://github.com/user-attachments/assets/2b20be1a-8141-478a-8fe7-405aff6d04fd)
2024-10-15 10:17:12 +00:00

179 lines
3.9 KiB
TypeScript

import { cssVar } from '@toeverything/theme';
import { createVar, style } from '@vanilla-extract/css';
export const terminalSize = createVar();
export const horizontalIndent = createVar();
export const indicatorColor = createVar();
export const treeLine = style({
vars: {
[terminalSize]: '8px',
},
// To make things a bit clearer we are making the box that the indicator in as
// big as the whole tree item
position: 'absolute',
top: 0,
right: 0,
left: horizontalIndent,
bottom: 0,
// We don't want to cause any additional 'dragenter' events
pointerEvents: 'none',
// Terminal
'::before': {
display: 'block',
content: '""',
position: 'absolute',
zIndex: 2,
boxSizing: 'border-box',
width: terminalSize,
height: terminalSize,
left: 0,
background: 'transparent',
borderColor: indicatorColor,
borderWidth: 2,
borderRadius: '50%',
borderStyle: 'solid',
},
// Line
'::after': {
display: 'block',
content: '""',
position: 'absolute',
zIndex: 1,
background: indicatorColor,
left: `calc(${terminalSize} / 2)`, // putting the line to the right of the terminal
height: 2,
right: 0,
},
selectors: {
['&[data-no-terminal="true"]::before']: {
display: 'none',
},
},
});
export const lineAboveStyles = style({
// terminal
'::before': {
top: 0,
// move to position to be a 'cap' on the line
transform: `translate(calc(-0.5 * ${terminalSize}), calc(-0.5 * ${terminalSize}))`,
},
// line
'::after': {
top: `${-0.5 * 2}px`,
},
});
export const lineBelowStyles = style({
'::before': {
bottom: 0,
// move to position to be a 'cap' on the line
transform: `translate(calc(-0.5 * ${terminalSize}), calc(0.5 * ${terminalSize}))`,
},
// line
'::after': {
bottom: `${-0.5 * 2}px`,
},
});
export const outlineStyles = style({
// To make things a bit clearer we are making the box that the indicator in as
// big as the whole tree item
position: 'absolute',
top: 0,
right: 0,
left: horizontalIndent,
bottom: 0,
// We don't want to cause any additional 'dragenter' events
pointerEvents: 'none',
border: `2px solid ${indicatorColor}`,
// TODO: make this a prop?
// For now: matching the Confluence tree item border radius
borderRadius: '3px',
});
export const horizontal = style({
height: 2,
left: `calc(${terminalSize}/2)`,
right: 0,
'::before': {
// Horizontal indicators have the terminal on the left
left: `calc(-1 * ${terminalSize})`,
},
});
export const vertical = style({
width: 2,
top: `calc(${terminalSize}/2)`,
bottom: 0,
'::before': {
// Vertical indicators have the terminal at the top
top: `calc(-1 * ${terminalSize})`,
},
});
export const localLineOffset = createVar();
export const top = style({
top: localLineOffset,
'::before': {
top: `calc(-1 * ${terminalSize} + 1px)`,
},
});
export const right = style({
right: localLineOffset,
'::before': {
right: `calc(-1 * ${terminalSize} + 1px)`,
},
});
export const bottom = style({
bottom: localLineOffset,
'::before': {
bottom: `calc(-1 * ${terminalSize} + 1px)`,
},
});
export const left = style({
left: localLineOffset,
'::before': {
left: `calc(-1 * ${terminalSize} + 1px)`,
},
});
export const edgeLine = style({
vars: {
[terminalSize]: '6px',
},
display: 'block',
position: 'absolute',
zIndex: 1,
// Blocking pointer events to prevent the line from triggering drag events
// Dragging over the line should count as dragging over the element behind it
pointerEvents: 'none',
background: cssVar('--affine-primary-color'),
// Terminal
'::before': {
content: '""',
width: 0,
height: 0,
boxSizing: 'border-box',
position: 'absolute',
border: `${terminalSize} solid ${cssVar('--affine-primary-color')}`,
borderRadius: '50%',
},
selectors: {
['&[data-no-terminal="true"]::before']: {
display: 'none',
},
},
});