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

@chameleon-ds/sheet

v3.0.2

Published

Chameleon sheet

Downloads

36

Readme

Chameleon Sheet

import { html } from "@open-wc/demoing-storybook";
import { withKnobs, text } from "@open-wc/demoing-storybook";
import "./chameleon-sheet.js";
import "./sheet-content.js";

export default {
  title: "Components|Overlays/Sheet",
  component: "chameleon-sheet",
  decorators: [withKnobs],
  parameters: {
    backgrounds: [
      { name: "gray", value: "#f5f5f8", default: true },
      { name: "black", value: "#252a33" },
    ],
  },
  options: { selectedPanel: "storybookjs/dovs/panel" },
};

Properties

chameleon-card

| Property Name | Type(s) | Default Value | Description | | --------------------- | ------- | ------------- | ------------------------------------------------- | | trapsKeyboardFocus | Boolean | true | Whether or not the sheet will trap keyboard focus | | hasBackdrop | Boolean | true | If the sheet has an overlay backdrop | | hidesOnOutsideClick | Boolean | true | If the sheet hides when clicked outside of | | hidesOnEsc | Boolean | true | If the sheet hides when the ESC key is pressed | | preventsScroll | Boolean | true | If the sheet prevents page scrolling when open |

sheet-content

| Property Name | Type(s) | Default Value | Description | | ------------- | ------- | ------------- | ------------------------- | | dismissable | Boolean | true | The card header title | | width | String | "320px" | The sheet content's width |

How the Sheet Works

chameleon-sheet now uses @lion/overlays to power behavior. This lets us keep an extremely simple, declaratively composed approach:

<chameleon-sheet>
  <button slot="invoker">Open Sheet</button>
  <p slot="content">Your content here!</p>
</chameleon-sheet>

There are now just two slots to understand:

  • the invoker slot is the content a user interacts with in order to open the sheet (for example the enticing "..." icon inside a table row).
  • the content slot is the content which shows inside the sheet. If you want something to show up in the sheet, throw it in here.

The content node itself is moved outside Chameleon Sheet's shadow dom, and relocated top-level onto document.body. This lets us ensure people can see it/interact with it, that it's accessible, and other reasons.

How do we ensure relocated content doesn't leak styles, while still getting all the benefits of our existing system? Simple! - build the content that should be relocated as it's own custom element. This lets us relocate a single node, and maintain full encapsulation of styles.

To streamline this, there's another component made available: sheet-content. You don't have to use sheet-content, you can put whatever you'd like into chameleon-sheet. However, sheet-content streamlines the look and feel of chameleon-sheet to be like v1, with some other enhancements:

  • You can customize the width (to set it, for example to '75vw' for a "big sheet").
  • You can apply other instance-specific styling to each component by specifying local <style>'s.

Understanding Bindings

As stated above, the entire node is moved. This means, any bindings you use when creating it are brought along.

Breaking Changes:

  • v1.x.x -> v2.x.x: Removed .header, .subheader, added use of @lion/overlays.

Migrating from V1 -> V2

You should be able to include your same content, along with the styling it used, as-is inside sheet-content.

Examples

Default

export const Default = () => {
  const width = text("Width", "320px");

  return html`
    <chameleon-sheet>
      <span slot="invoker">
        <button>Standard Sheet</button>
      </span>
      <sheet-content slot="content" width="${width}">
        <style>
          section {
            padding: 20px;
            font-size: 0.938rem;
          }

          .divider-top {
            border-top: solid 2px #e1e3e4;
          }

          .divider-bottom {
            border-bottom: solid 2px #e1e3e4;
          }

          .header {
            font-family: var(--app-heading-font, sans-serif);
            color: var(--primary-color, #2c6fb7);
            font-size: 1.4rem;
            font-weight: 400;
            margin-top: 0;
          }

          .sub-header {
            display: block;
            font-family: var(--app-heading-font, sans-serif);
            color: var(--primary-color, #2c6fb7);
            letter-spacing: normal;
            line-height: 21px;
            font-size: 18px;
            font-weight: 400;
          }

          label,
          .label {
            font-family: var(--app-body-font, Arial);
            color: var(--gray-darkest, #6c737a);
            font-size: 14px;
            line-height: 20px;
            letter-spacing: 0;
            margin-bottom: 8px;
            display: block;
          }
        </style>
        <section>
          <h1 class="header">Header</h1>
          <h2 class="sub-header">Subheader</h1>
        </section>
        <section class="divider-top">
          <p>City: Saint Louis</p>
          <p>Parks: Forest Park</p>
        </section>
        <section class="divider-top">
          <p>Food: Blue Ocean Sushi</p>
          <p>Art: Saint Louis Art Gallery</p>
        </section>
        <section class="divider-top divider-bottom">
          <p>Hockey: Blues</p>
          <p>Baseball: Cards</p>
          <p>Famous People: Nelly</p>
        </section>
      </sheet-content>
    </chameleon-sheet>
  `;
};