-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
382 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Box, styled, SxProps } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
export const Container = styled(Box)` | ||
color: ${({ theme }) => theme.palette.tokens.icon.secondary}; | ||
font-size: 15px; | ||
`; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
sx?: SxProps; | ||
className?: string; | ||
}; | ||
|
||
export const TaskId = ({ children, sx, className }: Props) => { | ||
return <Container {...{ sx, className }}>#{children}</Container>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { Box, IconButton, styled, Tooltip, useTheme } from '@mui/material'; | ||
import { FlagImage } from 'tg.component/languages/FlagImage'; | ||
import { components } from 'tg.service/apiSchema.generated'; | ||
import { TaskId } from './TaskId'; | ||
import { TaskTypeChip } from './TaskTypeChip'; | ||
import { BatchProgress } from 'tg.views/projects/translations/BatchOperations/OperationsSummary/BatchProgress'; | ||
import { useDateFormatter } from 'tg.hooks/useLocale'; | ||
import { AccessAlarm, MoreVert } from '@mui/icons-material'; | ||
import { AvatarImg } from 'tg.component/common/avatar/AvatarImg'; | ||
|
||
type TaskModel = components['schemas']['TaskModel']; | ||
|
||
const StyledContainer = styled('div')` | ||
display: contents; | ||
&:hover > * { | ||
background: ${({ theme }) => theme.palette.tokens.text._states.hover}; | ||
} | ||
`; | ||
|
||
const StyledItem = styled(Box)` | ||
display: flex; | ||
align-items: center; | ||
align-self: stretch; | ||
justify-self: stretch; | ||
gap: 8px; | ||
`; | ||
|
||
const StyledName = styled(StyledItem)` | ||
grid-column: 1; | ||
padding: 8px 0px; | ||
padding-left: 16px; | ||
`; | ||
|
||
const StyledProgress = styled(StyledItem)` | ||
display: grid; | ||
grid-template-columns: 80px 1fr; | ||
gap: 24px; | ||
color: ${({ theme }) => theme.palette.tokens.icon.secondary}; | ||
`; | ||
|
||
const StyledAssignees = styled(StyledItem)` | ||
justify-content: start; | ||
display: flex; | ||
flex-wrap: wrap; | ||
`; | ||
|
||
type Props = { | ||
task: TaskModel; | ||
}; | ||
|
||
export const TaskItem = ({ task }: Props) => { | ||
const theme = useTheme(); | ||
const language = task.language; | ||
const formatDate = useDateFormatter(); | ||
return ( | ||
<StyledContainer> | ||
<StyledName> | ||
<Tooltip title={`${language.name} (${language.tag})`}> | ||
<FlagImage flagEmoji={language.flagEmoji!} height={20} /> | ||
</Tooltip> | ||
<Box>{task.name}</Box> | ||
<TaskId>{task.id}</TaskId> | ||
<TaskTypeChip type={task.type} /> | ||
</StyledName> | ||
<StyledItem | ||
color={theme.palette.tokens.text.secondary} | ||
alignItems="center" | ||
justifyContent="center" | ||
> | ||
{task.keys.length} | ||
</StyledItem> | ||
<StyledProgress> | ||
<BatchProgress progress={0.5} max={1} /> | ||
{task.dueDate ? ( | ||
<Box display="flex" alignItems="center" gap={0.5}> | ||
<AccessAlarm sx={{ fontSize: 16 }} /> | ||
{formatDate(task.dueDate, { timeZone: 'UTC' })} | ||
</Box> | ||
) : null} | ||
</StyledProgress> | ||
<StyledAssignees> | ||
{task.assignees.map((user) => ( | ||
<Tooltip key={user.id} title={<div>{user.username}</div>}> | ||
<div> | ||
<AvatarImg | ||
owner={{ | ||
name: user.name, | ||
avatar: user.avatar, | ||
type: 'USER', | ||
id: user.id, | ||
}} | ||
size={24} | ||
/> | ||
</div> | ||
</Tooltip> | ||
))} | ||
</StyledAssignees> | ||
<StyledItem sx={{ pr: 1 }}> | ||
<IconButton size="small"> | ||
<MoreVert fontSize="small" /> | ||
</IconButton> | ||
</StyledItem> | ||
</StyledContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Chip, styled, useTheme } from '@mui/material'; | ||
import { components } from 'tg.service/apiSchema.generated'; | ||
import { useTaskTranslation } from 'tg.translationTools/useTaskTranslation'; | ||
|
||
type TaskType = components['schemas']['TaskModel']['type']; | ||
|
||
const StyledChip = styled(Chip)``; | ||
|
||
type Props = { | ||
type: TaskType; | ||
}; | ||
|
||
export const TaskTypeChip = ({ type }: Props) => { | ||
const translateTaskType = useTaskTranslation(); | ||
const theme = useTheme(); | ||
|
||
function getBackgroundColor() { | ||
switch (type) { | ||
case 'TRANSLATE': | ||
return theme.palette.tokens.text._states.focus; | ||
case 'REVIEW': | ||
return theme.palette.tokens.secondary._states.focus; | ||
} | ||
} | ||
|
||
return ( | ||
<StyledChip | ||
size="small" | ||
label={translateTaskType(type)} | ||
sx={{ background: getBackgroundColor() }} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.