mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 11:34:21 +00:00
✨ Add support for Preformatted
and improve Code
This commit is contained in:
parent
0e34793ca0
commit
a169255d22
3 changed files with 51 additions and 2 deletions
|
@ -2,6 +2,7 @@ import * as React from "react"
|
|||
import * as ReactDOM from "react-dom"
|
||||
import * as Decorators from "../../utils/Decorators"
|
||||
import { Code as CodeComponent } from "./Code"
|
||||
import { Preformatted } from "./Preformatted"
|
||||
|
||||
|
||||
export default {
|
||||
|
@ -11,7 +12,21 @@ export default {
|
|||
}
|
||||
|
||||
|
||||
export const Code = props => (
|
||||
export const CodeInline = props => (
|
||||
<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 = {}
|
||||
|
|
17
src/components/semantics/Preformatted.stories.jsx
Normal file
17
src/components/semantics/Preformatted.stories.jsx
Normal 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 = {}
|
17
src/components/semantics/Preformatted.tsx
Normal file
17
src/components/semantics/Preformatted.tsx
Normal 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}/>
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue