-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63d9c03
commit 516477b
Showing
5 changed files
with
190 additions
and
64 deletions.
There are no files selected for viewing
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
80 changes: 80 additions & 0 deletions
80
apps/site/src/lib/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,80 @@ | ||
.root { | ||
color: black; | ||
} | ||
|
||
.item { | ||
border-bottom: 2px #36352f solid; | ||
} | ||
|
||
.trigger { | ||
width: 100%; | ||
padding: 20px 0; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: #fff; | ||
|
||
font-size: 24px; | ||
font-weight: 700; | ||
line-height: 150%; /* 36px */ | ||
|
||
.icons { | ||
$icon-size: 24px; | ||
|
||
position: relative; | ||
width: $icon-size; | ||
height: $icon-size; | ||
|
||
& > * { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: $icon-size; | ||
height: $icon-size; | ||
opacity: 0; | ||
} | ||
} | ||
|
||
&[data-state="closed"] .plusIcon { | ||
opacity: 1; | ||
} | ||
&[data-state="open"] .minusIcon { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.content { | ||
font-size: 20px; | ||
font-weight: 500; | ||
line-height: 125%; | ||
overflow: hidden; | ||
|
||
.contentPadding { | ||
padding-bottom: 24px; | ||
} | ||
|
||
@keyframes slideDown { | ||
from { | ||
height: 0; | ||
} | ||
to { | ||
height: var(--radix-accordion-content-height); | ||
} | ||
} | ||
|
||
@keyframes slideUp { | ||
from { | ||
height: var(--radix-accordion-content-height); | ||
} | ||
to { | ||
height: 0; | ||
} | ||
} | ||
|
||
&[data-state="open"] { | ||
animation: slideDown 300ms cubic-bezier(0.87, 0, 0.13, 1); | ||
} | ||
&[data-state="closed"] { | ||
animation: slideUp 300ms cubic-bezier(0.87, 0, 0.13, 1); | ||
} | ||
} |
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,70 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import * as RadixAccordion from "@radix-ui/react-accordion"; | ||
import { Plus, Minus } from "lucide-react"; | ||
import clsx from "clsx"; | ||
|
||
import styles from "./Accordion.module.scss"; | ||
|
||
export const Root = React.forwardRef< | ||
React.ElementRef<typeof RadixAccordion.Root>, | ||
React.ComponentPropsWithoutRef<typeof RadixAccordion.Root> | ||
>(({ children, className, ...props }, forwardedRef) => ( | ||
<RadixAccordion.Root | ||
className={clsx(styles.root, className)} | ||
{...props} | ||
ref={forwardedRef} | ||
> | ||
{children} | ||
</RadixAccordion.Root> | ||
)); | ||
Root.displayName = RadixAccordion.Root.displayName; | ||
|
||
export const Item = React.forwardRef< | ||
React.ElementRef<typeof RadixAccordion.Item>, | ||
React.ComponentPropsWithoutRef<typeof RadixAccordion.Item> | ||
>(({ children, className, ...props }, forwardedRef) => ( | ||
<RadixAccordion.Item | ||
className={clsx(styles.item, className)} | ||
{...props} | ||
ref={forwardedRef} | ||
> | ||
{children} | ||
</RadixAccordion.Item> | ||
)); | ||
Item.displayName = RadixAccordion.Item.displayName; | ||
|
||
export const Trigger = React.forwardRef< | ||
React.ElementRef<typeof RadixAccordion.Trigger>, | ||
React.ComponentPropsWithoutRef<typeof RadixAccordion.Trigger> | ||
>(({ children, className, ...props }, forwardedRef) => ( | ||
<RadixAccordion.Header> | ||
<RadixAccordion.Trigger | ||
className={clsx(styles.trigger, className)} | ||
{...props} | ||
ref={forwardedRef} | ||
> | ||
{children} | ||
<div className={styles.icons}> | ||
<Plus size={24} className={styles.plusIcon} aria-hidden /> | ||
<Minus size={24} className={styles.minusIcon} aria-hidden /> | ||
</div> | ||
</RadixAccordion.Trigger> | ||
</RadixAccordion.Header> | ||
)); | ||
Trigger.displayName = "AccordionTrigger"; | ||
|
||
export const Content = React.forwardRef< | ||
React.ElementRef<typeof RadixAccordion.Content>, | ||
React.ComponentPropsWithoutRef<typeof RadixAccordion.Content> | ||
>(({ children, className, ...props }, forwardedRef) => ( | ||
<RadixAccordion.Content | ||
className={clsx(styles.content, className)} | ||
{...props} | ||
ref={forwardedRef} | ||
> | ||
<div className={styles.contentPadding}>{children}</div> | ||
</RadixAccordion.Content> | ||
)); | ||
Content.displayName = RadixAccordion.Content.displayName; |
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 { Root, Item, Trigger, Content } from "./Accordion"; |
Oops, something went wrong.