Adjust tabs

This commit is contained in:
Steve Kinney
2024-10-02 03:19:52 -05:00
parent 265c6255a8
commit 1708a4c5c4
2 changed files with 8 additions and 12 deletions

View File

@@ -1,16 +1,10 @@
<script>
import { onMount } from 'svelte';
/** @type {Array<{ title: string, content: string, id?: string }>} */
export let tabs = [];
let tabbedContent = null;
let activeIndex = 0;
const isSelected = (index) => index === activeIndex;
const getTabIndex = (index) => (isSelected(index) ? 0 : -1);
</script>
<section bind:this={tabbedContent}>
<section>
<div role="tablist">
{#each tabs as tab, i}
{@const id = tab.id || i}

View File

@@ -7,10 +7,7 @@ describe('Tabs', () => {
beforeEach(() => {
render(Tabs, {
tabs: [
{
label: 'Venue',
content: 'This year, we will be at this awesome venue',
},
{ label: 'Venue', content: 'We will be at this place!' },
{ label: 'Lineup', content: 'Check out our exciting lineup!' },
{ label: 'Tickets', content: 'Buy tickets today!' },
],
@@ -40,4 +37,9 @@ describe('Tabs', () => {
const content = screen.getByRole('tabpanel', { hidden: false });
expect(content).toHaveTextContent('lineup');
});
it('should render the content of the first tab by default', async () => {
const content = screen.getByRole('tabpanel', { hidden: false });
expect(content).toHaveTextContent('We will be at this place!');
});
});