-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
119 additions
and
143 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useCallback } from 'react'; | ||
import classNames from 'classnames'; | ||
import Link from 'next/link'; | ||
import type { ReactElement } from 'react'; | ||
import ContentWrapper from '@/components/layout/ContentWrapper'; | ||
import isNotEmptyString from '@/lib/common/helper/isNotEmptyString'; | ||
import useLocalStorage from '@/lib/common/hooks/useLocalStorage'; | ||
|
||
const HeaderBanner = (): ReactElement => { | ||
|
||
// TODO: Move config to CMS | ||
const isBannerActive = false; | ||
const bannerId = 4711; | ||
const bannerText = 'Die besten Veranstaltungen in deiner Nähe!'; | ||
const bannerLink = '/events'; | ||
const bannerColor = '#f6981e'; | ||
const bannerTextColor = '#ffffff'; | ||
|
||
const [hasDismissedBanner, setDismissedBanner] = useLocalStorage(`header_${bannerId}_dismissed`, false); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
const isBannerVisible = isBannerActive && !hasDismissedBanner; | ||
|
||
const onDismissClick = useCallback(() => setDismissedBanner(true), [setDismissedBanner]); | ||
|
||
const content = ( | ||
<ContentWrapper className="!py-2"> | ||
<div className="flex justify-between items-center gap-2"> | ||
{bannerText} | ||
|
||
<div onClick={onDismissClick}>✕</div> | ||
</div> | ||
</ContentWrapper> | ||
); | ||
|
||
return ( | ||
<div | ||
className={classNames( | ||
'font-serif', | ||
'text-sm', | ||
'md:text-base', | ||
'lg:text-lg', | ||
!isBannerVisible && 'hidden' | ||
)} | ||
style={{ backgroundColor: bannerColor, color: bannerTextColor }} | ||
> | ||
{isNotEmptyString(bannerLink) ? <Link href={bannerLink}>{content}</Link> : content} | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
export default HeaderBanner; |
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
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
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
74 changes: 0 additions & 74 deletions
74
components/layout/navigation/mobile/MobileNavigationItemsEnglish.tsx
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useCallback, useState } from 'react'; | ||
import useEffectOnMount from '@/lib/common/hooks/useEffectOnMount'; | ||
|
||
const useLocalStorage = <T>(key: string, defaultValue: T): [T, (value: T) => void] => { | ||
|
||
const [currentValue, setCurrentValue] = useState<T>(defaultValue); | ||
|
||
useEffectOnMount(() => { | ||
const valueFromStorage = window.localStorage.getItem(key); | ||
|
||
if (valueFromStorage !== null) { | ||
setCurrentValue(JSON.parse(valueFromStorage) as T); | ||
} | ||
}); | ||
|
||
const setValue = useCallback((newValue: T) => { | ||
setCurrentValue(newValue); | ||
window.localStorage.setItem(key, JSON.stringify(newValue)); | ||
}, [key]); | ||
|
||
return [currentValue, setValue]; | ||
}; | ||
|
||
export default useLocalStorage; |
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
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
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
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
Oops, something went wrong.