Skip to content

Commit

Permalink
newslettr: load modal code dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
elbotho committed Jul 29, 2024
1 parent e61822f commit a19b56d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/components/modal-with-close-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FaIcon } from './fa-icon'
import { useInstanceData } from '@/contexts/instance-context'
import { cn } from '@/helper/cn'

interface ModalWithCloseButtonProps {
export interface ModalWithCloseButtonProps {
title?: string
isOpen: boolean
setIsOpen: (open: boolean) => void
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/components/scripts/newsletter-popup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import dynamic from 'next/dynamic'
import Head from 'next/head'
import { useEffect, useState } from 'react'

import { ModalWithCloseButton } from '../modal-with-close-button'
import type { ModalWithCloseButtonProps } from '../modal-with-close-button'
import { useInstanceData } from '@/contexts/instance-context'
import { Instance } from '@/fetcher/graphql-types/operations'
import { useScrollUpTrigger } from '@/helper/use-scroll-up-trigger'
Expand Down Expand Up @@ -45,6 +46,10 @@ const pages = [
const imageSrc =
'https://assets.serlo.org/db99f830-6f49-11ed-b282-836733dd2d87/SerloStandorte.jpg'

const ModalWithCloseButton = dynamic<ModalWithCloseButtonProps>(() =>
import('../modal-with-close-button').then((mod) => mod.ModalWithCloseButton)
)

export function NewsletterPopup() {
const { lang } = useInstanceData()
const [shouldLoad, setShouldLoad] = useState(false)
Expand Down

0 comments on commit a19b56d

Please sign in to comment.