Skip to content

Commit

Permalink
fix(web): Stop server side rendering some dynamically imported footers (
Browse files Browse the repository at this point in the history
#14634)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
RunarVestmann and kodiakhq[bot] authored Apr 30, 2024
1 parent cfc06df commit 9bb7eaf
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { style } from '@vanilla-extract/css'
import { themeUtils } from '@island.is/island-ui/theme'

import { theme, themeUtils } from '@island.is/island-ui/theme'

export const container = style({
background: 'linear-gradient(180deg, #E6F2FB 21.56%, #90D9E3 239.74%)',
Expand Down Expand Up @@ -42,3 +43,7 @@ export const bsiLogo = style({
export const bsiLogoMobile = style({
height: '40px',
})

export const marginLeft = style({
marginLeft: theme.spacing[2],
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import { ReactNode } from 'react'
import cn from 'classnames'
import { BLOCKS } from '@contentful/rich-text-types'

import { SliceType } from '@island.is/island-ui/contentful'
import {
Box,
GridColumn,
GridContainer,
GridRow,
Hyphen,
Text,
} from '@island.is/island-ui/core'
import { theme } from '@island.is/island-ui/theme'
import { FooterItem } from '@island.is/web/graphql/schema'
import { useNamespace } from '@island.is/web/hooks'
import { useWindowSize } from '@island.is/web/hooks/useViewport'
import { theme } from '@island.is/island-ui/theme'
import { SliceType } from '@island.is/island-ui/contentful'
import { webRichText } from '@island.is/web/utils/richText'
import { useNamespace } from '@island.is/web/hooks'

import * as styles from './FiskistofaFooter.css'

Expand All @@ -35,19 +34,19 @@ const FiskistofaFooter = ({

return (
<footer>
<Box className={styles.container}>
<div className={styles.container}>
<GridContainer className={styles.mainColumn}>
<GridColumn>
<GridRow>
<Box marginLeft={2}>
<div className={styles.marginLeft}>
<img
src={n(
'fiskistofaFooterLogo',
'https://images.ctfassets.net/8k0h54kbe6bj/2JSIJ4WbQ4Up84KQlMnIBb/34c1a74806884e456e3ab809a54d41f6/fiskistofa-footer-logo.png',
)}
alt="fiskistofa-logo"
/>
</Box>
</div>
</GridRow>
<GridRow marginTop={2} className={styles.linkRow}>
{footerItems.slice(0, 3).map((item, idx) => (
Expand Down Expand Up @@ -91,7 +90,7 @@ const FiskistofaFooter = ({
),
},
})}
<Box className={styles.iconContainer}>
<div className={styles.iconContainer}>
<img
src={n(
'fiskistofaGraenSkrefLogo',
Expand Down Expand Up @@ -121,13 +120,13 @@ const FiskistofaFooter = ({
[styles.bsiLogoMobile]: isMobile,
})}
/>
</Box>
</div>
</GridColumn>
)}
</GridRow>
</GridColumn>
</GridContainer>
</Box>
</div>
</footer>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Header from './HeilbrigdisstofnunAusturlandsHeader'

export const HeilbrigdisstofnunAusturlandsFooter = dynamic(
() => import('./HeilbrigdisstofnunAusturlandsFooter'),
{ ssr: true },
{ ssr: false },
)

export const HeilbrigdisstofnunAusturlandsHeader = Header
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const HeilbrigdisstofnunNordurlandsHeader = Header

export const HeilbrigdisstofnunNordurlandsFooter = dynamic(
() => import('./HeilbrigdisstofnunNordurlandsFooter'),
{ ssr: true },
{ ssr: false },
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const HeilbrigdisstofnunSudurlandsHeader = Header

export const HeilbrigdisstofnunSudurlandsFooter = dynamic(
() => import('./HeilbrigdisstofnunSudurlandsFooter'),
{ ssr: true },
{ ssr: false },
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import dynamic from 'next/dynamic'
import Header from './HveHeader'

export const HveHeader = Header
export const HveFooter = dynamic(() => import('./HveFooter'), { ssr: true })
export const HveFooter = dynamic(() => import('./HveFooter'), { ssr: false })
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useEffect, useState } from 'react'

import { SliceType } from '@island.is/island-ui/contentful'
import {
Box,
Expand Down Expand Up @@ -25,7 +27,11 @@ const IcelandicNaturalDisasterInsuranceFooter = ({
}: IcelandicNaturalDisasterInsuranceFooterProps) => {
const n = useNamespace(namespace)
const { width } = useWindowSize()
const shouldWrap = width < theme.breakpoints.xl
const [shouldWrap, setShouldWrap] = useState(false)

useEffect(() => {
setShouldWrap(width < theme.breakpoints.xl)
}, [width])

return (
<footer className={styles.footer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dynamic from 'next/dynamic'
import Header from './LandlaeknirHeader'

export const LandlaeknirFooter = dynamic(() => import('./LandlaeknirFooter'), {
ssr: true,
ssr: false,
})

export const LandlaeknirHeader = Header

0 comments on commit 9bb7eaf

Please sign in to comment.