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

@sf-digital-services/ui-components

v0.3.10-sf1

Published

Shared user interface components for Bloom affordable housing system

Downloads

4

Readme

Bloom UI Components

This package is the home of the core UI components for the Bloom affordable housing system, meant to be imported from one or more applications that provide the end-user interface.

Types of Components

Bloom components have been design with the principles of Atomic Design in mind, and some of the directory structure and naming conventions are based on that.

There are also Page Components as a distinct class, which represent larger combinations of components (atomic: organisms) that are meant to be directly imported into specific pages in the system (e.g. a home page).

Locales/Translations

Look in src/locales for JSON files containing translated keys for UI elements and copy across all monorepo sites.

Storybook

The UI components package includes Storybook for easy browsing of the component tree, and is the best way to get started understand what's available.

CLI

To spin up Storybook locally, run:

yarn start

To run the test suite which is a combination of storyshots and tests via Jest and Enzyme, run:

yarn test

# or

yarn test -u  # updates storyshots based on latest code

Style Organization and Best Practices

Style Frameworks

  • Tailwind v1: Low-level utility library that styles components based on custom settings.

Sass Architecture

  • /ui-components: Components and styles are accessible by multiple apps
    • /global: Styles are accessible by any component
      • index: import frameworks, fonts, components, utilities
      • /elements (no associated markup pattern, if more than 300 lines we break this into a folder with files)
      • mixins
      • utilities
      • typography
      • print
      • /vendors
    • Components: Styles are isolated per component
      • /actions
      • /footers
      • /headers
      • /icons
      • /forms
      • /layouts
      • /lists
      • /navigations
      • /notifications
      • /overlays
      • /sections
      • /structure
      • /tables
      • /text
    • Settings
      • tailwind.config
  • Apps: Components and styles that are accessible to a single app
    • Reference
    • Reference components (temp/prototype)

Vendor Plugins

Naming Conventions

  • BEM

    • Structures CSS such that every entity is composed of blocks, elements and modifiers
    • Avoid using Sass nesting to build class names
      • Bad
        • .accordion
          • &-item
      • Good
        • .accordion
        • .accordion-item
  • Suggested custom methodology: Our recommendation for a naming methodology is a modified version of BEM. It still uses blocks, sections within blocks and modifiers, but with a subclass syntax for modifiers.

    • BEM

      • .accordion
      • .accordion-item
      • .accordion-item__label
    • Sub Class Modifiers: Name modifiers and state-based rules with adjectives

      • is-, has-
      • .accordion-item__label.is-open
  • Component naming

    • Name things clearly
    • Be wary of naming components based on content, as this limits the use of the class
    • Avoid presentation- or location-specific naming
  • Use capitals for React component names

    • SelectButton instead of selectbutton, or Menu instead of menu
  • Tokenize prop values

    • Avoid presentation-specific words in prop values, as it will change with theming

Utilities & Custom Class Names

  • Use Tailwind utilities to prototype components before writing a custom styles sheet or creating custom classes.
    • Create custom component classes once you understand the component structure and variants.
  • Use Tailwind utilities at the app level when creating layout and page level objects.
    • Create custom layout classes once you identify a repeatable layout pattern.

CSS Formatting

  • File declaration order
    1. Local variables
    2. Tailwind utilities
    3. Media queries
    4. Pseudo states
    5. Nested classes
    6. Nested elements

Specificity

  • IDs should be reserved for JavaScript. Don’t use IDs for styles.
  • Don’t nest more than 3 layers deep.
  • Don’t fix problems with !important. Use !important purposefully.
  • Refrain from using overqualified selectors; div.container can simply be stated as .container.

Spacing Units

  • Base 16 using Tailwind Tokens for padding and margins

Layout

  • Use flex instead of float
  • Use grid utilities for uniform grids

Style Customization

  • Tailwind Configuration

Accessibility

  • Storybook AXE panel
  • Keyboard accessibility
    • Roles
    • Focus state
  • Color contrast
    • AA
  • Accessible forms
    • Labels for each input
    • Screen reader labels for inputs with no label
    • Fieldsets for groups
    • Required
  • Accessible data tables
  • Alt tags for images
  • Errors and alert messages
  • Overlay focus
  • Screen reader utilities

Build Process

Upstream vs Downstream

React Best Practices

Calculate Style Based on Props

  • a warning={true} prop might turn into an is-warning className applied

Nesting

Naming Conventions

  • CamelCase to css

Storybook: Creating Stories

  • Include a default story for base component
  • Include stories for each state

Accessibility

  • Use accessibility tab for QA

Storybook Knobs