From 7dfc56019f5aed943b09e80b8e688b10550f460b Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Tue, 25 Jul 2023 11:02:27 +0200 Subject: [PATCH] Rename fillSvgWithColor helper by optimizeAndDefineColor --- .../ActivityButton/ActivityButton.tsx | 4 ++-- frontend/src/components/CardIcon/CardIcon.tsx | 4 ++-- .../Information/RemoteIconInformation/index.tsx | 4 ++-- .../details/components/DetailsSource/DetailsSource.tsx | 4 ++-- .../components/DetailsTopIcons/DetailsTopIcons.tsx | 6 ++++-- .../pages/home/components/HomeSection/HomeSection.tsx | 8 ++++++-- .../pages/search/components/FilterBar/Field.tsx | 4 ++-- frontend/src/stylesheet.ts | 2 +- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/ActivitySearchFilter/ActivityButton/ActivityButton.tsx b/frontend/src/components/ActivitySearchFilter/ActivityButton/ActivityButton.tsx index 21e2eb5a1..9ff43e363 100644 --- a/frontend/src/components/ActivitySearchFilter/ActivityButton/ActivityButton.tsx +++ b/frontend/src/components/ActivitySearchFilter/ActivityButton/ActivityButton.tsx @@ -1,7 +1,7 @@ import React from 'react'; import SVG from 'react-inlinesvg'; -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; import { Link } from 'components/Link'; interface Props { @@ -16,7 +16,7 @@ export const ActivityButton: React.FC = ({ iconUrl, href, label }) => { href={href} className="flex flex-col items-center text-center mt-6 text-greyDarkColored bg-white transition hover:text-primary3 focus:text-primary3" > - + {label} ); diff --git a/frontend/src/components/CardIcon/CardIcon.tsx b/frontend/src/components/CardIcon/CardIcon.tsx index ea4a684bc..580a5c41b 100644 --- a/frontend/src/components/CardIcon/CardIcon.tsx +++ b/frontend/src/components/CardIcon/CardIcon.tsx @@ -1,4 +1,4 @@ -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; import SVG from 'react-inlinesvg'; import styled from 'styled-components'; import Image from 'next/image'; @@ -36,7 +36,7 @@ const Icon: React.FC = ({ iconUri = '', className = '', color }) => { ); } diff --git a/frontend/src/components/Information/RemoteIconInformation/index.tsx b/frontend/src/components/Information/RemoteIconInformation/index.tsx index 4cbc30a7e..df8f68250 100644 --- a/frontend/src/components/Information/RemoteIconInformation/index.tsx +++ b/frontend/src/components/Information/RemoteIconInformation/index.tsx @@ -1,7 +1,7 @@ import Image from 'next/image'; import SVG from 'react-inlinesvg'; -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; import { Information } from '../BaseInformation'; export interface Props { @@ -16,7 +16,7 @@ export interface Props { export const RemoteIconInformation: React.FC = ({ iconUri, ...props }) => { let icon = null; if (RegExp(/(.*).svg/).test(iconUri)) { - icon = ; + icon = ; } else if (typeof iconUri === 'string' && iconUri.length) { icon = ( = ({ pictogramUri }) => { ); diff --git a/frontend/src/components/pages/details/components/DetailsTopIcons/DetailsTopIcons.tsx b/frontend/src/components/pages/details/components/DetailsTopIcons/DetailsTopIcons.tsx index cac9aa080..2209c1fec 100644 --- a/frontend/src/components/pages/details/components/DetailsTopIcons/DetailsTopIcons.tsx +++ b/frontend/src/components/pages/details/components/DetailsTopIcons/DetailsTopIcons.tsx @@ -3,7 +3,7 @@ import getActivityColor from 'components/pages/search/components/ResultCard/getA import { Activity } from 'modules/activities/interface'; import Image from 'next/image'; import SVG from 'react-inlinesvg'; -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; import { Details } from '../../../../../modules/details/interface'; import { OutdoorCourseDetails } from '../../../../../modules/outdoorCourse/interface'; import { OutdoorSiteDetails } from '../../../../../modules/outdoorSite/interface'; @@ -33,7 +33,9 @@ const Icon: React.FC = ({ src = '', ...props }) => { return null; } if (RegExp(/(.*).svg/).test(src)) { - return ; + return ( + + ); } return ; }; diff --git a/frontend/src/components/pages/home/components/HomeSection/HomeSection.tsx b/frontend/src/components/pages/home/components/HomeSection/HomeSection.tsx index 40d548ef5..a8912fd39 100644 --- a/frontend/src/components/pages/home/components/HomeSection/HomeSection.tsx +++ b/frontend/src/components/pages/home/components/HomeSection/HomeSection.tsx @@ -4,7 +4,7 @@ import { getHoverId } from 'components/pages/search/utils'; import { ActivitySuggestion } from 'modules/activitySuggestions/interface'; import SVG from 'react-inlinesvg'; import styled from 'styled-components'; -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; export interface HomeSectionProps { title: string; @@ -19,7 +19,11 @@ export const HomeSection: React.FC = ({ title, iconUrl, result id="home_sectionTitle" className="flex border-t border-greySoft border-solid pt-4 desktop:pt-10 mb-2 desktop:mb-6 mx-4 desktop:mx-10percent" > - + {title} diff --git a/frontend/src/components/pages/search/components/FilterBar/Field.tsx b/frontend/src/components/pages/search/components/FilterBar/Field.tsx index cb83c33ab..ae623c760 100644 --- a/frontend/src/components/pages/search/components/FilterBar/Field.tsx +++ b/frontend/src/components/pages/search/components/FilterBar/Field.tsx @@ -1,7 +1,7 @@ import React from 'react'; import SVG from 'react-inlinesvg'; import { useIntl } from 'react-intl'; -import { fillSvgWithColor } from 'stylesheet'; +import { optimizeAndDefineColor } from 'stylesheet'; import { cn } from 'services/utils/cn'; import { FilterState, Option } from '../../../../../modules/filters/interface'; @@ -24,7 +24,7 @@ const Icon: React.FC = ({ option, isSelected }) => { ); }; diff --git a/frontend/src/stylesheet.ts b/frontend/src/stylesheet.ts index 3d6b55e4a..e3060d80d 100644 --- a/frontend/src/stylesheet.ts +++ b/frontend/src/stylesheet.ts @@ -219,7 +219,7 @@ export const optimizeSVG = (svg: string): string => { return data; }; -export const fillSvgWithColor = +export const optimizeAndDefineColor = (color = 'currentColor') => (svg: string): string => { const optimizedSVG = optimizeSVG(svg);