Skip to content

Commit

Permalink
Working on Collapse function on About page
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-mini committed Dec 6, 2022
1 parent 9ee7fea commit 8dd2336
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 47 deletions.
70 changes: 29 additions & 41 deletions src/components/Collapse/_collapse.scss
Original file line number Diff line number Diff line change
@@ -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;
}

}
}
}


19 changes: 13 additions & 6 deletions src/components/Collapse/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<article className="collapse__content">
<div>
<article className="collapsible">
<div className="collapsible__header" {...getToggleProps()}>
<h2>{title}</h2>
<img className='rotate' src={Arrow} alt="arrow-icone" />
<div className="icon">
<i className={'fas fa-chevron-' + (isExpanded ? 'up' : 'down')}></i>
</div>
</div>
<div {...getCollapseProps()}>
<p className="collapsible__content">{description}</p>
</div>
<p>{description}</p>
</article>
);
}

0 comments on commit 8dd2336

Please sign in to comment.