feat: add used app icons in FlowRow
This commit is contained in:
@@ -6,6 +6,7 @@ type AppIconProps = {
|
|||||||
name?: string;
|
name?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
variant?: AvatarProps['variant'];
|
||||||
};
|
};
|
||||||
|
|
||||||
const inlineImgStyle: React.CSSProperties = {
|
const inlineImgStyle: React.CSSProperties = {
|
||||||
@@ -13,12 +14,12 @@ const inlineImgStyle: React.CSSProperties = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function AppIcon(props: AppIconProps & AvatarProps): React.ReactElement {
|
export default function AppIcon(props: AppIconProps & AvatarProps): React.ReactElement {
|
||||||
const { name, url, color, sx = {}, ...restProps } = props;
|
const { name, url, color, sx = {}, variant = "square", ...restProps } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Avatar
|
<Avatar
|
||||||
component="span"
|
component="span"
|
||||||
variant="square"
|
variant={variant}
|
||||||
sx={{ bgcolor: color, display: 'flex', width: 50, height: 50, ...sx }}
|
sx={{ bgcolor: color, display: 'flex', width: 50, height: 50, ...sx }}
|
||||||
imgProps={{ style: inlineImgStyle }}
|
imgProps={{ style: inlineImgStyle }}
|
||||||
src={url}
|
src={url}
|
||||||
|
@@ -1,18 +1,17 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import Box from '@mui/material/Box';
|
|
||||||
import IconButton from '@mui/material/IconButton';
|
import IconButton from '@mui/material/IconButton';
|
||||||
import Stack from '@mui/material/Stack';
|
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import type { IFlow } from '@automatisch/types';
|
import type { IFlow } from '@automatisch/types';
|
||||||
|
import AppIcon from 'components/AppIcon';
|
||||||
import FlowContextMenu from 'components/FlowContextMenu';
|
import FlowContextMenu from 'components/FlowContextMenu';
|
||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import * as URLS from 'config/urls';
|
import * as URLS from 'config/urls';
|
||||||
import { CardContent, Typography } from './style';
|
import { Apps, CardContent, ContextMenu, Title, Typography } from './style';
|
||||||
|
|
||||||
type FlowRowProps = {
|
type FlowRowProps = {
|
||||||
flow: IFlow;
|
flow: IFlow;
|
||||||
@@ -45,10 +44,22 @@ export default function FlowRow(props: FlowRowProps): React.ReactElement {
|
|||||||
<Card sx={{ mb: 1 }}>
|
<Card sx={{ mb: 1 }}>
|
||||||
<CardActionArea component={Link} to={URLS.FLOW(flow.id)}>
|
<CardActionArea component={Link} to={URLS.FLOW(flow.id)}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Stack
|
<Apps direction="row" gap={1} sx={{gridArea:"apps"}}>
|
||||||
|
{["Twitter", "+3", "Github"].map((app) => (
|
||||||
|
<AppIcon
|
||||||
|
name={app}
|
||||||
|
color="lightpink"
|
||||||
|
variant="rounded"
|
||||||
|
url="httpss://via.placeholder.com/50"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Apps>
|
||||||
|
|
||||||
|
<Title
|
||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
alignItems="flex-start"
|
alignItems="flex-start"
|
||||||
spacing={1}
|
spacing={1}
|
||||||
|
sx={{gridArea:"title"}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" noWrap>
|
<Typography variant="h6" noWrap>
|
||||||
{flow?.name}
|
{flow?.name}
|
||||||
@@ -58,9 +69,9 @@ export default function FlowRow(props: FlowRowProps): React.ReactElement {
|
|||||||
{isUpdated && formatMessage('flow.updatedAt', { datetime: relativeUpdatedAt })}
|
{isUpdated && formatMessage('flow.updatedAt', { datetime: relativeUpdatedAt })}
|
||||||
{!isUpdated && formatMessage('flow.createdAt', { datetime: relativeCreatedAt })}
|
{!isUpdated && formatMessage('flow.createdAt', { datetime: relativeCreatedAt })}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Title>
|
||||||
|
|
||||||
<Box>
|
<ContextMenu>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="large"
|
size="large"
|
||||||
edge="start"
|
edge="start"
|
||||||
@@ -71,7 +82,7 @@ export default function FlowRow(props: FlowRowProps): React.ReactElement {
|
|||||||
>
|
>
|
||||||
<MoreHorizIcon />
|
<MoreHorizIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Box>
|
</ContextMenu>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
|
@@ -1,20 +1,42 @@
|
|||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
|
import MuiStack from '@mui/material/Stack';
|
||||||
|
import MuiBox from '@mui/material/Box';
|
||||||
import MuiCardContent from '@mui/material/CardContent';
|
import MuiCardContent from '@mui/material/CardContent';
|
||||||
import MuiTypography from '@mui/material/Typography';
|
import MuiTypography from '@mui/material/Typography';
|
||||||
|
|
||||||
export const CardContent = styled(MuiCardContent)(({ theme }) => ({
|
export const CardContent = styled(MuiCardContent)(({ theme }) => ({
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
gridTemplateRows: 'auto',
|
gridTemplateRows: 'auto',
|
||||||
gridTemplateColumns: '1fr auto',
|
gridTemplateColumns: 'calc(50px * 3 + 8px * 2) minmax(0, auto) min-content',
|
||||||
gridColumnGap: theme.spacing(2),
|
gridGap: theme.spacing(2),
|
||||||
|
gridTemplateAreas: `
|
||||||
|
"apps title menu"
|
||||||
|
`,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
gridTemplateAreas: `
|
||||||
|
"apps menu"
|
||||||
|
"title menu"
|
||||||
|
`,
|
||||||
|
gridTemplateColumns: 'minmax(0, auto) min-content',
|
||||||
|
gridTemplateRows: 'auto auto',
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const Apps = styled(MuiStack)(() => ({
|
||||||
|
gridArea: 'apps',
|
||||||
|
}));
|
||||||
|
export const Title = styled(MuiStack)(() => ({
|
||||||
|
gridArea: 'title',
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const ContextMenu = styled(MuiBox)(() => ({
|
||||||
|
gridArea: 'menu',
|
||||||
|
}));
|
||||||
export const Typography = styled(MuiTypography)(() => ({
|
export const Typography = styled(MuiTypography)(() => ({
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
maxWidth: '70%',
|
maxWidth: '85%',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const DesktopOnlyBreakline = styled('br')(({ theme }) => ({
|
export const DesktopOnlyBreakline = styled('br')(({ theme }) => ({
|
||||||
|
Reference in New Issue
Block a user