File tree Expand file tree Collapse file tree 8 files changed +177
-0
lines changed Expand file tree Collapse file tree 8 files changed +177
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { ReactNode } from 'react' ;
2
+
3
+ import { Box } from '../box' ;
4
+ import { Flex } from '../flex' ;
5
+ import { Text } from '../text' ;
6
+
7
+ import * as styles from './setting.css' ;
8
+
9
+ interface SettingsItemProps {
10
+ addon ?: ReactNode ;
11
+ description : ReactNode ;
12
+ onClick ?: ( ) => void ;
13
+ testId ?: string ;
14
+ title ?: ReactNode | string ;
15
+ }
16
+
17
+ export const Setting = ( {
18
+ description,
19
+ addon,
20
+ onClick,
21
+ testId = 'setting' ,
22
+ title,
23
+ } : SettingsItemProps ) : React . ReactElement => (
24
+ < Box mb = "$32" className = { styles . root } >
25
+ < div className = { styles . separator } />
26
+ < Box
27
+ pt = "$32"
28
+ pb = "$32"
29
+ pl = "$16"
30
+ pr = "$16"
31
+ className = { styles . content }
32
+ onClick = { onClick }
33
+ data-testid = { testId }
34
+ >
35
+ { title ? (
36
+ < Box >
37
+ < Text . Body . Large weight = "$semibold" data-testid = { `${ testId } -title` } >
38
+ { title }
39
+ </ Text . Body . Large >
40
+ </ Box >
41
+ ) : null }
42
+ < Flex justifyContent = "space-between" >
43
+ < Text . Body . Normal data-testid = { `${ testId } -description` } >
44
+ { description }
45
+ </ Text . Body . Normal >
46
+ < div data-testid = { `${ testId } -addon` } > { addon } </ div >
47
+ </ Flex >
48
+ </ Box >
49
+ </ Box >
50
+ ) ;
Original file line number Diff line number Diff line change
1
+ import { style , vars } from '../../design-tokens' ;
2
+
3
+ export const root = style ( { } ) ;
4
+
5
+ export const separator = style ( {
6
+ width : '100%' ,
7
+ height : 1 ,
8
+ background : vars . colors . $settings_item_separator_color ,
9
+ selectors : {
10
+ [ `${ root } :first-of-type &` ] : {
11
+ background : 'none' ,
12
+ } ,
13
+ [ `${ root } :hover &` ] : {
14
+ background : 'none' ,
15
+ } ,
16
+ } ,
17
+ } ) ;
18
+
19
+ export const content = style ( {
20
+ selectors : {
21
+ '&:hover' : {
22
+ background : vars . colors . $settings_item_hover_bgColor ,
23
+ borderRadius : vars . spacing . $16 ,
24
+ cursor : 'pointer' ,
25
+ } ,
26
+ } ,
27
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { Box } from '../box' ;
4
+ import { Text } from '../text' ;
5
+
6
+ import * as styles from './settings-section.css' ;
7
+
8
+ interface SettingsCardProps {
9
+ title : string ;
10
+ testId ?: string ;
11
+ children : React . ReactNode ;
12
+ }
13
+
14
+ export const SettingsSection = ( {
15
+ children,
16
+ title,
17
+ testId = 'settings-section' ,
18
+ } : SettingsCardProps ) : React . ReactElement => (
19
+ < div data-testid = "settings-card" className = { styles . root } >
20
+ < Box pl = "$16" mb = "$16" >
21
+ < Text . SubHeading data-testid = { `${ testId } -heading` } >
22
+ { title }
23
+ </ Text . SubHeading >
24
+ </ Box >
25
+ < div > { children } </ div >
26
+ </ div >
27
+ ) ;
Original file line number Diff line number Diff line change
1
+ import { style , vars } from '../../design-tokens' ;
2
+
3
+ export const root = style ( [
4
+ {
5
+ width : vars . spacing . $fill ,
6
+ marginBottom : vars . spacing . $40 ,
7
+ } ,
8
+ ] ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { action } from '@storybook/addon-actions' ;
4
+ import type { Meta } from '@storybook/react' ;
5
+
6
+ import * as Button from '../buttons/' ;
7
+ import { page , Section , Variants } from '../decorators' ;
8
+ import { Flex } from '../flex' ;
9
+ import { Grid , Cell } from '../grid' ;
10
+
11
+ import { Setting } from './setting.component' ;
12
+ import { SettingsSection } from './settings-section.component' ;
13
+
14
+ export default {
15
+ title : 'Settings/Overview' ,
16
+
17
+ decorators : [
18
+ page ( {
19
+ title : 'Settings Components' ,
20
+ subtitle :
21
+ 'These components can be used to render the sections and items on a settings page.' ,
22
+ } ) ,
23
+ ] ,
24
+ } as Meta ;
25
+
26
+ export const Overview = ( ) : React . JSX . Element => (
27
+ < div id = "storybook" >
28
+ < Grid columns = "$1" >
29
+ < Cell >
30
+ < Section title = "Usage Example" >
31
+ < Variants . Table >
32
+ < Variants . Row >
33
+ < Variants . Cell >
34
+ < Flex justifyContent = "center" w = "$fill" >
35
+ < SettingsSection title = "Example Setting" >
36
+ < Setting
37
+ description = "this is an example of a first setting"
38
+ title = "First Setting"
39
+ onClick = { action ( 'first setting clicked' ) }
40
+ />
41
+ < Setting
42
+ description = "this is an example of a second setting"
43
+ title = "Second Setting"
44
+ onClick = { action ( 'second setting clicked' ) }
45
+ addon = { < Button . CallToAction label = "test addon" /> }
46
+ />
47
+ </ SettingsSection >
48
+ </ Flex >
49
+ </ Variants . Cell >
50
+ </ Variants . Row >
51
+ </ Variants . Table >
52
+ </ Section >
53
+ </ Cell >
54
+ </ Grid >
55
+ </ div >
56
+ ) ;
Original file line number Diff line number Diff line change @@ -295,6 +295,9 @@ export const colors = {
295
295
$address_tag_own_bgColor : '' ,
296
296
$address_tag_foreign_color : '' ,
297
297
$address_tag_foreign_bgColor : '' ,
298
+
299
+ $settings_item_separator_color : '' ,
300
+ $settings_item_hover_bgColor : '' ,
298
301
} ;
299
302
300
303
export type Colors = typeof colors ;
Original file line number Diff line number Diff line change @@ -394,6 +394,9 @@ const colors: Colors = {
394
394
darkColorScheme . $primary_accent_purple ,
395
395
0.1 ,
396
396
) ,
397
+
398
+ $settings_item_separator_color : darkColorScheme . $primary_mid_grey ,
399
+ $settings_item_hover_bgColor : darkColorScheme . $primary_mid_grey ,
397
400
} ;
398
401
399
402
const elevation : Elevation = {
Original file line number Diff line number Diff line change @@ -422,6 +422,9 @@ const colors: Colors = {
422
422
lightColorScheme . $primary_accent_purple ,
423
423
0.1 ,
424
424
) ,
425
+
426
+ $settings_item_separator_color : lightColorScheme . $primary_light_grey_plus ,
427
+ $settings_item_hover_bgColor : lightColorScheme . $primary_light_grey ,
425
428
} ;
426
429
427
430
export const elevation : Elevation = {
You can’t perform that action at this time.
0 commit comments