Links menu in nav on mobile, DRY-er icon styles

This commit is contained in:
daudix
2024-06-09 00:29:17 +03:00
parent 047552a6e3
commit a69c24ef0a
4 changed files with 147 additions and 19 deletions

View File

@ -64,17 +64,10 @@
}
i {
-webkit-mask-size: cover;
display: inline-block;
mask-size: cover;
transition: background-color var(--transition);
background-color: var(--fg-muted-4);
width: 1.5rem;
height: 1.5rem;
font-style: normal;
font-variant: normal;
line-height: 1;
text-rendering: auto;
}
span {

View File

@ -29,27 +29,40 @@
li {
display: inline-flex;
list-style: none;
@media only screen and (max-width: 480px) {
&.link {
display: none;
}
}
}
a {
a,
summary {
position: relative;
transition-duration: var(--transition);
transition-property: box-shadow, background-color, color, transform;
border-radius: 999px;
padding: 0.325rem 0.75rem;
color: var(--fg-muted-4);
text-decoration: none;
&:hover {
box-shadow: var(--edge-highlight);
background-color: var(--fg-muted-1);
color: var(--primary-color);
text-decoration: none;
}
&:active {
transform: scale(var(--active));
}
}
a {
text-decoration: none;
&:hover {
text-decoration: none;
}
&.active {
&:hover::before {
@ -117,18 +130,109 @@
}
}
#feed a {
#feed a,
#dropdown summary {
padding: 0.325rem 0.625rem;
svg {
vertical-align: -0.125em;
width: 1rem;
height: 1rem;
&:hover i {
background-color: var(--primary-color);
}
span {
display: none;
}
}
#dropdown {
display: none;
details {
position: relative;
border-radius: unset;
background-color: unset;
padding: 0;
summary {
transition-duration: var(--transition);
transition-property: box-shadow, background-color, color, transform;
border-radius: 999px;
background-color: unset;
color: var(--fg-muted-4);
list-style: none;
&::marker,
&::-webkit-details-marker {
display: none;
}
&:hover {
box-shadow: var(--edge-highlight);
background-color: var(--fg-muted-1);
color: var(--primary-color);
i {
background-color: var(--primary-color);
}
}
&:active {
transform: scale(var(--active));
}
}
ul {
-webkit-backdrop-filter: var(--blur);
position: absolute;
left: 50%;
transform: translate(-50%, 1rem);
z-index: 1;
backdrop-filter: var(--blur);
box-shadow: var(--edge-highlight), var(--shadow);
border-radius: var(--rounded-corner);
background-color: var(--nav-bg);
padding: 0.25rem;
text-align: center;
li {
width: 100%;
a {
border-radius: calc(var(--rounded-corner) - 0.25rem);
width: 100%;
&.active::before {
top: 0;
border-radius: 0.25rem;
}
}
}
}
}
@media only screen and (max-width: 480px) {
display: inline-flex;
}
}
#feed-icon,
#menu-icon {
vertical-align: -0.125em;
transition: background-color var(--transition);
background-color: var(--fg-muted-4);
width: 1rem;
height: 1rem;
}
#feed-icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M1.988 1.988V3c.008.547.453.984 1 .988.004-.004.008-.004.012-.004v.028A8.977 8.977 0 0 1 11.988 13a.991.991 0 0 0 1 .984h1V13h-.004c0-.004 0-.004.004-.008C13.984 7.02 9.184 2.148 3.242 2.02A1.004 1.004 0 0 0 3 1.988v-.004zm0 4V7c.008.547.453.984 1 .988.004-.004.008-.004.012-.004V8a4.985 4.985 0 0 1 4.996 4.844 1.002 1.002 0 0 0 .988 1.145c.008-.005.012-.005.016-.005v.004h.984V13H10c0-3.793-3.047-6.898-6.82-6.992 0-.004-.004-.004-.004-.004A.892.892 0 0 0 3 5.988v-.004zm2 4a1.999 1.999 0 1 0-.002 3.998 1.999 1.999 0 0 0 .002-3.998m0 0'%3E%3C/path%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
}
#menu-icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M1 2h14v2H1zm0 5h14v2H1zm0 5h14v2H1zm0 0'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
}
}
}

View File

@ -47,7 +47,7 @@
{% for link in config.extra.footer.socials %}
<li>
<a href="{{ link.url | safe }}" rel="me" title="{{ link.name }}">
<i style='mask-image: url("data:image/svg+xml,{{ link.icon }}"); -webkit-mask-image: url("data:image/svg+xml,{{ link.icon }}")'></i>
<i class="icon" style='mask-image: url("data:image/svg+xml,{{ link.icon }}"); -webkit-mask-image: url("data:image/svg+xml,{{ link.icon }}")'></i>
<span>{{ link.name }}</span>
</a>
</li>

View File

@ -11,6 +11,42 @@
{{ config.title }}
</a>
</li>
{% for link in config.extra.nav.links %}
{%- if link.url is matching('https?://') %}
<li class="link">
<a href="{{ link.url | safe }}"
{% if current_url | default(value='/') | safe == link.url | safe %}
class="active"
{% endif %}>
{{ link.name }}
</a>
</li>
{%- else %}
<li class="link">
<a href="{{ get_url(path=link.url | safe )}}"
{% if current_url | default(value='/') | safe == get_url(path=link.url) | safe %}
class="active"
{% endif %}>
{{ link.name }}
</a>
</li>
{%- endif %}
{% endfor %}
{% if config.extra.nav.show_feed %}
<li id="feed">
<a href="{{ get_url(path=config.feed_filename) | safe }}">
<i id="feed-icon" class="icon"></i>
<span>Feed</span>
</a>
</li>
{% endif %}
<li id="dropdown">
<details>
<summary>
<i id="menu-icon" class="icon"></i>
<span>Menu</span>
</summary>
<ul>
{% for link in config.extra.nav.links %}
{%- if link.url is matching('https?://') %}
<li>
@ -32,14 +68,9 @@
</li>
{%- endif %}
{% endfor %}
{% if config.extra.nav.show_feed %}
<li id="feed">
<a href="{{ get_url(path=config.feed_filename) | safe }}">
<svg viewBox="0 0 16 16" fill="currentColor" height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M1.988 1.988V3c.008.547.453.984 1 .988.004-.004.008-.004.012-.004v.028A8.977 8.977 0 0 1 11.988 13a.991.991 0 0 0 1 .984h1V13h-.004c0-.004 0-.004.004-.008C13.984 7.02 9.184 2.148 3.242 2.02A1.004 1.004 0 0 0 3 1.988v-.004zm0 4V7c.008.547.453.984 1 .988.004-.004.008-.004.012-.004V8a4.985 4.985 0 0 1 4.996 4.844 1.002 1.002 0 0 0 .988 1.145c.008-.005.012-.005.016-.005v.004h.984V13H10c0-3.793-3.047-6.898-6.82-6.992 0-.004-.004-.004-.004-.004A.892.892 0 0 0 3 5.988v-.004zm2 4a1.999 1.999 0 1 0-.002 3.998 1.999 1.999 0 0 0 .002-3.998m0 0"></path></svg>
<span>Feed</span>
</a>
</ul>
</details>
</li>
{% endif %}
</ul>
</nav>
</header>