framework-utils

1.1.0 · active · verified Sun Apr 19

framework-utils is a concise, TypeScript-first utility library providing focused functions primarily for front-end framework development, with its current stable version being 1.1.0. It's part of the broader Daybrush ecosystem of UI components and tools, distinguishing itself by offering specific, lightweight solutions like CSS class prefixing and CSS string manipulation. The package generally follows an 'as-needed' release cadence, with updates typically coinciding with new features, bug fixes, or compatibility adjustments within the Daybrush project family. Its key differentiators include its explicit TypeScript support, minimal dependencies, and clear focus on solving common boilerplate problems in UI development, making it suitable for projects that require precise, low-overhead utility functions rather than a broad, opinionated framework.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the core functionality of `framework-utils` by prefixing both class names and CSS selectors, highlighting common use cases for UI development.

import { prefixNames, prefixCSS } from 'framework-utils';

// Example 1: Prefixing multiple class names
const baseName = "my-component-";
const namesToPrefix = ["header", "body", "footer"];
const prefixedClassNames = prefixNames(baseName, ...namesToPrefix);

console.log(`Prefixed class names: ${prefixedClassNames}`);
// Expected output: "Prefixed class names: my-component-header my-component-body my-component-footer"

// Example 2: Prefixing CSS selectors within a style string
const cssPrefix = "app-scope-";
const rawCSS = `
.button {
  background-color: blue;
}
.text-input, .text-area {
  border: 1px solid gray;
}
/* Comments are also handled */
`;
const prefixedStyle = prefixCSS(cssPrefix, rawCSS);

console.log(`Prefixed CSS:
${prefixedStyle}`);
/* Expected output:
Prefixed CSS:
.app-scope-button {
  background-color: blue;
}
.app-scope-text-input, .app-scope-text-area {
  border: 1px solid gray;
}
*/

// Demonstrate using another utility if available (hypothetical, based on common patterns)
// As the README only shows prefixNames and prefixCSS, we focus on expanding those.
// const someOtherUtil = FrameworkUtilsRuntime.someOtherUtility();
// console.log(someOtherUtil);

view raw JSON →