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

Add support for Preformatted and improve Code

This commit is contained in:
Steffo 2022-03-12 04:54:57 +01:00
parent 0e34793ca0
commit a169255d22
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 51 additions and 2 deletions

View file

@ -2,6 +2,7 @@ import * as React from "react"
import * as ReactDOM from "react-dom" import * as ReactDOM from "react-dom"
import * as Decorators from "../../utils/Decorators" import * as Decorators from "../../utils/Decorators"
import { Code as CodeComponent } from "./Code" import { Code as CodeComponent } from "./Code"
import { Preformatted } from "./Preformatted"
export default { export default {
@ -11,7 +12,21 @@ export default {
} }
export const Code = props => ( export const CodeInline = props => (
<CodeComponent {...props}>"Hello world!"</CodeComponent> <CodeComponent {...props}>"Hello world!"</CodeComponent>
) )
Code.args = {} CodeInline.args = {}
const botsbuildbots =
`(defun botsbuildbots () (
(botsbuildbots)
))`
export const CodeBlock = props => (
<Preformatted>
<CodeComponent {...props}>{botsbuildbots}</CodeComponent>
</Preformatted>
)
CodeBlock.args = {}

View file

@ -0,0 +1,17 @@
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Decorators from "../../utils/Decorators"
import { Preformatted as PreformattedComponent } from "./Preformatted"
export default {
component: PreformattedComponent,
title: "Semantics/Preformatted",
decorators: [Decorators.Bluelib],
}
export const Preformatted = props => (
<PreformattedComponent {...props}>{`Look at me!\nI can start new lines and have indentation!`}</PreformattedComponent>
)
Preformatted.args = {}

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 PreformattedProps extends Types.BluelibHTMLProps<HTMLPreElement> {}
export function Preformatted({...props}: PreformattedProps): JSX.Element {
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "semantic-pre")
return (
<BaseElement kind={"pre"} {...props}/>
)
}