diff --git a/frontend/src/components/AppCrashFallback/AppCrashFallback.style.ts b/frontend/src/components/AppCrashFallback/AppCrashFallback.style.ts index 69cea769f..2e705322b 100644 --- a/frontend/src/components/AppCrashFallback/AppCrashFallback.style.ts +++ b/frontend/src/components/AppCrashFallback/AppCrashFallback.style.ts @@ -1,9 +1,6 @@ import styled from 'styled-components'; import { typography } from 'stylesheet'; -import BaseButton from 'components/Button'; export const Title = styled.h1` ${typography.h1} `; - -export const Button = styled(BaseButton)``; diff --git a/frontend/src/components/AppCrashFallback/AppCrashFallback.tsx b/frontend/src/components/AppCrashFallback/AppCrashFallback.tsx index bb29e035b..028c7824b 100644 --- a/frontend/src/components/AppCrashFallback/AppCrashFallback.tsx +++ b/frontend/src/components/AppCrashFallback/AppCrashFallback.tsx @@ -1,14 +1,12 @@ import * as Sentry from '@sentry/nextjs'; -import { Button, Title } from './AppCrashFallback.style'; +import Button from 'components/Button'; +import { Title } from './AppCrashFallback.style'; export interface FallbackProps { eventId: string; } -// TS reports `showReportDialog` as not being a property of `@sentry/node`. This -// is correct, except we use `@sentry/browser` in the browser! -// @ts-ignore-next-line const reportDialog = (eventId: string) => () => Sentry.showReportDialog({ eventId }); export const AppCrashFallback: React.FC = ({ eventId }) => { diff --git a/frontend/src/components/Button/Button.tsx b/frontend/src/components/Button/Button.tsx index 4c48577b7..c8b6771b1 100644 --- a/frontend/src/components/Button/Button.tsx +++ b/frontend/src/components/Button/Button.tsx @@ -1,8 +1,5 @@ -import styled from 'styled-components'; -import { borderRadius, colorPalette, getSpacing, sizes, typography } from 'stylesheet'; -import { buttonCssResets } from 'services/cssHelpers'; - import { GenericIconProps } from 'components/Icons/types'; +import { cn } from 'services/utils/cn'; interface Props extends React.ButtonHTMLAttributes { icon?: React.FC; @@ -11,42 +8,22 @@ interface Props extends React.ButtonHTMLAttributes { export const Button: React.FC = ({ icon: Icon, children, - className = '', + className, ...nativeButtonsProps }) => { return ( - - {Icon && } + {Icon && } {children} - + ); }; -export const StyledButton = styled.button` - ${buttonCssResets}; - - padding: ${getSpacing(2)} ${getSpacing(4)}; - height: ${sizes.button}px; - - border: 1px solid ${colorPalette.primary1}; - border-radius: ${borderRadius.squareButton}; - - ${typography.main} - color: ${colorPalette.primary1}; - font-weight: 600; - - background-color: ${colorPalette.white}; - transition: background-color 0.3s ease-in-out; - - cursor: pointer; - - &:hover { - background-color: ${colorPalette.primary2}; - } -`; - export default Button; diff --git a/frontend/src/components/Map/components/Popup/index.tsx b/frontend/src/components/Map/components/Popup/index.tsx index bd44cfec6..2220fc84d 100644 --- a/frontend/src/components/Map/components/Popup/index.tsx +++ b/frontend/src/components/Map/components/Popup/index.tsx @@ -6,7 +6,7 @@ import { FormattedMessage } from 'react-intl'; import Loader from 'components/Loader'; import { desktopOnly, getSpacing } from 'stylesheet'; -import { Button as RawButton } from 'components/Button'; +import { Button } from 'components/Button'; import { generateResultDetailsUrl } from 'components/pages/search/utils'; import Link from 'components/Link'; @@ -46,15 +46,15 @@ const PopupContent: React.FC = ({ showButton, id, type, parentId }) => {trekPopupResult.place} - + <h3 className="text-Mobile-C1 text-primary1 font-bold desktop:text-H4 line-clamp-1"> {trekPopupResult.title} - + {showButton && ( - @@ -100,21 +100,6 @@ const desktopImgHeight = 122; const mobileWidth = 215; const mobileImgHeight = 133; -const Button = styled(RawButton)` - margin-top: ${getSpacing(4)}; - width: 100%; - text-align: center; -`; - -const Title = styled.span` - ${desktopOnly(css` - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - display: block; - `)} -`; - const StyledTooltip = styled(LeafletTooltip)` padding: 0; border: 0px !important; diff --git a/frontend/src/components/MobileFilterMenu/CloseButton/index.tsx b/frontend/src/components/MobileFilterMenu/CloseButton/index.tsx index 15c03bfb1..0e3269062 100644 --- a/frontend/src/components/MobileFilterMenu/CloseButton/index.tsx +++ b/frontend/src/components/MobileFilterMenu/CloseButton/index.tsx @@ -1,22 +1,13 @@ -import React from 'react'; -import styled from 'styled-components'; - -import { buttonCssResets } from 'services/cssHelpers'; - interface Props { onClick: () => void; icon: React.ReactNode; className?: string; } -export const CloseButton: React.FC = ({ onClick, className, icon }) => { +export const CloseButton: React.FC = ({ icon, ...props }) => { return ( - + ); }; - -const Button = styled.button` - ${buttonCssResets}; -`; diff --git a/frontend/src/components/OpenMapButton/OpenMapButton.tsx b/frontend/src/components/OpenMapButton/OpenMapButton.tsx index 54548152b..3c000165c 100644 --- a/frontend/src/components/OpenMapButton/OpenMapButton.tsx +++ b/frontend/src/components/OpenMapButton/OpenMapButton.tsx @@ -1,10 +1,8 @@ -import React from 'react'; -import styled from 'styled-components'; -import { borderRadius, colorPalette, getSpacing, typography, zIndex } from 'stylesheet'; -import { buttonCssResets } from 'services/cssHelpers'; import { Map } from 'components/Icons/Map'; import { FormattedMessage } from 'react-intl'; import { useHideOnScrollDown } from 'hooks/useHideOnScrollDown'; +import { Button } from 'components/Button'; +import { cn } from 'services/utils/cn'; export const OpenMapButton: React.FC< React.ButtonHTMLAttributes & { displayMap: () => void } @@ -12,46 +10,17 @@ export const OpenMapButton: React.FC< const buttonDisplayState = useHideOnScrollDown(); return ( - - - + + ); }; - -const MapButton = styled.button<{ displayState: 'DISPLAYED' | 'HIDDEN' }>` - ${buttonCssResets} - - padding: ${getSpacing(3)} ${getSpacing(4)}; - - box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.15); - border-radius: ${borderRadius.roundButton}; - - ${typography.main}; - color: ${colorPalette.primary1}; - - position: fixed; - z-index: ${zIndex.floatingButton}; - bottom: ${({ displayState: showState }) => (showState === 'HIDDEN' ? '-100px' : getSpacing(6))}; - - /* Horizontally center the button */ - left: 50%; - transform: translateX(-50%); - - background-color: ${colorPalette.white}; - - transition-property: background-color bottom; - transition-duration: 0.3s; - transition-timing-function: ease-in-out; - - &:hover { - background-color: ${colorPalette.primary2}; - } -`; diff --git a/frontend/src/components/pages/details/components/OfflineButton/index.tsx b/frontend/src/components/pages/details/components/OfflineButton/index.tsx index b367c750c..f119d44bf 100644 --- a/frontend/src/components/pages/details/components/OfflineButton/index.tsx +++ b/frontend/src/components/pages/details/components/OfflineButton/index.tsx @@ -1,19 +1,21 @@ +import { useCallback, useEffect, useState } from 'react'; +import { FormattedMessage } from 'react-intl'; + import { WifiOff } from 'components/Icons/WifiOff'; import Loader from 'components/Loader'; import Popup from 'components/Popup'; -import React, { useCallback, useEffect, useState } from 'react'; -import { FormattedMessage } from 'react-intl'; - import { Check } from 'components/Icons/Check'; import { Bin } from 'components/Icons/Bin'; +import { Button } from 'components/Button'; + import CacheManager from 'services/offline/CacheManager'; -import { colorPalette } from 'stylesheet'; +import { cn } from 'services/utils/cn'; +import { Download } from 'components/Icons/Download'; import { Details } from '../../../../../modules/details/interface'; import { OutdoorCourseDetails } from '../../../../../modules/outdoorCourse/interface'; import { OutdoorSiteDetails } from '../../../../../modules/outdoorSite/interface'; import { TouristicContentDetails } from '../../../../../modules/touristicContent/interface'; import { TouristicEventDetails } from '../../../../../modules/touristicEvent/interface'; -import { Button } from '../../../../Button/Button'; interface Props { details: @@ -25,30 +27,6 @@ interface Props { type: 'TREK' | 'TOURISTIC_CONTENT' | 'OUTDOOR_SITE' | 'OUTDOOR_COURSE' | 'TOURISTIC_EVENT'; } -const ActionButton = ({ - onClick, - isInCache, -}: { - onClick: () => Promise; - isInCache: boolean; -}) => { - return ( - - ); -}; - const OfflineButton: React.FC = ({ details, type }) => { const [openDialog, setOpenDialog] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -125,20 +103,19 @@ const OfflineButton: React.FC = ({ details, type }) => { - {isInCache ? ( - - ) : ( - - )} + )} diff --git a/frontend/src/components/pages/search/components/ErrorFallback/ErrorFallback.tsx b/frontend/src/components/pages/search/components/ErrorFallback/ErrorFallback.tsx index 79c9c3ace..19a031238 100644 --- a/frontend/src/components/pages/search/components/ErrorFallback/ErrorFallback.tsx +++ b/frontend/src/components/pages/search/components/ErrorFallback/ErrorFallback.tsx @@ -1,11 +1,6 @@ -import React from 'react'; -import styled from 'styled-components'; import { FormattedMessage } from 'react-intl'; import { Reload } from 'components/Icons/Reload'; - -import { getSpacing, sizes } from 'stylesheet'; -import { buttonCssResets } from 'services/cssHelpers'; import { UseQueryResult } from '@tanstack/react-query'; interface Props { @@ -14,25 +9,16 @@ interface Props { export const ErrorFallback: React.FC = ({ refetch }) => { return ( - -
+
+

-

- + + +
); }; - -const Container = styled.div` - margin-top: ${sizes.desktopHeader + sizes.filterBar}; -`; - -const ReloadButton = styled.button` - ${buttonCssResets}; - margin-top: ${getSpacing(4)}; -`; diff --git a/frontend/src/components/pages/search/components/NumberBadge/NumberBadge.tsx b/frontend/src/components/pages/search/components/NumberBadge/NumberBadge.tsx index 90f5b5560..44c43b99d 100644 --- a/frontend/src/components/pages/search/components/NumberBadge/NumberBadge.tsx +++ b/frontend/src/components/pages/search/components/NumberBadge/NumberBadge.tsx @@ -1,5 +1,4 @@ -import React from 'react'; -import styled from 'styled-components'; +import { cn } from 'services/utils/cn'; interface Props { children: React.ReactNode; @@ -8,14 +7,13 @@ interface Props { export const NumberBadge: React.FC = ({ children, className }) => { return ( - + {children} - + ); }; - -const Badge = styled.div` - border-radius: 50%; - display: grid; - place-items: center; -`; diff --git a/frontend/src/components/pages/search/components/ToggleFilterButton/ToggleFilterButton.tsx b/frontend/src/components/pages/search/components/ToggleFilterButton/ToggleFilterButton.tsx index 909a8a042..1b9ee83ce 100644 --- a/frontend/src/components/pages/search/components/ToggleFilterButton/ToggleFilterButton.tsx +++ b/frontend/src/components/pages/search/components/ToggleFilterButton/ToggleFilterButton.tsx @@ -1,10 +1,6 @@ -import React, { ButtonHTMLAttributes } from 'react'; -import styled from 'styled-components'; +import { ButtonHTMLAttributes } from 'react'; import { FormattedMessage } from 'react-intl'; -import { colorPalette, typography } from 'stylesheet'; -import { buttonCssResets } from 'services/cssHelpers'; - import { Filter } from 'components/Icons/Filter'; import { NumberBadge } from '../NumberBadge'; @@ -14,26 +10,15 @@ interface Props extends ButtonHTMLAttributes { export const ToggleFilterButton: React.FC = ({ numberSelected, ...nativeButtonProps }) => { return ( - + + ); }; - -const Button = styled.button` - ${buttonCssResets} - color: ${colorPalette.primary1}; -`; - -const FilterText = styled.span` - ${typography.main}; - ${typography.bold}; - color: ${colorPalette.primary1}; -`; diff --git a/frontend/src/services/cssHelpers.ts b/frontend/src/services/cssHelpers.ts deleted file mode 100644 index 574fdb3f9..000000000 --- a/frontend/src/services/cssHelpers.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { css, FlattenSimpleInterpolation } from 'styled-components'; - -/** - * Emulates flex-gap which has yet to be implemented on every browser - * https://coryrylan.com/blog/css-gap-space-with-flexbox - */ -export const flexGap = (gapX: string, gapY?: string): FlattenSimpleInterpolation => css` - --gapX: ${gapX}; - --gapY: ${gapY ?? gapX}; - display: inline-flex; - flex-wrap: wrap; - margin: calc(-1 * var(--gapY)) 0 0 calc(-1 * var(--gapX)); - width: calc(100% + var(--gapX)); - - & > * { - margin: var(--gapY) 0 0 var(--gapX); - } -`; - -/** - * Allows you to properly re-design a HTML button without all the defaults - */ -export const buttonCssResets = css` - border: none; - margin: 0; - text-decoration: none; - cursor: pointer; - text-align: center; - -webkit-appearance: none; - -moz-appearance: none; - - &:focus { - outline: 0; - } -`;