Skip to content

Commit

Permalink
feat: do not capitalize custom category label in chips
Browse files Browse the repository at this point in the history
  • Loading branch information
dmijatovic committed Feb 3, 2025
1 parent 586e89c commit ea895cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions frontend/components/category/CategoryChipFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center
// SPDX-FileCopyrightText: 2024 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2024 - 2025 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -14,7 +14,8 @@ export function CategoryChipFilter({nodes}:{nodes:TreeNode<CategoryEntry>[]}){
const children = node.children()
return (
<Fragment key={cat.id}>
<TagChipFilter key={cat.id} title={cat.name} label={cat.short_name} />
{/* Do not capitalize category labels */}
<TagChipFilter key={cat.id} title={cat.name} label={cat.short_name} capitalize={false} />
<CategoryChipFilter nodes={children} />
</Fragment>
)
Expand Down
22 changes: 15 additions & 7 deletions frontend/components/layout/TagChipFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
// SPDX-FileCopyrightText: 2022 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2022 dv4all
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center
// SPDX-FileCopyrightText: 2024 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2024 - 2025 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

import Chip from '@mui/material/Chip'
import SearchIcon from '@mui/icons-material/Search'
import Link from 'next/link'

export default function TagChipFilter({url, label, title}:
{label: string, url?:string ,title?: string }
){
type TagChipFilterProps={
label: string,
url?:string ,
title?: string
capitalize?: boolean
}

export default function TagChipFilter({
url, label,
title, capitalize=true
}:TagChipFilterProps){
// if no label no chip
if (!label) return null

Expand All @@ -23,7 +31,7 @@ export default function TagChipFilter({url, label, title}:
sx={{
maxWidth: '19rem',
borderRadius: '0.125rem',
textTransform: 'capitalize',
textTransform: capitalize ? 'capitalize' : 'none',
'& .MuiChip-icon': {
order: 1,
margin:'0rem 0.5rem 0rem 0rem',
Expand All @@ -47,7 +55,7 @@ export default function TagChipFilter({url, label, title}:
sx={{
maxWidth: '19rem',
borderRadius: '0.125rem',
textTransform: 'capitalize',
textTransform: capitalize ? 'capitalize' : 'none',
'& .MuiChip-icon': {
order: 1,
margin:'0rem 0.5rem 0rem 0rem',
Expand Down

0 comments on commit ea895cd

Please sign in to comment.