Skip to content

Commit 688fead

Browse files
author
Joe Crick
committed
(master): Refactor dropdown
1 parent 9a3a6ae commit 688fead

File tree

5 files changed

+83
-82
lines changed

5 files changed

+83
-82
lines changed

index.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,19 @@ <h3>Toggling Button Label Collapse</h3>
462462

463463
</div>
464464

465-
<div class="content dropdown-content">
465+
<div class="content drop-down-content">
466466
<a name="dropdown"></a>
467467
<h2 class="content-subhead">Dropdown</h2>
468468

469-
<div tabindex="0" class="dropdown">
470-
<ul class="dropdown-content">
471-
<li>
472-
<button>Edit</button>
473-
</li>
474-
<li>
475-
<button>Delete</button>
476-
</li>
477-
</ul>
478-
</div>
469+
<div tabindex="0" class="pure-button dropdown">Dropdown Button</div>
470+
<ul class="dropdown-content">
471+
<li class="dropdown-menu-item">
472+
<button class="dropdown-action-item">Edit</button>
473+
</li>
474+
<li class="dropdown-menu-item">
475+
<button class="dropdown-action-item">Delete</button>
476+
</li>
477+
</ul>
479478

480479
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;margin-top: 50px;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre
481480
style="margin: 0; line-height: 125%">

main.css

Lines changed: 27 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/dropdown.less

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,33 @@
33
.dropdown {
44
position: relative;
55
cursor: pointer;
6-
7-
&:before {
8-
padding: 5px 10px;
9-
background-color: @white;
10-
border: 1px solid @off-white;
11-
border-radius: 5px;
12-
content: '...';
13-
}
6+
display: inline-block;
147

158
&:focus {
169
pointer-events: none;
1710
outline: none;
1811

19-
.dropdown-content {
12+
& + .dropdown-content {
2013
opacity: 1;
2114
visibility: visible;
2215
pointer-events: auto;
2316
}
2417

2518
}
19+
}
2620

27-
.dropdown-content {
28-
position: absolute;
29-
z-index: 1;
30-
opacity: 0;
31-
visibility: hidden;
32-
transition: visibility 0.5s;
33-
background-color: @white;
34-
border: 1px solid @off-white;
35-
width: auto;
36-
margin-top: 5px;
37-
padding: 10px;
38-
border-radius: 5px;
39-
40-
li {
41-
list-style-type: none;
42-
white-space: nowrap;
43-
44-
button {
45-
background: transparent;
46-
border: 0;
47-
border-radius: 5px;
48-
color: inherit;
49-
outline: 0;
50-
cursor: pointer;
51-
width: 120px;
52-
text-align: left;
53-
54-
&:hover {
55-
color: @white;
56-
background: @light-blue;
57-
}
21+
.dropdown-content {
22+
position: absolute;
23+
z-index: 1;
24+
visibility: hidden;
25+
width: auto;
5826

59-
}
27+
.dropdown-menu-item {
28+
list-style-type: none;
29+
white-space: nowrap;
6030

31+
.dropdown-action-item {
32+
background: transparent;
6133
}
6234

6335
}

src/layout.less

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,36 @@ body {
3535

3636
}
3737

38+
.dropdown-content {
39+
z-index: 1;
40+
transition: visibility 0.5s;
41+
background-color: @white;
42+
border: 1px solid @off-white;
43+
width: auto;
44+
margin-top: 5px;
45+
padding: 10px;
46+
border-radius: 5px;
47+
48+
.dropdown-menu-item {
49+
50+
.dropdown-action-item {
51+
border: 0;
52+
border-radius: 5px;
53+
color: inherit;
54+
outline: 0;
55+
cursor: pointer;
56+
width: 120px;
57+
text-align: left;
58+
59+
&:hover {
60+
color: @white;
61+
background: @light-blue;
62+
}
63+
64+
}
65+
66+
}
67+
68+
}
69+
3870
}

0 commit comments

Comments
 (0)