notice: allow for optional icon setting #212

This commit is contained in:
Sören Weber 2022-03-07 09:37:18 +01:00
parent a847d8f7bc
commit 05fa313e59
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
5 changed files with 23 additions and 44 deletions

View file

@ -38,6 +38,7 @@ That's all!
| Parameter | Default | Description | | Parameter | Default | Description |
|:--|:--|:--| |:--|:--|:--|
| title | "Attachments" | List's title | | title | "Attachments" | List's title |
| icon | "paperclip" | Sets the icon near the title; if you want no icon at all, you have to set this parameter to `" "` (a non empty string filled with spaces) |
| sort | "asc" | Sorting the output in `asc`ending or `desc`ending order | | sort | "asc" | Sorting the output in `asc`ending or `desc`ending order |
| style | "" | Choose between `orange`, `grey`, `blue` and `green` for nice style | | style | "" | Choose between `orange`, `grey`, `blue` and `green` for nice style |
| pattern | ".*" | A regular expressions, used to filter the attachments by file name. <br/><br/>The **pattern** parameter value must be [regular expressions](https://en.wikipedia.org/wiki/Regular_expression). | pattern | ".*" | A regular expressions, used to filter the attachments by file name. <br/><br/>The **pattern** parameter value must be [regular expressions](https://en.wikipedia.org/wiki/Regular_expression).

View file

@ -8,7 +8,7 @@ The notice shortcode shows four types of disclaimers to help you structure your
## Usage ## Usage
````go ````go
{{%/* notice ( note | info | tip | warning ) [ <string> ] */%}} {{%/* notice ( note | info | tip | warning ) [ <string> [ <string> ] ] */%}}
Some markup Some markup
{{%/* /notice */%}} {{%/* /notice */%}}
```` ````
@ -17,6 +17,7 @@ The first parameter is required and indicates the type of notice.
The second parameter is optional. If provided, it will be used as the title of the notice. If not provided, then the type of notice will be used as the title. For example, the title of a warning notice will be "Warning". The second parameter is optional. If provided, it will be used as the title of the notice. If not provided, then the type of notice will be used as the title. For example, the title of a warning notice will be "Warning".
The third parameter is optional. If provided, it will set the icon of near the title. For the standard types of notices, this is automatically determined but can be overridden with this parameter. If you want no icon at all, you have to set this parameter to `" "` (a non empty string filled with spaces).
## Examples ## Examples
### Note ### Note
@ -195,17 +196,17 @@ You can add:
```` ````
{{% /expand %}} {{% /expand %}}
### Notice with custom title and default color ### Notice with default color, custom title and icon
You can customize the title of the notice by passing it as a second parameter. You can customize the title of the notice by passing it as a second parameter.
{{% notice default "Pay Attention to this Note!" %}} {{% notice default "Pay Attention to this Note!" "skull-crossbones" %}}
The title is now the parameter that was provided. The title is now the parameter that was provided.
{{% /notice %}} {{% /notice %}}
{{% expand "Show markup" %}} {{% expand "Show markup" %}}
````go ````go
{{%/* notice default "Pay Attention to this Note!" */%}} {{%/* notice default "Pay Attention to this Note!" "skull-crossbones" */%}}
The title is now the parameter that was provided. The title is now the parameter that was provided.
{{%/* /notice */%}} {{%/* /notice */%}}
```` ````

View file

@ -2,8 +2,13 @@
{{- $style := .Get "style" | default "transparent" }} {{- $style := .Get "style" | default "transparent" }}
{{- $title := .Get "title" | default ("Attachments-label" | T) }} {{- $title := .Get "title" | default ("Attachments-label" | T) }}
{{- $sort := .Get "sort" | default "asc" }} {{- $sort := .Get "sort" | default "asc" }}
{{- $icon := .Get "icon" | default "" }}
{{- if and (not $icon) (eq (len $icon) 0) }}
{{- $icon = "paperclip" }}
{{- end }}
{{- $icon = trim $icon " " }}
<div class="box attachments {{ $style }}"> <div class="box attachments {{ $style }}">
<div class="box-label">{{ $title }}</div> <div class="box-label">{{ if $icon }}<i class="fas fa-{{ $icon }} fa-fw"></i> {{ end }}{{ $title }}</div>
<ul class="box-content attachments-files"> <ul class="box-content attachments-files">
{{- $filesName := "files" }} {{- $filesName := "files" }}
{{- if ne .Page.File.BaseFileName "index" }} {{- if ne .Page.File.BaseFileName "index" }}

View file

@ -1,8 +1,16 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $style := .Get 0 }} {{- $style := .Get 0 }}
{{- $title := .Get 1 | default ($style | T) }} {{- $title := .Get 1 | default ($style | T) }}
{{- $icon := .Get 2 }}
{{- if and (not $icon) (eq (len $icon) 0) }}
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
{{- if eq $style "tip" }}{{ $icon = default "lightbulb " }}{{ end }}
{{- end }}
{{- $icon = trim $icon " " }}
<div class="box notices {{ $style }}"> <div class="box notices {{ $style }}">
<div class="box-label">{{ $title }}</div> <div class="box-label">{{ if $icon }}<i class="fas fa-{{ $icon }} fa-fw"></i> {{ end }}{{ $title }}</div>
<div class="box-content"> <div class="box-content">
{{ .Inner }} {{ .Inner }}
</div> </div>

View file

@ -486,13 +486,7 @@ div.box {
div.box > .box-label { div.box > .box-label {
color: rgba( 255, 255, 255, 1 ); /* var(--BOX-CAPTION-color) */ color: rgba( 255, 255, 255, 1 ); /* var(--BOX-CAPTION-color) */
font-weight: 500; font-weight: 500;
padding: .2rem 1rem; padding: .2rem .6rem;
}
div.box > .box-label:first-child:before {
content: "";
font-family: "Font Awesome 5 Free";
font-weight: 900;
} }
div.box > .box-content { div.box > .box-content {
@ -518,12 +512,6 @@ div.box.info {
background-color: rgba( 48, 117, 229, 1 ); /* var(--INTERNAL-BOX-INFO-color) */ background-color: rgba( 48, 117, 229, 1 ); /* var(--INTERNAL-BOX-INFO-color) */
} }
div.box.info > .box-label:first-child:before {
content: "\f05a";
margin-left: -.15rem;
margin-right: .35rem;
}
div.box.info > .box-content { div.box.info > .box-content {
color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-INFO-TEXT-color) */ color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-INFO-TEXT-color) */
} }
@ -534,12 +522,6 @@ div.box.warning {
background-color: rgba( 224, 62, 62, 1 ); /* var(--INTERNAL-BOX-WARNING-color) */ background-color: rgba( 224, 62, 62, 1 ); /* var(--INTERNAL-BOX-WARNING-color) */
} }
div.box.warning > .box-label:first-child:before {
content: "\f071";
margin-left: -.15rem;
margin-right: .35rem;
}
div.box.warning > .box-content { div.box.warning > .box-content {
color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-WARNING-TEXT-color) */ color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-WARNING-TEXT-color) */
} }
@ -550,12 +532,6 @@ div.box.note {
background-color: rgba( 237, 153, 9, 1 ); /* var(--INTERNAL-BOX-NOTE-color) */ background-color: rgba( 237, 153, 9, 1 ); /* var(--INTERNAL-BOX-NOTE-color) */
} }
div.box.note > .box-label:first-child:before {
content: "\f06a";
margin-left: -.15rem;
margin-right: .35rem;
}
div.box.note > .box-content { div.box.note > .box-content {
color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-NOTE-TEXT-color) */ color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-NOTE-TEXT-color) */
} }
@ -566,12 +542,6 @@ div.box.tip {
background-color: rgba( 42, 178, 24, 1 ); /* var(--INTERNAL-BOX-TIP-color) */ background-color: rgba( 42, 178, 24, 1 ); /* var(--INTERNAL-BOX-TIP-color) */
} }
div.box.tip > .box-label:first-child:before {
content: "\f0eb";
margin-left: -.15rem;
margin-right: .35rem;
}
div.box.tip > .box-content { div.box.tip > .box-content {
color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-TIP-TEXT-color) */ color: rgba( 16, 16, 16, 1 ); /* var(--INTERNAL-BOX-TIP-TEXT-color) */
} }
@ -644,12 +614,6 @@ div.box.transparent > .box-content {
/* attachments shortcode */ /* attachments shortcode */
div.attachments > .box-label:first-child:before {
content: "\f0c6";
margin-left: -.35rem;
margin-right: .35rem;
}
div.attachments .box-content { div.attachments .box-content {
display: block; display: block;
margin: 0; margin: 0;