mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 19:44:21 +00:00
✨ Update bluelib and add Details
element
This commit is contained in:
parent
dfb88533f1
commit
e91c0ac3fc
6 changed files with 114 additions and 1 deletions
|
@ -1 +1 @@
|
|||
Subproject commit ee3213e7c3853777af7052295b4d425746860ba5
|
||||
Subproject commit 5878b6d9b3fa5e2578aadde8afad309211f0b224
|
15
src/components/common/Content.tsx
Normal file
15
src/components/common/Content.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
|
||||
|
||||
interface ContentProps {
|
||||
|
||||
}
|
||||
|
||||
|
||||
export function Content({}: ContentProps): JSX.Element {
|
||||
return (
|
||||
<>
|
||||
</>
|
||||
)
|
||||
}
|
25
src/components/common/Details.stories.jsx
Normal file
25
src/components/common/Details.stories.jsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
import * as Decorators from "../../utils/Decorators"
|
||||
import { Details as DetailsComponent } from "./Details"
|
||||
import { DetailsSummary } from "./DetailsSummary"
|
||||
|
||||
|
||||
export default {
|
||||
component: DetailsComponent,
|
||||
title: "Common/Details",
|
||||
decorators: [Decorators.Bluelib],
|
||||
}
|
||||
|
||||
|
||||
export const Details = props => (
|
||||
<DetailsComponent {...props}>
|
||||
<DetailsComponent.Summary>
|
||||
The Tragedy
|
||||
</DetailsComponent.Summary>
|
||||
<DetailsComponent.Content>
|
||||
Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.
|
||||
</DetailsComponent.Content>
|
||||
</DetailsComponent>
|
||||
)
|
||||
Details.args = {}
|
37
src/components/common/Details.tsx
Normal file
37
src/components/common/Details.tsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
import * as Types from "../../types"
|
||||
import {BaseElement} from "../BaseElement"
|
||||
import mergeClassNames from "classnames"
|
||||
import {DetailsSummary} from "./DetailsSummary";
|
||||
import {DetailsContent} from "./DetailsContent";
|
||||
|
||||
|
||||
export interface DetailsProps extends Types.BluelibHTMLProps<HTMLDetailsElement> {}
|
||||
|
||||
|
||||
export function Details({children, disabled, onClick, ...props}: DetailsProps): JSX.Element {
|
||||
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "details")
|
||||
|
||||
const onClickWrapper =
|
||||
React.useCallback(
|
||||
event => {
|
||||
if(disabled) {
|
||||
event.preventDefault()
|
||||
}
|
||||
else if(onClick) {
|
||||
onClick(event)
|
||||
}
|
||||
},
|
||||
[disabled, onClick]
|
||||
)
|
||||
|
||||
return (
|
||||
<BaseElement kind={"details"} onClick={onClickWrapper} disabled={disabled} {...props}>
|
||||
{children}
|
||||
</BaseElement>
|
||||
)
|
||||
}
|
||||
|
||||
Details.Summary = DetailsSummary
|
||||
Details.Content = DetailsContent
|
18
src/components/common/DetailsContent.tsx
Normal file
18
src/components/common/DetailsContent.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
import * as Types from "../../types";
|
||||
import {BaseElement} from "../BaseElement";
|
||||
import {DetailsProps} from "./Details";
|
||||
import mergeClassNames from "classnames"
|
||||
|
||||
|
||||
export interface DetailsContentProps extends Types.BluelibHTMLProps<HTMLElement> {}
|
||||
|
||||
|
||||
export function DetailsContent({...props}: DetailsContentProps): JSX.Element {
|
||||
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "details-content")
|
||||
|
||||
return (
|
||||
<BaseElement kind={"div"} {...props}/>
|
||||
)
|
||||
}
|
18
src/components/common/DetailsSummary.tsx
Normal file
18
src/components/common/DetailsSummary.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
import * as Types from "../../types";
|
||||
import {BaseElement} from "../BaseElement";
|
||||
import {DetailsProps} from "./Details";
|
||||
import mergeClassNames from "classnames"
|
||||
|
||||
|
||||
export interface DetailsSummaryProps extends Types.BluelibHTMLProps<HTMLElement> {}
|
||||
|
||||
|
||||
export function DetailsSummary({...props}: DetailsSummaryProps): JSX.Element {
|
||||
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "details-summary")
|
||||
|
||||
return (
|
||||
<BaseElement kind={"summary"} {...props}/>
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue