mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-23 03:54:21 +00:00
✨ Add regular lists
This commit is contained in:
parent
7aa7f0b46c
commit
38a5eb7d10
2 changed files with 70 additions and 0 deletions
34
src/components/lists/List.stories.jsx
Normal file
34
src/components/lists/List.stories.jsx
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ReactDOM from "react-dom"
|
||||||
|
import * as Decorators from "../../utils/Decorators"
|
||||||
|
import { List } from "./List"
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
component: List,
|
||||||
|
title: "Lists/List",
|
||||||
|
decorators: [Decorators.Bluelib],
|
||||||
|
argTypes: {
|
||||||
|
customColor: {
|
||||||
|
control: {type: "color"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const Unordered = props => (
|
||||||
|
<List {...props}>
|
||||||
|
<List.Item>Io</List.Item>
|
||||||
|
<List.Item>Gyrocopter</List.Item>
|
||||||
|
<List.Item>Chaos Knight</List.Item>
|
||||||
|
</List>
|
||||||
|
)
|
||||||
|
Unordered.args = {
|
||||||
|
ordered: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const Ordered = Unordered.bind({})
|
||||||
|
Ordered.args = {
|
||||||
|
ordered: true,
|
||||||
|
}
|
36
src/components/lists/List.tsx
Normal file
36
src/components/lists/List.tsx
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ReactDOM from "react-dom"
|
||||||
|
import * as Types from "../../types"
|
||||||
|
import {BaseElement} from "../BaseElement"
|
||||||
|
import mergeClassNames from "classnames"
|
||||||
|
|
||||||
|
|
||||||
|
interface ListProps {
|
||||||
|
ordered: boolean,
|
||||||
|
|
||||||
|
[props: string]: any,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function List({ordered, ...props}: ListProps): JSX.Element {
|
||||||
|
|
||||||
|
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "list", ordered ? "list-ordered" : "list-unordered")
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseElement kind={ordered ? "ol" : "ul"} {...props}/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface ListItemProps {
|
||||||
|
[props: string]: any,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List.Item = function({...props}: ListItemProps): JSX.Element {
|
||||||
|
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "list-item")
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseElement kind={"li"} {...props}/>
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue