-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathinline.css.ts
More file actions
140 lines (123 loc) · 3.52 KB
/
inline.css.ts
File metadata and controls
140 lines (123 loc) · 3.52 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import {style, createVar, globalStyle, fallbackVar} from '@vanilla-extract/css';
import * as mq from './media-queries.css';
const space = createVar();
const spaceMobile = createVar();
const spaceTablet = createVar();
const spaceDesktop = createVar();
const verticalSpace = createVar();
const verticalSpaceMobile = createVar();
const verticalSpaceTablet = createVar();
const verticalSpaceDesktop = createVar();
export const vars = {
space,
spaceMobile,
spaceTablet,
spaceDesktop,
verticalSpace,
verticalSpaceMobile,
verticalSpaceTablet,
verticalSpaceDesktop,
};
export const marginInline = style({
marginTop: `calc(${verticalSpace} * -1)`,
marginLeft: `calc(${space} * -1)`,
'@media': {
[mq.mobile]: {
vars: {
[space]: spaceMobile,
[verticalSpace]: verticalSpaceMobile,
},
},
[mq.tablet]: {
vars: {
[space]: fallbackVar(spaceTablet, spaceMobile),
[verticalSpace]: fallbackVar(verticalSpaceTablet, verticalSpaceMobile),
},
},
[mq.desktopOrBigger]: {
vars: {
[space]: spaceDesktop,
[verticalSpace]: verticalSpaceDesktop,
},
},
},
});
/**
* https://caniuse.com/flexbox-gap
* chrome 84; safari 14.1
*/
const supportsFlexGap = '(display: flex) and (gap: 0px)';
export const inline = style({
pointerEvents: 'none', // to prevent negative margins from affecting clickable areas
gridAutoFlow: 'column',
marginTop: `calc(${fallbackVar(verticalSpace, space)} * -1)`,
marginLeft: `calc(${space} * -1)`,
'@supports': {
[supportsFlexGap]: {
margin: 0, // restore
pointerEvents: 'auto', // restore
flexDirection: 'row',
gap: space,
rowGap: fallbackVar(verticalSpace, space),
},
},
});
export const fullWidth = style({
/**
* @deprecated - this should be "flex"
* Once changed, the usages that depend on this behavior should be migrated to use <Grid>
* See "inline-cases" private story
*/
display: ['flex', 'grid'],
});
export const wrap = style({
display: 'inline-flex',
flexWrap: 'wrap',
});
export const noFullWidth = style({
display: ['inline-flex', 'inline-grid'],
});
export const stringSpace = style({
display: ['flex', 'grid'],
justifyContent: space,
});
export const stringSpaceWithWrap = style({
// if we use display: grid, the content doesn't wrap
display: 'flex',
justifyContent: space,
});
export const flexLayout = style({
display: 'flex',
});
export const growItem = style({
flex: 1,
minWidth: 0,
});
globalStyle(`${marginInline} > div`, {
marginLeft: space,
marginTop: fallbackVar(verticalSpace, space),
});
globalStyle(`${inline} > div`, {
pointerEvents: 'auto', // restore pointer events for children
// Hack to fix https://jira.tid.es/browse/WEB-1683
// In iOS the inline component sometimes cuts the last line of the content
paddingBottom: 1,
'@supports': {
[supportsFlexGap]: {
padding: 0, // restore
// negative gap is not supported in flexbox, so we use negative margins instead
margin: `0 0 0 calc(min(${space}, 0px))`,
},
},
});
globalStyle(`${inline} > div:first-child`, {
marginLeft: space,
'@supports': {
[supportsFlexGap]: {
marginLeft: 0,
},
},
});
globalStyle(`${inline} > div:empty`, {
display: 'none',
});