nickyhajal / svelte-tabs Goto Github PK
View Code? Open in Web Editor NEWTabs component for Svelte
Home Page: https://joeattardi.github.io/svelte-tabs/
Tabs component for Svelte
Home Page: https://joeattardi.github.io/svelte-tabs/
I installed this lib and it worked great for the first 30min. Then I stopped my server and started again, now gives error. Have no idea what to do. Didn't change code.
Error: <Tabs> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
at validate_component (webpack:///./node_modules/svelte/internal/index.mjs?:1375:15)
at eval (webpack:///./src/components/EmptyDash.svelte?:28:77)
at Object.$$render (webpack:///./node_modules/svelte/internal/index.mjs?:1398:22)
at eval (webpack:///./src/routes/%5Busername%5D/%5Bdash%5D.svelte?:81:165)
at Object.$$render (webpack:///./node_modules/svelte/internal/index.mjs?:1398:22)
at Object.default (webpack:///./src/node_modules/@sapper/internal/App.svelte?:37:190)
at eval (webpack:///./src/node_modules/@sapper/internal/layout.svelte?:7:45)
at Object.$$render (webpack:///./node_modules/svelte/internal/index.mjs?:1398:22)
at eval (webpack:///./src/node_modules/@sapper/internal/App.svelte?:33:144)
at $$render (webpack:///./node_modules/svelte/internal/index.mjs?:1398:22)
500
JSON.parse: unexpected character at line 1 column 1 of the JSON data
My component:
<script>
import { Tabs, Tab, TabList, TabPanel } from "svelte-tabs";
export let page;
</script>
<h1>Hello there {page.params.username}</h1>
<Tabs>
<TabList>
<Tab>JavaScript</Tab>
<Tab>Curl</Tab>
<Tab>Python</Tab>
<Tab>Elixir</Tab>
</TabList>
<TabPanel>
[...truncated...]
</TabPanel>
<TabPanel>
[...truncated...]
</TabPanel>
<TabPanel>
[...truncated...]
</TabPanel>
<TabPanel>
[...truncated...]
</TabPanel>
</Tabs>
There is no way to restore the current state of the tabs. It would be nice to have an event fire when the tab changes. Users can update their svelte state and localStorage.
Something like...
<Tabs initialSelectedIndex={$tabIndex} on:tabChanged={index =>{
tabIndex.set(index);
}>
<TabList>
<Tab>Triage</Tab>
</TabList>
<TabPanel>
<TriageForm visit_id={visit.id} />
</TabPanel>
</Tabs>
Any content after Tabs
will be shifted upward by .5em when the last Tab is selected.
This is due to this CSS rule:
.svelte-tabs__tab-panel { margin-top: 0.5em; }
Putting the margin on the TabList
instead fixes the problem.
.svelte-tabs__tab-list { margin-bottom: .5em; }
Hi, I realy like your Tab implementation.
However since I use typescript the editor always complains that there are no types. I always need to add following in my d.ts
file:
declare module "svelte-tabs" {
import { SvelteComponentTyped } from "svelte"
export class Tab extends SvelteComponentTyped { }
export class Tabs extends SvelteComponentTyped<{ initialSelectedIndex?: number }> { }
export class TabList extends SvelteComponentTyped { }
export class TabPanel extends SvelteComponentTyped { }
}
And since I need to look up how to type SvelteConmponents, it would be nice if you could include the Typings in your package.
node_modules/svelte-tabs/src/Tab.svelte:46:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
44: </style>
45:
46: <li
^
47: bind:this={tabEl}
48: role="tab"
node_modules/svelte-tabs/src/Tabs.svelte:98:0 A11y: <div> with keydown handler must have an ARIA role
96: </script>
97:
98: <div class="svelte-tabs" on:keydown={handleKeyDown}>
^
99: <slot></slot>
100: </div>
@joeattardi Did you forget to release a new version?
Hope to release version 1.2.0.
Thanks!
How change tab programmatically?
Trying to change tabs from outside the Tabs component by changing the selectedTabIndex prop, but it isn't working.
Not sure if the $: variable, anonymous function syntax is legacy, but it doesn't seem to do anything now. I changed it to a function call containing the variable:
on the Tabs.svelte:
$: selectedTabIndex, ()=>{
selectedTab.set(tabs[selectedTabIndex]);
selectedPanel.set(panels[selectedTabIndex]);
};
doesn't work
Changing it to
const setTabAndPanel = (idx) => {
selectedTab.set(tabs[idx]);
selectedPanel.set(panels[idx]);
}
$: setTabAndPanel(selectedTabIndex)
works.
If I can, I'll make a pull request, but it'll be some time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.