From ce62f7bc44539fff6aeca996a04614fb5763a7c5 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 31 Aug 2023 23:27:11 +0200 Subject: [PATCH] feat: add anchors to propertylist shortcode (#697) --- layouts/_default/_markup/render-heading.html | 8 ++++---- layouts/shortcodes/propertylist.html | 13 +++++++++---- src/sass/_base.scss | 8 ++++---- src/sass/_shortcodes.scss | 11 ++++++----- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index f947f96a..3e7a270f 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -3,16 +3,16 @@ {{- if $showAnchor -}} -
+
{{ .Text | safeHTML }} - - - + + +
{{- else -}}
diff --git a/layouts/shortcodes/propertylist.html b/layouts/shortcodes/propertylist.html index a1cdf330..ec62a48e 100644 --- a/layouts/shortcodes/propertylist.html +++ b/layouts/shortcodes/propertylist.html @@ -1,6 +1,7 @@ {{- $name := .Get "name" -}} {{- $sort := .Get "sort" -}} {{- $order := default "asc" (.Get "order") -}} +{{- $showAnchor := (and (default true .Page.Params.geekdocAnchor) (default true .Page.Site.Params.geekdocAnchor)) -}} {{- if .Site.Data.properties }}
@@ -10,11 +11,11 @@ {{- $properties = (sort $properties . $order) }} {{- end }} {{- range $properties }} -
+
{{ .name }} {{- if .required }} {{ i18n "propertylist_required" | lower }} - {{ else }} + {{- else }} {{ i18n "propertylist_optional" | lower }} {{- end }} {{- with .type }} @@ -30,6 +31,11 @@ {{ . }} {{- end }} {{- end }} + {{- if $showAnchor }} + + + + {{- end }}
@@ -38,9 +44,8 @@ {{- if reflect.IsMap $desc }} {{- $desc = (index $desc $.Site.Language.Lang) }} {{- end }} - {{ $desc | $.Page.RenderString }} - {{ end }} + {{- end }}
{{- with default "none" (.defaultValue | string) }} diff --git a/src/sass/_base.scss b/src/sass/_base.scss index 2ff735e6..395bd4b2 100644 --- a/src/sass/_base.scss +++ b/src/sass/_base.scss @@ -397,17 +397,17 @@ svg.gdoc-icon { } &__anchorwrap { + gap: 0.5em; + &:hover .gdoc-page__anchor svg.gdoc-icon { color: var(--control-icons); } } &__anchor { - margin-left: $padding-8; - svg.gdoc-icon { - width: 1.25em; - height: 1.25em; + width: 1.85em; + height: 1.85em; color: transparent; } diff --git a/src/sass/_shortcodes.scss b/src/sass/_shortcodes.scss index e13b3142..e2fb5742 100644 --- a/src/sass/_shortcodes.scss +++ b/src/sass/_shortcodes.scss @@ -203,17 +203,18 @@ .gdoc-props { &__title, &__default { + padding: 0; + margin: 0; font-family: "Liberation Mono", monospace; } &__meta { + gap: 0.5em; line-height: normal; margin-bottom: $padding-4; - > span { - margin-bottom: $padding-2; - &:not(:last-child) { - margin-right: $padding-8; - } + + &:hover .gdoc-page__anchor svg.gdoc-icon { + color: var(--control-icons); } }