From 42493c2e982a3efd0ac8ae62b43eb3f9d570891b Mon Sep 17 00:00:00 2001 From: kvakazyambra Date: Wed, 20 Sep 2023 23:57:44 +0300 Subject: [PATCH] Table of contents mobile style --- src/components/Article/FullArticle.tsx | 2 +- .../TableOfContents.module.scss | 74 +++++++++++++-- .../TableOfContents/TableOfContents.tsx | 90 +++++++++++++------ 3 files changed, 133 insertions(+), 33 deletions(-) diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index a4545dc2..a2d03729 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -297,7 +297,7 @@ export const FullArticle = (props: Props) => { - +
diff --git a/src/components/TableOfContents/TableOfContents.module.scss b/src/components/TableOfContents/TableOfContents.module.scss index 501bae9f..a743a105 100644 --- a/src/components/TableOfContents/TableOfContents.module.scss +++ b/src/components/TableOfContents/TableOfContents.module.scss @@ -1,7 +1,38 @@ .TableOfContentsFixedWrapper { min-height: 100%; + position: relative; top: 0; + @include media-breakpoint-down(xl) { + background: #000; + bottom: 0; + color: #fff; + font-size: 1.6rem; + left: 0; + min-height: auto; + max-height: 50vh; + position: fixed; + top: auto; + width: 100%; + + .TableOfContentsHeading { + text-transform: capitalize; + } + + .TableOfContentsHeading, + button { + &, + &:hover { + color: #fff; + } + } + + .TableOfContentsHeadingsItem { + font-size: 1.6rem; + margin-top: 1.6rem; + } + } + &:not(.TableOfContentsFixedWrapperLefted) { margin-top: -0.2em; @@ -32,19 +63,31 @@ } .TableOfContentsContainer { - position: sticky; top: 100px; right: 20px; display: flex; width: 100%; - height: calc(100vh - 120px); overflow: auto; - flex-direction: column; align-items: flex-start; background-color: transparent; - .TableOfContentsFixedWrapperLefted & { - height: calc(100vh - 250px); + @include media-breakpoint-up(xl) { + flex-direction: column; + height: calc(100vh - 120px); + position: sticky; + + .TableOfContentsFixedWrapperLefted & { + height: calc(100vh - 250px); + } + } +} + +.TableOfContentsContainerInner { + @include media-breakpoint-down(xl) { + flex: 1 100%; + max-height: 50vh; + overflow: auto; + padding: 1.4rem 2rem; } } @@ -74,11 +117,31 @@ border: none; cursor: pointer; + @include media-breakpoint-down(xl) { + background: #fff; + border: 1px solid #000; + border-radius: 100%; + bottom: 1rem; + height: 40px; + position: fixed; + right: 1rem; + top: auto; + width: 40px; + } + &:hover { filter: invert(1); } } +.TableOfContentsCloseButton { + height: 2.4rem; + position: absolute; + top: 1.4rem; + right: 1.4rem; + width: 2.4rem; +} + .TableOfContentsHeadingsList { position: relative; display: flex; @@ -97,7 +160,6 @@ font-weight: 400; line-height: 20px; text-align: left; - letter-spacing: -0.14px; &:hover { color: rgb(0 0 0 / 50%); diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index 97807d14..8761700a 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -68,42 +68,48 @@ export const TableOfContents = (props: Props) => { >
-
-

{t('contents')}

-
-
    - - {(h) => ( -
  • -
  • - )} -
    -
+ scrollToHeader(h) + }} + /> + + )} + + +
+ + + + + + + +
)