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

@clds/design-system-foundations

v0.50.0

Published

---

Downloads

2,777

Readme

@clds/design-system-foundations


npm version

Design System Foundations establish two abstract concepts:

  • Size
  • Surface

Size

When some component can contain other inside, it usually creates a slot for it, sometimes called "area". For example, the button can contain the icon.

In order to make implementations of all components decoupled, we introduce a concept that describes how much space child component is expected to consume.

It is expressed in an abstract unit, which is equal to theme spacing units: xxs, sm, md, etc.

We create components that can automatically adjust it's size if the component hasn't specified size directly.

The communication between containers and children is done via special FoundationContext.

Once component puts the expected size into the context, then any component inside can read it and default it's size to make sure it consumes the space expected by the container.

Size mapping

Components size props are not standardized. For example sm button doesn't have spacing.sm height but greater. Also, button supports only sm and md sizes. We should map context props into components props individually.

Surface

Components can have different color versions. The thing, which is common for many components, is their tone and variant. Variant implies the main color for the component theme (primary, error, etc), and tone implies how colors are used (subtle - lightweight, non eye-disturbing, solid - intense colors, bring user attention). The surface is an abstract concept that combines both tone and variant.

Many components in design system accept properties which are superset of the surface concept. But when one component is used inside the other, it is expected that the child component will somehow adjust own surface to be clearly visible when inside the container.

This is why we share this information about container surface via SurfaceContext. It means that if the component doesn't have own surface-related props specified, they will default to ones mapped from the Surface context.

Surface mapping

Child surface-related default props are mapped from the surface context, which means that the child component has to decide how to create own default style to make it visible on the surface.

For example, if Banner component is used with success variant, it will put { tone: 'solid', variant: 'success' } into the context.

If you put a Chip inside a banner, it reads the context and defaults its own variant to success but the button tone, to be clearly visible, has to be the opposite - solid when subtle and subtle when solid.

API

This package contains API for two independent contexts.

  • foundation context - FoundationContextProvider and createUseFoundationHook
  • surface context - SurfaceContextProvider and createUseSurfaceHook

You can find more information about them in JSDocs.

Versioning

This library follows Semantic Versioning.

License

See LICENSE