Previews

No matching results.

x
1
2
3
4
5
6
7
8
9
10
<details data-view-component="true" class="dropdown details-overlay details-reset">
<summary role="button" data-view-component="true" class="btn"> Dropdown
</summary>
<div data-view-component="true"> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-se">
<a role="menuitem" data-view-component="true" class="dropdown-item">Item 1</a>
<a role="menuitem" data-view-component="true" class="dropdown-item">Item 2</a>
<a role="menuitem" data-view-component="true" class="dropdown-item">Item 3</a>
</details-menu>
</div>
</details>
1
2
3
4
5
6
7
8
render(Primer::Alpha::Dropdown.new) do |component|
component.with_button { "Dropdown" }
component.with_menu do |menu|
menu.with_item { "Item 1" }
menu.with_item { "Item 2" }
menu.with_item { "Item 3" }
end
end

app/components/primer/alpha/dropdown.css

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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* dropdown */
.dropdown {
position: relative;
}
.dropdown-caret {
display: inline-block;
width: 0;
height: 0;
vertical-align: middle;
content: '';
border-style: solid;
border-width: var(--borderWidth-thicker) var(--borderWidth-thicker) 0;
border-right-color: transparent;
border-bottom-color: transparent;
border-left-color: transparent;
}
/* Requires a positioning class (e.g., `.dropdown-menu-w`) to determine which
** way the menu should render from the element triggering it. */
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 100;
width: 160px;
/* stylelint-disable-next-line primer/spacing */
padding-top: var(--control-small-paddingBlock);
/* stylelint-disable-next-line primer/spacing */
padding-bottom: var(--control-small-paddingBlock);
margin-top: var(--base-size-2);
list-style: none;
background-color: var(--overlay-bgColor);
background-clip: padding-box;
border: var(--borderWidth-thin) solid var(--borderColor-default);
border-radius: var(--borderRadius-medium);
box-shadow: var(--shadow-floating-legacy, var(--color-shadow-large));
}
.dropdown-menu::before,.dropdown-menu::after {
position: absolute;
display: inline-block;
content: '';
}
/* caret border */
.dropdown-menu::before {
/* stylelint-disable-next-line primer/borders */
border: 8px solid transparent;
border-bottom-color: var(--borderColor-default);
}
/* caret background (should match dropdown background) */
.dropdown-menu::after {
/* stylelint-disable-next-line primer/borders */
border: 7px solid transparent;
border-bottom-color: var(--overlay-bgColor);
}
/* stylelint-disable-next-line selector-max-type */
.dropdown-menu > ul {
list-style: none;
}
.dropdown-menu-no-overflow {
width: auto;
}
.dropdown-menu-no-overflow .dropdown-item {
/* stylelint-disable-next-line primer/spacing */
padding: var(--control-small-paddingBlock) var(--control-medium-paddingInline-spacious);
overflow: visible;
text-overflow: inherit;
}
/* Dropdown items (can be links or buttons) */
.dropdown-item {
display: block;
/* stylelint-disable-next-line primer/spacing */
padding: var(--control-small-paddingBlock) var(--control-medium-paddingInline-condensed) var(--control-small-paddingBlock) var(--control-medium-paddingInline-spacious);
overflow: hidden;
color: var(--fgColor-default);
text-overflow: ellipsis;
white-space: nowrap;
}
.dropdown-item:hover {
color: var(--fgColor-onEmphasis);
-webkit-text-decoration: none;
text-decoration: none;
background-color: var(--bgColor-accent-emphasis);
}
.dropdown-item:hover > .octicon {
color: inherit;
opacity: 1;
}
.dropdown-item:hover [class*='color-fg-'] {
color: inherit !important;
}
.dropdown-item:hover > .Label {
color: inherit !important;
border-color: currentcolor;
}
.dropdown-item.btn-link {
width: 100%;
text-align: left;
}
.dropdown-signout {
width: 100%;
text-align: left;
background: none;
border: 0;
}
.dropdown-divider {
display: block;
height: 0;
/* stylelint-disable-next-line primer/spacing */
margin: var(--stack-gap-condensed) 0;
border-top: var(--borderWidth-thin) solid var(--borderColor-default);
}
.dropdown-header {
/* stylelint-disable-next-line primer/spacing */
padding: var(--control-small-paddingBlock) var(--control-medium-paddingInline-spacious);
font-size: var(--text-body-size-small);
color: var(--fgColor-muted);
}
.dropdown-item[aria-checked='false'] .octicon-check {
display: none;
}
/* Directional classes
**
** Move the menu and the caret attached to it. Requires at least one of these on
** the `.dropdown-menu` element. */
.dropdown-menu-w {
top: 0;
right: 100%;
left: auto;
width: auto;
margin-top: 0;
margin-right: var(--base-size-8);
}
.dropdown-menu-w::before {
/* stylelint-disable-next-line primer/spacing */
top: 10px;
/* stylelint-disable-next-line primer/spacing */
right: -16px;
left: auto;
border-color: transparent;
border-left-color: var(--borderColor-default);
}
.dropdown-menu-w::after {
top: var(--base-size-12);
/* stylelint-disable-next-line primer/spacing */
right: -14px;
left: auto;
border-color: transparent;
border-left-color: var(--overlay-bgColor);
}
.dropdown-menu-e {
top: 0;
left: 100%;
width: auto;
margin-top: 0;
margin-left: var(--base-size-8);
}
.dropdown-menu-e::before {
/* stylelint-disable-next-line primer/spacing */
top: 10px;
/* stylelint-disable-next-line primer/spacing */
left: -16px;
border-color: transparent;
border-right-color: var(--borderColor-default);
}
.dropdown-menu-e::after {
top: var(--base-size-12);
/* stylelint-disable-next-line primer/spacing */
left: -14px;
border-color: transparent;
border-right-color: var(--overlay-bgColor);
}
.dropdown-menu-ne {
top: auto;
bottom: 100%;
left: 0;
margin-bottom: var(--base-size-4);
}
.dropdown-menu-ne::before,.dropdown-menu-ne::after {
top: auto;
right: auto;
}
.dropdown-menu-ne::before {
/* stylelint-disable-next-line primer/spacing */
bottom: -8px;
left: var(--base-size-8);
/* stylelint-disable-next-line primer/borders */
border-top: 8px solid var(--borderColor-default);
/* stylelint-disable-next-line primer/borders */
border-right: 8px solid transparent;
border-bottom: 0;
/* stylelint-disable-next-line primer/borders */
border-left: 8px solid transparent;
}
.dropdown-menu-ne::after {
/* stylelint-disable-next-line primer/spacing */
bottom: -7px;
/* stylelint-disable-next-line primer/spacing */
left: 10px;
/* stylelint-disable-next-line primer/borders */
border-top: 7px solid var(--overlay-bgColor);
/* stylelint-disable-next-line primer/borders */
border-right: 7px solid transparent;
border-bottom: 0;
/* stylelint-disable-next-line primer/borders */
border-left: 7px solid transparent;
}
.dropdown-menu-s {
right: 50%;
left: auto;
transform: translateX(50%);
}
.dropdown-menu-s::before {
/* stylelint-disable-next-line primer/spacing */
top: -16px;
right: 50%;
transform: translateX(50%);
}
.dropdown-menu-s::after {
/* stylelint-disable-next-line primer/spacing */
top: -14px;
right: 50%;
transform: translateX(50%);
}
.dropdown-menu-sw {
right: 0;
left: auto;
}
.dropdown-menu-sw::before {
/* stylelint-disable-next-line primer/spacing */
top: -16px;
right: var(--base-size-8);
left: auto;
}
.dropdown-menu-sw::after {
/* stylelint-disable-next-line primer/spacing */
top: -14px;
/* stylelint-disable-next-line primer/spacing */
right: 10px;
left: auto;
}
.dropdown-menu-se::before {
/* stylelint-disable-next-line primer/spacing */
top: -16px;
left: var(--base-size-8);
}
.dropdown-menu-se::after {
/* stylelint-disable-next-line primer/spacing */
top: -14px;
/* stylelint-disable-next-line primer/spacing */
left: 10px;
}

app/components/primer/alpha/dropdown.ts

1
import './dropdown/menu'