Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Add section component #53

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions components/Section/Section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Section Component

Section component can be used to wrap content to apply padding and background color.

## Props List

| Name | Type | Optional |
| --------------- | --------- | -------- |
| className | string | ✔ |
| p | string | ✔ |
| px | string | ✔ |
| py | string | ✔ |
| pt | string | ✔ |
| pb | string | ✔ |
| pl | string | ✔ |
| pr | string | ✔ |
| backgroundColor | string | ✔ |
| children | ReactNode | ✖ |

## Usage

```tsx
<Section px="0.5rem" py="1rem" backgroundColor="red">
```

- For paddings you need to specify the unit. (i.e. `rem`, `em` or `px`)
- `backgroundColor` can take anything that is valid for css. (i.e. `red`, `#000`, `rgb(0, 0, 0)`)
- `pb` and `pt` will override `py`
- `pl` and `pr` will override `px`
33 changes: 33 additions & 0 deletions components/Section/Section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ReactNode } from 'react'

interface Props {
className?: string
p?: string
px?: string
wralith marked this conversation as resolved.
Show resolved Hide resolved
py?: string
pt?: string
pb?: string
pl?: string
pr?: string
backgroundColor?: string
wralith marked this conversation as resolved.
Show resolved Hide resolved
children: ReactNode
}

const Section = (props: Props) => {
return (
<section
style={{
wralith marked this conversation as resolved.
Show resolved Hide resolved
backgroundColor: props.backgroundColor,
padding: props.p,
paddingLeft: props.pl || props.px,
paddingRight: props.pl || props.px,
paddingTop: props.pt || props.py,
paddingBottom: props.pb || props.py,
}}
className={props.className}>
{props.children}
</section>
)
}

export default Section