improve anchor link alignment and spacing

master
Robert Kaussow 2020-03-17 23:22:51 +01:00
parent d94c32f892
commit 06c9a95b75
5 changed files with 45 additions and 12 deletions

View File

@ -1,5 +1,3 @@
* FEATURE * ENHANCEMENT
* add iconfont based on svg icons * improve anchor link alignment and spacing
* BUGFIX * show anchor link only on `:hover`
* use iconfont in next/prev links to fix unicode errors on mobile devices
* use fake underline for next/pref links on hover

View File

@ -28,3 +28,5 @@ params:
geekdocLegalNotice: https://geeklabor.de/legal-notice/#impressum geekdocLegalNotice: https://geeklabor.de/legal-notice/#impressum
geekdocPrivacyPolicy: https://geeklabor.de/legal-notice/#datenschutzerkl%C3%A4rung geekdocPrivacyPolicy: https://geeklabor.de/legal-notice/#datenschutzerkl%C3%A4rung
geekdocAnchorLeft: true

View File

@ -22,6 +22,14 @@ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.
##### Level 2.1.1.1
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
###### Level 2.1.1.1.1
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
### Level 2.2 ### Level 2.2
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

View File

@ -3,9 +3,9 @@
{{ $.Scratch.Set "content" (.Content | replaceRE `<nav id="TableOfContents">\s*<ul>\s*<li>\s*<ul>` `<nav id="TableOfContents"><ul>` | replaceRE `</ul>\s*</li>\s*</ul>\s*</nav>` `</ul></nav>` | safeHTML) }} {{ $.Scratch.Set "content" (.Content | replaceRE `<nav id="TableOfContents">\s*<ul>\s*<li>\s*<ul>` `<nav id="TableOfContents"><ul>` | replaceRE `</ul>\s*</li>\s*</ul>\s*</nav>` `</ul></nav>` | safeHTML) }}
{{ if and $showAnchor $anchorLeft }} {{ if and $showAnchor $anchorLeft }}
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--left clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s%s` `${1}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${3}` `${4}`) | safeHTML) }} {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `<div class="gdoc-page__anchorwrap">%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--left clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s%s</div>` `${1}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${3}` `${4}`) | safeHTML) }}
{{ else if and $showAnchor (not $anchorLeft) }} {{ else if and $showAnchor (not $anchorLeft) }}
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `%s%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--right clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s` `${1}` `${3}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${4}`) | safeHTML) }} {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `<div class="gdoc-page__anchorwrap">%s%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--right clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s</div>` `${1}` `${3}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${4}`) | safeHTML) }}
{{ end }} {{ end }}
{{ $.Scratch.Get "content" }} {{ $.Scratch.Get "content" }}

View File

@ -234,18 +234,29 @@ img {
} }
} }
&__anchorwrap {
&:hover .gdoc-page__anchor .icon {
color: $gray-500;
}
}
&__anchor { &__anchor {
min-width: 30px;
&--left { &--left {
min-width: 35px; position: absolute;
margin-left: -25px;
text-align: left; text-align: left;
} }
&--right { &--right {
margin-left: 0.5em; text-align: right;
} }
.icon { .icon {
color: $gray-400; width: 1.4rem;
height: 1.4rem;
color: transparent;
} }
} }
} }
@ -452,6 +463,10 @@ img {
} }
.gdoc-header { .gdoc-header {
.container {
padding: $padding-16 $padding-16 * 2;
}
.icon { .icon {
width: $font-size-16 * 1.5; width: $font-size-16 * 1.5;
height: $font-size-16 * 1.5; height: $font-size-16 * 1.5;
@ -492,9 +507,19 @@ img {
display: none; display: none;
} }
.gdoc-footer__item { .gdoc-page {
padding: $padding-16 * 1.5 $padding-16 * 2;
}
.gdoc-footer {
.container {
padding: $padding-16 $padding-16 * 2;
}
&__item {
width: 100%; width: 100%;
} }
}
#menu-control:checked ~ main { #menu-control:checked ~ main {
.gdoc-nav nav, .gdoc-nav nav,