diff --git a/src/components/Clickable/Clickable.module.scss b/src/components/Clickable/Clickable.module.scss index 33ef3a26..28ef3653 100644 --- a/src/components/Clickable/Clickable.module.scss +++ b/src/components/Clickable/Clickable.module.scss @@ -1,6 +1,6 @@ .actionButton { cursor: pointer; - text-transform: uppercase; + padding: 0; border: 0; border-bottom: 5px solid black; color: black; diff --git a/src/components/Posts/Post.tsx b/src/components/Posts/Post.tsx index 9c9ae050..fa14b29f 100644 --- a/src/components/Posts/Post.tsx +++ b/src/components/Posts/Post.tsx @@ -4,6 +4,7 @@ import {FC} from 'react' import {formatDate} from '@/utils/formatDate' import {useSeminarInfo} from '@/utils/useSeminarInfo' +import {Button} from '../Clickable/Button' import {Link} from '../Clickable/Link' export interface IPost { @@ -16,9 +17,10 @@ export interface IPost { visible_after: string visible_until: string sites: number[] + openDetail: () => void } -export const Post: FC = ({caption, short_text, links, sites, added_at}) => { +export const Post: FC = ({caption, short_text, links, details, sites, added_at, openDetail}) => { const {seminarId} = useSeminarInfo() if (!sites.includes(seminarId)) return null @@ -26,19 +28,23 @@ export const Post: FC = ({caption, short_text, links, sites, added_at}) = return ( {caption} - - {short_text} - - + + {short_text} + + {/* alignItems so the links don't stretch */} + {details.length > 0 && ( + + )} {links.map(({id, url, caption}) => ( {caption} ))} - {formatDate(added_at)} diff --git a/src/components/Posts/PostDetail.tsx b/src/components/Posts/PostDetail.tsx new file mode 100644 index 00000000..c3754f61 --- /dev/null +++ b/src/components/Posts/PostDetail.tsx @@ -0,0 +1,28 @@ +import {Stack, Typography} from '@mui/material' +import {FC} from 'react' + +import {PostMarkdown} from './PostMarkdown' + +type PostDetailProps = { + caption: string + details: string +} + +export const PostDetail: FC = ({caption, details}) => { + return ( + + + {caption} + + + + ) +} diff --git a/src/components/Posts/PostMarkdown.tsx b/src/components/Posts/PostMarkdown.tsx new file mode 100644 index 00000000..fb2a0033 --- /dev/null +++ b/src/components/Posts/PostMarkdown.tsx @@ -0,0 +1,35 @@ +import 'katex/dist/katex.min.css' + +import {FC} from 'react' +import ReactMarkdown from 'react-markdown' +import rehypeKatex from 'rehype-katex' +import remarkGfm from 'remark-gfm' +import remarkMath from 'remark-math' + +import {Header, MarkdownLink, Ol, Paragraph, Ul} from './PostMarkdownTexts' + +type PostMarkdownProps = { + content: string +} + +export const PostMarkdown: FC = ({content}) => ( + + {content} + +) diff --git a/src/components/Posts/PostMarkdownTexts.tsx b/src/components/Posts/PostMarkdownTexts.tsx new file mode 100644 index 00000000..f3ac1d23 --- /dev/null +++ b/src/components/Posts/PostMarkdownTexts.tsx @@ -0,0 +1,40 @@ +import {Typography} from '@mui/material' +import {FC, ReactNode} from 'react' +import {HeadingProps, OrderedListProps, ReactMarkdownProps, UnorderedListProps} from 'react-markdown/lib/ast-to-react' + +import {Link} from '../Clickable/Link' + +type MarkdownLinkProps = { + children: ReactNode[] + href?: string +} + +export const MarkdownLink: FC = ({children, href}) => ( + + {children} + +) + +export const Ol: FC = ({children}) => ( + + {children} + +) + +export const Ul: FC = ({children}) => ( + + {children} + +) + +export const Paragraph: FC = ({children}) => ( + + {children} + +) + +export const Header: FC = ({children}) => ( + + {children} + +) diff --git a/src/components/Posts/Posts.tsx b/src/components/Posts/Posts.tsx index dab23501..a2a1c263 100644 --- a/src/components/Posts/Posts.tsx +++ b/src/components/Posts/Posts.tsx @@ -1,10 +1,13 @@ import {Stack, Typography} from '@mui/material' +// new MUI Grid without spacing issues: https://mui.com/material-ui/react-grid2/ +import Grid from '@mui/material/Unstable_Grid2' import {useQuery} from '@tanstack/react-query' import axios from 'axios' -import {FC} from 'react' +import {FC, useState} from 'react' import {Loading} from '../Loading/Loading' import {IPost, Post} from './Post' +import {PostDetail} from './PostDetail' export const Posts: FC = () => { const { @@ -17,15 +20,46 @@ export const Posts: FC = () => { }) const posts = postsData?.data ?? [] + const [activePostDetailIndex, setActivePostDetailIndex] = useState() + if (postsIsLoading) return if (postsError) return {postsError.message} return ( - - {posts.map((post) => ( - - ))} - + <> + {/* detail prispevku chceme zobrazit na urovni toho prispevku - `activePostDetailIndex` teda rozdeluje prispevky na dva gridy: + - prvy grid su vsetky prispevky do rozbaleneho prispevku - len jeden grid item ako jeden stlpec prispevkov (`xs={4}` ako 4 stlpce z 12) + - druhy grid su prispevky od rozbaleneho prispevku - dva grid itemy ako jeden stlpec prispevkov (`xs={4}`) a druhy stlpec ako detail prispevku (`xs={5}` - detail je sirsi) */} + {activePostDetailIndex !== 0 && ( + + + + {posts.slice(0, activePostDetailIndex).map((post, index) => ( + setActivePostDetailIndex(index)} /> + ))} + + + + )} + {activePostDetailIndex !== undefined && ( + + + + {posts.slice(activePostDetailIndex).map((post, index) => ( + setActivePostDetailIndex(activePostDetailIndex + index)} + /> + ))} + + + + + + + )} + ) } diff --git a/src/components/Problems/Problems.module.scss b/src/components/Problems/Problems.module.scss index d7e9214c..ea3fb9dc 100644 --- a/src/components/Problems/Problems.module.scss +++ b/src/components/Problems/Problems.module.scss @@ -8,9 +8,7 @@ .sideContainer { margin: 1rem 0px; height: auto; - display: grid; - grid-template-rows: auto 1fr; - + position: fixed; top: 12rem; bottom: 2rem; diff --git a/src/components/StaticSites/Markdown.tsx b/src/components/StaticSites/Markdown.tsx index 43c57d26..67b7b426 100644 --- a/src/components/StaticSites/Markdown.tsx +++ b/src/components/StaticSites/Markdown.tsx @@ -6,7 +6,7 @@ import rehypeKatex from 'rehype-katex' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' -import {H1, H2, H3, Li, MarkdownLink, Ol, P, Table, Td, Th} from './Texts' +import {H1, H2, H3, MarkdownLink, Ol, P, Table, Td, Th, Ul} from './Texts' type MarkdownProps = { content: string @@ -25,8 +25,11 @@ export const Markdown: FC = ({content}) => ( h1: H1, h2: H2, h3: H3, + h4: H3, + h5: H3, + h6: H3, ol: Ol, - li: Li, + ul: Ul, }} > {content} diff --git a/src/components/StaticSites/Texts.tsx b/src/components/StaticSites/Texts.tsx index 2878e764..7910403c 100644 --- a/src/components/StaticSites/Texts.tsx +++ b/src/components/StaticSites/Texts.tsx @@ -2,11 +2,11 @@ import {Typography} from '@mui/material' import {FC, ReactNode} from 'react' import { HeadingProps, - LiProps, OrderedListProps, ReactMarkdownProps, TableDataCellProps, TableHeaderCellProps, + UnorderedListProps, } from 'react-markdown/lib/ast-to-react' import {Link} from '../Clickable/Link' @@ -45,8 +45,8 @@ export const Ol: FC = ({children}) => ( ) -export const Li: FC = ({children}) => ( - +export const Ul: FC = ({children}) => ( + {children} ) @@ -58,19 +58,19 @@ export const P: FC = ({children}) => ( ) export const H1: FC = ({children}) => ( - + {children} ) export const H2: FC = ({children}) => ( - + {children} ) export const H3: FC = ({children}) => ( - + {children} ) diff --git a/src/pages/malynar/index.tsx b/src/pages/malynar/index.tsx index 286b5f7e..c381ff30 100644 --- a/src/pages/malynar/index.tsx +++ b/src/pages/malynar/index.tsx @@ -1,12 +1,9 @@ import {NextPage} from 'next' -import {PageLayout} from '@/components/PageLayout/PageLayout' -import {Posts} from '@/components/Posts/Posts' +import Page from '../strom/index' -const Malynar: NextPage = () => ( - - - -) +const Malynar: NextPage = () => { + return +} export default Malynar diff --git a/src/pages/matik/index.tsx b/src/pages/matik/index.tsx index 7715ecc2..f34a7baf 100644 --- a/src/pages/matik/index.tsx +++ b/src/pages/matik/index.tsx @@ -1,12 +1,9 @@ import {NextPage} from 'next' -import {PageLayout} from '@/components/PageLayout/PageLayout' -import {Posts} from '@/components/Posts/Posts' +import Page from '../strom/index' -const Matik: NextPage = () => ( - - - -) +const Matik: NextPage = () => { + return +} export default Matik diff --git a/src/pages/strom/index.tsx b/src/pages/strom/index.tsx index 52345e36..6fbf0eeb 100644 --- a/src/pages/strom/index.tsx +++ b/src/pages/strom/index.tsx @@ -4,7 +4,7 @@ import {PageLayout} from '@/components/PageLayout/PageLayout' import {Posts} from '@/components/Posts/Posts' const Strom: NextPage = () => ( - + ) diff --git a/src/theme.ts b/src/theme.ts index 6c344996..107ec214 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -66,7 +66,7 @@ const _theme = createTheme({ button1: 'span', button2: 'span', button3: 'span', - postTitle: 'span', + postTitle: 'h1', postBody: 'span', }, },