home ยป zplus/freepost.git
Author zPlus <zplus@peers.community> 2018-12-21 23:05:58
Committer zPlus <zplus@peers.community> 2018-12-21 23:05:58
Commit cd8cded (patch)
Tree b935b27
Parent(s)

Add burger menu (see issue #78).


commits diff: 145a539..cd8cded
4 files changed, 140 insertions, 49 deletions โ€” download


Diffstat
-rwxr-xr-x freepost/static/javascript/freepost.js 9
-rwxr-xr-x freepost/static/stylus/freepost.styl 121
-rwxr-xr-x freepost/static/stylus/reset.styl 30
-rw-r--r-- freepost/templates/layout.html 29

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+9/-0 M   freepost/static/javascript/freepost.js
index 62fd1ad..ef28937
old size: 5K - new size: 6K
@@ -144,4 +144,13 @@ document.addEventListener ('DOMContentLoaded', function() {
144 144 }
145 145 }
146 146
147 + // Function to hide/show menu when burger-icon has been clicked
148 + var burger_menus = document.getElementsByClassName ('burger-icon')
149 + for (var i = 0; i < burger_menus.length; i++)
150 + burger_menus[i].addEventListener ('click', function (event) {
151 + // Toggle menu visibility
152 + document.getElementById ('menu').classList.toggle ('visible');
153 +
154 + this.classList.toggle ('open');
155 + });
147 156 });

+83/-38 M   freepost/static/stylus/freepost.styl
index 644a2f3..99aabd0
old size: 10K - new size: 12K
@@ -40,17 +40,22 @@ body
40 40
41 41 /* Page header */
42 42 > .header
43 - @media screen and (max-width: 600px)
44 - display block
45 - text-align center
43 + @media only screen and (max-width: 800px)
44 + display grid
45 + grid-template-columns auto
46 + text-align center
46 47
47 48 > .title-large
48 49 display none
49 50
50 51 > .title-small
52 + display grid
53 + grid-template-columns max-content auto
54 + text-align center
55 +
51 56 padding-bottom 1rem
52 57
53 - @media screen and (min-width: 600px)
58 + @media only screen and (min-width: 800px)
54 59 display grid
55 60 grid-template-columns max-content auto
56 61 text-align center
@@ -61,41 +66,81 @@ body
61 66 padding 1rem 0
62 67
63 68 /* Menu under the logo */
64 - .menu
65 - border-bottom 1px solid transparent
66 - display flex
67 - flex-direction row
68 - flex-wrap wrap
69 - justify-content flex-start
70 - align-content flex-start
71 - align-items flex-end
69 + @media only screen and (max-width: 800px)
70 + .burger-icon
71 + display inline-block
72 72
73 - > .flex-item
74 - flex 0 1 auto
75 - align-self auto
76 - order 0
73 + .menu
74 + border-bottom 2px dashed #aaa
75 + display none
76 + padding-bottom 1rem
77 77
78 - border 0
79 - border-bottom 1px solid #ccc
80 - color #000
81 - margin 0
82 - padding 0 .5rem .5rem .5rem
83 -
84 - /* Highlight menu item of the current active page (Hot/New/Submit/...) */
85 - > .active_page
86 - border-bottom 3px solid #000
78 + /* This class is toggled when the burger icon is clicked */
79 + &.visible
80 + display block
81 +
82 + /* Every menu item */
83 + > a
84 + border 0
85 + color #000
86 + display block
87 + margin 0
88 + padding .5rem
89 + text-align left
90 + text-decoration none
91 +
92 + /* Highlight menu item of the current active page (Hot/New/Submit/...) */
93 + > .active_page
94 + background-color #f8f8f8
95 + border-right 4px solid black
96 + font-weight bold
97 +
98 + /* Highlight username if there are unread messages */
99 + .new_messages
100 + background-color rgb(255, 175, 50)
101 + border-radius 4px
102 + color #fff
103 + font-weight bold
104 +
105 + @media only screen and (min-width: 800px)
106 + .burger-icon
107 + display none
87 108
88 - /* Highlight username if there are unread messages */
89 - .new_messages
90 - background-color rgb(255, 175, 50)
91 - border 0
92 - border-radius 4px
93 - color #fff
94 - font-weight bold
95 - margin 0
96 - padding .5em .5em
97 - text-decoration none
98 -
109 + .menu
110 + border-bottom 1px solid transparent
111 + display flex
112 + flex-direction row
113 + flex-wrap wrap
114 + justify-content flex-start
115 + align-content flex-start
116 + align-items flex-end
117 +
118 + > .flex-item
119 + flex 0 1 auto
120 + align-self auto
121 + order 0
122 +
123 + border 0
124 + border-bottom 1px solid #ccc
125 + color #000
126 + margin 0
127 + padding 0 .5rem .5rem .5rem
128 +
129 + /* Highlight menu item of the current active page (Hot/New/Submit/...) */
130 + > .active_page
131 + border-bottom 3px solid #000
132 +
133 + /* Highlight username if there are unread messages */
134 + .new_messages
135 + background-color rgb(255, 175, 50)
136 + border 0
137 + border-radius 4px
138 + color #fff
139 + font-weight bold
140 + margin 0
141 + padding .5em .5em
142 + text-decoration none
143 +
99 144 > .content
100 145 padding 1em 0
101 146 line-height 1.5em
@@ -280,7 +325,7 @@ body
280 325
281 326 /* Login page */
282 327 > .login
283 - @media screen and (min-width: 1024px)
328 + @media only screen and (min-width: 1024px)
284 329 margin auto
285 330 max-width 40%
286 331
@@ -326,6 +371,6 @@ body
326 371 float left
327 372 margin 0 2em 0 0
328 373
329 - @media screen and (max-width: 600px)
374 + @media only screen and (max-width: 1024px)
330 375 float none
331 376 margin 1rem 0

+30/-0 M   freepost/static/stylus/reset.styl
index cb0ef21..caef7ec
old size: 5K - new size: 6K
@@ -213,3 +213,33 @@ select
213 213
214 214 ul, ol
215 215 margin 1.2em 2em
216 +
217 + /* Burger menu icon
218 + *
219 + * How to use:
220 + * <div class="burger-icon">
221 + * <div class="line1"></div>
222 + * <div class="line2"></div>
223 + * <div class="line3"></div>
224 + * </div>
225 + */
226 + .burger-icon
227 + display inline-block
228 + cursor pointer
229 +
230 + > .line1, .line2, .line3
231 + background-color #000
232 + height 4px
233 + margin 4px 0
234 + transition .5s
235 + width 36px
236 +
237 + &.open
238 + > .line1
239 + transform rotate(-45deg) translate(-0px, 11px);
240 +
241 + > .line2
242 + opacity 0
243 +
244 + > .line3
245 + transform rotate(45deg) translate(-0px, -11px)

+18/-11 M   freepost/templates/layout.html
index 208fff8..30d3092
old size: 5K - new size: 6K
@@ -15,37 +15,44 @@
15 15 <div class="container">
16 16
17 17 <div class="header">
18 - <div class="title-large">
18 +
19 + <div class="title-small">
20 + <div class="burger-icon">
21 + <div class="line1"></div>
22 + <div class="line2"></div>
23 + <div class="line3"></div>
24 + </div>
25 +
19 26 {% if topic %}
20 27 <a href="{{ url ('topic', name=topic) }}" class="flex-item logo">
21 28 topic / {{ topic }}
22 29 </a>
23 30 {% else %}
24 31 <a href="{{ url ('homepage') }}" class="flex-item logo">
25 - freepost
32 + free
33 + <img alt="๐Ÿต&nbsp;" title="freepost" src="/images/freepost.png" class="monkey" />
34 + post
26 35 </a>
27 36 {% endif %}
28 -
29 - <a href="{{ url ('homepage') }}" class="flex-item logo">
30 - <img alt="๐Ÿต&nbsp;" title="freepost" src="/images/freepost.png" class="monkey" />
31 - </a>
32 37 </div>
33 38
34 - <div class="title-small">
39 + <div class="title-large">
35 40 {% if topic %}
36 41 <a href="{{ url ('topic', name=topic) }}" class="flex-item logo">
37 42 topic / {{ topic }}
38 43 </a>
39 44 {% else %}
40 45 <a href="{{ url ('homepage') }}" class="flex-item logo">
41 - free
42 - <img alt="๐Ÿต&nbsp;" title="freepost" src="/images/freepost.png" class="monkey" />
43 - post
46 + freepost
44 47 </a>
45 48 {% endif %}
49 +
50 + <a href="{{ url ('homepage') }}" class="flex-item logo">
51 + <img alt="๐Ÿต&nbsp;" title="freepost" src="/images/freepost.png" class="monkey" />
52 + </a>
46 53 </div>
47 54
48 - <div class="menu">
55 + <div class="menu" id="menu">
49 56 <a href="{{ url ('topic', name=topic) if topic else url ('homepage') }}" class="flex-item {{ 'active_page' if active_page == 'hot' }}">
50 57 Hot
51 58 </a>