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

@atb-as/theme

v11.1.1

Published

AtB Design System Colors

Downloads

1,595

Readme

@atb-as/theme

Install

yarn add @atb-as/theme

Usage

Import through ts/js:

import {createThemesFor,ThemeVariant} from '@atb-as/theme';
const themes = createThemesFor(ThemeVariant.AtB)
console.log(themes.light.colors.background_0);

Usage CSS

⚠️ We're currently transitioning to a new variable structure. Importing CSS from ../theme-fs/.. applies variables to data-theme["auto"]. The theme follows the device preference.

This behaviour can be overwritten by explicitly setting data-theme["light"] or data-theme["dark"] on an element. All children will follow that specific theme.

Or you could import CSS files or as CSS Modules. The actual content is currently the same, but named differently to be imported by CSS modules.

// When using imports from bundlers

// With CSS Modules for atb-theme
import * as classNamesTheme from '@atb-as/theme/lib/themes/atb-theme/theme.module.css';
import * as classNamesTypo from '@atb-as/theme/lib/typography.module.css';


// Without CSS Modules for atb-theme
import '@atb-as/theme/lib/themes/atb-theme/theme.css';
import '@atb-as/theme/lib/typography.css';
/* Using css/postcss/bundlers */
@import '@atb-as/theme/lib/themes/atb-theme/theme.module.css';
@import '@atb-as/theme/lib/typography.module.css';

/* or without modules */
@import '@atb-as/theme/lib/themes/atb-theme/theme.css';
@import '@atb-as/theme/lib/typography.css';


/* And potentially */
@value myClassname from "@atb-as/theme/lib/themes/atb-theme/theme.css";

(note: This all depends on how you setup bundlers and consumes styles.)

Theming with CSS

Uses CSS Custom Properties to do theming. This means by default it only support newer browsers. This needs to be compansated for by the consumer if wanted. By setting class light or dark on a parent component the cascading of custom props will change the theme. This means we can set what level we want the theming to operate on.

<body class="light">
  <!-- My content -->
</body>

<body class="dark">
  <!-- My content -->
</body>

You must set either light or dark for themes to work.

Regular CSS

With regular CSS.

<!-- Named same as theme objects -->

<div class="colors-primary_2">
  <!-- background color and text color set -->
</div>

<div class="colors-transport_city" />

CSS Modules

.mySpecificClassName {
  composes: colors-primary_2 from 'theme.modules.css';
}
@import 'theme.modules.css';

.mySpecificClassName {
  composes: colors-transport_train;
}

Theme API

createThemes(themes: Themes,overrides?: ConfigurationOverride<Theme>): Themes

Create new themes (light/dark) with optinally overriden defaults

const themesVariant = createThemesFor(ThemeVariant.AtB)
const themes = createThemes(
  themesVariant,
  {
  light: {
    spacings: {
      medium: 20,
    },
  },
});
themes.dark.spacings.medium;
//=> 20

createExtendedThemes<T>(themes: Themes,extension: T)

Use Theme as base and extend with new properties. Properties can be nested and will be deep merged.

type FooExtension = {
  statusBarStyle: 'dark' | 'light';
}
const themesVariant = createThemesFor(ThemeVariant.AtB)

const _themes = createExtendedThemes<FooExtension>(
  themesVariant,
  {
  light: {statusBarStyle: 'dark'},
  dark: {statusBarStyle: 'light'}
});
_themes.dark.statusBarStyle;
//=> (property) statusBarStyle: "dark" | "light"

Typography API

createTextTypeStyles(PlatformTypes, ConfigurationOverride<TextTypeStyles>)

Create new text type style with optinally overriden defaults.

createTextTypeStyles({
  paragraphHeadline: {
    fontWeight: Platform.select({
      ios: '600',
      android: 'bold'
    })
  }
})

extendTextTypeStyles<T>(type: PlatformTypes, extension: T)

Use text type style as base and extend with new properties. Properties can be nested and will be deep merged.

type Foo = {
  paragraphHeadline: {
    additional: boolean;
  };
};
const foo = extendTextTypeStyles<Foo>({
  paragraphHeadline: {
    additional: true,
  },
});

console.log(foo.paragraphHeadline.additional);
//=> (property) additional: boolean

Building locally

From monorepo root, to generate CSS run:

yarn workspace @atb-as/theme create-css

or from project root:

yarn create-css