forked from primer/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flash.tsx
75 lines (68 loc) · 1.56 KB
/
Flash.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import styled from 'styled-components'
import {variant} from 'styled-system'
import {get} from './constants'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'
const variants = variant({
variants: {
default: {
color: 'fg.default',
backgroundColor: 'accent.subtle',
borderColor: 'accent.muted',
svg: {
color: 'accent.fg'
}
},
success: {
color: 'fg.default',
backgroundColor: 'success.subtle',
borderColor: 'success.muted',
svg: {
color: 'success.fg'
}
},
danger: {
color: 'fg.default',
backgroundColor: 'danger.subtle',
borderColor: 'danger.muted',
svg: {
color: 'danger.fg'
}
},
warning: {
color: 'fg.default',
backgroundColor: 'attention.subtle',
borderColor: 'attention.muted',
svg: {
color: 'attention.fg'
}
}
}
})
const Flash = styled.div<
{
variant?: 'default' | 'warning' | 'success' | 'danger'
full?: boolean
} & SxProp
>`
position: relative;
color: ${get('colors.fg.default')};
padding: ${get('space.3')};
border-style: solid;
border-width: ${props => (props.full ? '1px 0px' : '1px')};
border-radius: ${props => (props.full ? '0' : get('radii.2'))};
margin-top: ${props => (props.full ? '-1px' : '0')};
p:last-child {
margin-bottom: 0;
}
svg {
margin-right: ${get('space.2')};
}
${variants};
${sx};
`
Flash.defaultProps = {
variant: 'default'
}
export type FlashProps = ComponentProps<typeof Flash>
export default Flash