1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 11:34:21 +00:00

Add regular lists

This commit is contained in:
Steffo 2021-08-18 16:30:30 +02:00
parent 7aa7f0b46c
commit 38a5eb7d10
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 70 additions and 0 deletions

View 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,
}

View 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}/>
)
}