-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* save * feat: add notification popup * fix: jaen update only for jaen:admin * chore: remove console logs * fix: useJaenPageIndex handle deleted child pages Added handling of deleted child pages in useJaenPageIndex function. --------- Co-authored-by: Nico Schett <[email protected]>
- Loading branch information
1 parent
1300357
commit 2526160
Showing
42 changed files
with
2,401 additions
and
141 deletions.
There are no files selected for viewing
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,27 @@ | ||
diff --git a/node_modules/gatsby/cache-dir/create-content-digest-browser-shim.js b/node_modules/gatsby/cache-dir/create-content-digest-browser-shim.js | ||
index edc673f..cbd390c 100644 | ||
--- a/node_modules/gatsby/cache-dir/create-content-digest-browser-shim.js | ||
+++ b/node_modules/gatsby/cache-dir/create-content-digest-browser-shim.js | ||
@@ -1 +1 @@ | ||
-exports.createContentDigest = () => `` | ||
+export const createContentDigest = () => `` | ||
diff --git a/node_modules/gatsby/cache-dir/public-page-renderer.js b/node_modules/gatsby/cache-dir/public-page-renderer.js | ||
index 6a91ada..e2ee03a 100644 | ||
--- a/node_modules/gatsby/cache-dir/public-page-renderer.js | ||
+++ b/node_modules/gatsby/cache-dir/public-page-renderer.js | ||
@@ -1,9 +1,11 @@ | ||
const preferDefault = m => (m && m.default) || m | ||
|
||
+let renderer = () => null; | ||
+ | ||
if (process.env.BUILD_STAGE === `develop`) { | ||
- module.exports = preferDefault(require(`./public-page-renderer-dev`)) | ||
+ renderer = preferDefault(require(`./public-page-renderer-dev`)) | ||
} else if (process.env.BUILD_STAGE === `build-javascript`) { | ||
- module.exports = preferDefault(require(`./public-page-renderer-prod`)) | ||
-} else { | ||
- module.exports = () => null | ||
+ renderer = preferDefault(require(`./public-page-renderer-prod`)) | ||
} | ||
+ | ||
+export default renderer; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
}, | ||
"aliases": { | ||
"components": "components", | ||
"utils": "../../lib/utils" | ||
"utils": "utils" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, {useEffect} from 'react' | ||
|
||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger | ||
} from './ui/dialog' | ||
import {Button} from './ui/button' | ||
import {useNotificationPopupWidget} from '../hooks/use-notification-popup-widget' | ||
|
||
export const Popup: React.FC<{}> = () => { | ||
const [{data}] = useNotificationPopupWidget() | ||
|
||
const [consent, setConsent] = React.useState(true) | ||
|
||
useEffect(() => { | ||
// The local storage contains the notification popup data so we can check if the user has already seen the notification | ||
// When the data is missing or the data is outdated we show the notification | ||
const localStorageData = localStorage.getItem('notification-popup') | ||
|
||
if (!localStorageData) { | ||
setConsent(false) | ||
} | ||
|
||
// String comparison to check if the data is outdated | ||
else if (data && localStorageData !== JSON.stringify(data)) { | ||
setConsent(false) | ||
} else { | ||
setConsent(true) | ||
} | ||
}, [data]) | ||
|
||
const handleConsent = () => { | ||
localStorage.setItem('notification-popup', JSON.stringify(data)) | ||
setConsent(true) | ||
} | ||
|
||
useEffect(() => { | ||
// Skip if the user has already seen the notification | ||
if (consent) { | ||
return | ||
} | ||
|
||
const popup = document.getElementById('notification-popup') | ||
if (popup) { | ||
// Check if the notification is enabled | ||
const isEnabled = data?.isEnabled ?? false | ||
const from = data?.from ? new Date(data?.from) : null | ||
const to = data?.to ? new Date(data?.to) : null | ||
|
||
if (isEnabled) { | ||
const now = new Date() | ||
|
||
let isInTimeRange = true | ||
if (from && to) { | ||
isInTimeRange = now >= from && now <= to | ||
} else if (from) { | ||
isInTimeRange = now >= from | ||
} else if (to) { | ||
isInTimeRange = now <= to | ||
} | ||
|
||
if (isInTimeRange) { | ||
popup.click() | ||
} | ||
} | ||
} | ||
}, [consent, data]) | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger id="notification-popup" className="hidden" /> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle className="text-2xl">{data?.title}</DialogTitle> | ||
</DialogHeader> | ||
<p | ||
className="prose" | ||
dangerouslySetInnerHTML={{__html: data?.message || ''}}></p> | ||
|
||
<DialogFooter> | ||
<DialogClose> | ||
<Button onClick={handleConsent}>Gelesen / Read</Button> | ||
</DialogClose> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} |
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
64 changes: 64 additions & 0 deletions
64
packages/gatsby-plugin-jaen/src/components/ui/calendar.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as React from 'react' | ||
import {ChevronLeft, ChevronRight} from 'lucide-react' | ||
import {DayPicker} from 'react-day-picker' | ||
|
||
import {cn} from '../../lib/utils' | ||
import {buttonVariants} from './button' | ||
|
||
export type CalendarProps = React.ComponentProps<typeof DayPicker> | ||
|
||
function Calendar({ | ||
className, | ||
classNames, | ||
showOutsideDays = true, | ||
...props | ||
}: CalendarProps) { | ||
return ( | ||
<DayPicker | ||
showOutsideDays={showOutsideDays} | ||
className={cn('p-3', className)} | ||
classNames={{ | ||
months: 'flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0', | ||
month: 'space-y-4', | ||
caption: 'flex justify-center pt-1 relative items-center', | ||
caption_label: 'text-sm font-medium', | ||
nav: 'space-x-1 flex items-center', | ||
nav_button: cn( | ||
buttonVariants({variant: 'outline'}), | ||
'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100' | ||
), | ||
nav_button_previous: 'absolute left-1', | ||
nav_button_next: 'absolute right-1', | ||
table: 'w-full border-collapse space-y-1', | ||
head_row: 'flex', | ||
head_cell: | ||
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]', | ||
row: 'flex w-full mt-2', | ||
cell: 'h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20', | ||
day: cn( | ||
buttonVariants({variant: 'ghost'}), | ||
'h-9 w-9 p-0 font-normal aria-selected:opacity-100' | ||
), | ||
day_range_end: 'day-range-end', | ||
day_selected: | ||
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground', | ||
day_today: 'bg-accent text-accent-foreground', | ||
day_outside: | ||
'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30', | ||
day_disabled: 'text-muted-foreground opacity-50', | ||
day_range_middle: | ||
'aria-selected:bg-accent aria-selected:text-accent-foreground', | ||
day_hidden: 'invisible', | ||
...classNames | ||
}} | ||
components={{ | ||
IconLeft: ({...props}) => <ChevronLeft className="h-4 w-4" />, | ||
IconRight: ({...props}) => <ChevronRight className="h-4 w-4" /> | ||
}} | ||
{...props} | ||
/> | ||
) | ||
} | ||
Calendar.displayName = 'Calendar' | ||
|
||
export {Calendar} |
Oops, something went wrong.