feat: add sizes 'regular' and 'large' to button shortcode (#50)

This commit is contained in:
Robert Kaussow 2021-05-24 15:22:22 +02:00 committed by GitHub
parent 29b10769b7
commit c697cf1edd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 8 deletions

View File

@ -70,6 +70,9 @@ steps:
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
status:
- failure
- success
trigger: trigger:
ref: ref:
@ -273,6 +276,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: ed591d67a16d6ff6ea8b7dbff12194da646bb369903a6c2e62be812e66ae6700 hmac: ebb333a66d8fd050835b2b5b479e5b9f3316aaa919c48476f5714979567d0e0a
... ...

View File

@ -23,7 +23,7 @@ The theme bundles some handy shortcodes that tries to cover common situations.
Buttons are styled links that can lead to local page or external link. Buttons are styled links that can lead to local page or external link.
```tpl ```tpl
{{</* button relref="/" [class="..."] */>}}Get Home{{</* /button */>}} {{</* button relref="/" [class="...", size="large|regular"] */>}}Get Home{{</* /button */>}}
{{</* button href="https://github.com/thegeeklab/hugo-geekblog" */>}}Contribute{{</* /button */>}} {{</* button href="https://github.com/thegeeklab/hugo-geekblog" */>}}Contribute{{</* /button */>}}
``` ```

View File

@ -1,17 +1,20 @@
{{ $ref := "" }} {{ $ref := "" }}
{{ $target := "" }} {{ $size := default "regular" (.Get "size" | lower) }}
{{ if not (in (slice "regular" "large") $size) }}
{{ $size = "regular" }}
{{ end }}
{{ with .Get "href" }} {{ with .Get "href" }}
{{ $ref = . }} {{ $ref = . }}
{{ $target = "_blank" }}
{{ end }} {{ end }}
{{ with .Get "relref" }} {{ with .Get "relref" }}
{{ $ref = relref $ . }} {{ $ref = relref $ . }}
{{ end }} {{ end }}
<span class="gblog-button{{ with .Get "class" }} {{ . }}{{ end }}"> <span class="gblog-button gblog-button--{{ $size }}{{ with .Get "class" }} {{ . }}{{ end }}">
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" {{ end }} class="gblog-button__link"> <a {{ with $ref }} href="{{.}}" {{ end }} class="gblog-button__link">
{{ $.Inner }} {{ $.Inner }}
</a> </a>
</span> </span>

View File

@ -82,6 +82,8 @@
// {{< button >}} // {{< button >}}
.gblog-button { .gblog-button {
$root: &;
display: inline-block; display: inline-block;
color: $gray-700; color: $gray-700;
border: $border-1 solid $gray-500; border: $border-1 solid $gray-500;
@ -93,14 +95,33 @@
display: inline-block; display: inline-block;
color: inherit !important; color: inherit !important;
text-decoration: none !important; text-decoration: none !important;
padding: $padding-4 $padding-16;
&:hover {
background: none;
}
} }
&:hover { &:hover {
background: rgba($main-color, 0.9); background: lighten($main-color, 2);
border-color: $main-color; border-color: $main-color;
color: $gray-100; color: $gray-100;
} }
&--regular {
font-size: $font-size-base;
#{$root}__link {
padding: $padding-4 $padding-8;
}
}
&--large {
font-size: $font-size-20;
#{$root}__link {
padding: $padding-8 $padding-16;
}
}
} }
// {{< hint >}} // {{< hint >}}