-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-11281] Implemented new Accordion component
- Loading branch information
Showing
7 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/slate-editor/src/components/Accordion/Accordion.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@import "styles/variables"; | ||
@import "styles/helpers"; | ||
|
||
.Accordion { | ||
border-top: 1px solid rgba($color: $white, $alpha: 0.12); | ||
} | ||
|
||
.button { | ||
@include btn-unstyled; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
padding: $spacing-2; | ||
color: $grey-300; | ||
font-size: $font-size-small; | ||
font-weight: 600; | ||
} | ||
|
||
.content { | ||
display: none; | ||
padding: 0 $spacing-2 $spacing-2; | ||
|
||
&.open { | ||
display: block; | ||
} | ||
} | ||
|
||
.icon { | ||
fill: $white; | ||
transition: transform 0.3s ease-in; | ||
|
||
&.open { | ||
transform: rotate(180deg); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/slate-editor/src/components/Accordion/Accordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import classNames from 'classnames'; | ||
import React, { useState, type ReactNode } from 'react'; | ||
|
||
import { Caret } from '#icons'; | ||
|
||
import styles from './Accordion.module.scss'; | ||
|
||
interface Props { | ||
title: string; | ||
children: ReactNode; | ||
} | ||
|
||
export function Accordion({ title, children }: Props) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
function toggleOpen() { | ||
setIsOpen(!isOpen); | ||
} | ||
|
||
return ( | ||
<div className={styles.Accordion}> | ||
<button className={styles.button} onClick={toggleOpen}> | ||
<span>{title}</span> | ||
{ | ||
<Caret | ||
className={classNames(styles.icon, { | ||
[styles.open]: isOpen, | ||
})} | ||
/> | ||
} | ||
</button> | ||
<div | ||
className={classNames(styles.content, { | ||
[styles.open]: isOpen, | ||
})} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Accordion } from './Accordion'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters