diff --git a/src/components/images/Image.stories.jsx b/src/components/images/Image.stories.jsx new file mode 100644 index 0000000..b1fcc89 --- /dev/null +++ b/src/components/images/Image.stories.jsx @@ -0,0 +1,35 @@ +import * as React from "react" +import * as ReactDOM from "react-dom" +import * as Decorators from "../../utils/Decorators" +import { Image } from "./Image" +import PineappleWithSunglasses from "./elena-cordery-RLlcbkemwnw-unsplash.jpg" + + +export default { + component: Image, + title: "Images/Image", + decorators: [Decorators.Bluelib], +} + + +export const NoLimit = props => ( + +) +NoLimit.args = { + src: PineappleWithSunglasses, + limit: "no", +} + + +export const HalfLimit = NoLimit.bind({}) +HalfLimit.args = { + ...NoLimit.args, + limit: "half", +} + + +export const QuarterLimit = NoLimit.bind({}) +QuarterLimit.args = { + ...NoLimit.args, + limit: "quarter", +} \ No newline at end of file diff --git a/src/components/images/Image.tsx b/src/components/images/Image.tsx new file mode 100644 index 0000000..8e230f7 --- /dev/null +++ b/src/components/images/Image.tsx @@ -0,0 +1,34 @@ +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 ImageProps { + src: string, + limit?: "no" | "half" | "quarter", + + [props: string]: any, +} + + +const LIMIT_CLASSES = { + no: "", + half: "image-limit-half", + quarter: "image-limit-quarter", +} + + +export function Image({limit, ...props}: ImageProps): JSX.Element { + props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "image") + + if(limit) { + props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, LIMIT_CLASSES[limit]) + } + + // TODO: Capture the src and make the image clickable + return ( + + ) +} diff --git a/src/components/images/elena-cordery-RLlcbkemwnw-unsplash.jpg b/src/components/images/elena-cordery-RLlcbkemwnw-unsplash.jpg new file mode 100644 index 0000000..f8882cd Binary files /dev/null and b/src/components/images/elena-cordery-RLlcbkemwnw-unsplash.jpg differ diff --git a/src/utils/Decorators.jsx b/src/utils/Decorators.jsx index 21d7cd1..a85f1f3 100644 --- a/src/utils/Decorators.jsx +++ b/src/utils/Decorators.jsx @@ -1,6 +1,9 @@ import { Bluelib as BluelibComponent } from "../components/Bluelib" +import { Box as BoxComponent } from "../components/panels/Box" export const Bluelib = Story => export const Fill = Story =>
+ +export const Box = Story => \ No newline at end of file