feat(tabs): revamp tabs #815
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current way to set up the tabs does not seem straightforward.
This PR allows setting up the name on each tab instead of on the tab group.
This is non-breaking: the previous behavior is still supported.
To understand how it works, you should know two things:
Storeof the parent.Storefrom the parent, because the render of the parent is called after the render of all the children.Store, and the parents will get the child's values from theirStore.Store(because it will be called after the children).Store(filled by children) before defining the default value.This approach is powerful, but it also has some limitations (ex, the parent shortcode should always call
.Inneror.InnerDeindent, but it's possible to store the.Innerinside an unused variable)I also added the possibility to enable/disable synchronized tabs per page.
Before
{{< tabs items="JSON,YAML,TOML" defaultIndex="1" >}} {{< tab >}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{< /tab >}} {{< tab >}}**YAML**: YAML is a human-readable data serialization language.{{< /tab >}} {{< tab >}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{< /tab >}} {{< /tabs >}}After
{{< tabs >}} {{< tab name="JSON" >}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{< /tab >}} {{< tab name="YAML" selected=true >}}**YAML**: YAML is a human-readable data serialization language.{{< /tab >}} {{< tab name="TOML" >}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{< /tab >}} {{< /tabs >}}Demo: https://deploy-preview-815--hugo-hextra.netlify.app/docs/guide/shortcodes/tabs/