From e679765da907168e6bf204f492472e0c6f78af4b Mon Sep 17 00:00:00 2001 From: amirhouieh Date: Mon, 15 May 2023 15:39:24 +0200 Subject: [PATCH] resolve conflicts --- src/components/Article/Article.Body.tsx | 14 ++---- src/components/Article/Article.Heading.tsx | 15 ++++-- src/components/Article/Article.MobileToc.tsx | 8 ++- src/components/Article/Article.Stats.tsx | 30 ++++++------ src/components/Article/Article.module.css | 8 ++- .../Article/Footer/Article.Footer.tsx | 7 ++- .../Article/Header/Article.Header.tsx | 24 +++++++-- .../Article/Header/Article.Summary.tsx | 49 +++++++++++++++++-- .../ArticleReference/ArticleReference.tsx | 2 +- src/components/Authors/Authors.tsx | 19 +++++-- src/components/Collapse/Collapse.tsx | 5 +- .../TableOfContents/TableOfContents.tsx | 23 ++++++--- src/configs/ui.configs.ts | 1 + src/containers/ArticleContainer.tsx | 3 +- src/pages/_app.tsx | 3 ++ 15 files changed, 154 insertions(+), 57 deletions(-) diff --git a/src/components/Article/Article.Body.tsx b/src/components/Article/Article.Body.tsx index 190c2ea..003f2e1 100644 --- a/src/components/Article/Article.Body.tsx +++ b/src/components/Article/Article.Body.tsx @@ -37,14 +37,11 @@ export default function ArticleBody({ data }: Props) { return ( {resultsNumber === null && } - {resultsNumber === null && } - - {/*@ts-ignore*/} - - {resultsNumber === 0 && ( - No results found - )} - + {/*@ts-ignore*/} + + {resultsNumber === 0 && ( + No results found + )} ) @@ -69,6 +66,5 @@ const TextContainer = styled.div` display: flex; flex-direction: column; gap: 16px; - margin-top: 24px; margin-bottom: 80px; ` diff --git a/src/components/Article/Article.Heading.tsx b/src/components/Article/Article.Heading.tsx index 1a0ba38..f42bf85 100644 --- a/src/components/Article/Article.Heading.tsx +++ b/src/components/Article/Article.Heading.tsx @@ -33,7 +33,7 @@ export const ArticleHeading = ({ { const { tocId } = useArticleContainerContext() return toc?.length > 0 ? ( - + {toc.map((toc, idx) => ( { active={tocId ? toc.href.substring(1) === tocId : idx === 0} > - {toc.title} + {(tocId ? toc.href.substring(1) === tocId : idx === 0) + ? `☞ ${toc.title} ☜` + : toc.title} ))} @@ -39,6 +41,8 @@ const CustomTypography = styled(Typography)` const TocItem = styled(Link)<{ active: boolean }>` padding: 8px 14px; + text-decoration: none; + background-color: ${(p) => p.active ? 'rgb(var(--lsd-theme-primary))' diff --git a/src/components/Article/Article.Stats.tsx b/src/components/Article/Article.Stats.tsx index 830036d..99ff506 100644 --- a/src/components/Article/Article.Stats.tsx +++ b/src/components/Article/Article.Stats.tsx @@ -8,21 +8,19 @@ const ArticleStats = ({ dateStr: string readingLength: number }) => ( -
- - - {readingLength} minutes read - - - - {new Date(dateStr).toLocaleString('en-GB', { - day: 'numeric', - month: 'long', // TODO: Should be uppercase - year: 'numeric', - })} - - -
+ + + {readingLength} minutes read + + + + {new Date(dateStr).toLocaleString('en-GB', { + day: 'numeric', + month: 'long', // TODO: Should be uppercase + year: 'numeric', + })} + + ) const Row = styled.div` @@ -30,7 +28,7 @@ const Row = styled.div` flex-direction: row; align-items: center; gap: 8px; - margin-bottom: 8px; + margin-bottom: 12px; ` export default ArticleStats diff --git a/src/components/Article/Article.module.css b/src/components/Article/Article.module.css index 3ab7663..da47378 100644 --- a/src/components/Article/Article.module.css +++ b/src/components/Article/Article.module.css @@ -1,5 +1,9 @@ -/* temporary breakpoint */ -@media (min-width: 1024px) { +.mobileToc{ + /*margin-block: 32px;*/ + margin-bottom: -2px; +} + +@media (min-width: 768px){ .mobileToc { display: none !important; } diff --git a/src/components/Article/Footer/Article.Footer.tsx b/src/components/Article/Footer/Article.Footer.tsx index bdfba13..e3db46e 100644 --- a/src/components/Article/Footer/Article.Footer.tsx +++ b/src/components/Article/Footer/Article.Footer.tsx @@ -31,11 +31,14 @@ const ArticleFooter = ({ data }: { data: ArticlePostData }) => { const ArticleFooterContainer = styled.div` margin-top: 16px; - + & > div:not(:first-child) > div > button, & > div:not(:first-child) > div { border-top: none; } -` + @media (max-width: 768px) { + margin-top: 72px; + } +` export default ArticleFooter diff --git a/src/components/Article/Header/Article.Header.tsx b/src/components/Article/Header/Article.Header.tsx index e051e58..0995b8e 100644 --- a/src/components/Article/Header/Article.Header.tsx +++ b/src/components/Article/Header/Article.Header.tsx @@ -1,12 +1,12 @@ import { GoogleDocEnhanced } from '@/lib/unbody/unbody.types' import { getArticleCover } from '@/utils/data.utils' -import { useMemo } from 'react' +import React, { useMemo } from 'react' import { ArticleImageBlockWrapper } from '../Article.ImageBlockWrapper' import { PostImageRatio } from '../../Post/Post' import ArticleStats from '../Article.Stats' import { Typography } from '@acid-info/lsd-react' import styled from '@emotion/styled' -import ArticleSummary from './Article.Summary' +import ArticleSummary, { MobileSummary } from './Article.Summary' import { calcReadingTime } from '@/utils/string.utils' import { Authors } from '@/components/Authors' import { Tags } from '@/components/Tags' @@ -14,6 +14,8 @@ import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types' import { ArticleHeading } from '@/components/Article/Article.Heading' import { useArticleContainerContext } from '@/containers/ArticleContainer.Context' import { useIntersectionObserver } from '@/utils/ui.utils' +import { MobileToc } from '@/components/Article/Article.MobileToc' +import { useSearchBarContext } from '@/context/searchbar.context' const ArticleHeader = ({ title, @@ -27,6 +29,7 @@ const ArticleHeader = ({ }: GoogleDocEnhanced) => { const { setTocId, tocId } = useArticleContainerContext() const headingElementsRef = useIntersectionObserver(setTocId) + const { resultsNumber } = useSearchBarContext() const _thumbnail = useMemo(() => { const coverImage = getArticleCover(blocks) @@ -63,6 +66,7 @@ const ArticleHeader = ({ variant: 'h1', genericFontFamily: 'serif', component: 'h1', + style: { marginBottom: '16px' }, }} headingElementsRef={headingElementsRef} /> @@ -77,14 +81,22 @@ const ArticleHeader = ({ )} - + + + {resultsNumber === null && } + {resultsNumber === null && } + {_thumbnail} - + {/**/} ) } +const MobileCollapseContainer = styled.div` + margin-bottom: 32px; +` + const CustomTypography = styled(Typography)` text-overflow: ellipsis; word-break: break-word; @@ -100,7 +112,9 @@ const ArticleSubtitle = styled(CustomTypography)` ` const AuthorsContainer = styled.div` - margin-block: 24px; + //margin-block: 24px; + margin-top: 24px; + margin-bottom: 32px; ` export default ArticleHeader diff --git a/src/components/Article/Header/Article.Summary.tsx b/src/components/Article/Header/Article.Summary.tsx index 09709a7..749bfae 100644 --- a/src/components/Article/Header/Article.Summary.tsx +++ b/src/components/Article/Header/Article.Summary.tsx @@ -1,16 +1,57 @@ -import { Quote } from '@acid-info/lsd-react' +import { Typography } from '@acid-info/lsd-react' import styled from '@emotion/styled' +import React from 'react' +import { Collapse } from '@/components/Collapse' +import useIsDarkState from '@/states/isDarkState/isDarkState' + +export const MobileSummary = ({ summary }: { summary: string }) => { + const isDark = useIsDarkState().get() + return ( + + + {summary} + + + ) +} const ArticleSummary = ({ summary }: { summary: string }) => ( - //TODO for ihor to work out the design for this - {summary} + summary + + {summary} + +
) const ArticleSummaryContainer = styled('div')` - padding-left: 40px; + margin-block: 16px; + + > span { + margin-bottom: 16px; + display: block; + } +` + +const SummaryParagraph = styled(Typography)` margin-bottom: 32px; + display: block; +` + +const SummaryContainerMobile = styled(Collapse)` + @media (max-width: 770px) { + p { + padding: 12px 14px; + margin-bottom: 0; + font-size: var(--lsd-font-size-body2); + line-height: var(--lsd-line-height-body2); + } + } ` export default ArticleSummary diff --git a/src/components/ArticleReference/ArticleReference.tsx b/src/components/ArticleReference/ArticleReference.tsx index a94f4e4..a0834ad 100644 --- a/src/components/ArticleReference/ArticleReference.tsx +++ b/src/components/ArticleReference/ArticleReference.tsx @@ -46,7 +46,7 @@ export default function ArticleReference({ const Container = styled.div` display: flex; flex-direction: column; - padding: 8px 14px; + padding: 12px 14px; border-bottom: 1px solid rgb(var(--lsd-border-primary)); text-decoration: none; diff --git a/src/components/Authors/Authors.tsx b/src/components/Authors/Authors.tsx index bc1145b..6ab6e8f 100644 --- a/src/components/Authors/Authors.tsx +++ b/src/components/Authors/Authors.tsx @@ -1,6 +1,7 @@ import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types' import Author from './Author' import styled from '@emotion/styled' +import { Typography } from '@acid-info/lsd-react' export enum AuthorsDirection { COLUMN = 'column', @@ -20,9 +21,16 @@ const Authors = ({ }) => { return mentions?.length > 0 ? ( - {mentions.map((mention) => ( - - ))} + {mentions.map((mention, index) => + index < mentions.length - 1 ? ( + <> + + . + + ) : ( + + ), + )} ) : null } @@ -46,4 +54,9 @@ const AuthorsContainer = styled.div<{ } */ ` +const Dot = styled(Typography)` + transform: translateY(1px); + font-size: 18px; +` + export default Authors diff --git a/src/components/Collapse/Collapse.tsx b/src/components/Collapse/Collapse.tsx index 81cd917..a0cfef2 100644 --- a/src/components/Collapse/Collapse.tsx +++ b/src/components/Collapse/Collapse.tsx @@ -8,6 +8,8 @@ type Props = { children: React.ReactNode className?: string onClick?: () => void + initOpen?: boolean + style?: React.CSSProperties } export default function Collapse({ @@ -15,9 +17,10 @@ export default function Collapse({ children, className, onClick, + initOpen = true, ...props }: Props) { - const [open, setOpen] = useState(true) + const [open, setOpen] = useState(initOpen) const handleClick = (e: React.MouseEvent) => { e.stopPropagation() diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index 920744c..0996b20 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -15,7 +15,7 @@ type Props = { export default function TableOfContents({ contents, ...props }: Props) { const { tocId, setTocId } = useArticleContainerContext() - const dy = uiConfigs.navbarRenderedHeight + uiConfigs.postSectionMargin + const dy = uiConfigs.navbarRenderedHeight + 2 * uiConfigs.articleSectionMargin const { resultsNumber } = useSearchBarContext() const router = useRouter() @@ -46,13 +46,16 @@ export default function TableOfContents({ contents, ...props }: Props) { sticky ? 'sticky' : '' }`} > - Contents + + Contents + {contents?.map((content, index) => ( {content.title} @@ -67,13 +70,10 @@ export default function TableOfContents({ contents, ...props }: Props) { const Container = styled.aside<{ dy: number; height: number }>` display: flex; flex-wrap: wrap; - flex-direction: column; - width: 162px; + flex-direction: row; box-sizing: border-box; - /* height: ${(p) => (p.height > 0 ? `${p.height}px` : 'fit-content')}; */ position: sticky; top: ${(p) => `${p.dy}px`}; - margin-left: 16px; padding-bottom: 72px; transition: opacity 0.3s ease-in-out; @@ -96,6 +96,7 @@ const Contents = styled.div<{ height: number }>` display: flex; flex-direction: column; overflow-y: auto; + height: calc( 100vh - ${uiConfigs.navbarRenderedHeight + uiConfigs.postSectionMargin + 40}px @@ -108,7 +109,7 @@ const Contents = styled.div<{ height: number }>` const TocItem = styled(Link)<{ active: boolean }>` display: flex; - padding: 8px 0 8px 12px; + padding: 4px 16px 4px 16px; text-decoration: none; border-left: ${(p) => p.active @@ -119,4 +120,12 @@ const TocItem = styled(Link)<{ active: boolean }>` label { cursor: pointer; } + + &.level-1 { + } + &.level-2 { + } + &.level-3 { + text-indent: 16px; + } ` diff --git a/src/configs/ui.configs.ts b/src/configs/ui.configs.ts index c6fed50..71e5e85 100644 --- a/src/configs/ui.configs.ts +++ b/src/configs/ui.configs.ts @@ -2,6 +2,7 @@ export const uiConfigs = { navbarRenderedHeight: 45, postSectionMargin: 108, postSectionMobileMargin: 78, + articleSectionMargin: 40, maxContainerWidth: 1400, articleRenderedMT: 45 * 2, } diff --git a/src/containers/ArticleContainer.tsx b/src/containers/ArticleContainer.tsx index 3af00c3..88094a0 100644 --- a/src/containers/ArticleContainer.tsx +++ b/src/containers/ArticleContainer.tsx @@ -22,8 +22,7 @@ const ArticleContainer = (props: Props) => { width: '100%', }} > - - + diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index c1916fa..ee764c6 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -48,6 +48,9 @@ export default function App({ Component, pageProps }: AppLayoutProps) { margin: 0; width: 100%; height: 100%; + + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } #__next {