Sort labels by name

This commit is contained in:
Jackson Harper
2023-05-05 12:03:50 +08:00
parent fde5ec29cf
commit aab332eefc
2 changed files with 10 additions and 6 deletions

View File

@ -178,9 +178,11 @@ export function LibraryGridCard(props: LinkedItemCardProps): JSX.Element {
minHeight: '35px',
}}
>
{props.item.labels?.map(({ name, color }, index) => (
<LabelChip key={index} text={name || ''} color={color} />
))}
{props.item.labels
?.sort((a, b) => a.name.localeCompare(b.name))
.map(({ name, color }, index) => (
<LabelChip key={index} text={name || ''} color={color} />
))}
</HStack>
<VStack
css={{

View File

@ -118,9 +118,11 @@ export function LibraryListCard(props: LinkedItemCardProps): JSX.Element {
display: 'block',
}}
>
{props.item.labels?.map(({ name, color }, index) => (
<LabelChip key={index} text={name || ''} color={color} />
))}
{props.item.labels
?.sort((a, b) => a.name.localeCompare(b.name))
.map(({ name, color }, index) => (
<LabelChip key={index} text={name || ''} color={color} />
))}
</HStack>
</HStack>
</VStack>