mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
tabs: add title and icon option #552
This commit is contained in:
parent
f50c362c8e
commit
a79f81322a
4 changed files with 43 additions and 15 deletions
|
@ -20,9 +20,9 @@ This document shows you what's new in the latest release. For a detailed list of
|
||||||
|
|
||||||
## 5.16.0 (2023-06-05)
|
## 5.16.0 (2023-06-05)
|
||||||
|
|
||||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) and the [`tab` shortcode]({{% relref "shortcodes/tab" %}}) received some love and style, color and icon parameter similar to other shortcodes.
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) and the [`tab` shortcode]({{% relref "shortcodes/tab" %}}) received some love and now align with their style, color, title and icon parameter to the other shortcodes.
|
||||||
|
|
||||||
If you now display a single code block in a tab, its default styling will adapt to that of a code block but with a tab handle at the top.
|
The visuals are now slightly different compared to previous versions. Most noteable, if you now display a single code block in a tab, its default styling will adapt to that of a code block but with a tab handle at the top.
|
||||||
|
|
||||||
Additionally the `name` parameter was renamed to `title` but you don't need to change anything yet as the old name will be used as a fallback but you will get deprecation warnings while executing Hugo.
|
Additionally the `name` parameter was renamed to `title` but you don't need to change anything yet as the old name will be used as a fallback but you will get deprecation warnings while executing Hugo.
|
||||||
|
|
||||||
|
|
|
@ -9,20 +9,27 @@ This comes in handy eg. for providing code snippets for multiple languages.
|
||||||
|
|
||||||
If you just want a single tab you can instead call the [`tab` shortcode]({{% relref "shortcodes/tab" %}}) standalone.
|
If you just want a single tab you can instead call the [`tab` shortcode]({{% relref "shortcodes/tab" %}}) standalone.
|
||||||
|
|
||||||
{{< tabs >}}
|
{{< tabs title="hello." >}}
|
||||||
{{% tab title="python" %}}
|
{{% tab title="py" %}}
|
||||||
|
|
||||||
```python
|
```python
|
||||||
print("Hello World!")
|
print("Hello World!")
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
{{% tab title="bash" %}}
|
{{% tab title="sh" %}}
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "Hello World!"
|
echo "Hello World!"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{{% /tab %}}
|
||||||
|
{{% tab title="c" %}}
|
||||||
|
|
||||||
|
```c
|
||||||
|
printf("Hello World!");
|
||||||
|
```
|
||||||
|
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
@ -36,17 +43,22 @@ See the [`tab` shortcode]({{% relref "shortcodes/tab" %}}) for a description of
|
||||||
{{% tab title="shortcode" %}}
|
{{% tab title="shortcode" %}}
|
||||||
|
|
||||||
````go
|
````go
|
||||||
{{</* tabs */>}}
|
{{</* tabs title="hello." */>}}
|
||||||
{{%/* tab title="python" */%}}
|
{{%/* tab title="py" */%}}
|
||||||
```python
|
```python
|
||||||
print("Hello World!")
|
print("Hello World!")
|
||||||
```
|
```
|
||||||
{{%/* /tab */%}}
|
{{%/* /tab */%}}
|
||||||
{{%/* tab title="bash" */%}}
|
{{%/* tab title="sh" */%}}
|
||||||
```bash
|
```bash
|
||||||
echo "Hello World!"
|
echo "Hello World!"
|
||||||
```
|
```
|
||||||
{{%/* /tab */%}}
|
{{%/* /tab */%}}
|
||||||
|
{{%/* tab title="c" */%}}
|
||||||
|
```c
|
||||||
|
printf"Hello World!");
|
||||||
|
```
|
||||||
|
{{%/* /tab */%}}
|
||||||
{{</* /tabs */>}}
|
{{</* /tabs */>}}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -56,15 +68,20 @@ echo "Hello World!"
|
||||||
````go
|
````go
|
||||||
{{ partial "shortcodes/tabs.html" (dict
|
{{ partial "shortcodes/tabs.html" (dict
|
||||||
"context" .
|
"context" .
|
||||||
|
"title" "hello."
|
||||||
"content" (slice
|
"content" (slice
|
||||||
(dict
|
(dict
|
||||||
"title" "python"
|
"title" "py"
|
||||||
"content" ("```python\nprint(\"Hello World!\")\n```" | .RenderString)
|
"content" ("```python\nprint(\"Hello World!\")\n```" | .RenderString)
|
||||||
)
|
)
|
||||||
(dict
|
(dict
|
||||||
"title" "bash"
|
"title" "sh"
|
||||||
"content" ("```bash\necho \"Hello World!\"\n```" | .RenderString)
|
"content" ("```bash\necho \"Hello World!\"\n```" | .RenderString)
|
||||||
)
|
)
|
||||||
|
(dict
|
||||||
|
"title" "c"
|
||||||
|
"content" ("```c\nprintf(\"Hello World!\");\n```" | .RenderString)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)}}
|
)}}
|
||||||
````
|
````
|
||||||
|
@ -79,6 +96,8 @@ echo "Hello World!"
|
||||||
| **groupid** | _<random>_ | Arbitrary name of the group the tab view belongs to.<br><br>Tab views with the same **groupid** sychronize their selected tab. The tab selection is restored automatically based on the `groupid` for tab view. If the selected tab can not be found in a tab group the first tab is selected instead.<br><br>This sychronization applies to the whole site! |
|
| **groupid** | _<random>_ | Arbitrary name of the group the tab view belongs to.<br><br>Tab views with the same **groupid** sychronize their selected tab. The tab selection is restored automatically based on the `groupid` for tab view. If the selected tab can not be found in a tab group the first tab is selected instead.<br><br>This sychronization applies to the whole site! |
|
||||||
| **style** | _<empty>_ | Sets a default value for every contained tab. Can be overridden by each tab. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values. |
|
| **style** | _<empty>_ | Sets a default value for every contained tab. Can be overridden by each tab. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values. |
|
||||||
| **color** | _<empty>_ | Sets a default value for every contained tab. Can be overridden by each tab. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values. |
|
| **color** | _<empty>_ | Sets a default value for every contained tab. Can be overridden by each tab. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values. |
|
||||||
|
| **title** | _<empty>_ | Arbitrary title written in front of the tabs. |
|
||||||
|
| **icon** | _<empty>_ | [Font Awesome icon name]({{%relref "shortcodes/icon#finding-an-icon" %}}) set to the left of the title. |
|
||||||
| _**<content>**_ | _<empty>_ | Arbitrary number of tabs defined with the `tab` sub-shortcode. |
|
| _**<content>**_ | _<empty>_ | Arbitrary number of tabs defined with the `tab` sub-shortcode. |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
@ -200,10 +219,10 @@ Hello = World
|
||||||
|
|
||||||
In case you want to nest tabs, the parent tab that contains the subtabs needs to be declared with `{{</* tab */>}}` instead of `{{%/* tab */%}}`. Note, that in this case it is not possible to put markdown in the parent tab.
|
In case you want to nest tabs, the parent tab that contains the subtabs needs to be declared with `{{</* tab */>}}` instead of `{{%/* tab */%}}`. Note, that in this case it is not possible to put markdown in the parent tab.
|
||||||
|
|
||||||
You can also set various color parameter for all tabs or just selected ones. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values.
|
You can also set various color parameter for all tabs or just selected ones. See the [`tab` shortcode]({{% relref "shortcodes/tab#parameter" %}}) for possible values.
|
||||||
|
|
||||||
````go
|
````go
|
||||||
{{</* tabs groupid="main" style="primary" */>}}
|
{{</* tabs groupid="main" style="primary" title="Rationale" icon="thumbtack" */>}}
|
||||||
{{</* tab title="Text" */>}}
|
{{</* tab title="Text" */>}}
|
||||||
Simple text is possible here...
|
Simple text is possible here...
|
||||||
{{</* tabs groupid="tabs-example-language" */>}}
|
{{</* tabs groupid="tabs-example-language" */>}}
|
||||||
|
@ -219,7 +238,7 @@ You can also set various color parameter for all tabs or just selected ones. See
|
||||||
{{</* /tabs */>}}
|
{{</* /tabs */>}}
|
||||||
{{</* /tab */>}}
|
{{</* /tab */>}}
|
||||||
|
|
||||||
{{</* tab title="Code" style="default" color="fuchsia" */>}}
|
{{</* tab title="Code" style="default" color="darkorchid" */>}}
|
||||||
...but no markdown
|
...but no markdown
|
||||||
{{</* tabs groupid="tabs-example-language" */>}}
|
{{</* tabs groupid="tabs-example-language" */>}}
|
||||||
{{%/* tab title="python" */%}}
|
{{%/* tab title="python" */%}}
|
||||||
|
@ -237,7 +256,7 @@ You can also set various color parameter for all tabs or just selected ones. See
|
||||||
{{</* /tabs */>}}
|
{{</* /tabs */>}}
|
||||||
````
|
````
|
||||||
|
|
||||||
{{< tabs groupid="main" style="primary" >}}
|
{{< tabs groupid="main" style="primary" title="Rationale" icon="thumbtack" >}}
|
||||||
{{< tab title="Text" >}}
|
{{< tab title="Text" >}}
|
||||||
Simple text is possible here...
|
Simple text is possible here...
|
||||||
{{< tabs groupid="tabs-example-language" >}}
|
{{< tabs groupid="tabs-example-language" >}}
|
||||||
|
@ -253,7 +272,7 @@ You can also set various color parameter for all tabs or just selected ones. See
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
|
|
||||||
{{< tab title="Code" style="default" color="fuchsia" >}}
|
{{< tab title="Code" style="default" color="darkorchid" >}}
|
||||||
...but no markdown
|
...but no markdown
|
||||||
{{< tabs groupid="tabs-example-language" >}}
|
{{< tabs groupid="tabs-example-language" >}}
|
||||||
{{% tab title="python" %}}
|
{{% tab title="python" %}}
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
{{- with $context }}
|
{{- with $context }}
|
||||||
<div class="tab-panel" data-tab-group="{{ $groupid }}">
|
<div class="tab-panel" data-tab-group="{{ $groupid }}">
|
||||||
<div class="tab-nav">
|
<div class="tab-nav">
|
||||||
|
<div class="tab-nav-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | $context.RenderString }}{{ if (not $title) }}​{{ end }}</div>
|
||||||
{{- range $idx, $tab := $tabs }}
|
{{- range $idx, $tab := $tabs }}
|
||||||
<button
|
<button
|
||||||
data-tab-item="{{ .itemid }}"
|
data-tab-item="{{ .itemid }}"
|
||||||
|
|
|
@ -1849,6 +1849,14 @@ html[dir="rtl"] #sidebar ul.collapsible-menu > li > label > i.fa-chevron-right {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#body .tab-nav-title{
|
||||||
|
font-size: .9rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
padding: .2rem 0;
|
||||||
|
margin-inline-start: .6rem;
|
||||||
|
}
|
||||||
|
|
||||||
#body .tab-nav-button{
|
#body .tab-nav-button{
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
|
|
Loading…
Reference in a new issue