clickable headers

This commit is contained in:
zoe 2022-04-13 19:04:38 +02:00
parent 2e52a4843f
commit 2c56b25d22
10 changed files with 207 additions and 108 deletions

View file

@ -14,7 +14,8 @@ $dark-accent1: #b296ff;
$dark-accent2: #39b8a3; $dark-accent2: #39b8a3;
$dark-accent3: #dde4ff; $dark-accent3: #dde4ff;
$transition-time: 1s; $transition-time: 2s;
$trans-short: 0.2s;
body { body {
&.light { &.light {
@ -46,7 +47,7 @@ a.footer-nav-item:hover {
color: $dark-bg-alt; color: $dark-bg-alt;
background-color: $dark-bg; background-color: $dark-bg;
border-color: $dark-bg; border-color: $dark-bg;
transition: 0.24s; transition: $trans-short;
} }
footer { footer {
@ -113,62 +114,117 @@ article {
transition: $transition-time; transition: $transition-time;
} }
article h2 { h2,
h2 a {
background-color: $dark-accent1; background-color: $dark-accent1;
color: $dark-bg; color: $dark-bg;
transition: $transition-time; transition: $transition-time;
& a{
background-color: transparent;
} }
article h3 { }
h3,
h3 a {
background-color: $dark-accent2; background-color: $dark-accent2;
color: $dark-bg; color: $dark-bg;
transition: $transition-time; transition: $transition-time;
& a{
background-color: transparent;
}
} }
article.light h3 { h3.light {
background-color: $light-accent2; background-color: $light-accent2;
color: $light-bg; color: $light-bg;
transition: $transition-time; transition: $transition-time;
&a {
color: $light-bg;
}
} }
article h5, h5,
article h6, h6,
article h4 { h4 {
background-color: $dark-accent3; background-color: $dark-accent3;
color: $dark-bg; color: $dark-bg;
transition: $transition-time; transition: $transition-time;
& a {
color: $dark-bg;
background-color: transparent;
}
} }
article.light h5, h4.light,
article.light h6, h5.light,
article.light h4 { h6.light{
background-color: $light-accent3; background-color: $light-accent3;
color: $light-bg; color: $light-bg;
transition: $transition-time; transition: $transition-time;
} }
article.light h2 { h2.light {
background-color: $light-accent1; background-color: $light-accent1;
color: $light-bg; color: $light-bg;
transition: $transition-time; transition: $transition-time;
} }
article.light a { article.light a {
background-color: $light-ln; background-color: transparent;
color: $light-bg; color: $light-ln;
transition: $transition-time; transition: $transition-time;
&.hash-link{
color: $light-bg;
}
&.hash-link:hover{
background-color: transparent;
color: $light-bg;
}
} }
a:hover { a:hover {
&.light {
color: $light-bg;
background-color: $light-ln;
}
color: $dark-bg; color: $dark-bg;
background-color: $dark-ln; background-color: $dark-ln;
transition: $trans-short;
} }
.previous.light:hover,
.next.light:hover,
.postdescription a.light:hover,
article.light a:hover { article.light a:hover {
color: $light-ln; color: $light-bg;
background-color: $light-ln;
transition: $trans-short;
}
.light.hash-link:hover,
.hash-link:hover {
background-color: transparent;
transition: $transition-time;
}
h1, h2, h3, h4, h5, h6{
&a{
background-color: transparent;
color: $light-bg;
&:hover{
background-color: transparent; background-color: transparent;
} }
}
}
header.light{
background-color: $light-bg;
transition: $transition-time;
}
header{
transition: $transition-time;
}
.posttitle a{
background-color: transparent;
color: $dark-bg;
&:hover{
background-color: transparent;
}
}

View file

@ -23,16 +23,16 @@ h1 {
font-size: $huge; font-size: $huge;
} }
h2 { h2 a{
font-size: $huge; font-size: $huge;
font-style:bold; font-style:bold;
} }
h3, h4 { h3 a, h4 a {
font-size: $large; font-size: $large;
} }
h5 h6 { h5 a, h6 a {
font-size: $big; font-size: $big;
} }
@ -53,3 +53,7 @@ label::after {
h6 { h6 {
font-style: italic; font-style: italic;
} }
::before{
font-family: CaskaydiaCoveMono;
}

View file

@ -24,7 +24,8 @@ footer {
#content p, #content p,
#content ul, #content ul,
#content ol, #content ol,
#content table #content table,
.postdescription
{ {
margin-right: 24%; margin-right: 24%;
margin-left: 24%; margin-left: 24%;
@ -94,12 +95,18 @@ h6 {
padding-right: 6%; padding-right: 6%;
padding-top: 12pt; padding-top: 12pt;
padding-bottom: 12pt; padding-bottom: 12pt;
margin-right: 6%;
justify-content: right; justify-content: right;
display: flex; display: flex;
align-items: center; align-items: center;
} }
h1 {margin-right: 6%;}
h2 {margin-right: 12%;}
h3 {margin-right: 18%;}
h4 {margin-right: 24%;}
h5 {margin-right: 32%;}
h6 {margin-right: 38%;}
h2, h2,
h3, h3,
h4, h4,
@ -113,7 +120,8 @@ article {
margin-inline: auto; margin-inline: auto;
} }
.titlecontainer { .titlecontainer,
header{
width: 100%; width: 100%;
padding-top: 42pt; padding-top: 42pt;
} }

View file

@ -6,13 +6,13 @@ $toggle-height: 24pt;
border-width: 2pt; border-width: 2pt;
} }
input[type="checkbox"] { input[type="checkbox"] {
cursor: pointer; cursor: pointer;
} }
.toggleinput { .toggleinput {
opacity: 10; opacity: 0;
max-height: 10; max-height: 0;
max-width: 0;
overflow: hidden; overflow: hidden;
} }
@ -33,7 +33,7 @@ input[type="checkbox"]{
width: 20pt; width: 20pt;
border-width: 1pt; border-width: 1pt;
border-radius: 100pt; border-radius: 100pt;
transition: 0.3s; transition: 1s;
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
@ -42,14 +42,12 @@ input[type="checkbox"]{
justify-content: center; justify-content: center;
content: ""; content: "";
border-style: solid; border-style: solid;
} }
input:checked + label:after { input:checked + label:after {
left: calc(100% - 49pt); left: calc(100% - 49pt);
} }
input:checked + label::after { input:checked + label::after {
content: ""; content: "";
} }
@ -67,11 +65,25 @@ input:checked + label::after{
border: solid; border: solid;
} }
h1, h2, h3, h4, h5, h6 { h1,
h2,
h3,
h4,
h5,
h6 {
border-top-right-radius: $radius; border-top-right-radius: $radius;
border-bottom-right-radius: $radius; border-bottom-right-radius: $radius;
& .hash-link {
&:hover {
cursor: pointer;
&::before {
content: "";
}
}
}
} }
.postdescription,
#content p, #content p,
#content ul, #content ul,
#content ol, #content ol,

View file

@ -0,0 +1,5 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="colorswitch">
<a class="hash-link colorswitch" href="#{{ .Anchor | safeURL }}">
&nbsp;{{ .Text | safeHTML }}
</a>
</h{{ .Level }}>

View file

@ -3,9 +3,8 @@
{{- partial "head.html" . -}} {{- partial "head.html" . -}}
<body class="colorswitch"> <body class="colorswitch">
{{- partial "header.html" . -}} {{- partial "header.html" . -}}
<div id="content"> <div id="content">{{- block "main" . }}{{- end }}</div>
{{- block "main" . }}{{- end }}
</div>
{{- partial "footer.html" . -}} {{- partial "footer.html" . -}}
<script src="/js/main.js"></script>
</body> </body>
</html> </html>

View file

@ -1,7 +1,7 @@
{{ define "main" }} {{ define "main" }}
<main> <main>
<article> <article>
<header> <header class="colorswitch">
<h1 id="title">{{.Title}}</h1> <h1 id="title">{{.Title}}</h1>
</header> </header>
<!-- "{{.Content}}" pulls from the markdown content of the corresponding _index.md --> <!-- "{{.Content}}" pulls from the markdown content of the corresponding _index.md -->
@ -10,9 +10,12 @@
<div id="pagelist"> <div id="pagelist">
<!-- Ranges through content/posts/*.md --> <!-- Ranges through content/posts/*.md -->
{{ range .Pages }} {{ range .Pages }}
<h2> <div id="postlist">
<a class="colorswitch" href="{{.Permalink}}">{{.Title}}</h2>{{.Description}}<br>{{.WordCount}}</a> <h2 class="colorswitch posttitle">
<a class="colorswitch" href="{{.Permalink}}">{{.Title}}</h2><div class="postdescription">{{.Description}}<br>{{.WordCount}} words</a>
</div>
{{ end }} {{ end }}
</div> </div>
</div>
</main> </main>
{{ end }} {{ end }}

View file

@ -13,4 +13,3 @@
<label class="togglelabel colorswitch" for="darkmode-toggle" aria-label="darkmode toggle" role="checkbox"></label> <label class="togglelabel colorswitch" for="darkmode-toggle" aria-label="darkmode toggle" role="checkbox"></label>
</span> </span>
</footer> </footer>
<script src="/js/darkmode.js"></script>

13
static/js/headings.js Normal file
View file

@ -0,0 +1,13 @@
(function addHeadingLinks() {
var article = document.getElementById("content");
var headings = article.querySelectorAll("h1, h2, h3, h4, h5, h6");
headings.forEach(function (heading) {
if (heading.id) {
var a = document.createElement("a");
a.innerHTML = heading.innerHTML;
a.href = "#" + heading.id;
heading.innerHTML = "";
heading.appendChild(a);
}
});
})();