-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define categorie color to each activity bar link
- Loading branch information
Showing
2 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
42 changes: 37 additions & 5 deletions
42
frontend/src/components/ActivitySearchFilter/ActivityButton/ActivityButton.tsx
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 |
---|---|---|
@@ -1,23 +1,55 @@ | ||
import React from 'react'; | ||
import SVG from 'react-inlinesvg'; | ||
import getConfig from 'next/config'; | ||
import styled from 'styled-components'; | ||
|
||
import { optimizeAndDefineColor } from 'stylesheet'; | ||
import { Link } from 'components/Link'; | ||
import getActivityColor from 'components/pages/search/components/ResultCard/getActivityColor'; | ||
import { ActivityFilter } from 'modules/activities/interface'; | ||
|
||
interface Props { | ||
iconUrl: string; | ||
href: string; | ||
label: string; | ||
type: ActivityFilter['type']; | ||
} | ||
|
||
export const ActivityButton: React.FC<Props> = ({ iconUrl, href, label }) => { | ||
const { | ||
publicRuntimeConfig: { colors }, | ||
} = getConfig(); | ||
|
||
const getColor = (type: ActivityFilter['type']) => { | ||
if (type === 'PRACTICE') { | ||
return getActivityColor('practices'); | ||
} | ||
if (type === 'OUTDOOR_PRACTICE') { | ||
return getActivityColor('outdoorPractice'); | ||
} | ||
if (type === 'CATEGORY') { | ||
return getActivityColor('categories'); | ||
} | ||
if (type === 'TOURISTIC_EVENT_TYPE') { | ||
return getActivityColor('event'); | ||
} | ||
return colors.primary3; | ||
}; | ||
|
||
export const ActivityButton: React.FC<Props> = ({ iconUrl, href, label, type }) => { | ||
return ( | ||
<Link | ||
<StyleLink | ||
$color={getColor(type)} | ||
href={href} | ||
className="flex flex-col items-center text-center mt-6 text-greyDarkColored bg-white transition hover:text-primary3 focus:text-primary3" | ||
className={`flex flex-col items-center text-center mt-6 text-greyDarkColored bg-white transition`} | ||
> | ||
<SVG src={iconUrl} className="h-9 desktop:w-12" preProcessor={optimizeAndDefineColor()} /> | ||
<span className="w-20 text-sm mt-2 text-ellipsis overflow-hidden">{label}</span> | ||
</Link> | ||
</StyleLink> | ||
); | ||
}; | ||
|
||
const StyleLink = styled(Link)<{ $color?: string }>` | ||
&:hover, | ||
&:focus { | ||
color: ${props => props.$color}; | ||
} | ||
`; |
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