8000 GitHub - benjaminkott/bk2k-ui: bk2k UI: shared Lit component library for all bk2k apps · GitHub
[go: up one dir, main page]

Skip to content
benjaminkottPublic

About

bk2k UI: shared Lit component library for all bk2k apps

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bk2k UI

Generic, composable web components with a token-based theme, built with Lit. They work in any page and with any framework: an element is a tag, its look is a set of CSS custom properties.

Storybook shows every component, the tokens, the presets and five complete example apps.

<bk-card heading="Profile">
  <bk-chip slot="actions" tone="accent">Beta</bk-chip>
  <bk-stack>
    <bk-input-text label="Display name" name="name" required></bk-input-text>
    <bk-switch name="digest">Weekly digest</bk-switch>
  </bk-stack>
  <bk-button slot="footer" variant="solid" tone="accent" type="submit">Save</bk-button>
</bk-card>
  • Composable. Small parts with one role each: containers provide a surface, controls provide function, layout parts arrange. There are no large components with many options.
  • Like the platform. Form fields are form-associated: FormData, validation, reset, <label for>, and the native events input and change.
  • Themable by tokens. Six base colours and a set of knobs (radius, spacing, text size, shadow, motion) make a complete look in light and dark. Each component has its own tokens on top. The CSS of the app always has priority.
  • Accessible. WCAG 2.2 AA. axe checks each story in light and dark, and each interactive part follows the WAI-ARIA keyboard pattern.
  • Translatable. Each built-in text has English and German, and an app can replace it.
  • Light. lit is the only dependency. Each component is its own import.

Install

Install the package from npm:

npm install lit @bk2k/ui

Use

import "@bk2k/ui";                 // all components
import "@bk2k/ui/bk-button.js";    // or only what a view needs

The import of a component also puts the design tokens into the page. There is no other setup.

Set the look in one CSS file of the app:

:root {
  --bk-accent: #e8590c;
  --bk-radius-scale: 0.5;
  --bk-space-scale: 0.9;
}

A page without a bundler (a page that a server renders) loads the standalone build with one line: <script type="module" src="…/dist/standalone/auto.js"></script>. See "Pages without a bundler" in the guide.

USAGE.md is the guide for apps: all elements, forms, theming, charts, shortcuts, translations and icons. It is in the package, with custom-elements.json (the full API of each element for editors and tools).

BUILDING.md explains how to build a good screen: the frame, the containers, recipes to copy and the rules of the look of an app. It is in the package too.

Develop

make install      npm install
make start        Storybook in the background → http://localhost:6020
make check        typecheck, tests and build (fast, while you work)
make verify       check and all browser checks on the changed stories (before every commit)
make verify-all   the same on all stories
make help         all commands
src/tokens.ts                   the global design tokens (the only source; also built to dist/tokens.css)
src/components/bk-*.ts          one component per file; its JSDoc is the API documentation
src/components/bk-*.stories.ts  the stories of a component
src/components/*.test.ts        browser tests (Vitest and Playwright Chromium)
src/stories/                    foundations, theming, patterns and the example apps
scripts/                        the checks, the icon generator, the release

AGENTS.md contains the rules for a change to the library: the composition model, the API conventions, the checks and the release.

Licence

MIT. The icons come from Material Symbols (Apache-2.0), the brand marks partly from Simple Icons (CC0). The fonts Inter and JetBrains Mono are under the SIL Open Font License. dist/standalone/ bundles Lit (BSD-3-Clause). THIRD-PARTY-LICENSES.txt contains their licences.

About

bk2k UI: shared Lit component library for all bk2k apps

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0