From 38a5eb7d10acc580a70707209721f81db98d7b12 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 18 Aug 2021 16:30:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20regular=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/lists/List.stories.jsx | 34 +++++++++++++++++++++++++ src/components/lists/List.tsx | 36 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/components/lists/List.stories.jsx create mode 100644 src/components/lists/List.tsx diff --git a/src/components/lists/List.stories.jsx b/src/components/lists/List.stories.jsx new file mode 100644 index 0000000..c736dc4 --- /dev/null +++ b/src/components/lists/List.stories.jsx @@ -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 => ( + + Io + Gyrocopter + Chaos Knight + +) +Unordered.args = { + ordered: false, +} + + +export const Ordered = Unordered.bind({}) +Ordered.args = { + ordered: true, +} diff --git a/src/components/lists/List.tsx b/src/components/lists/List.tsx new file mode 100644 index 0000000..6931648 --- /dev/null +++ b/src/components/lists/List.tsx @@ -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 ( + + ) +} + + +interface ListItemProps { + [props: string]: any, +} + + +List.Item = function({...props}: ListItemProps): JSX.Element { + props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "list-item") + + return ( + + ) +}