feat: implement quote component

This commit is contained in:
jinhojang6 2023-02-20 20:37:44 +09:00
parent 5a3928fd7f
commit c5510df14e
No known key found for this signature in database
GPG Key ID: 0E7AA62CB0D9E6F3
6 changed files with 97 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import { BreadcrumbStyles } from '../Breadcrumb/Breadcrumb.styles'
import { BreadcrumbItemStyles } from '../BreadcrumbItem/BreadcrumbItem.styles'
import { defaultThemes, Theme, withTheme } from '../Theme'
import { TypographyStyles } from '../Typography/Typography.styles'
import { QuoteStyles } from '../Quote/Quote.styles'
const componentStyles: Array<ReturnType<typeof withTheme> | SerializedStyles> =
[
@ -26,6 +27,7 @@ const componentStyles: Array<ReturnType<typeof withTheme> | SerializedStyles> =
IconTagStyles,
BreadcrumbStyles,
BreadcrumbItemStyles,
QuoteStyles,
]
export const CSSBaseline: React.FC<{ theme?: Theme }> = ({

View File

@ -0,0 +1,8 @@
export const quoteClasses = {
root: `lsd-quote`,
indentedInline: 'lsd-quote--indented-inline',
parentheses: 'lsd-quote--parentheses',
text: 'lsd-quote__text',
}

View File

@ -0,0 +1,21 @@
import { Meta, Story } from '@storybook/react'
import { Quote, QuoteProps } from './Quote'
export default {
title: 'Quote',
component: Quote,
argTypes: {
mode: {
type: {
name: 'enum',
value: ['indented-line', 'parentheses'],
},
},
},
} as Meta
export const Root: Story<QuoteProps> = (args) => <Quote {...args}>Quote</Quote>
Root.args = {
text: 'A wise man can learn more from a foolish question than a fool can learn from a wise answer.',
mode: 'indented-line',
}

View File

@ -0,0 +1,26 @@
import { css } from '@emotion/react'
import { quoteClasses } from './Quote.classes'
export const QuoteStyles = css`
.${quoteClasses.root} {
color: rgb(var(--lsd-text-primary));
background: none;
white-space: break-spaces;
width: 600px;
}
.${quoteClasses.indentedInline} {
border-left: 1px solid rgb(var(--lsd-border-primary));
padding: 4px 8px 4px 28px;
}
.${quoteClasses.parentheses} {
padding: 0px;
text-align: center;
}
.${quoteClasses.text} {
font-size: 16px;
line-height: 24px;
}
`

View File

@ -0,0 +1,39 @@
import clsx from 'clsx'
import React from 'react'
import { Typography } from '../Typography'
import { quoteClasses } from './Quote.classes'
export type QuoteProps = React.HTMLAttributes<HTMLDivElement> & {
text?: string
mode?: 'indented-line' | 'parentheses'
}
export const Quote: React.FC<QuoteProps> & {
classes: typeof quoteClasses
} = ({ text = '', mode = 'indented-line', ...props }) => {
return (
<>
<div
{...props}
className={clsx(
props.className,
quoteClasses.root,
mode && mode === 'parentheses'
? quoteClasses.parentheses
: quoteClasses.indentedInline,
)}
>
<Typography
color="primary"
component="label"
variant={'label1'}
className={quoteClasses.text}
>
{mode === 'parentheses' ? `***\n${text}\n***` : text}
</Typography>
</div>
</>
)
}
Quote.classes = quoteClasses

View File

@ -0,0 +1 @@
export * from './Quote'