Skip to content

Commit 560694f

Browse files
smasher164andybons
authored andcommitted
playground: use flexbox for navbar layout
Previously, resizing the viewport until the width of the logo and control elements is greater would cause all of the control elements to disappear. This behavior became exacerbated with the addition of more control elements. Additionally, the alignment and styling of buttons would vary between browsers, particuarly between desktop and mobile. This change uses flexbox for layout in the navbar, instead of floats. Wrapping is now done per-element, instead of the whole control container. All buttons are adjusted to have a unified alignment, and styling is made more consistent across browsers. Fixes golang/go#38482. Change-Id: I1946c4a44da9de9b206b17d4d155ff8422e9ad80 Reviewed-on: https://go-review.googlesource.com/c/playground/+/229419 Reviewed-by: Andrew Bonventre <[email protected]> Run-TryBot: Andrew Bonventre <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 66a9e4b commit 560694f

File tree

2 files changed

+48
-52
lines changed

2 files changed

+48
-52
lines changed

edit.html

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,35 +104,31 @@
104104
<input type="button" value="Run" id="embedRun">
105105
<div id="banner">
106106
<div id="head" itemprop="name">The Go Playground</div>
107-
<div id="controls">
108-
<input type="button" value="Run" id="run">
109-
<input type="button" value="Format" id="fmt">
110-
<div id="importsBox">
111-
<label title="Rewrite imports on Format">
112-
<input type="checkbox" id="imports">
113-
Imports
114-
</label>
115-
</div>
116-
{{if $.Share}}
117-
<input type="button" value="Share" id="share">
118-
<input type="text" id="shareURL">
119-
<label id="embedLabel">
120-
<input type="checkbox" id="embed">
121-
embed
107+
<input type="button" value="Run" id="run">
108+
<input type="button" value="Format" id="fmt">
109+
<div id="importsBox">
110+
<label title="Rewrite imports on Format">
111+
<input type="checkbox" id="imports">
112+
Imports
122113
</label>
123-
{{end}}
124-
<select class="js-playgroundToysEl">
125-
<option value="hello.txt">Hello, playground</option>
126-
<option value="test.txt">Tests</option>
127-
<option value="multi.txt">Multiple files</option>
128-
<option value="image.txt">Display image</option>
129-
<option value="sleep.txt">Sleep</option>
130-
<option value="clear.txt">Clear</option>
131-
</select>
132-
</div>
133-
<div id="aboutControls">
134-
<input type="button" value="About" id="aboutButton">
135114
</div>
115+
{{if $.Share}}
116+
<input type="button" value="Share" id="share">
117+
<input type="text" id="shareURL">
118+
<label id="embedLabel">
119+
<input type="checkbox" id="embed">
120+
embed
121+
</label>
122+
{{end}}
123+
<select class="js-playgroundToysEl">
124+
<option value="hello.txt">Hello, playground</option>
125+
<option value="test.txt">Tests</option>
126+
<option value="multi.txt">Multiple files</option>
127+
<option value="image.txt">Display image</option>
128+
<option value="sleep.txt">Sleep</option>
129+
<option value="clear.txt">Clear</option>
130+
</select>
131+
<input type="button" value="About" id="aboutButton">
136132
</div>
137133
<div id="wrap">
138134
<textarea itemprop="description" id="code" name="code" autocorrect="off" autocomplete="off" autocapitalize="off" spellcheck="false">{{printf "%s" .Snippet.Body}}</textarea>

static/style.css

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,34 @@ a {
7979
margin: 0;
8080
}
8181
#banner {
82+
display: flex;
83+
flex-wrap: wrap;
84+
align-items: center;
8285
position: absolute;
8386
left: 0;
8487
right: 0;
8588
top: 0;
8689
height: 50px;
8790
background-color: #E0EBF5;
8891
}
92+
#banner > * {
93+
margin-top: 10px;
94+
margin-bottom: 10px;
95+
margin-right: 5px;
96+
border-radius: 5px;
97+
box-sizing: border-box;
98+
height: 30px;
99+
}
89100
#head {
90-
float: left;
91-
padding: 15px 10px;
92-
101+
padding-left: 10px;
102+
padding-right: 20px;
103+
padding-top: 5px;
93104
font-size: 20px;
94105
font-family: sans-serif;
95106
}
96-
#controls {
97-
float: left;
98-
padding: 10px 15px;
99-
min-width: 245px;
100-
}
101-
#controls > input {
102-
border-radius: 5px;
103-
}
104-
#aboutControls {
105-
float: right;
106-
padding: 10px 15px;
107+
#aboutButton {
108+
margin-left: auto;
109+
margin-right: 15px;
107110
}
108111
input[type=button],
109112
#importsBox {
@@ -116,30 +119,33 @@ input[type=button],
116119
position: static;
117120
top: 1px;
118121
border-radius: 5px;
122+
-webkit-appearance: none;
119123
}
120124
#importsBox {
121-
position: relative;
122-
display: inline;
123-
padding: 5px 0;
124-
margin-right: 5px;
125+
padding: 0.25em 7px;
125126
}
126127
#importsBox input {
127128
position: relative;
128129
top: -2px;
129130
left: 1px;
130131
height: 10px;
131132
width: 10px;
133+
margin-left: 0;
132134
}
133135
#shareURL {
134136
width: 280px;
135137
font-size: 16px;
136138
border: 1px solid #ccc;
137139
background: #eee;
138140
color: black;
139-
height: 23px;
140141
}
141142
#embedLabel {
142143
font-family: sans-serif;
144+
padding-top: 5px;
145+
}
146+
#banner > select {
147+
font-size: 0.875rem;
148+
border: 0.0625rem solid #375EAB;
143149
}
144150
.lines {
145151
float: left;
@@ -173,10 +179,4 @@ input[type=button],
173179
z-index: 1;
174180
top: 10px;
175181
right: 10px;
176-
}
177-
178-
#controls select {
179-
font-size: 0.875rem;
180-
border: 0.0625rem solid #375EAB;
181-
margin: 0;
182182
}

0 commit comments

Comments
 (0)