Merge pull request #2770 from alxhslm/accordion-icon
Feat: add icon param to accordian
This commit is contained in:
@@ -115,13 +115,14 @@ The alert sign (`+` or `-`) is optional to control whether the admonition is fol
|
|||||||
| `title` | **Required.** Title shown in the item header. |
|
| `title` | **Required.** Title shown in the item header. |
|
||||||
| `open` | **Optional.** Set to `true` to have the item open by default. |
|
| `open` | **Optional.** Set to `true` to have the item open by default. |
|
||||||
| `header` | **Optional.** Alias for `title`, kept for compatibility with other shortcodes. |
|
| `header` | **Optional.** Alias for `title`, kept for compatibility with other shortcodes. |
|
||||||
|
| `icon` | **Optional.** Icon name to display before the title. |
|
||||||
<!-- prettier-ignore-end -->
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
**Example 1: `mode="open"` (multiple items can be open) + `separated=true`**
|
**Example 1: `mode="open"` (multiple items can be open) + `separated=true`**
|
||||||
|
|
||||||
```md
|
```md
|
||||||
{{</* accordion mode="open" separated=true */>}}
|
{{</* accordion mode="open" separated=true */>}}
|
||||||
{{</* accordionItem title="Markdown example" open=true */>}}
|
{{</* accordionItem title="Markdown example" icon="code" open=true */>}}
|
||||||
This item demonstrates Markdown rendering:
|
This item demonstrates Markdown rendering:
|
||||||
- **Bold text**
|
- **Bold text**
|
||||||
- Lists
|
- Lists
|
||||||
@@ -137,7 +138,7 @@ The alert sign (`+` or `-`) is optional to control whether the admonition is fol
|
|||||||
```
|
```
|
||||||
|
|
||||||
{{< accordion mode="open" separated=true >}}
|
{{< accordion mode="open" separated=true >}}
|
||||||
{{< accordionItem title="Markdown example" open=true >}}
|
{{< accordionItem title="Markdown example" icon="code" open=true >}}
|
||||||
This item demonstrates Markdown rendering:
|
This item demonstrates Markdown rendering:
|
||||||
- **Bold text**
|
- **Bold text**
|
||||||
- Lists
|
- Lists
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
{{ $isSeparated := or (eq $separated true) (eq $separated "true") }}
|
{{ $isSeparated := or (eq $separated true) (eq $separated "true") }}
|
||||||
|
|
||||||
{{ $title := .Get "title" | default (.Get "header") }}
|
{{ $title := .Get "title" | default (.Get "header") }}
|
||||||
|
{{ $icon := .Get "icon" }}
|
||||||
{{ $md := .Get "md" | default true }}
|
{{ $md := .Get "md" | default true }}
|
||||||
{{ $open := .Get "open" | default false }}
|
{{ $open := .Get "open" | default false }}
|
||||||
{{ $isOpen := or (eq $open true) (eq $open "true") }}
|
{{ $isOpen := or (eq $open true) (eq $open "true") }}
|
||||||
@@ -16,7 +17,12 @@
|
|||||||
{{ if $isOpen }}open{{ end }}
|
{{ if $isOpen }}open{{ end }}
|
||||||
>
|
>
|
||||||
<summary class="flex w-full cursor-pointer items-center justify-between gap-4 px-4 py-3 text-left text-lg font-semibold text-neutral-900 dark:text-neutral-100">
|
<summary class="flex w-full cursor-pointer items-center justify-between gap-4 px-4 py-3 text-left text-lg font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
<span>{{ $title }}</span>
|
<span class="flex items-center gap-2">
|
||||||
|
{{ with $icon }}
|
||||||
|
{{ partial "icon.html" . }}
|
||||||
|
{{ end }}
|
||||||
|
<span>{{ $title }}</span>
|
||||||
|
</span>
|
||||||
<span>
|
<span>
|
||||||
{{ partial "icon" "chevron-down" }}
|
{{ partial "icon" "chevron-down" }}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user