Skip to content

Commit b937973

Browse files
committed
Update PHP
1 parent 609a7e4 commit b937973

File tree

2 files changed

+973
-266
lines changed

2 files changed

+973
-266
lines changed

docs/.vuepress/components/TableTabs.vue

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
11
<script setup>
2-
import { ref, computed, useSlots } from 'vue'
2+
import { ref, computed, useSlots, onMounted, watch, nextTick } from 'vue'
33
44
const slots = useSlots()
55
const tabKeys = Object.keys(slots)
66
const activeTab = ref(tabKeys[0] ?? '')
77
const currentTab = computed(() => activeTab.value)
8+
const wrapperRef = ref(null)
9+
10+
function formatKey(key) {
11+
return key.replace(/[__]/g, ' ')
12+
}
13+
14+
// Display select
15+
onMounted(() => {
16+
const hash = decodeURIComponent(window.location.hash.slice(1))
17+
if (tabKeys.includes(hash)) {
18+
activeTab.value = hash
19+
20+
nextTick(() => {
21+
const el = wrapperRef.value
22+
if (el) {
23+
const offset = 80
24+
const top = el.getBoundingClientRect().top + window.scrollY - offset
25+
window.scrollTo({ top, behavior: 'smooth' })
26+
}
27+
})
28+
}
29+
})
30+
31+
watch(activeTab, (newVal) => {
32+
if (newVal) {
33+
history.replaceState(null, '', `#${encodeURIComponent(newVal)}`)
34+
}
35+
})
836
</script>
937
1038
<template>
11-
<div class="table-tabs mt-8 border rounded-lg overflow-hidden text-sm">
12-
<div class="bg-gray-50 flex justify-between items-center border-b">
13-
<!-- <span class="font-medium text-gray-700">Optional Text:span> -->
39+
<div
40+
ref="wrapperRef"
41+
class="table-tabs mt-8 border rounded-lg overflow-hidden text-sm scroll-mt-24"
42+
:id="activeTab"
43+
>
44+
<div class="bg-gray-50 flex justify-between items-center border-b px-4 py-2">
45+
<!-- <span class="font-medium text-gray-700">Optional Text:</span> -->
1446
<select
1547
v-model="activeTab"
1648
class="bg-white text-gray-800 text-sm rounded border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500"
1749
>
1850
<option v-for="key in tabKeys" :key="key" :value="key">
19-
{{ key }}
51+
{{ formatKey(key) }}
2052
</option>
2153
</select>
2254
</div>
2355
24-
<div class="tab-content prose prose-sm max-w-none">
56+
<div class="tab-content prose prose-sm max-w-none p-4">
2557
<slot :name="currentTab" />
2658
</div>
2759
</div>
2860
</template>
2961
30-

0 commit comments

Comments
 (0)