mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-07 10:04:22 +00:00
Refactor download element
This commit is contained in:
@@ -5,7 +5,7 @@ arguments:
|
|||||||
comment: Unique name of the bookshop component.
|
comment: Unique name of the bookshop component.
|
||||||
group: partial
|
group: partial
|
||||||
|
|
||||||
# # a
|
# a
|
||||||
absolute-url:
|
absolute-url:
|
||||||
type: string
|
type: string
|
||||||
optional: true
|
optional: true
|
||||||
@@ -18,11 +18,6 @@ arguments:
|
|||||||
comment: >-
|
comment: >-
|
||||||
Account name of the video asset, required by some digital asset managers.
|
Account name of the video asset, required by some digital asset managers.
|
||||||
You can also set the default account name in the site's parameters.
|
You can also set the default account name in the site's parameters.
|
||||||
# # TODO: merge account
|
|
||||||
# account:
|
|
||||||
# type: string
|
|
||||||
# optional: true
|
|
||||||
# comment: Account name of the origin server.
|
|
||||||
active:
|
active:
|
||||||
type: bool
|
type: bool
|
||||||
optional: true
|
optional: true
|
||||||
@@ -328,6 +323,15 @@ arguments:
|
|||||||
- black
|
- black
|
||||||
- body
|
- body
|
||||||
- body-tertiary
|
- body-tertiary
|
||||||
|
color-mode:
|
||||||
|
type: select
|
||||||
|
optional: true
|
||||||
|
comment: >-
|
||||||
|
Color mode to apply to the illustration.
|
||||||
|
options:
|
||||||
|
values:
|
||||||
|
- light
|
||||||
|
- dark
|
||||||
cols:
|
cols:
|
||||||
type: int
|
type: int
|
||||||
optional: true
|
optional: true
|
||||||
@@ -336,10 +340,10 @@ arguments:
|
|||||||
options:
|
options:
|
||||||
min: 1
|
min: 1
|
||||||
max: 5
|
max: 5
|
||||||
# container:
|
container:
|
||||||
# type: string
|
type: string
|
||||||
# optional: true
|
optional: true
|
||||||
# comment: Container name of the origin server.
|
comment: Container name of the origin server.
|
||||||
# content:
|
# content:
|
||||||
# type: string
|
# type: string
|
||||||
# optional: true
|
# optional: true
|
||||||
@@ -404,12 +408,13 @@ arguments:
|
|||||||
# group: partial
|
# group: partial
|
||||||
# comment: >-
|
# comment: >-
|
||||||
# Target destination.
|
# Target destination.
|
||||||
# dir:
|
dims:
|
||||||
# type: string
|
type:
|
||||||
# optional: true
|
- slice
|
||||||
# comment: >-
|
- '[]string'
|
||||||
# All but the last element of an URL extension. For example, the dir of the
|
optional: false
|
||||||
# URL 'https://example.com/first/second/third.webp' equals '/first/second/'.
|
comment: >-
|
||||||
|
Image dimensions to use, specified as `width` `x` `height` in pixels.
|
||||||
disabled:
|
disabled:
|
||||||
type: bool
|
type: bool
|
||||||
optional: true
|
optional: true
|
||||||
@@ -419,6 +424,10 @@ arguments:
|
|||||||
optional: true
|
optional: true
|
||||||
default: false
|
default: false
|
||||||
comment: Flag to indicate the alert is dismissible.
|
comment: Flag to indicate the alert is dismissible.
|
||||||
|
download:
|
||||||
|
type: string
|
||||||
|
optional: false
|
||||||
|
comment: Path to the download file, relative to the site's static folder.
|
||||||
|
|
||||||
# e
|
# e
|
||||||
external:
|
external:
|
||||||
@@ -591,6 +600,10 @@ arguments:
|
|||||||
Address for the button or hyperlink. When set for a card group, a button
|
Address for the button or hyperlink. When set for a card group, a button
|
||||||
is added if the list exceeds the maximum number of cards to display.
|
is added if the list exceeds the maximum number of cards to display.
|
||||||
# group: partial
|
# group: partial
|
||||||
|
href-force:
|
||||||
|
type: bool
|
||||||
|
optional: true
|
||||||
|
comment: Forces the more button, ignoring page count.
|
||||||
# TODO: use title instead
|
# TODO: use title instead
|
||||||
href-title:
|
href-title:
|
||||||
type: string
|
type: string
|
||||||
@@ -652,11 +665,20 @@ arguments:
|
|||||||
type: int
|
type: int
|
||||||
optional: true
|
optional: true
|
||||||
comment: Width of the image in pixels.
|
comment: Width of the image in pixels.
|
||||||
|
imageset:
|
||||||
|
type: bool
|
||||||
|
optional: true
|
||||||
|
comment: Flag to indicate the image should be rendered as image set.
|
||||||
img:
|
img:
|
||||||
type: "*resources.resourceAdapter"
|
type: "*resources.resourceAdapter"
|
||||||
optional: true
|
optional: true
|
||||||
comment: >-
|
comment: >-
|
||||||
Image resource to process. Must be set when handling local images.
|
Image resource to process. Must be set when handling local images.
|
||||||
|
include-width:
|
||||||
|
type: bool
|
||||||
|
optional: true
|
||||||
|
comment: >-
|
||||||
|
Flag to indicate if the image set should render the image widths.
|
||||||
inline:
|
inline:
|
||||||
type: bool
|
type: bool
|
||||||
optional: true
|
optional: true
|
||||||
@@ -820,6 +842,10 @@ arguments:
|
|||||||
type: string
|
type: string
|
||||||
optional: true
|
optional: true
|
||||||
comment: ID of the asset to be embedded.
|
comment: ID of the asset to be embedded.
|
||||||
|
minimal:
|
||||||
|
type: bool
|
||||||
|
optional: true
|
||||||
|
comment: Renders the element with without a title.
|
||||||
|
|
||||||
# # TODO: merge menu
|
# # TODO: merge menu
|
||||||
# menu:
|
# menu:
|
||||||
@@ -895,7 +921,7 @@ arguments:
|
|||||||
nav-titles:
|
nav-titles:
|
||||||
type:
|
type:
|
||||||
- slice
|
- slice
|
||||||
- "[]string"
|
- '[]string'
|
||||||
optional: true
|
optional: true
|
||||||
comment: Titles of the nav items, used when passing preprocessed nav items.
|
comment: Titles of the nav items, used when passing preprocessed nav items.
|
||||||
group: partial
|
group: partial
|
||||||
@@ -1595,6 +1621,6 @@ arguments:
|
|||||||
# comment: Responsive width of the tab group.
|
# comment: Responsive width of the tab group.
|
||||||
# options:
|
# options:
|
||||||
# values:
|
# values:
|
||||||
# - "50"
|
# - 50
|
||||||
# - "100"
|
# - 100
|
||||||
# group: partial
|
# group: partial
|
||||||
|
15
data/structures/download.yml
Normal file
15
data/structures/download.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
comment: Generate a download button.
|
||||||
|
arguments:
|
||||||
|
download:
|
||||||
|
title:
|
||||||
|
class:
|
||||||
|
color:
|
||||||
|
default: primary
|
||||||
|
outline:
|
||||||
|
default: true
|
||||||
|
icon:
|
||||||
|
default: fas download
|
||||||
|
button-size:
|
||||||
|
default: sm
|
||||||
|
justify:
|
||||||
|
minimal:
|
@@ -4,24 +4,32 @@
|
|||||||
Visit gethinode.com/license for more details.
|
Visit gethinode.com/license for more details.
|
||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
{{- $download := partial "utilities/GetTargetPath.html" (dict "path" .download "page" page) -}}
|
{{ $error := false }}
|
||||||
{{- $title := .title }}
|
|
||||||
{{- $color := .color | default "primary" -}}
|
|
||||||
{{- $outline := .outline | default true -}}
|
|
||||||
{{- $icon := .icon | default "fas download" -}}
|
|
||||||
{{- $size := .size | default "sm" -}}
|
|
||||||
{{- $justify := .justify -}}
|
|
||||||
{{- $class := .class -}}
|
|
||||||
{{- $minimal := .minimal | default false -}}
|
|
||||||
|
|
||||||
|
{{/* Initialize arguments */}}
|
||||||
|
{{ $args := partial "utilities/InitArgs.html" (dict "structure" "download" "args" . "group" "partial") }}
|
||||||
|
{{ if or $args.err $args.warnmsg }}
|
||||||
|
{{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
|
||||||
|
"partial" "assets/download.html"
|
||||||
|
"msg" "Invalid arguments"
|
||||||
|
"details" ($args.errmsg | append $args.warnmsg)
|
||||||
|
"file" page.File
|
||||||
|
)}}
|
||||||
|
{{ $error = $args.err }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* Initialize local arguments */}}
|
||||||
|
{{- $title := $args.title -}}
|
||||||
|
{{- $download := partial "utilities/GetTargetPath.html" (dict "path" $args.download "page" page) -}}
|
||||||
{{- if and $download (not (fileExists (path.Join "static" $download))) -}}
|
{{- if and $download (not (fileExists (path.Join "static" $download))) -}}
|
||||||
{{- warnf "Cannot find download file for page '%s': %s" page.File.Path $download -}}
|
{{- errorf "Cannot find download file for page '%s': %s" page.File.Path $download -}}
|
||||||
|
{{- $error = true }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ with $download }}
|
{{ if not $error }}
|
||||||
{{ if not $title }}
|
{{ if not $title }}
|
||||||
{{ if not $minimal }}{{ $title = (T "download" ) }}{{ end }}
|
{{ if not $args.minimal }}{{ $title = (T "download" ) }}{{ end }}
|
||||||
{{ $lang := strings.TrimPrefix "." (path.Ext (path.BaseName .)) }}
|
{{ $lang := strings.TrimPrefix "." (path.Ext (path.BaseName $download)) }}
|
||||||
{{ if and $lang (ne (string site.LanguageCode) $lang) }}
|
{{ if and $lang (ne (string site.LanguageCode) $lang) }}
|
||||||
{{ range site.Languages }}
|
{{ range site.Languages }}
|
||||||
{{ if eq .LanguageCode $lang }}
|
{{ if eq .LanguageCode $lang }}
|
||||||
@@ -32,15 +40,15 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $attr := dict "download" (path.Base .) }}
|
{{ $attr := dict "download" (path.Base .) }}
|
||||||
{{ partial "assets/button.html" (dict
|
{{ partial "assets/button.html" (dict
|
||||||
"href" .
|
"href" $download
|
||||||
"title" $title
|
"title" $title
|
||||||
"color" $color
|
"color" $args.color
|
||||||
"outline" $outline
|
"outline" $args.outline
|
||||||
"icon" $icon
|
"icon" $args.icon
|
||||||
"button-size" $size
|
"button-size" $args.size
|
||||||
"justify" $justify
|
"justify" $args.justify
|
||||||
"class" $class
|
"class" $args.class
|
||||||
"attributes" $attr
|
"attributes" $attr
|
||||||
) }}
|
) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user