2022-09-22 09:37:49 +00:00
|
|
|
import type { JSX } from 'solid-js'
|
|
|
|
import { Header } from '../Nav/Header'
|
|
|
|
import { Footer } from '../Discours/Footer'
|
|
|
|
|
2023-04-17 10:31:20 +00:00
|
|
|
import { createEffect, createSignal, Show } from 'solid-js'
|
2022-11-16 21:08:04 +00:00
|
|
|
import { clsx } from 'clsx'
|
2023-02-17 09:21:02 +00:00
|
|
|
import '../../styles/app.scss'
|
|
|
|
import styles from './PageLayout.module.scss'
|
2023-03-02 18:48:39 +00:00
|
|
|
import { Meta } from '@solidjs/meta'
|
2023-09-14 11:40:46 +00:00
|
|
|
import { Topic } from '../../graphql/types.gen'
|
2022-09-22 09:37:49 +00:00
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
type PageLayoutProps = {
|
2022-09-22 09:37:49 +00:00
|
|
|
headerTitle?: string
|
2023-04-17 10:31:20 +00:00
|
|
|
slug?: string
|
2023-01-30 10:39:36 +00:00
|
|
|
articleBody?: string
|
|
|
|
cover?: string
|
2022-09-22 09:37:49 +00:00
|
|
|
children: JSX.Element
|
2022-09-23 21:29:32 +00:00
|
|
|
isHeaderFixed?: boolean
|
2022-09-29 11:15:59 +00:00
|
|
|
hideFooter?: boolean
|
2022-11-16 21:08:04 +00:00
|
|
|
class?: string
|
2023-02-17 09:21:02 +00:00
|
|
|
withPadding?: boolean
|
2023-04-17 10:31:20 +00:00
|
|
|
scrollToComments?: (value: boolean) => void
|
2023-09-14 11:40:46 +00:00
|
|
|
randomTopics?: Topic[]
|
2022-09-22 09:37:49 +00:00
|
|
|
}
|
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
export const PageLayout = (props: PageLayoutProps) => {
|
2022-11-21 13:02:04 +00:00
|
|
|
const isHeaderFixed = props.isHeaderFixed === undefined ? true : props.isHeaderFixed
|
2023-04-17 10:31:20 +00:00
|
|
|
const [scrollToComments, setScrollToComments] = createSignal<boolean>(false)
|
|
|
|
|
|
|
|
createEffect(() => {
|
|
|
|
if (props.scrollToComments) {
|
|
|
|
props.scrollToComments(scrollToComments())
|
|
|
|
}
|
|
|
|
})
|
2023-09-14 11:40:46 +00:00
|
|
|
// const { randomTopics } = useTopicsStore()
|
2022-09-22 09:37:49 +00:00
|
|
|
return (
|
|
|
|
<>
|
2023-03-02 18:48:39 +00:00
|
|
|
<Meta name="viewport" content="width=device-width, initial-scale=1" />
|
2023-01-30 10:39:36 +00:00
|
|
|
<Header
|
2023-04-17 10:31:20 +00:00
|
|
|
slug={props.slug}
|
2023-01-30 10:39:36 +00:00
|
|
|
title={props.headerTitle}
|
|
|
|
articleBody={props.articleBody}
|
|
|
|
cover={props.articleBody}
|
|
|
|
isHeaderFixed={isHeaderFixed}
|
2023-04-17 10:31:20 +00:00
|
|
|
scrollToComments={(value) => setScrollToComments(value)}
|
2023-09-14 11:40:46 +00:00
|
|
|
randomTopics={props.randomTopics}
|
2023-01-30 10:39:36 +00:00
|
|
|
/>
|
2022-11-16 21:08:04 +00:00
|
|
|
<main
|
2023-02-17 09:21:02 +00:00
|
|
|
class={clsx('main-content', {
|
|
|
|
[styles.withPadding]: props.withPadding
|
|
|
|
})}
|
2022-11-16 21:08:04 +00:00
|
|
|
classList={{ 'main-content--no-padding': !isHeaderFixed }}
|
|
|
|
>
|
2022-09-29 19:16:17 +00:00
|
|
|
{props.children}
|
|
|
|
</main>
|
2022-09-29 11:15:59 +00:00
|
|
|
<Show when={props.hideFooter !== true}>
|
|
|
|
<Footer />
|
|
|
|
</Show>
|
2022-09-22 09:37:49 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|