feat: add kanban card mask
This commit is contained in:
@@ -4,8 +4,14 @@ import {
|
|||||||
useKanban,
|
useKanban,
|
||||||
useRefPage,
|
useRefPage,
|
||||||
} from '@toeverything/components/editor-core';
|
} from '@toeverything/components/editor-core';
|
||||||
import { styled } from '@toeverything/components/ui';
|
import { PenIcon } from '@toeverything/components/icons';
|
||||||
|
import {
|
||||||
|
IconButton,
|
||||||
|
MuiClickAwayListener,
|
||||||
|
styled,
|
||||||
|
} from '@toeverything/components/ui';
|
||||||
import { useFlag } from '@toeverything/datasource/feature-flags';
|
import { useFlag } from '@toeverything/datasource/feature-flags';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
const CardContent = styled('div')({
|
const CardContent = styled('div')({
|
||||||
margin: '20px',
|
margin: '20px',
|
||||||
@@ -23,6 +29,7 @@ const CardActions = styled('div')({
|
|||||||
fontWeight: '300',
|
fontWeight: '300',
|
||||||
color: '#98ACBD',
|
color: '#98ACBD',
|
||||||
transition: 'all ease-in 0.2s',
|
transition: 'all ease-in 0.2s',
|
||||||
|
zIndex: 1,
|
||||||
|
|
||||||
':hover': {
|
':hover': {
|
||||||
background: '#F5F7F8',
|
background: '#F5F7F8',
|
||||||
@@ -39,11 +46,13 @@ const PlusIcon = styled('div')({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const CardContainer = styled('div')({
|
const CardContainer = styled('div')({
|
||||||
|
position: 'relative',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
border: '1px solid #E2E7ED',
|
border: '1px solid #E2E7ED',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
|
||||||
[CardActions.toString()]: {
|
[CardActions.toString()]: {
|
||||||
opacity: '0',
|
opacity: '0',
|
||||||
@@ -55,6 +64,23 @@ const CardContainer = styled('div')({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Overlay = styled('div')({
|
||||||
|
position: 'absolute',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
background: 'transparent',
|
||||||
|
|
||||||
|
'& > *': {
|
||||||
|
visibility: 'hidden',
|
||||||
|
position: 'absolute',
|
||||||
|
right: '24px',
|
||||||
|
top: '16px',
|
||||||
|
},
|
||||||
|
'&:hover > *': {
|
||||||
|
visibility: 'visible',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const CardItem = ({
|
export const CardItem = ({
|
||||||
id,
|
id,
|
||||||
block,
|
block,
|
||||||
@@ -64,8 +90,11 @@ export const CardItem = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { addSubItem } = useKanban();
|
const { addSubItem } = useKanban();
|
||||||
const { openSubPage } = useRefPage();
|
const { openSubPage } = useRefPage();
|
||||||
|
const [editable, setEditable] = useState(false);
|
||||||
const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false);
|
const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false);
|
||||||
|
|
||||||
const onAddItem = async () => {
|
const onAddItem = async () => {
|
||||||
|
setEditable(true);
|
||||||
await addSubItem(block);
|
await addSubItem(block);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,14 +103,28 @@ export const CardItem = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardContainer onClick={onClickCard}>
|
<MuiClickAwayListener onClickAway={() => setEditable(false)}>
|
||||||
<CardContent>
|
<CardContainer>
|
||||||
<RenderBlock blockId={id} />
|
<CardContent>
|
||||||
</CardContent>
|
<RenderBlock blockId={id} />
|
||||||
<CardActions onClick={onAddItem}>
|
</CardContent>
|
||||||
<PlusIcon />
|
{!editable && (
|
||||||
<span>Add a sub-block</span>
|
<Overlay onClick={onClickCard}>
|
||||||
</CardActions>
|
<IconButton
|
||||||
</CardContainer>
|
onClick={e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setEditable(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PenIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Overlay>
|
||||||
|
)}
|
||||||
|
<CardActions onClick={onAddItem}>
|
||||||
|
<PlusIcon />
|
||||||
|
<span>Add a sub-block</span>
|
||||||
|
</CardActions>
|
||||||
|
</CardContainer>
|
||||||
|
</MuiClickAwayListener>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user