forked from drowl87/hextra_mirror
feat: add tag support for card shortcode (#427)
* styles: accept tags on cards with default and custom colors * styles: compile css
This commit is contained in:
parent
9c0ba06db4
commit
f439e6bb87
@ -1214,6 +1214,9 @@ video {
|
|||||||
.hx-text-xs {
|
.hx-text-xs {
|
||||||
font-size: .75rem;
|
font-size: .75rem;
|
||||||
}
|
}
|
||||||
|
.hx-text-xxs {
|
||||||
|
font-size: .65rem;
|
||||||
|
}
|
||||||
.hx-font-bold {
|
.hx-font-bold {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
@ -2258,6 +2261,9 @@ article details > summary::before {
|
|||||||
.hextra-cards {
|
.hextra-cards {
|
||||||
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
|
||||||
}
|
}
|
||||||
|
.hextra-card {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
.hextra-card img {
|
.hextra-card img {
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
@ -2273,6 +2279,7 @@ article details > summary::before {
|
|||||||
}
|
}
|
||||||
.hextra-card p {
|
.hextra-card p {
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
.dark .hextra-card svg {
|
.dark .hextra-card svg {
|
||||||
color: #ffffff66;
|
color: #ffffff66;
|
||||||
@ -2280,6 +2287,13 @@ article details > summary::before {
|
|||||||
.dark .hextra-card:hover svg {
|
.dark .hextra-card:hover svg {
|
||||||
color: currentColor;
|
color: currentColor;
|
||||||
}
|
}
|
||||||
|
/* If tag, position upright on the card */
|
||||||
|
.hx-tag {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
.steps h3 {
|
.steps h3 {
|
||||||
counter-increment: step;
|
counter-increment: step;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hextra-card {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.hextra-card img {
|
.hextra-card img {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
@ -18,6 +22,7 @@
|
|||||||
|
|
||||||
.hextra-card p {
|
.hextra-card p {
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark .hextra-card svg {
|
.dark .hextra-card svg {
|
||||||
@ -27,3 +32,11 @@
|
|||||||
.dark .hextra-card:hover svg {
|
.dark .hextra-card:hover svg {
|
||||||
color: currentColor;
|
color: currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If tag, position upright on the card */
|
||||||
|
.hx-tag {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
@ -7,6 +7,7 @@ linkTitle: Cards
|
|||||||
|
|
||||||
{{< cards >}}
|
{{< cards >}}
|
||||||
{{< card link="../callout" title="Callout" icon="warning" >}}
|
{{< card link="../callout" title="Callout" icon="warning" >}}
|
||||||
|
{{< card link="../callout" title="Card with tag" icon="tag" tag="A custom tag">}}
|
||||||
{{< card link="/" title="No Icon" >}}
|
{{< card link="/" title="No Icon" >}}
|
||||||
{{< /cards >}}
|
{{< /cards >}}
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ linkTitle: Cards
|
|||||||
```
|
```
|
||||||
{{</* cards */>}}
|
{{</* cards */>}}
|
||||||
{{</* card link="../callout" title="Callout" icon="warning" */>}}
|
{{</* card link="../callout" title="Callout" icon="warning" */>}}
|
||||||
|
{{</* card link="../callout" title="Card with tag" icon="warning" tag= "A custom tag" */>}}
|
||||||
{{</* card link="/" title="No Icon" */>}}
|
{{</* card link="/" title="No Icon" */>}}
|
||||||
{{</* /cards */>}}
|
{{</* /cards */>}}
|
||||||
```
|
```
|
||||||
@ -35,12 +37,14 @@ linkTitle: Cards
|
|||||||
|
|
||||||
## Card Parameters
|
## Card Parameters
|
||||||
|
|
||||||
| Parameter | Description |
|
| Parameter | Description |
|
||||||
|----------- |---------------------------------------|
|
|----------- |-----------------------------------------------------------------|
|
||||||
| `link` | URL (internal or external). |
|
| `link` | URL (internal or external). |
|
||||||
| `title` | Title heading for the card. |
|
| `title` | Title heading for the card. |
|
||||||
| `subtitle` | Subtitle heading (supports Markdown). |
|
| `subtitle` | Subtitle heading (supports Markdown). |
|
||||||
| `icon` | Name of the icon. |
|
| `icon` | Name of the icon. |
|
||||||
|
| `tag` | Text in tag. |
|
||||||
|
| `tagColor` | Color of the tag: `gray` (default), `yellow`, `red` and `blue`. |
|
||||||
|
|
||||||
## Image Card
|
## Image Card
|
||||||
|
|
||||||
@ -62,3 +66,23 @@ Hextra auto-detects if image processing is needed during build and applies the `
|
|||||||
It currently supports these `method`: `Resize`, `Fit`, `Fill` and `Crop`.
|
It currently supports these `method`: `Resize`, `Fit`, `Fill` and `Crop`.
|
||||||
|
|
||||||
For more on Hugo's built in image processing commands, methods, and options see their [Image Processing Documentation](https://gohugo.io/content-management/image-processing/).
|
For more on Hugo's built in image processing commands, methods, and options see their [Image Processing Documentation](https://gohugo.io/content-management/image-processing/).
|
||||||
|
|
||||||
|
## Tags
|
||||||
|
|
||||||
|
The card supports adding tags with custom text and colors:
|
||||||
|
|
||||||
|
{{< cards >}}
|
||||||
|
{{< card link="../callout" title="Card with default tag color" tag= "tag text" >}}
|
||||||
|
{{< card link="../callout" title="Card with red tag" tag= "tag text" tagColor="red" >}}
|
||||||
|
{{< card link="../callout" title="Card with blue tag" tag= "tag text" tagColor="blue" >}}
|
||||||
|
{{< card link="../callout" title="Card with yellow tag" tag= "tag text" tagColor="yellow" >}}
|
||||||
|
{{< /cards >}}
|
||||||
|
|
||||||
|
```
|
||||||
|
{{</* cards */>}}
|
||||||
|
{{</* card link="../callout" title="Card with default tag color" tag= "tag text" */>}}
|
||||||
|
{{</* card link="../callout" title="Card with default red tag" tag= "tag text" tagColor="red" */>}}
|
||||||
|
{{</* card link="../callout" title="Card with blue tag" tag= "tag text" tagColor="blue" */>}}
|
||||||
|
{{</* card link="../callout" title="Card with yellow tag" tag= "tag text" tagColor="yellow" */>}}
|
||||||
|
{{</* /cards */>}}
|
||||||
|
```
|
||||||
|
@ -454,6 +454,7 @@
|
|||||||
"hx-shrink-0",
|
"hx-shrink-0",
|
||||||
"hx-sr-only",
|
"hx-sr-only",
|
||||||
"hx-sticky",
|
"hx-sticky",
|
||||||
|
"hx-tag",
|
||||||
"hx-text-2xl",
|
"hx-text-2xl",
|
||||||
"hx-text-4xl",
|
"hx-text-4xl",
|
||||||
"hx-text-[10px]",
|
"hx-text-[10px]",
|
||||||
@ -480,6 +481,7 @@
|
|||||||
"hx-text-white",
|
"hx-text-white",
|
||||||
"hx-text-xl",
|
"hx-text-xl",
|
||||||
"hx-text-xs",
|
"hx-text-xs",
|
||||||
|
"hx-text-xxs",
|
||||||
"hx-text-yellow-900",
|
"hx-text-yellow-900",
|
||||||
"hx-to-gray-600",
|
"hx-to-gray-600",
|
||||||
"hx-top-0",
|
"hx-top-0",
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
{{- $width := .width -}}
|
{{- $width := .width -}}
|
||||||
{{- $height := .height -}}
|
{{- $height := .height -}}
|
||||||
{{- $imageStyle := .imageStyle -}}
|
{{- $imageStyle := .imageStyle -}}
|
||||||
|
{{- $tag := .tag -}}
|
||||||
|
{{- $tagColor := .tagColor -}}
|
||||||
|
|
||||||
{{ $linkClass := "hover:hx-border-gray-300 hx-bg-transparent hx-shadow-sm dark:hx-border-neutral-800 hover:hx-bg-slate-50 hover:hx-shadow-md dark:hover:hx-border-neutral-700 dark:hover:hx-bg-neutral-900" }}
|
{{ $linkClass := "hover:hx-border-gray-300 hx-bg-transparent hx-shadow-sm dark:hx-border-neutral-800 hover:hx-bg-slate-50 hover:hx-shadow-md dark:hover:hx-border-neutral-700 dark:hover:hx-bg-neutral-900" }}
|
||||||
{{- with $image -}}
|
{{- with $image -}}
|
||||||
@ -50,5 +52,16 @@
|
|||||||
{{- with $subtitle -}}
|
{{- with $subtitle -}}
|
||||||
<div class="hextra-card-subtitle hx-line-clamp-3 hx-text-sm hx-font-normal hx-text-gray-500 dark:hx-text-gray-400 hx-px-4 hx-mb-4 hx-mt-2">{{- $subtitle | markdownify -}}</div>
|
<div class="hextra-card-subtitle hx-line-clamp-3 hx-text-sm hx-font-normal hx-text-gray-500 dark:hx-text-gray-400 hx-px-4 hx-mb-4 hx-mt-2">{{- $subtitle | markdownify -}}</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if $tag }}
|
||||||
|
{{ $defaultClass := "hx-text-gray-600 hx-text-xxs hx-bg-gray-100 hx-border dark:hx-bg-neutral-800 dark:hx-text-neutral-200" }}
|
||||||
|
{{ $yellowClass := "hx-border-yellow-100 hx-bg-yellow-50 hx-text-yellow-900 dark:hx-border-yellow-200/30 dark:hx-bg-yellow-700/30 dark:hx-text-yellow-200" }}
|
||||||
|
{{ $blueClass := "hx-border-blue-200 hx-bg-blue-100 hx-text-blue-900 dark:hx-border-blue-200/30 dark:hx-bg-blue-900/30 dark:hx-text-blue-200" }}
|
||||||
|
{{ $redClass := "hx-border-red-200 hx-bg-red-100 hx-text-red-900 dark:hx-border-red-200/30 dark:hx-bg-red-900/30 dark:hx-text-red-200" }}
|
||||||
|
|
||||||
|
{{ $class := cond (eq $tagColor "yellow") $yellowClass (cond (eq $tagColor "blue") $blueClass (cond (eq $tagColor "red") $redClass $defaultClass)) }}
|
||||||
|
|
||||||
|
<span class="hx-flex hx-tag hx-text-xxs hx-border hx-rounded-full hx-px-2 hx-py-1 {{ $class }}">{{ $tag }}</span>
|
||||||
|
{{- end -}}
|
||||||
</a>
|
</a>
|
||||||
{{- /* Strip trailing newline. */ -}}
|
{{- /* Strip trailing newline. */ -}}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
{{- $width := 0 -}}
|
{{- $width := 0 -}}
|
||||||
{{- $height := 0 -}}
|
{{- $height := 0 -}}
|
||||||
{{- $imageStyle := .Get "imageStyle" -}}
|
{{- $imageStyle := .Get "imageStyle" -}}
|
||||||
|
{{- $tag := .Get "tag" -}}
|
||||||
|
{{- $tagColor := .Get "tagColor" -}}
|
||||||
|
|
||||||
{{/* Image processing options */}}
|
{{/* Image processing options */}}
|
||||||
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
||||||
@ -48,5 +50,7 @@
|
|||||||
"width" $width
|
"width" $width
|
||||||
"height" $height
|
"height" $height
|
||||||
"imageStyle" $imageStyle
|
"imageStyle" $imageStyle
|
||||||
|
"tag" $tag
|
||||||
|
"tagColor" $tagColor
|
||||||
)
|
)
|
||||||
-}}
|
-}}
|
||||||
|
@ -29,6 +29,7 @@ module.exports = {
|
|||||||
'2xl': '1536px'
|
'2xl': '1536px'
|
||||||
},
|
},
|
||||||
fontSize: {
|
fontSize: {
|
||||||
|
xxs: '.65rem',
|
||||||
xs: '.75rem',
|
xs: '.75rem',
|
||||||
sm: '.875rem',
|
sm: '.875rem',
|
||||||
base: '1rem',
|
base: '1rem',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user