npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-super

v1.0.4

Published

This is a powerfull multicomponent. With it, you can create tabs, an accordion, step-by-step instructions, and everything you have enough imagination for.

Downloads

5

Readme

Svelte Super

This is a powerfull multicomponent. With it, you can create tabs, an accordion, step-by-step instructions, and everything you have enough imagination for.

Usage:

<script>
  import {Super, SuperControl, SuperContent} from 'svelte-super';
  // Also you can import as default object Super (or more smantic name)
  // And use it with fields: Super.Control and Super.Content
</script>

<Super let:select>

  <div class="tabs">
    <SuperControl let:id let:active>
      <button class:active on:click={() => select(id)}>{id}</button>
    </SuperControl>
  </div>

  <SuperContent id="TAB 1" opened>
    <h2>Tab 1</h2>
    <p>...</p>
  </SuperContent>

  <SuperContent id="TAB 2">
    <h2>Tab 2</h2>
    <p>...</p>
  </SuperContent>

  <SuperContent id="TAB 3">
    <h2>Tab 3</h2>
    <p>...</p>
  </SuperContent>

</Super>

<style>
  .active {
    font-weight: 700;
  }
</style>

Super

The component has four let: directives. These are methods that you can use inside the component. All methods take one or more arguments - the ID of the SuperContent or SuperControl components.

Directives:

  • let:open Return a method makes visible one or more SuperContent blocks whose IDs are passed as arguments.
  • let:close Return a method hides one or more SuperContent blocks whose IDs are passed as arguments.
  • let:toggle Returns a method that hides or shows (depending on the current state) one or more Supercontinent blocks whose IDs are passed as arguments.
  • let:select Returns a method that makes visible one or more Supercontinent blocks whose IDs are passed as arguments. And makes other blocks hidden.

SuperContent (Super.Content)

Everything inside the component will be hidden or shown depending on the property opened

Props:

  • id (any) The ID of the block. Required.
  • opened (boolean) If true, the block will be shown, else - hidden. This property can be binded. Default: false.

Directives:

  • let:id The ID of the block.
  • let:opened Value of the opened property.

SuperControl (Super.Control)

A component that is associated with the SuperContent block via the id property. But it is always visible.

Props:

  • id (any) The ID of the block. Optional*.
  • active (boolean) If true, the block will be shown, else - hidden. This property can be binded. Default: false.

Directives:

  • let:id The ID of the block.
  • let:active Value of the active property.

Notes:

The id property is optional. If the id property is not passed to the component, then the contents of the component will be applied in a loop to each identifier of each SuperContent block. The identifier value can be accessed via the directive let:id.

<script> 
  import Tabs from 'svelte-super';
  
  const tabs = ['Home', 'Blog', 'Contact'];
</script>

<Tabs let:select>

  <Tabs.Control let:id let:active>
    <button class:active on:click={() => select(id)}>{id}</button>
  </Tabs.Control>

  {#each tabs as tab}
    <Tabs.Content id={tab} opened={tab === 'Home'}>
      <h2>{tab}</h2>
      <p>...</p>
    </Tabs.Content>
  {/each}

</Tabs>

<style>
  .active {
    font-weight: 700;
  }
</style>

If you pass the id parameter to SuperControl , then the contents of the block will relate only to this identifier. This is convenient, for example, for layout with SuperContent blocks.

<script> 
  import { slide } from 'svelte/transition';
  import Accordion from 'svelte-super';
  
  const faq = {
    'Q1': {
      question: 'Question 1',
      answer: 'Answer 1',
    },
    'Q2': {
      question: 'Question 2',
      answer: 'Answer 2',
    },
    'Q3': {
      question: 'Question 3',
      answer: 'Answer 3',
    },
  };
</script>

<Accordion let:toggle>

  {#each Object.entries(faq) as [id, item]}

    <div>
      <Accordion.Control {id} active={id === 'Q1'} let:id let:active >
        <button class:active on:click={() => toggle(id)}>{item.question}</button>
      </Accordion.Control>
      <Accordion.Content id={id}>
        <p transition:slide>{item.answer}</p>
      </Accordion.Content>
    </div>

  {/each}

</Accordion>