Skip to content

Commit

Permalink
feat(web): Organization page - "standalone" theme (#16976)
Browse files Browse the repository at this point in the history
* Render standalone screen if theme is 'standalone'

* Standalone layout first draft

* Mobile menu refactor

* Set up frontpage styles

* Banner title shown

* Minor spacing and search tweaks

* og:url set

* Add fallback

* More fallbacks

* fix header component styles

* Reorder imports

* Add top level Box

* Minor header style fix

---------

Co-authored-by: Ármann Pétur Ævarsson <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 20768c5 commit fb6f69a
Show file tree
Hide file tree
Showing 17 changed files with 914 additions and 32 deletions.
2 changes: 1 addition & 1 deletion apps/web/components/Organization/Slice/SliceMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface SliceMachineProps {

const fullWidthSlices = ['TimelineSlice', 'LogoListSlice', 'EmailSignup']

const renderSlice = (
export const renderSlice = (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore make web strict
slice,
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/real.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ export * from './CardWithFeaturedItems/CardWithFeaturedItems'
export * from './GenericList/GenericList'
export * from './GenericList/LatestGenericListItems/LatestGenericListItems'
export * from './connected/ParentalLeaveCalculator/ParentalLeaveCalculator'
export * from './Organization/OrganizationIslandFooter'
7 changes: 7 additions & 0 deletions apps/web/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ export const PLAUSIBLE_SCRIPT_SRC =
'https://plausible.io/js/script.outbound-links.js'
export const DIGITAL_ICELAND_PLAUSIBLE_TRACKING_DOMAIN =
'island.is/s/stafraent-island'
export const PRELOADED_FONTS = [
'/fonts/ibm-plex-sans-v7-latin-300.woff2',
'/fonts/ibm-plex-sans-v7-latin-regular.woff2',
'/fonts/ibm-plex-sans-v7-latin-italic.woff2',
'/fonts/ibm-plex-sans-v7-latin-500.woff2',
'/fonts/ibm-plex-sans-v7-latin-600.woff2',
]
26 changes: 11 additions & 15 deletions apps/web/layouts/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from '@island.is/web/components'

import { OrganizationIslandFooter } from '../components/Organization/OrganizationIslandFooter'
import { PRELOADED_FONTS } from '../constants'
import { GlobalContextProvider } from '../context'
import { MenuTabsContext } from '../context/MenuTabsContext/MenuTabsContext'
import {
Expand Down Expand Up @@ -56,7 +57,7 @@ import { getLocaleFromPath, useI18n } from '../i18n'
import { GET_CATEGORIES_QUERY, GET_NAMESPACE_QUERY } from '../screens/queries'
import { GET_ALERT_BANNER_QUERY } from '../screens/queries/AlertBanner'
import { GET_GROUPED_MENU_QUERY } from '../screens/queries/Menu'
import { Screen } from '../types'
import { Screen, ScreenContext } from '../types'
import { extractOrganizationSlugFromPathname } from '../utils/organization'
import {
formatMegaMenuCategoryLinks,
Expand Down Expand Up @@ -237,14 +238,6 @@ const Layout: Screen<LayoutProps> = ({
}
}, [router.asPath, router.events])

const preloadedFonts = [
'/fonts/ibm-plex-sans-v7-latin-300.woff2',
'/fonts/ibm-plex-sans-v7-latin-regular.woff2',
'/fonts/ibm-plex-sans-v7-latin-italic.woff2',
'/fonts/ibm-plex-sans-v7-latin-500.woff2',
'/fonts/ibm-plex-sans-v7-latin-600.woff2',
]

const isServiceWeb = pathIsRoute(router.asPath, 'serviceweb', activeLocale)

const organizationSearchFilter = extractOrganizationSlugFromPathname(
Expand All @@ -256,7 +249,7 @@ const Layout: Screen<LayoutProps> = ({
<GlobalContextProvider namespace={namespace} isServiceWeb={isServiceWeb}>
<Page component="div">
<Head>
{preloadedFonts.map((href, index) => {
{PRELOADED_FONTS.map((href, index) => {
return (
<link
key={index}
Expand Down Expand Up @@ -681,7 +674,10 @@ Layout.getProps = async ({ apolloClient, locale, req }) => {
}
}

type LayoutWrapper<T> = Screen<{ layoutProps: LayoutProps; componentProps: T }>
type LayoutWrapper<T, C = ScreenContext> = Screen<
{ layoutProps: LayoutProps; componentProps: T },
C
>

interface LayoutComponentProps {
themeConfig?: Partial<LayoutProps>
Expand All @@ -691,11 +687,11 @@ interface LayoutComponentProps {
languageToggleQueryParams?: LayoutProps['languageToggleQueryParams']
}

export const withMainLayout = <T,>(
Component: Screen<T>,
export const withMainLayout = <T, C extends ScreenContext>(
Component: Screen<T, C>,
layoutConfig: Partial<LayoutProps> = {},
): LayoutWrapper<T> => {
const WithMainLayout: LayoutWrapper<T> = ({
): LayoutWrapper<T, C> => {
const WithMainLayout: LayoutWrapper<T, C> = ({
layoutProps,
componentProps,
}) => {
Expand Down
85 changes: 85 additions & 0 deletions apps/web/layouts/organization/standalone/components/Header.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { style } from '@vanilla-extract/css'

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

export const gridContainer = style({
display: 'grid',
maxWidth: '1342px',
margin: '0 auto',
...themeUtils.responsiveStyle({
lg: {
gridTemplateRows: '315px',
gridTemplateColumns: '65fr 35fr',
},
}),
})

export const gridContainerSubpage = style({
...themeUtils.responsiveStyle({
lg: {
gridTemplateRows: 'auto',
gridTemplateColumns: '100fr',
},
}),
})

export const gridContainerWidth = style({
maxWidth: '1342px',
margin: '0 auto',
})

export const textContainer = style({
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
textAlign: 'center',
...themeUtils.responsiveStyle({
xs: {
order: 1,
paddingTop: '32px',
paddingBottom: '20px',
},
lg: {
order: 0,
},
}),
})

export const textContainerNoTitle = style({
order: 0,
})

export const textContainerSubpage = style({
minHeight: '20px',
})

export const textInnerContainer = style({
paddingLeft: '16px',
paddingRight: '16px',
...themeUtils.responsiveStyle({
lg: {
height: '100%',
maxWidth: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
}),
})

export const headerImage = style({
width: '100%',
order: 1,
...themeUtils.responsiveStyle({
xs: {
maxHeight: '200px',
},
lg: {
maxHeight: '100%',
},
}),
})

export const title = style({
zIndex: 0,
})
95 changes: 95 additions & 0 deletions apps/web/layouts/organization/standalone/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { useEffect, useState } from 'react'
import { useWindowSize } from 'react-use'
import cn from 'classnames'

import { ResponsiveSpace, Text, TextProps } from '@island.is/island-ui/core'
import { theme } from '@island.is/island-ui/theme'

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

export interface HeaderProps {
fullWidth?: boolean
image?: string
background?: string
mobileBackground?: string | null
underTitle?: string
titleSectionPaddingLeft?: ResponsiveSpace
titleColor?: TextProps['color']
imagePadding?: string
imageIsFullHeight?: boolean
imageObjectFit?: 'contain' | 'cover'
imageObjectPosition?: 'left' | 'center' | 'right'
className?: string
isFrontpage?: boolean
}

export const Header: React.FC<React.PropsWithChildren<HeaderProps>> = ({
fullWidth,
image,
background,
mobileBackground,
underTitle,
titleColor = 'dark400',
imagePadding = '20px',
imageIsFullHeight = true,
imageObjectFit = 'contain',
imageObjectPosition = 'center',
className,
isFrontpage = false,
}) => {
const { width } = useWindowSize()
const imageProvided = !!image

const [isMobile, setIsMobile] = useState(false)

useEffect(() => {
setIsMobile(width < theme.breakpoints.lg)
}, [width])
return (
<div
className={cn({ [styles.gridContainerWidth]: !fullWidth })}
style={{
background: isMobile ? mobileBackground || background : background,
}}
>
<div
className={cn(
{
[styles.gridContainer]: !className,
[styles.gridContainerSubpage]: !isFrontpage,
},
className,
)}
>
<div
className={cn({
[styles.textContainerNoTitle]: isFrontpage && !underTitle,
[styles.textContainer]: isFrontpage && underTitle,
[styles.textContainerSubpage]: !isFrontpage,
})}
>
{underTitle && isFrontpage && (
<div className={cn(styles.textInnerContainer)}>
<Text variant="h1" as="h1" color={titleColor}>
{underTitle}
</Text>
</div>
)}
</div>
{imageProvided && isFrontpage && (
<img
style={{
padding: imagePadding,
objectFit: imageObjectFit,
objectPosition: imageObjectPosition,
height: imageIsFullHeight ? '100%' : undefined,
}}
className={styles.headerImage}
src={image}
alt=""
/>
)}
</div>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { style } from '@vanilla-extract/css'

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

export const container = style({
overflowY: 'auto',
overflowX: 'hidden',
width: '80%',
height: '100%',
maxWidth: '305px',
marginLeft: 'auto',
background: theme.color.white,
padding: '37px 24px',
boxShadow: '-5px 4px 10px 4px rgba(0, 0, 0, 0.2)',
})

export const icon = style({
marginRight: '20px',
})

export const mobileContent = style({
marginTop: '40px',
})

export const links = style({
paddingLeft: '10px',
paddingRight: '10px',
})
Loading

0 comments on commit fb6f69a

Please sign in to comment.