Code Monkey home page Code Monkey logo

svelte-tabs's Issues

Error: <Tabs> is not a valid SSR component.

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>

Missing on:tabChanged event

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>

Changing margin shifts following content

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; }

Typings

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.

A11y issues

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>

tabs

How change tab programmatically?

reactivity on selectedTabIndex not working

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.