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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@magik_io/grimoire

v1.12.0

Published

A Web Component Library for Genie

Readme

Grimoire 📖

A lightweight, type-safe Web Component library built for the Genie ecosystem. Grimoire provides beautifully styled, customizable components with built-in dark/light theme support.

npm version License: MIT

Features

  • 🎨 Theme-Aware: Built-in dark/light mode support with flexible theming options
  • 🔧 Type-Safe: Full TypeScript support with comprehensive type definitions
  • 🪄 Magik Integration: Built on @magik_io/mote for powerful DOM manipulation
  • 📦 Tree-Shakeable: ES modules with dynamic imports for optimal bundle size
  • 🎯 Standards-Based: Pure Web Components using Custom Elements API
  • 💅 CSS Variables: Fully customizable via CSS custom properties

Installation

# Using pnpm (recommended)
pnpm add @magik_io/grimoire

# Using npm
npm install @magik_io/grimoire

# Using yarn
yarn add @magik_io/grimoire

Requirements

  • Node.js 22.x or higher
  • pnpm 9.x or higher (for development)

Quick Start

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Grimoire Demo</title>
</head>
<body>
  <!-- Use components in your HTML -->
  <slide-toggle label="Enable notifications" checked="true"></slide-toggle>
  <e-sig>John Doe</e-sig>

  <script type="module">
    import { Grimoire } from '@magik_io/grimoire';

    // Define which components you want to use
    await Grimoire.Define('slide-toggle', 'e-sig');
  </script>
</body>
</html>

Components

SlideToggle

A beautiful, animated toggle switch component.

<slide-toggle
  label="Dark Mode"
  checked="false"
  name="darkModeToggle">
</slide-toggle>

Attributes:

  • label (string): The label text displayed next to the toggle
  • checked (boolean): Initial checked state (default: false)
  • name (string): Name attribute for the input element

Properties:

  • activated: Get/set the toggle state programmatically

Events:

  • change: Fired when the toggle state changes
    • detail.checked: Current checked state

CSS Variables:

--st-body-bg: Background color
--st-checked-bg: Background color when checked
--st-border-width: Border width
--st-border-color: Border color
--st-color: Text color
--st-check-bg: Checkbox background
--st-check-bg-image: Checkbox background image

Example:

const toggle = document.querySelector('slide-toggle');

// Listen for changes
toggle.addEventListener('change', (e) => {
  console.log('Toggle is now:', e.detail.checked);
});

// Programmatically control
toggle.activated = true;

ESig

An elegant electronic signature component with multiple font choices.

<e-sig font="dancing-script" icon="fas fa-pen">
  Antonio Bourassa
</e-sig>

Attributes:

  • font (string): Font style for the signature
    • dancing-script (default)
    • great-vibes
    • homemade-apple
    • marck-script
    • sacramento
    • satisfy
  • icon (string): Font Awesome icon class (default: fas fa-cog)

CSS Variables:

--eSig-bg: Background color
--eSig-border-color: Border color
--eSig-border-style: Border style
--eSig-border-radius: Border radius
--eSig-border-width: Border width
--eSig-line-height: Line height
--eSig-padding: Padding
--eSig-margin-bottom: Bottom margin
--eSig-color: Text color

Features:

  • Click the icon to open a font selection modal
  • Interactive font preview
  • Responsive scaling

Note: You'll need to include Google Fonts in your HTML:

<link href="https://fonts.googleapis.com/css?family=Dancing+Script|Great+Vibes|Homemade+Apple|Marck+Script|Sacramento|Satisfy" rel="stylesheet">

Theme Configuration

Grimoire provides flexible theming options:

Browser-Based (Default)

Uses CSS media queries to detect system preferences:

Grimoire.Configure({ chroma: 'browser' });

Class-Based

Uses body classes (.dark and .light):

Grimoire.Configure({ chroma: 'class' });

Custom Classes

Define your own theme classes:

Grimoire.Configure({
  chroma: {
    dark: 'my-dark-theme',
    light: 'my-light-theme'
  }
});

Disabled Theming

Disable theme switching:

Grimoire.Configure({ chroma: false });

Advanced Usage

Selective Component Loading

Only load the components you need to keep your bundle small:

// Load only SlideToggle
await Grimoire.Define('slide-toggle');

// Load multiple components
await Grimoire.Define('slide-toggle', 'e-sig');

Custom Styling

Override CSS variables globally or per-component:

/* Global overrides */
:root {
  --st-checked-bg: #ff6b6b;
  --eSig-bg: #f0f0f0;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --st-checked-bg: #ff4757;
    --eSig-bg: #2c2c2c;
  }
}

/* Component-specific overrides */
slide-toggle {
  --st-checked-bg: green;
}

TypeScript Support

Full type definitions are included:

import { Grimoire, type GrimoireTemplateNames } from '@magik_io/grimoire';

const components: GrimoireTemplateNames[] = ['slide-toggle', 'e-sig'];
await Grimoire.Define(...components);

// Type-safe component references
const toggle = document.querySelector('slide-toggle') as HTMLElement & {
  activated: boolean;
};

Architecture

Grimoire uses a sophisticated component registration system:

  1. Dynamic Imports: Components are loaded on-demand
  2. Style Extraction: CSS is automatically extracted and injected
  3. Theme Management: Automatic light/dark theme handling
  4. Custom Elements: Standards-based Web Components

Component Descriptor Pattern

Each component uses a ComponentDescriptor that defines:

  • Component name and HTML tag
  • Element class (extends HTMLElement)
  • Style configuration (base styles, CSS variables, theme variants)
  • Type of custom element
export default new ComponentDescriptor({
  name: 'my-component',
  element: MyComponent,
  type: 'custom-element',
  style: {
    base: CSSVars => CSSVars`/* CSS */`,
    vars: { /* CSS variables */ },
    theme: {
      light: { /* light theme vars */ },
      dark: { /* dark theme vars */ }
    }
  }
});

Development

Setup

# Clone the repository
git clone https://github.com/MagikIO/grimoire.git
cd grimoire

# Install dependencies
pnpm install

# Start development server
pnpm dev

Build

# Build for production
pnpm build

Publishing

# Bump version, push tags, and publish
pnpm iterate

Browser Support

Grimoire supports all modern browsers that implement:

  • Custom Elements v1
  • ES2022
  • CSS Custom Properties
  • ES Modules

Tested on:

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+

Dependencies

  • @magik_io/mote - Lightweight DOM manipulation library
  • ulid - Universally Unique Lexicographically Sortable Identifiers

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

MIT © Antonio B.

Changelog

See CHANGELOG.md for a list of changes.

Support

Related Projects


Made with ✨ by MagikIO