From 8dd23360d63448736b42ca0a63fd23d54034fd9e Mon Sep 17 00:00:00 2001 From: anthony-mini Date: Tue, 6 Dec 2022 23:31:15 +0100 Subject: [PATCH] Working on Collapse function on About page --- src/components/Collapse/_collapse.scss | 70 +++++++++++--------------- src/components/Collapse/index.jsx | 19 ++++--- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/components/Collapse/_collapse.scss b/src/components/Collapse/_collapse.scss index d17e025..38796b3 100644 --- a/src/components/Collapse/_collapse.scss +++ b/src/components/Collapse/_collapse.scss @@ -1,53 +1,41 @@ -.collapse{ +.collapsible { + display: flex; flex-direction: column; align-items: center; - - &__content{ - - margin-bottom: 20px; - background-color: $grey-background-color; - border-radius: 5px; - width: 100%; - max-width: 1023px; - height: auto; - - div{ - position: relative; + margin-bottom: 20px; + + &__header{ background-color: $salmon-color; + padding: 6px; + cursor: pointer; border-radius: 5px; width: 100%; height: 30px; + position: relative; - h2{ - @include typographie-collapse-title; - margin: 5.5px 0px 5.46px 11.51px; - position: absolute; - bottom: 0; - left: 0; - } - - img{ - width: 18.46px; - height: 19.37px; - position: absolute; - bottom: 0; - right: 0; - margin: 5.77px 5.19px 5.77px 0px; - - img > .rotate{ - transform: rotate(180deg); - } - } + h2{ + @include typographie-collapse-title; } - p{ - @include typographie-collapse-description; - padding: 17.31px 11.5px 53px 11.5px; + .fa-solid, .fas{ + color: white; + position: absolute; + bottom: 5.77px; + right: 5.18px; + } + } - @media screen and (min-width: map-get($breakpoint, laptop)) { - padding-bottom: 10px; - } - } + &__content { + background-color: $grey-background-color; + @include typographie-collapse-description; + padding: 17.31px 11.5px 53px 11.5px; + border-radius: 0 0 5px 5px; + @media screen and (min-width: map-get($breakpoint, laptop)) { + padding-bottom: 10px; + } + } -} \ No newline at end of file +} + + \ No newline at end of file diff --git a/src/components/Collapse/index.jsx b/src/components/Collapse/index.jsx index 471cf06..94c457f 100644 --- a/src/components/Collapse/index.jsx +++ b/src/components/Collapse/index.jsx @@ -1,13 +1,20 @@ -import Arrow from '../../assets/collapse-arrow.svg'; +import useCollapse from 'react-collapsed'; -export default function Collapse({ title, description }) { +// https://www.npmjs.com/package/react-collapsed + +export default function Collapsible({ title, description }) { + const { getCollapseProps, getToggleProps, isExpanded } = useCollapse(); return ( -
-
+
+

{title}

- arrow-icone +
+ +
+
+
+

{description}

-

{description}

); }