Skip to content

Commit 654fd18

Browse files
Wojciech KrysiakWojciech Krysiak
authored andcommitted
feat: add ValueGroup
1 parent 77864f3 commit 654fd18

File tree

6 files changed

+94
-7
lines changed

6 files changed

+94
-7
lines changed

src/atoms/header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ H6.defaultProps = {
103103

104104
const CaptionShared = css<TypographyProps & SpaceProps>`
105105
font-family: ${themeGet('font')};
106+
font-weight: ${themeGet('fontWeights', 'normal')};
106107
${typography};
107108
${space};
108109
`

src/atoms/label.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { cssClass } from '../utils/css-class'
1111
import themeGet from '../utils/theme-get'
1212
import { ColorProps } from '../utils/color-props'
1313

14-
const labelVariants = variant<any, VariantType>({
14+
export type LabelVariantType = VariantType | 'light'
15+
16+
const labelVariants = variant<any, LabelVariantType>({
1517
variants: {
1618
primary: {
1719
color: 'primary100',
@@ -43,6 +45,14 @@ const labelVariants = variant<any, VariantType>({
4345
fill: 'accent',
4446
},
4547
},
48+
light: {
49+
color: 'grey60',
50+
mb: 'sm',
51+
fontWeight: 'light',
52+
[`& .${cssClass('Icon')} svg`]: {
53+
fill: 'grey60',
54+
},
55+
},
4656
default: {},
4757
},
4858
})
@@ -69,7 +79,7 @@ export type LabelProps = ColorProps & SpaceProps & TypographyProps & {
6979
/** If label represents disabled field (dimmed version) */
7080
disabled?: boolean;
7181
/** Color variant */
72-
variant?: VariantType;
82+
variant?: LabelVariantType;
7383

7484
/** Label size */
7585
size?: 'default' | 'lg'
@@ -119,15 +129,15 @@ const setDisabled = ({ disabled, theme }): ReturnType<ThemedCssFunction<DefaultT
119129
*/
120130
const Label = styled.label<LabelProps>`
121131
display: ${({ inline }): string => (inline ? 'inline-block' : 'block')};
122-
font-family: ${({ theme }): string => theme.font};
132+
font-family: ${themeGet('font')};
123133
font-size: ${(props): string => themeGet('fontSizes', props.size === 'lg' ? 'md' : 'sm')(props)};
124-
line-height: ${({ theme }): string => theme.lineHeights.default};
134+
line-height: ${themeGet('lineHeights', 'default')};
125135
margin-bottom: ${({ theme, inline }): string => (inline ? '0' : theme.space.default)};
126136
127137
&:before {
128138
content: "${({ required }): string => (required ? '*' : '')}";
129-
color: ${({ theme }): string => theme.colors.primary100};
130-
margin-right: ${({ theme }): string => theme.space.sm};
139+
color: ${themeGet('colors', 'primary100')};
140+
margin-right: ${themeGet('space', 'sm')};
131141
display: ${({ required }): string => (required ? 'block-inline' : 'none')};
132142
}
133143

src/atoms/text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ export type TextProps = TypographyProps & SpaceProps & ColorProps & LayoutProps
8080
* @section design-system
8181
*/
8282
const Text = styled.div<TextProps>`
83+
${contentCSS};
8384
${typography};
8485
${space};
8586
${layout};
8687
${color};
8788
${variants};
88-
${contentCSS};
8989
`
9090

9191
Text.defaultProps = {

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export * from './atoms/loader'
161161
export * from './atoms/placeholder'
162162
export * from './atoms/tooltip'
163163
export * from './molecules/form-group/index'
164+
export * from './molecules/value-group'
164165
export * from './molecules/date-picker'
165166
export * from './molecules/drop-zone/index'
166167
export * from './molecules/rich-text/index'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react'
2+
import { withKnobs, object } from '../../storybook/node_modules/@storybook/addon-knobs'
3+
4+
import { ValueGroup, Box, CardTitle, Text } from '..'
5+
import StoryWrapper from '../utils/story-wrapper'
6+
7+
export default {
8+
title: 'DesignSystem/Molecules/ValueGroup',
9+
decorators: [withKnobs],
10+
argTypes: {
11+
onClick: { action: 'clicked' },
12+
},
13+
}
14+
export const Default: React.FC = ({ onClick }) => {
15+
const handleClick = (event) => {
16+
event.preventDefault()
17+
onClick(event)
18+
}
19+
20+
const objects = object('objects', [{
21+
label: 'First Name',
22+
onClick: handleClick,
23+
value: 'Wojtek',
24+
}, {
25+
label: 'Last Name',
26+
onClick: handleClick,
27+
value: 'Krysiak',
28+
}])
29+
30+
return (
31+
<StoryWrapper label="ValueGroup default settings">
32+
<Box>
33+
{objects.map((field) => (
34+
<ValueGroup key={field.label} {...field} />
35+
))}
36+
<ValueGroup label="value with styled children">
37+
<CardTitle>With children which are wrapped with CardTitle</CardTitle>
38+
</ValueGroup>
39+
<ValueGroup label="With Multiline Content">
40+
<Box variant="white" border="default">
41+
<Text>
42+
<h4>I am header</h4>
43+
<p>And I am content</p>
44+
</Text>
45+
</Box>
46+
</ValueGroup>
47+
</Box>
48+
</StoryWrapper>
49+
)
50+
}

src/molecules/value-group.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react'
2+
import { Box, Label, Text } from '..'
3+
4+
export type ValueGroupProps = {
5+
label: string,
6+
value?: string,
7+
children?: React.ReactNode,
8+
}
9+
10+
const ValueGroup: React.FC<ValueGroupProps> = (props) => {
11+
const { label, value, children } = props
12+
13+
return (
14+
<Box mb="xl">
15+
<Label variant="light">{label}</Label>
16+
{value ? <Text>{value}</Text> : ''}
17+
{children}
18+
</Box>
19+
)
20+
}
21+
22+
export {
23+
ValueGroup as default,
24+
ValueGroup,
25+
}

0 commit comments

Comments
 (0)