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

Add support for Figure and Caption

This commit is contained in:
Steffo 2022-03-12 05:06:02 +01:00
parent d581f69efd
commit 9f96e01bc3
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Types from "../../types"
import {BaseElement} from "../BaseElement"
import mergeClassNames from "classnames"
export interface CaptionProps extends Types.BluelibHTMLProps<HTMLElement> {}
export function Caption({...props}: CaptionProps): JSX.Element {
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "figure-caption")
return (
<BaseElement kind={"figcaption"} {...props}/>
)
}

View file

@ -0,0 +1,50 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Decorators from "../../utils/Decorators"
import { Figure as FigureComponent } from "./Figure"
import { Image as ImageComponent } from "./Image"
import PineappleWithSunglasses from "./elena-cordery-RLlcbkemwnw-unsplash.jpg"
export default {
component: FigureComponent,
subcomponents: {Image: ImageComponent, },
title: "Images/Figure",
decorators: [Decorators.Bluelib],
}
export const Figure = props => (
<FigureComponent {...props}>
<ImageComponent src={PineappleWithSunglasses} limit="quarter"/>
</FigureComponent>
)
Figure.args = {
}
export const TopCaption = props => (
<FigureComponent {...props}>
<FigureComponent.Caption>
A pineapple with sunglasses.
</FigureComponent.Caption>
<ImageComponent src={PineappleWithSunglasses} limit="quarter"/>
</FigureComponent>
)
TopCaption.args = {
}
export const BottomCaption = props => (
<FigureComponent {...props}>
<ImageComponent src={PineappleWithSunglasses} limit="quarter"/>
<FigureComponent.Caption>
A pineapple with sunglasses.
</FigureComponent.Caption>
</FigureComponent>
)
BottomCaption.args = {
}

View file

@ -0,0 +1,20 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Types from "../../types"
import {BaseElement} from "../BaseElement"
import { Caption } from "./Caption"
import mergeClassNames from "classnames"
export interface FigureProps extends Types.BluelibHTMLProps<HTMLElement> {}
export function Figure({...props}: FigureProps): JSX.Element {
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "figure")
return (
<BaseElement kind={"figure"} {...props}/>
)
}
Figure.Caption = Caption