Skip to content

Commit

Permalink
Merge pull request #2808 from SUI-Components/label-doc-article-change
Browse files Browse the repository at this point in the history
docs(components/atom/label): label documentation articles
  • Loading branch information
andresin87 authored Jan 20, 2025
2 parents 616df44 + 77ed1a5 commit 13f6619
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 104 deletions.
34 changes: 34 additions & 0 deletions components/atom/label/demo/articles/ArticleFontSize.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Article, Box, Cell, Code, Grid, H2, Paragraph} from '@s-ui/documentation-library'
import AtomInput from '@s-ui/react-atom-input'

import AtomLabel, {type FontSize, AtomLabelFontSizes} from '../../src/index'
import {flexCenteredStyle} from '../settings.js'

const ArticleFontSize = ({className}: {className?: string}) => {
const labelFontSizes = [['default', undefined], ...Object.entries(AtomLabelFontSizes)] as Array<[string, FontSize]>
return (
<Article>
<H2>FontSize</H2>
<Paragraph>
The component provides 4 different sizes provided using the <Code>fontSize</Code> prop
</Paragraph>
<Grid cols={5} gutter={[8, 8]}>
{labelFontSizes.map(([key, value], index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box>
<AtomLabel
name={`atomLabelName-${key}`}
htmlFor={`labelName-${key}`}
text={`Size ${value as string}`}
fontSize={value}
/>
<AtomInput />
</Box>
</Cell>
))}
</Grid>
</Article>
)
}

export default ArticleFontSize
44 changes: 44 additions & 0 deletions components/atom/label/demo/articles/ArticleInline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {Article, Box, Cell, Code, Grid, H2, Paragraph} from '@s-ui/documentation-library'
import AtomButton from '@s-ui/react-atom-button'
import AtomCheckbox from '@s-ui/react-atom-checkbox'
import AtomInput from '@s-ui/react-atom-input'

import AtomLabel, {type Inline} from '../../src/index'
import {CheckedIcon, flexCenteredStyle, IndeterminateIcon} from '../settings.js'

const ArticleInline = ({className}: {className?: string}) => {
return (
<Article className={className}>
<H2>Inline</H2>
<Paragraph>
<Code>inline</Code> prop can be used to define where teh element is going to be inline positioned. The value
options are 'left' and 'right'
</Paragraph>
<Grid cols={3} gutter={[8, 8]}>
{[
<AtomInput key={0} />,
<AtomCheckbox key={1} checkedIcon={CheckedIcon} intermediateIcon={IndeterminateIcon} />,
<AtomButton key={2}>Button</AtomButton>
].map((component, index) =>
['left', undefined, 'right'].map((value, index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box>
{value === 'right' && component}
<AtomLabel
name={`atomLabelName-${value as string}`}
htmlFor={`labelName-${value as string}`}
text={`Label ${value as string}`}
optionalText="(Optional)"
inline={value as Inline}
/>
{value !== 'right' && component}
</Box>
</Cell>
))
)}
</Grid>
</Article>
)
}

export default ArticleInline
36 changes: 36 additions & 0 deletions components/atom/label/demo/articles/ArticleType.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {Article, Box, Cell, Code, Grid, H2, Paragraph} from '@s-ui/documentation-library'
import AtomInput from '@s-ui/react-atom-input'

import AtomLabel, {type Type, AtomLabelTypes} from '../../src/index'
import {flexCenteredStyle} from '../settings.js'

const ArticleType = ({className}: {className?: string}) => {
const labelTypes = [['default', undefined], ...Object.entries(AtomLabelTypes)] as Array<[string, Type]>

return (
<Article className={className}>
<H2>Type</H2>
<Paragraph>
You can select any of the available predefined types using the <Code>type</Code> prop.
</Paragraph>
<Grid cols={labelTypes.length} gutter={[8, 8]}>
{labelTypes.map(([key, value]: [string, Type], index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box mode={value === AtomLabelTypes.CONTRAST ? 'dark' : 'light'}>
<AtomLabel
name={`atomLabelName-${key}`}
htmlFor={`labelName-${key}`}
text={`Label ${value as string}`}
optionalText="(Optional)"
type={value}
/>
<AtomInput />
</Box>
</Cell>
))}
</Grid>
</Article>
)
}

export default ArticleType
111 changes: 8 additions & 103 deletions components/atom/label/demo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,23 @@
import {AntDesignIcon, Article, Box, Cell, Code, Grid, H1, H2, Paragraph} from '@s-ui/documentation-library'
import AtomButton from '@s-ui/react-atom-button'
import AtomCheckbox from '@s-ui/react-atom-checkbox'
import AtomIcon from '@s-ui/react-atom-icon'
import AtomInput from '@s-ui/react-atom-input'
import {H1, Paragraph} from '@s-ui/documentation-library'

import AtomLabel, {type FontSize, type Inline, type Type, AtomLabelFontSizes, AtomLabelTypes} from '../src/index'

const flexCenteredStyle = {
display: 'flex',
justifyContent: 'center',
flexDirection: 'row',
wrap: 'nowrap',
alignItems: 'center',
alignContent: 'center'
}

const CheckedIcon = () => (
<AtomIcon>
<AntDesignIcon icon="AiOutlineCheck" style={{color: 'currentColor'}} />
</AtomIcon>
)

const IndeterminateIcon = () => (
<AtomIcon>
<AntDesignIcon icon="AiOutlineLine" style={{color: 'currentColor'}} />
</AtomIcon>
)
import ArticleFontSize from './articles/ArticleFontSize'
import ArticleInline from './articles/ArticleInline'
import ArticleType from './articles/ArticleType'
import {CLASS_SECTION} from './settings'

const Demo = () => {
const labelTypes = [['default', undefined], ...Object.entries(AtomLabelTypes)] as Array<[string, Type]>
const labelFontSizes = [['default', undefined], ...Object.entries(AtomLabelFontSizes)] as Array<[string, FontSize]>

return (
<div className="sui-StudioPreview">
<H1>Label</H1>
<Paragraph>
The Label is the name of the associated field, that explains what is the about. It should be clear, concise and
short.
</Paragraph>
<Article>
<H2>Type</H2>
<Paragraph>
You can select any of the avaliable predefined types using the <Code>type</Code> prop.
</Paragraph>
<Grid cols={labelTypes.length} gutter={[8, 8]}>
{labelTypes.map(([key, value], index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box mode={value === AtomLabelTypes.CONTRAST ? 'dark' : 'light'}>
<AtomLabel
name={`atomLabelName-${key}`}
htmlFor={`labelName-${key}`}
text={`Label ${value}`}
optionalText="(Optional)"
type={value}
/>
<AtomInput />
</Box>
</Cell>
))}
</Grid>
</Article>
<ArticleType className={CLASS_SECTION} />
<br />
<Article>
<H2>Inline</H2>
<Paragraph>
<Code>inline</Code> prop can be used to define where teh element is going to be inline positioned. The value
options are 'left' and 'right'
</Paragraph>
<Grid cols={3} gutter={[8, 8]}>
{[
<AtomInput key={0} />,
<AtomCheckbox key={1} checkedIcon={CheckedIcon} intermediateIcon={IndeterminateIcon} />,
<AtomButton key={2}>Button</AtomButton>
].map((component, index) =>
['left', undefined, 'right'].map((value, index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box>
{value === 'right' && component}
<AtomLabel
name={`atomLabelName-${value as string}`}
htmlFor={`labelName-${value as string}`}
text={`Label ${value as string}`}
optionalText="(Optional)"
inline={value as Inline}
/>
{value !== 'right' && component}
</Box>
</Cell>
))
)}
</Grid>
</Article>
<ArticleInline className={CLASS_SECTION} />
<br />
<Article>
<H2>FontSize</H2>
<Paragraph>
The component provides 4 diferent sizes provided using the <Code>fontSize</Code> prop
</Paragraph>
<Grid cols={5} gutter={[8, 8]}>
{labelFontSizes.map(([key, value], index) => (
<Cell key={index} style={flexCenteredStyle}>
<Box>
<AtomLabel
name={`atomLabelName-${key}`}
htmlFor={`labelName-${key}`}
text={`Size ${value as string}`}
fontSize={value}
/>
<AtomInput />
</Box>
</Cell>
))}
</Grid>
</Article>
<ArticleFontSize className={CLASS_SECTION} />
</div>
)
}
Expand Down
25 changes: 25 additions & 0 deletions components/atom/label/demo/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {AntDesignIcon} from '@s-ui/documentation-library'
import AtomIcon from '@s-ui/react-atom-icon'

export const BASE_CLASS_DEMO = `DemoAtomLabel`
export const CLASS_SECTION = `${BASE_CLASS_DEMO}-section`

export const flexCenteredStyle = {
display: 'flex',
justifyContent: 'center',
wrap: 'nowrap',
alignItems: 'center',
alignContent: 'center'
}

export const CheckedIcon = () => (
<AtomIcon>
<AntDesignIcon icon="AiOutlineCheck" style={{color: 'currentColor'}} />
</AtomIcon>
)

export const IndeterminateIcon = () => (
<AtomIcon>
<AntDesignIcon icon="AiOutlineLine" style={{color: 'currentColor'}} />
</AtomIcon>
)
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13f6619

Please sign in to comment.