Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Functional css generator
Functional css (à la tachyons), but customizable for your project's visual language. No more rewriting long stylesheets to include your colours, typefaces, and spacing scale! 🌺
:construction: This project is still v0.x.x
and the API is subject to change.
npm install hibiscss --save
For a quick start, use the default rule kit. You can pass in options to define your project’s visual language:
import hibiscss from 'hibiscss';
import kit from 'hibiscss/default';
const styles = hibiscss(kit({
colors: {
pink: '#ffb7b3',
black: '#141414'
},
fontFamily: {
work: 'Work Sans, sans-serif'
},
fontSize: [36, 24, 19, 17, 15, 12]
}));
Then use the classes like so:
<div class="c-pink ff-work fs-2">Work Sans in pink at 24px!</div>
Yay! :tada: Check out the examples or default kit docs for more!
Hibiscss returns a string of css. You can integrate it with your build system however you'd like. I find the easiest is to spit out a static css file, like so:
Make a file with your config and output it to console.log
, like so:
// css.js
import hibiscss from 'hibscss';
import tachyons from 'hibscss/tachyons';
const styles = hibiscss(tachyons());
console.log(styles);
Then add a package.json
script to generate the styles:
{
"scripts": {
"build-css": "node css.js > /path/to/styles.css"
}
}
Run npm run build-css
to create your styles, and re-run whenever you make changes to your kit.
Hibiscss generates css using kits, presets that map your visual language to functional css styles. Hibiscss comes with two kits bundled into the package:
Kits are functions which take options, and return css rules for hibiscss to generate. For example, using the default kit:
import hibiscss from 'hibiscss';
import kit from 'hibiscss/default';
const config = {
spacing: [0, 8, 16, 24, 48, 64],
colors: { rausch: '#ff5a5f', foggy: '#767676' },
fontSize: { title: 44, large: 24, regular: 19 },
fontWeight: { light: 300, regular: 400, semibold: 600 }
};
const rules = kit(config);
const css = hibiscss(rules);
Will give you classes like:
<div class="c-foggy mh-2 mh-4-m fs-title fw-semibold">Semibold and large</div>
Kits let you customize everything whether you can adjust line heights to how verbose the class names should be (eg. mh-2
vs. marginHorizontal-2
).
If you'd like fine-grained control over the final css, you can write your own kit. Kits are simply a function that returns a set of rules, created with the rule
helper function.
Check out the custom kit example, or read the API docs to learn more.
functional css makes css a lot of fun, but many of the toolkits out there are difficult to customize.
I found myself manually editing tachyons colours, typefaces, and breakpoints more times than I’d like. So I built hibiscss
to provide a simple structure for quickly generating functional css frameworks.
Lots of prior art in the functional css area:
Hibiscss pairs nicely with:
MIT
FAQs
Tool for making functional css stylesheets
We found that hibiscss demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.