feat(ui) : TabList — prop maxWidth (défaut 1100) pour le bloc d'onglets fenêtré
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ type TabListProps = {
|
|||||||
modelValue?: string
|
modelValue?: string
|
||||||
id?: string
|
id?: string
|
||||||
maxVisibleTabs?: number
|
maxVisibleTabs?: number
|
||||||
|
maxWidth?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabListForTest = TabList as DefineComponent<TabListProps>
|
const TabListForTest = TabList as DefineComponent<TabListProps>
|
||||||
@@ -198,6 +199,16 @@ describe('MalioTabList — fenêtrage maxVisibleTabs', () => {
|
|||||||
{key: 't7', label: 'Tab 7'},
|
{key: 't7', label: 'Tab 7'},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
it('applies the default maxWidth (1100px) on the tabs container when windowed', () => {
|
||||||
|
const wrapper = mountComponent({tabs: sevenTabs, maxVisibleTabs: 5})
|
||||||
|
expect(wrapper.find('[role="tablist"]').attributes('style')).toContain('max-width: 1100px')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('applies a custom maxWidth on the tabs container', () => {
|
||||||
|
const wrapper = mountComponent({tabs: sevenTabs, maxVisibleTabs: 5, maxWidth: 1200})
|
||||||
|
expect(wrapper.find('[role="tablist"]').attributes('style')).toContain('max-width: 1200px')
|
||||||
|
})
|
||||||
|
|
||||||
it('renders only maxVisibleTabs buttons and disables prev at start', () => {
|
it('renders only maxVisibleTabs buttons and disables prev at start', () => {
|
||||||
const wrapper = mountComponent({tabs: sevenTabs, maxVisibleTabs: 5})
|
const wrapper = mountComponent({tabs: sevenTabs, maxVisibleTabs: 5})
|
||||||
const buttons = wrapper.findAll('[role="tab"]')
|
const buttons = wrapper.findAll('[role="tab"]')
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
role="tablist"
|
role="tablist"
|
||||||
class="flex flex-1 max-w-[1200px] justify-center gap-[60px]"
|
class="flex flex-1 justify-center gap-[60px]"
|
||||||
|
:style="{ maxWidth: `${maxWidth}px` }"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
v-for="tab in visibleTabs"
|
v-for="tab in visibleTabs"
|
||||||
@@ -132,10 +133,12 @@ const props = withDefaults(defineProps<{
|
|||||||
modelValue?: string
|
modelValue?: string
|
||||||
id?: string
|
id?: string
|
||||||
maxVisibleTabs?: number
|
maxVisibleTabs?: number
|
||||||
|
maxWidth?: number
|
||||||
}>(), {
|
}>(), {
|
||||||
modelValue: undefined,
|
modelValue: undefined,
|
||||||
id: '',
|
id: '',
|
||||||
maxVisibleTabs: undefined,
|
maxVisibleTabs: undefined,
|
||||||
|
maxWidth: 1100,
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
|||||||
Reference in New Issue
Block a user