generated from abelflopes/lerna-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add collapse & list components
- Loading branch information
1 parent
566342f
commit f3701be
Showing
5 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
import styles from "./styles/index.module.scss"; | ||
|
||
export interface CollapseProps extends React.DetailsHTMLAttributes<HTMLDetailsElement> { | ||
header: NonNullable<React.ReactNode>; | ||
} | ||
|
||
export const Collapse = ({ | ||
header, | ||
children, | ||
className, | ||
...otherProps | ||
}: Readonly<CollapseProps>): React.ReactElement => ( | ||
<details {...otherProps}> | ||
<summary className={styles.header}>{header}</summary> | ||
{children} | ||
</details> | ||
); |
4 changes: 4 additions & 0 deletions
4
packages/components/all/src/collapse/styles/index.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,4 @@ | ||
.header { | ||
appearance: auto; | ||
cursor: pointer; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
import styles from "./styles/index.module.scss"; | ||
import classNames from "classnames"; | ||
|
||
export interface ListProps extends Omit<React.HTMLAttributes<HTMLUListElement>, "children"> { | ||
skin?: "bordered"; | ||
items: React.ReactNode[]; | ||
} | ||
|
||
export const List = ({ | ||
skin, | ||
items, | ||
className, | ||
...otherProps | ||
}: Readonly<ListProps>): React.ReactElement => ( | ||
<ul className={classNames(styles.root, skin && styles[skin], className)} {...otherProps}> | ||
{items.map((item, key) => ( | ||
<li key={`${item?.toString()}-${key.toString()}`} className={styles.item}> | ||
{item} | ||
</li> | ||
))} | ||
</ul> | ||
); |
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,24 @@ | ||
@import "@rck/theme"; | ||
|
||
.root { | ||
--border-color: transparent; | ||
|
||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
border: solid 1px var(--border-color); | ||
border-radius: get-spacing(2); | ||
overflow: hidden; | ||
} | ||
|
||
.item { | ||
padding: get-spacing(2); | ||
|
||
&:not(:first-child) { | ||
border-top: solid 1px var(--border-color); | ||
} | ||
} | ||
|
||
.bordered { | ||
--border-color: #{get-color(neutral100)}; | ||
} |