Bukwild Stylus Library
Bukwild Stylus Library is a collection of opinionated utility mixins, functions, and global conventions designed for Stylus CSS preprocessor projects. It aims to streamline development by providing pre-built solutions for common CSS patterns, particularly focusing on responsive design with its `fluid()` mixin for scaling property values. The library is currently at version 3.2.1. While Stylus itself has had periods of uncertainty regarding maintenance, this library appears to be actively maintained, with a recent update (v3.2.1) published in February 2022. Its key differentiators include the advanced `fluid()` mixin for complex responsive scaling and the provision of `boilerplate.styl` for quick setup with Bukwild's internal conventions. It is specifically built for Stylus, differentiating it from Sass or Less-based utility collections.
Common errors
-
npm ERR! code ETARGET npm ERR! notarget No matching version found for stylus@^0.64.0
cause The main `stylus` package (a peer dependency of this library) was temporarily removed or flagged from the npm registry, often due to security advisories, leading to installation failures.fixCheck the `stylus` package's official npm page or GitHub repository for status updates. You might need to temporarily override the `stylus` version in your `package.json` to a known good one or use a GitHub reference if the npm registry version is unavailable. -
Error: `~bukwild-stylus-library/index.styl` not found
cause Stylus cannot resolve the `@import` path to the `bukwild-stylus-library` package. This typically means the package is not correctly installed in `node_modules` or the Stylus compiler's `paths` option is not configured to include `node_modules`.fixEnsure `bukwild-stylus-library` is listed in your `package.json` and installed (`npm install` or `yarn install`). Verify your Stylus compiler configuration (e.g., in webpack, Gulp, or CLI) includes `node_modules` in its `paths` option for resolving `@import` statements starting with `~`. -
Stylus compilation error: 'fluid' is not defined
cause The `fluid` mixin, or the main `index.styl` file containing it, was not successfully imported into the current Stylus file being compiled.fixEnsure that `@import "~bukwild-stylus-library/index.styl";` is present at the top of your main Stylus file or any file that requires the mixins. Also, verify that no syntax errors in the import path or the imported file itself are preventing successful loading.
Warnings
- breaking The default `fluid-default-max-break` variable, which dictates the upper breakpoint for the `fluid()` mixin's scaling, was changed from its previous value to 1440px. Projects relying on the old default will see altered responsive scaling behavior.
- gotcha Stylus relies on a peer dependency of the `stylus` package itself. There have been instances where the core `stylus` package was temporarily unavailable or flagged in the npm registry due to unrelated malicious packages published by a maintainer's compromised account. While resolved, such incidents can cause installation failures.
- gotcha Stylus mixins, especially those with many arguments or optional parameters, can be prone to incorrect invocation syntax, leading to silent failures or unexpected CSS output. Stylus's transparent mixin behavior can sometimes cause ambiguity.
Install
-
npm install bukwild-stylus-library -
yarn add bukwild-stylus-library -
pnpm add bukwild-stylus-library
Imports
- index.styl (main entry)
import { fluid } from 'bukwild-stylus-library'@import "~bukwild-stylus-library/index.styl"
- fluid (mixin)
.selector fluid(padding: 20px, 10px)
.selector fluid padding, 20, 10, min-break: 768px
- boilerplate.styl
@import "boilerplate"
@import "~bukwild-stylus-library/boilerplate.styl"
Quickstart
// my-project.styl @import "~bukwild-stylus-library/index.styl"; // Define some base variables if needed, otherwise library defaults apply // fluid-default-max-break = 1440px // Default in v3.0.0+ // fluid-default-min-break = 375px .my-responsive-element font-size: 16px; // Scales padding from 20px (at 1440px viewport) down to 10px (at 375px viewport) fluid padding, 20, 10; .my-custom-breakpoint-element margin-top: 50px; // Scales margin-top from 30px (at 1024px viewport) down to 15px (at 768px viewport) fluid(margin-top, 30, 15, min-break: 768px, max-break: 1024px); // Using fluid with CSS custom properties (variables) :root fluid(--site-padding, 40, 20); // Scale a custom property .header padding: var(--site-padding); background: lightblue; .footer padding: calc(var(--site-padding) / 2); background: lightgray;