An experiment in cleaning up CSS by just avoiding dis-features and focusing on flexbox and CSS grids.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
fsckcss/src/thumbs/Tabs.svelte

91 lines
2.0 KiB

<script>
let panels = [
{title: 'Panel 1', active: true},
{title: 'Panel 2', active: false},
{title: 'Panel 3', active: false},
];
const activate = (index) => {
panels.forEach((panel, i) => panel.active = index == i);
panels = panels; // for the svelte update
}
</script>
<style>
content {
display: flex;
flex-direction: column;
}
tabs {
margin-top: 1em;
/* added so you can see it in the display */
display: flex;
justify-content: space-evenly;
border-bottom: var(--color-accent);
}
tabs a {
text-decoration: none;
color: var(--color-text);
border-bottom: 1px solid var(--color-accent);
border-width: thin;
width: 100%;
text-align: center;
padding: 2rem 0rem 0.5rem;
}
tabs a:hover {
box-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
tabs a.active {
background-color: var(--color-bg-secondary);
}
panel {
display: none;
}
panel.active {
border: 1px solid var(--color-accent);
display: flex;
flex-direction: column;
padding: 1em;
}
</style>
<content>
<h1>Basic Tabs</h1>
<tabs>
<a class="active">Tab1</a>
<a>Tab2</a>
<a>Tab3</a>
</tabs>
<h1>Interactive Demo</h1>
<tabs>
{#each panels as panel, i}
<a class:active={ panel.active} on:click={ () => activate(i) }>{panel.title}</a>
{/each}
</tabs>
<panels>
{#each panels as panel, i}
<panel class:active={panel.active}>
<h1>{ panel.title }</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</panel>
{/each}
</panels>
</content>