Skip to content

Commit

Permalink
Add main menu
Browse files Browse the repository at this point in the history
Move some less-used menu items to a new click-to-show menu at the top right.
  • Loading branch information
samwilson authored Feb 7, 2023
1 parent 3a87a48 commit de5c4a2
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 45 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.less]
indent_style = space
indent_size = 2

30 changes: 1 addition & 29 deletions assets/css/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "security";
@import "contact";
@import "tags";
@import "site-header";

@font-color: #283434;
@font-color-light: #768282;
Expand Down Expand Up @@ -114,35 +115,6 @@ a {
text-decoration: none;
}

body > header {
flex: 2;
text-align: center;
border-bottom: @border-primary;
padding: 0.5rem;
background-color: #f1f8f2;
a { color: @font-color; }

h1 {
color: @font-color;
margin: 0;
font-variant: small-caps;
letter-spacing: 0.1em;
}

nav ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
margin: 0;
padding: 0;
}

nav ul li {
flex: 1;
padding: 0 0.2em;
}
}

a:hover {
text-decoration: underline;
color: #2c2cff;
Expand Down
105 changes: 105 additions & 0 deletions assets/css/site-header.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
body > header {
flex: 2;
text-align: center;
border-bottom: @border-primary;
padding: 0.5rem;
background-color: #f1f8f2;

a {
color: @font-color;
}

h1 {
color: @font-color;
margin: 0;
font-variant: small-caps;
letter-spacing: 0.1em;
}
}

nav.main-nav ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
margin: 0;
padding: 0;

li {
flex: 1;
padding: 0 0.2em;
}
}

.opaque-underlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(326deg, #fdfbf9 0%, #f3f2f1 98%);
opacity: 0.5;
content: '';
z-index: 10;
display: none;
}

nav.main-menu {
position: absolute;
right: 0;
top: 0;
text-align: right;
opacity: 0.6;
z-index: 20;

&.menu-open {
background-color: white;
box-shadow: -3px 3px 6px 0 rgba(212, 212, 212, 1);
border: 1px solid #bbb;
border-width: 0 0 1px 1px;
opacity: 1;

ul {
display: block;
}
}

&.menu-closed ul {
display: none;
}

div {
padding-right: 5px;
text-align: right;
}

img {
cursor: pointer;
}

ul {
text-align: left;
margin: 0;
padding: 0;
display: block;
list-style-type: none;
}

li > * {
display: block;
padding: 5px 15px;
border-bottom: 1px solid #bbb;
}

li:first-of-type > * {
border-top: 1px solid #bbb;
}

li:last-of-type > * {
border-bottom: 0;
}

li > *:hover {
text-decoration: none;
background-color: lightcyan;
}
}
1 change: 1 addition & 0 deletions assets/img/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../css/app.less';
import './timezone-converter';
import './tags';
import './site-header';
15 changes: 15 additions & 0 deletions assets/js/site-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(function () {
const mainMenu = document.querySelector('.main-menu');
const underlay = document.querySelector('.opaque-underlay');
document.querySelector('.main-menu img').onclick = () => {
if (mainMenu.classList.contains('menu-closed')) {
mainMenu.classList.add('menu-open');
mainMenu.classList.remove('menu-closed');
underlay.style.display = 'block';
} else {
mainMenu.classList.remove('menu-open');
mainMenu.classList.add('menu-closed');
underlay.style.display = 'none';
}
};
})();
1 change: 0 additions & 1 deletion public/build/app.5e9a0e52.css

This file was deleted.

2 changes: 0 additions & 2 deletions public/build/app.6dc3586a.js

This file was deleted.

1 change: 1 addition & 0 deletions public/build/app.72b68240.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/build/app.89a670f8.js

Large diffs are not rendered by default.

File renamed without changes.
4 changes: 2 additions & 2 deletions public/build/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"js": [
"/build/runtime.188fa053.js",
"/build/98.7dea510e.js",
"/build/app.6dc3586a.js"
"/build/app.89a670f8.js"
],
"css": [
"/build/app.5e9a0e52.css"
"/build/app.72b68240.css"
]
},
"map": {
Expand Down
1 change: 1 addition & 0 deletions public/build/images/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions public/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build/app.css": "/build/app.5e9a0e52.css",
"build/app.js": "/build/app.6dc3586a.js",
"build/app.css": "/build/app.72b68240.css",
"build/app.js": "/build/app.89a670f8.js",
"build/map.css": "/build/map.fa728e1a.css",
"build/map.js": "/build/map.3c3bd4fc.js",
"build/frontend.css": "/build/frontend.709f92e8.css",
Expand All @@ -17,6 +17,7 @@
"build/images/layers.png": "/build/images/layers.416d9136.png",
"build/images/map-pin.png": "/build/images/map-pin.png",
"build/images/send.png": "/build/images/send.png",
"build/images/menu.svg": "/build/images/menu.svg",
"build/images/map-pin.svg": "/build/images/map-pin.svg",
"build/images/send.svg": "/build/images/send.svg",
"build/images/wikidata-logo.png": "/build/images/wikidata-logo.png"
Expand Down
28 changes: 19 additions & 9 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,35 @@
</head>
<body>
<header>
<h1><a href="{{ path('home') }}">{{ settings.siteName }}</a></h1>
<nav>
<div class="opaque-underlay"></div>
<nav class="main-menu menu-closed">
<div>
<img src="{{ asset('build/images/menu.svg') }}" alt="Main menu icon." />
</div>
<ul>
<li><a href="{{ path('home') }}">Home</a></li>
<li><a href="{{ path('tags') }}">Tags</a></li>
<li><a href="{{ path('dates') }}">Dates</a></li>
<li><a href="{{ path('map') }}">Map</a></li>
{% if is_granted('ROLE_ADMIN') %}
<li><a href="{{ path('post_create') }}">New post</a></li>
<li><a href="{{ path('post_upload') }}">Upload</a></li>
<li><a href="{{ path('contacts') }}">Contacts</a></li>
<li><a href="{{ path('settings') }}">Settings</a></li>
{% endif %}
{% if app.user %}
<li>Logged in as {{ app.user.username }}</li>
<li><span>Logged in as {{ app.user.username }}</span></li>
<li><a href="{{ path('logout') }}">Log out</a></li>
{% else %}
<li><a href="{{ path('login') }}">{{'security.log_in'|trans}}</a></li>
{% endif %}
<ul>
</nav>
<h1><a href="{{ path('home') }}">{{ settings.siteName }}</a></h1>
<nav class="main-nav">
<ul>
<li><a href="{{ path('home') }}">Home</a></li>
<li><a href="{{ path('tags') }}">Tags</a></li>
<li><a href="{{ path('dates') }}">Dates</a></li>
<li><a href="{{ path('map') }}">Map</a></li>
{% if is_granted('ROLE_ADMIN') %}
<li><a href="{{ path('post_create') }}">New post</a></li>
<li><a href="{{ path('post_upload') }}">Upload</a></li>
{% endif %}
</ul>
</nav>
</header>
Expand Down

0 comments on commit de5c4a2

Please sign in to comment.