-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add target subject label to activity cards
Make shared `TargetSubjectLabel` component which will also be used in the activity screens. Also fix missing translations and missing/incorrect use of i18next plural forms in several `ActivityLabel` subcomponents.
- Loading branch information
1 parent
4a02258
commit 2b4cf90
Showing
15 changed files
with
115 additions
and
41 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
import { SubjectDTO } from '~/shared/api/types/subject'; | ||
|
||
export const getSubjectName = ({ firstName, lastName }: SubjectDTO) => { | ||
const lastInitial = lastName[0] ? ` ${lastName[0]}.` : ''; | ||
|
||
return `${firstName}${lastInitial}`; | ||
}; |
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
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,43 @@ | ||
import { Avatar } from '@mui/material'; | ||
|
||
import SubjectIcon from '~/assets/subject-icon.svg'; | ||
import { SubjectDTO } from '~/shared/api/types/subject'; | ||
import { Theme } from '~/shared/constants'; | ||
import { Box, Text } from '~/shared/ui'; | ||
import { getSubjectName, useCustomTranslation } from '~/shared/utils'; | ||
|
||
type Props = { | ||
subject: SubjectDTO; | ||
}; | ||
|
||
export const TargetSubjectLabel = ({ subject }: Props) => { | ||
const { t } = useCustomTranslation(); | ||
|
||
const name = getSubjectName(subject); | ||
|
||
return ( | ||
<Box | ||
data-testid="subject-label" | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
padding: '4px 8px', | ||
borderRadius: '8px', | ||
gap: '8px', | ||
backgroundColor: Theme.colors.light.accentYellow30, | ||
whiteSpace: 'nowrap', | ||
}} | ||
> | ||
<Avatar src={SubjectIcon} sx={{ width: '18px', height: '18px' }} /> | ||
<Text | ||
color={Theme.colors.light.onSurface} | ||
fontSize="14px" | ||
fontWeight="400" | ||
lineHeight="20px" | ||
letterSpacing="0.1px" | ||
> | ||
{t('targetSubjectLabel', { name })} | ||
</Text> | ||
</Box> | ||
); | ||
}; |