Skip to content

Commit 4c3f980

Browse files
committed
Eliminate extra div layer
1 parent 6f6b977 commit 4c3f980

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

site/plugins/site/src/Marsdown/Marsdown.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ protected function blockGroupsTabsComplete(array $Block): array
105105
$titles[1]
106106
);
107107

108+
$id = Str::random(3);
109+
108110
return [
109111
'element' => [
110112
'name' => 'div',
113+
'attributes' => [
114+
'class' => 'tabs',
115+
'id' => 'tabs-' . $id
116+
],
111117
'rawHtml' => snippet('kirbytext/tabs', [
112-
'tabs' => $tabs ?? []
118+
'id' => $id,
119+
'tabs' => $tabs,
113120
], true),
114121
]
115122
];

site/snippets/kirbytext/tabs.php

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
<?php
2-
$uuid = Str::uuid();
3-
?>
4-
5-
<div class="tabs" id="tabs-<?= $uuid ?>">
6-
<menu>
7-
<?php foreach ($tabs as $key => $tab): ?>
8-
<button
9-
:aria-current="current === '<?= $key ?>'"
10-
@click="current = '<?= $key ?>'"
11-
>
12-
<?= $tab['title'] ?>
13-
</button>
14-
<?php endforeach ?>
15-
</menu>
16-
1+
<menu>
172
<?php foreach ($tabs as $key => $tab): ?>
18-
<div v-show="current === '<?= $key ?>'">
19-
<?= $tab['content'] ?>
20-
</div>
3+
<button
4+
:aria-current="current === '<?= $key ?>'"
5+
@click="current = '<?= $key ?>'"
6+
>
7+
<?= $tab['title'] ?>
8+
</button>
219
<?php endforeach ?>
10+
</menu>
11+
12+
<?php foreach ($tabs as $key => $tab): ?>
13+
<div v-show="current === '<?= $key ?>'">
14+
<?= $tab['content'] ?>
2215
</div>
16+
<?php endforeach ?>
2317

2418
<script type="module">
2519
import {
@@ -28,5 +22,5 @@
2822

2923
createApp({
3024
current: "<?= array_keys($tabs)[0] ?>",
31-
}).mount("#tabs-<?= $uuid ?>")
25+
}).mount("#tabs-<?= $id ?>")
3226
</script>

0 commit comments

Comments
 (0)