-
Notifications
You must be signed in to change notification settings - Fork 1
/
modal.css.ts
93 lines (82 loc) · 2.08 KB
/
modal.css.ts
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { style, type StyleRule } from '@vanilla-extract/css';
import { precomputedViewportRules, type Viewport } from './box.css.js';
import { typedObjectEntries, typedObjectFromEntries } from './utils.js';
import { propsVars, baseVars } from './vars.css.js';
// WARN: ordering is important here as it affects the generated CSS
// it should be the opposite order of viewportSizes (I think)
const commonViewportRules: Record<Viewport, StyleRule> = {
tablet: {
width: '60vw',
padding: propsVars.space[6],
marginInline: 'auto',
},
mobile: {
minWidth: '100vw',
minHeight: '100vh',
marginBlock: 'unset', // unset inheritance from tablet
},
desktop: {
width: '35rem',
marginBlock: propsVars.space[8],
marginInline: 'auto',
},
wide: {},
all: {},
};
const commonBackdropProps: StyleRule = {
// WARN: Brightness should probably be a var based on contrast scheme?
backdropFilter: 'blur(0.5rem) brightness(0.95)',
};
export const dialogClass = style({
// these are annoyingly not part of dialog element reset
border: 0,
padding: 0,
margin: 0,
selectors: {
'&:not([open])': {
visibility: 'hidden',
},
'&::backdrop': {
...commonBackdropProps,
},
},
});
export const modalClassName = style({
position: 'fixed',
top: 0,
left: 0,
maxWidth: '100%',
width: '100vw',
height: '100vh',
zIndex: 100,
selectors: {
// '&:not([open])': {
// visibility: 'hidden',
// },
'&::before': {
content: '',
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
zIndex: -1,
...commonBackdropProps,
},
},
});
export const modalInnerClassName = style({
backgroundColor: baseVars.color.bgColor,
borderRadius: baseVars.border.radius,
outlineColor: baseVars.color.borderColor,
outlineWidth: baseVars.border.width,
outlineStyle: 'solid',
});
export const commonDimensionsClass = style({
'@media': typedObjectFromEntries(
typedObjectEntries(commonViewportRules).map(([viewport, rule]) => [
precomputedViewportRules[viewport],
rule,
]),
),
});