Skip to content

Commit 8ce6ea1

Browse files
committed
Simplify sidebar style
Avoid element shifting when rendering
1 parent e6ebcab commit 8ce6ea1

File tree

5 files changed

+211
-172
lines changed

5 files changed

+211
-172
lines changed

_includes/sidebar.html

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
MIT License
77
-->
88

9-
<div id="nav-wrapper">
9+
<div id="sidebar" class="d-flex flex-column align-items-end">
1010

11-
<div id="profile-wrapper" class="d-flex flex-column">
12-
<div id="avatar" class="d-flex justify-content-center">
13-
<a href="{{ site.baseurl }}/" alt="avatar">
11+
<div class="profile-wrapper text-center">
12+
<div id="avatar">
13+
<a href="{{ site.baseurl }}/" alt="avatar" class="mx-auto">
1414
{% assign avatar_url = site.avatar %}
1515
{% capture start %}{{ site.avatar | slice: 0 }}{% endcapture %}
1616
{% if start == '/' %}
@@ -20,26 +20,26 @@
2020
</a>
2121
</div>
2222

23-
<div class="profile-text mt-3">
24-
<div class="site-title">
25-
<a href="{{ '/' | relative_url }}">{{- site.title -}}</a>
26-
</div>
27-
<div class="site-subtitle font-italic">{{- site.tagline -}}</div>
23+
<div class="site-title mt-3">
24+
<a href="{{ '/' | relative_url }}">{{- site.title -}}</a>
2825
</div>
29-
</div><!-- #profile-wrapper -->
3026

31-
<ul class="nav flex-column">
27+
<div class="site-subtitle font-italic">{{- site.tagline -}}</div>
28+
29+
</div><!-- .profile-wrapper -->
30+
31+
<ul class="w-100">
3232
<!-- home -->
33-
<li class="nav-item d-flex justify-content-center {% if page.layout == 'home' %}active{% endif %}">
34-
<a href="{{ '/' | relative_url }}" class="nav-link d-flex justify-content-center align-items-center w-100">
33+
<li class="nav-item{% if page.layout == 'home' %}{{ " active" }}{% endif %}">
34+
<a href="{{ '/' | relative_url }}" class="nav-link">
3535
<i class="fa-fw fas fa-home ml-xl-3 mr-xl-3 unloaded"></i>
3636
<span>{{ "HOME" }}</span>
3737
</a>
3838
</li>
3939
<!-- the real tabs -->
4040
{% for tab in site.tabs %}
41-
<li class="nav-item d-flex justify-content-center {% if tab.url == page.url %}active{% endif %}">
42-
<a href="{{ tab.url | relative_url }}" class="nav-link d-flex justify-content-center align-items-center w-100">
41+
<li class="nav-item{% if tab.url == page.url %}{{ " active" }}{% endif %}">
42+
<a href="{{ tab.url | relative_url }}" class="nav-link">
4343
<i class="fa-fw {{ tab.icon }} ml-xl-3 mr-xl-3 unloaded"></i>
4444
<span>{{ tab.title | upcase }}</span>
4545
</a>
@@ -48,38 +48,44 @@
4848

4949
</ul> <!-- ul.nav.flex-column -->
5050

51-
</div><!-- #nav-wrapper -->
51+
<div class="sidebar-bottom mt-auto d-flex flex-wrap justify-content-center">
52+
53+
{% for entry in site.data.contact %}
54+
{% capture url %}
55+
{%- if entry.type == 'github' -%}
56+
https://github.com/{{ site.github.username }}
57+
{%- elsif entry.type == 'twitter' -%}
58+
https://twitter.com/{{ site.twitter.username }}
59+
{%- elsif entry.type == 'email' -%}
60+
{% assign email = site.social.email | split: '@' %}
61+
javascript:location.href = 'mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@')
62+
{%- elsif entry.type == 'rss' -%}
63+
{{ "/feed.xml" | relative_url }}
64+
{%- else -%}
65+
{{ entry.url }}
66+
{%- endif -%}
67+
{% endcapture %}
5268

53-
<div class="sidebar-bottom d-flex flex-wrap justify-content-around mt-4">
69+
{% if url %}
70+
<a href="{{ url }}" aria-label="{{ entry.type }}"
71+
{% unless site.theme_mode %}class="order-{{ forloop.index | plus: 2 }}"{% endunless %}
72+
{% unless entry.noblank %}target="_blank" rel="noopener"{% endunless %}>
73+
<i class="{{ entry.icon }}"></i>
74+
</a>
75+
{% endif %}
76+
77+
{% endfor %}
5478

55-
{% unless site.theme_mode %}
56-
<span id="mode-toggle-wrapper">
57-
{% include mode-toggle.html %}
58-
</span>
59-
<span class="icon-border"></span>
60-
{% endunless %}
79+
{% unless site.theme_mode %}
80+
{% if site.data.contact.size > 0 %}
81+
<span class="icon-border order-2"></span>
82+
{% endif %}
6183

62-
{% for entry in site.data.contact %}
63-
{% capture url %}
64-
{%- if entry.type == 'github' -%}
65-
https://github.com/{{ site.github.username }}
66-
{%- elsif entry.type == 'twitter' -%}
67-
https://twitter.com/{{ site.twitter.username }}
68-
{%- elsif entry.type == 'email' -%}
69-
{% assign email = site.social.email | split: '@' %}
70-
javascript:location.href = 'mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@')
71-
{%- elsif entry.type == 'rss' -%}
72-
{{ "/feed.xml" | relative_url }}
73-
{%- else -%}
74-
{{ entry.url }}
75-
{%- endif -%}
76-
{% endcapture %}
84+
<span id="mode-toggle-wrapper" class="order-1">
85+
{% include mode-toggle.html %}
86+
</span>
87+
{% endunless %}
7788

78-
{% if url %}
79-
<a href="{{ url }}" aria-label="{{ entry.type }}" {% unless entry.noblank %}target="_blank" rel="noopener"{% endunless %}>
80-
<i class="{{ entry.icon }}"></i>
81-
</a>
82-
{% endif %}
83-
{% endfor %}
89+
</div> <!-- .sidebar-bottom -->
8490

85-
</div>
91+
</div><!-- #sidebar -->

_layouts/default.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
<body data-spy="scroll" data-target="#toc">
2323

24-
<div id="sidebar" class="d-flex flex-column">
25-
{% include sidebar.html %}
26-
</div>
24+
{% include sidebar.html %}
2725

2826
{% include topbar.html %}
2927

0 commit comments

Comments
 (0)