forked from primer/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DropdownStyles.ts
128 lines (114 loc) · 2.46 KB
/
DropdownStyles.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
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
import {get} from './constants'
import {Theme} from './ThemeProvider'
const getDirectionStyles = (theme: Theme, direction: 'ne' | 'e' | 'se' | 's' | 'sw' | 'w') => {
const map = {
w: `
top: 0;
right: 100%;
left: auto;
width: auto;
margin-top: 0;
margin-right: 10px;
&::before {
top: 10px;
right: -16px;
left: auto;
border-color: transparent;
border-left-color: ${get('colors.border.default')(theme)};
}
&::after {
top: 11px;
right: -14px;
left: auto;
border-color: transparent;
border-left-color: ${get('colors.border.default')(theme)};
}
`,
e: `
top: 0;
left: 100%;
width: auto;
margin-top: 0;
margin-left: 10px;
&::before {
top: 10px;
left: -16px;
border-color: transparent;
border-right-color: ${get('colors.border.default')(theme)};
}
&::after {
top: 11px;
left: -14px;
border-color: transparent;
border-right-color: ${get('colors.border.default')(theme)};
}
`,
ne: `
top: auto;
bottom: 100%;
left: 0;
margin-bottom: 3px;
&::before,
&::after {
top: auto;
right: auto;
}
&::before {
bottom: -8px;
left: 9px;
border-top: 8px solid ${get('colors.border.default')(theme)};
border-bottom: 0;
border-left: 8px solid transparent;
}
&::after {
bottom: -7px;
left: 10px;
border-top: 7px solid ${get('colors.border.default')(theme)};
border-right: 7px solid transparent;
border-bottom: 0;
border-left: 7px solid transparent;
}
`,
s: `
right: 50%;
left: auto;
transform: translateX(50%);
&::before {
top: -16px;
right: 50%;
transform: translateX(50%);
}
&::after {
top: -14px;
right: 50%;
transform: translateX(50%);
}
`,
sw: `
right: 0;
left: auto;
&::before {
top: -16px;
right: 9px;
left: auto;
}
&::after {
top: -14px;
right: 10px;
left: auto;
}
`,
se: `
&::before {
top: -16px;
left: 9px;
}
&::after {
top: -14px;
left: 10px;
}
`
}
return map[direction]
}
export default getDirectionStyles