diff --git a/assets/css/theme.css b/assets/css/theme.css index d19724990f..b309e786e4 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -1825,7 +1825,9 @@ html[dir='rtl'] .expand[open] > .box-label > i.expander-icon { margin-inline-end: 3px; } -.list-tree i.cstyle { +/* icons with style attribute */ + +i.cstyle { color: var(--VARIABLE-BOX-color); } diff --git a/docs/content/introduction/releasenotes/7/6.en.md b/docs/content/introduction/releasenotes/7/6.en.md index befb9ec2a8..101df166b3 100644 --- a/docs/content/introduction/releasenotes/7/6.en.md +++ b/docs/content/introduction/releasenotes/7/6.en.md @@ -14,6 +14,8 @@ weight = -6 - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The new [`tree` shortcode](shortcodes/tree) displays lists as nicely formatted trees with configurable icon and icon color. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`icon` shortcode](shortcodes/icon) has learned the `style` and `color` options known from other shortcodes. + - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme [supports versioning](configuration/sitemanagement/versioning) now, where you can keep older versions of your site accessible via a version switcher at the top of the menu. - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The menu configuration for the main menu area, [introduced in 7.1.0](introduction/releasenotes/7/1), is extended to the non-scrolling menu header area between search box and main scrolling area using the `sidebarheadermenus` option and to the menu footer area using the `sidebarfootermenus` option. diff --git a/docs/content/shortcodes/icon.en.md b/docs/content/shortcodes/icon.en.md index 5994b62076..624fd9381a 100644 --- a/docs/content/shortcodes/icon.en.md +++ b/docs/content/shortcodes/icon.en.md @@ -6,9 +6,9 @@ title = 'Icon' The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome.com) library. -{{% icon exclamation-triangle %}} -{{% icon angle-double-up %}} {{% icon skull-crossbones %}} +{{% icon style="warning" %}} +{{% icon icon="angle-double-up" color="blue" %}} ## Usage @@ -16,18 +16,18 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome {{% tab title="shortcode" %}} ````go -{{%/* icon icon="exclamation-triangle" */%}} -{{%/* icon icon="angle-double-up" */%}} {{%/* icon icon="skull-crossbones" */%}} +{{%/* icon style="warning" */%}} +{{%/* icon icon="angle-double-up" color="blue" */%}} ```` {{% /tab %}} {{% tab title="shortcode (positional)" %}} ````go +{{%/* icon skull-crossbones */%}} {{%/* icon exclamation-triangle */%}} {{%/* icon angle-double-up */%}} -{{%/* icon skull-crossbones */%}} ```` {{% /tab %}} @@ -36,15 +36,16 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome ````go {{ partial "shortcodes/icon.html" (dict "page" . - "icon" "exclamation-triangle" + "icon" "skull-crossbones" +)}} +{{ partial "shortcodes/icon.html" (dict + "page" . + "style" "warning" )}} {{ partial "shortcodes/icon.html" (dict "page" . "icon" "angle-double-up" -)}} -{{ partial "shortcodes/icon.html" (dict - "page" . - "icon" "skull-crossbones" + "color" "blue" )}} ```` @@ -56,6 +57,8 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome | Name | Position | Default | Notes | |-----------------------|----------|-----------------|-------------| | **icon** | 1 | _<empty>_ | [Font Awesome icon name](#finding-an-icon) to be displayed. It will be displayed in the text color of its according context. | +| **style** | | _<empty>_ | The style scheme used for the icon.<br><br>- by severity: `caution`, `important`, `info`, `note`, `tip`, `warning`<br>- by brand color: `primary`, `secondary`, `accent`<br>- by color: `blue`, `cyan`, `green`, `grey`, `magenta`, `orange`, `red`<br>- by special color: `default`, `transparent`, `code`<br><br>You can also [define your own styles](shortcodes/notice#defining-own-styles). | +| **color** | | _<empty>_ | The [CSS color value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to be used. If not set, the chosen color depends on the **style**. Any given value will overwrite the default.<br><br>- for severity styles: a nice matching color for the severity<br>- for all other styles: the corresponding color<br><br> | ### Finding an icon @@ -63,7 +66,7 @@ Browse through the available icons in the [Font Awesome Gallery](https://fontawe Once on the Font Awesome page for a specific icon, for example the page for the [heart](https://fontawesome.com/v6/icons/heart?s=solid), copy the icon name and paste into the Markdown content. -### Customising Icons +### Customizing Icons Font Awesome provides many ways to modify the icon @@ -84,6 +87,14 @@ Built with {{%/* icon heart */%}} by Relearn and Hugo Built with {{% icon heart %}} by Relearn and Hugo +### With color + +````go +Built with {{%/* icon icon="heart" style="red" */%}} by Relearn and Hugo +```` + +Built with {{% icon icon="heart" style="red" %}} by Relearn and Hugo + ### Advanced HTML Usage While the shortcode simplifies using standard icons, the icon customization and other advanced features of the Font Awesome library require you to use HTML directly. Paste the `<i>` HTML into markup, and Font Awesome will load the relevant icon. diff --git a/layouts/partials/shortcodes/icon.html b/layouts/partials/shortcodes/icon.html index c850debe22..1f3253b240 100644 --- a/layouts/partials/shortcodes/icon.html +++ b/layouts/partials/shortcodes/icon.html @@ -4,13 +4,15 @@ {{- $filepath := "[virtual file]" }}{{ with and $page $page.File $page.File.Filename }}{{ $filepath = . }}{{ end }} {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'icon' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-18-0" $filepath }} {{- end }} -{{- $icon := .icon | default "" }} -{{- $icon = trim $icon " " }} +{{- $color := .color | default "" }} +{{- $style := .style | default "" }} +{{- $boxStyle := partial "_relearn/boxStyle.gotmpl" (dict "style" $style "icon" .icon) }} +{{- $icon := trim ($boxStyle.icon) " " }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- end }} {{- with $page }} {{- if $icon -}} -<i class="{{ $icon }}"></i> +<i class="{{ $icon }}{{ if $style }} cstyle {{ $style }}{{ end }}"{{ if $color }} style="color: {{ $color }};"{{ end }}></i> {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index 015061267d..ddefa49ced 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.5.0+64c314c65460adb4477a7001dae028ccc241bcc2 \ No newline at end of file +7.5.0+a5b517d1aadb9c5feb6e5fed9f848527763e35e7 \ No newline at end of file diff --git a/layouts/shortcodes/icon.html b/layouts/shortcodes/icon.html index a0e422addc..f5048d2766 100644 --- a/layouts/shortcodes/icon.html +++ b/layouts/shortcodes/icon.html @@ -2,4 +2,6 @@ {{- partial "shortcodes/icon.html" (dict "page" .Page "icon" (.Get "icon" | default (.Get 0)) + "style" (.Get "style" ) + "color" (.Get "color" ) ) }} \ No newline at end of file