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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@madajoe6969/style-core

v1.0.0

Published

Unified style rendering system for MicroFeedback widgets

Readme

@my-better-t-app/style-core

Unified style rendering system for MicroFeedback widgets that ensures pixel-perfect consistency between dashboard customization and embedded widgets across HTML/JavaScript, React, and Vue implementations.

Features

  • Unified Style Renderer: Single source of truth for CSS generation across all widget implementations
  • Type-Safe Configuration: Comprehensive TypeScript interfaces with Zod validation
  • Multiple Output Formats: Generate CSS variables, CSS-in-JS objects, and styled-components themes
  • Responsive Design: Built-in support for mobile and tablet breakpoints
  • Security: CSS sanitization to prevent injection attacks
  • Framework Agnostic: Works with vanilla HTML/JS, React, and Vue

Installation

bun add @my-better-t-app/style-core

Usage

Basic Usage

import { UnifiedStyleRenderer, createDefaultStyleConfig } from '@my-better-t-app/style-core';

// Create a renderer with default configuration
const config = createDefaultStyleConfig();
const renderer = new UnifiedStyleRenderer(config);

// Generate CSS variables
const variables = renderer.generateCSSVariables();

// Generate complete CSS stylesheet
const css = renderer.generateCSS('my-widget');

// Generate CSS-in-JS styles for React
const styles = renderer.generateCSSInJS();

// Generate styled-components theme
const theme = renderer.generateStyledComponentsTheme();

Custom Configuration

import { UnifiedStyleRenderer, validateStyleConfig } from '@my-better-t-app/style-core';

const customConfig = {
  version: "1.0.0",
  colors: {
    primary: "#ff6b35",
    background: "#ffffff",
    text: "#333333",
    border: "#e1e5e9",
  },
  typography: {
    fontFamily: "Inter, system-ui, sans-serif",
    fontSize: {
      small: "0.875rem",
      base: "1rem",
      large: "1.125rem",
    },
    fontWeight: {
      normal: 400,
      bold: 600,
    },
    lineHeight: 1.5,
  },
  // ... other configuration options
};

// Validate and sanitize the configuration
const validatedConfig = validateStyleConfig(customConfig);
const renderer = new UnifiedStyleRenderer(validatedConfig);

Framework-Specific Usage

HTML/JavaScript

// Generate scoped CSS for vanilla JS widgets
const css = renderer.generateCSS('microfeedback-widget-123');

// Inject styles into the page
const styleElement = document.createElement('style');
styleElement.textContent = css;
document.head.appendChild(styleElement);

React with styled-components

import styled, { ThemeProvider } from 'styled-components';

const theme = renderer.generateStyledComponentsTheme();

const StyledWidget = styled.div`
  background-color: ${props => props.theme.colors.background};
  color: ${props => props.theme.colors.text};
  border-radius: ${props => props.theme.layout.borderRadius};
`;

function Widget() {
  return (
    <ThemeProvider theme={theme}>
      <StyledWidget>
        {/* Widget content */}
      </StyledWidget>
    </ThemeProvider>
  );
}

Vue with CSS Variables

<template>
  <div class="widget" :style="cssVariables">
    <!-- Widget content -->
  </div>
</template>

<script>
export default {
  computed: {
    cssVariables() {
      return this.renderer.generateCSSVariables();
    }
  }
}
</script>

<style scoped>
.widget {
  background-color: var(--mf-background-color);
  color: var(--mf-text-color);
  border-radius: var(--mf-border-radius);
}
</style>

API Reference

UnifiedStyleRenderer

The main class for generating consistent styles across all widget implementations.

Methods

  • generateCSSVariables(): Returns CSS custom properties object
  • generateCSS(scope?): Returns complete CSS stylesheet with optional scoping
  • generateCSSInJS(): Returns CSS-in-JS style objects for React
  • generateStyledComponentsTheme(): Returns theme object for styled-components
  • getConfig(): Returns current configuration
  • updateConfig(newConfig): Returns new renderer instance with updated configuration

Validation Functions

  • validateStyleConfig(config): Validates configuration against schema
  • createDefaultStyleConfig(): Creates a valid default configuration
  • sanitizeStyleConfig(config): Validates and sanitizes configuration
  • sanitizeCSSValue(value): Sanitizes individual CSS values

Configuration Schema

See the TypeScript interfaces in the source code for the complete configuration schema. The main interface is WidgetStyleConfig which includes:

  • colors: Primary, background, text, border, error, success colors
  • typography: Font family, sizes, weights, line height
  • layout: Border radius, padding, margins, spacing
  • interactions: Hover effects, focus styles, transitions
  • responsive: Mobile and tablet-specific overrides
  • accessibility: High contrast, reduced motion options

Development

# Install dependencies
bun install

# Build the package
bun run build

# Run tests
bun run test

# Type checking
bun run check-types