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.
v0.3.0
- A simple CSS preprocessor that interprets JavaScript
jsheets file
Jsheets is a CSS preprocessor that executes JavaScript. It also replaces function calls and variables inside CSS. A simple approach to CSS preprocessing.
npm install -g jsheets
$
ObjectInside CSS the whole $
object is availible to you. Because $
is also a function (as explained in the helpers section), you can't write to its arguments
, caller
, length
and prototype
attributes.
div {
background: $.someColor;
}
include '
file/directory'
With include
you can import files or directories to a jsheet. When you include a directory, it will search that directory for files with the jsheet
file extension.
css(
string)
With the css
function you can output css. So you can do:
css('div {display: block}')
All combined files have the same global scope.
Inside your JavaScript you have the following variables availible to you.
As documented above
Documented in the hooks section
on(
hook,
function)
on
is the function to add functions to hooks. See under the hooks section for examples.
There are some helpers provided inside the $
object.
$(
expression)
$
itself is not just an object but also a function that executes and returns what is passed to it. This can be usefull for math or sometimes you can use it to use variables in weird places. Example:
div {
width: $(100 * 30)px
/* WON'T WORK */
width: $.someWithem
/* WILL WORK */
width: $($.someWith)em
}
You cannot use braces inside of a call to $
. That's because the $
variables and functions are replaced using a mediocar RegEx.
extend.add(
name,
attributes)
extend.that(
name,
selector)
With extend
you can reuse css attributes. It has two methods: add
and that
. With add you create save a bunch of attributes under a name.
$.extend.add('roundbutton', '\
display: block;'
)
Then with extend.that
you can then reuse those attributes.
$.extend.that('roundbutton', '.dialogue__button')
$.extend.that('roundbutton', '.escape__button')
What is special about this function, is that it renders only one CSS block per extend.add
. So the above renders to:
roundbutton, .dialogue__button, .escape__button { display: block; }
$.calc(
calculation)
With calc you can do calculations in css units. You pass it a string. It also does a printf-style replacement with %d
.
$.someVar = '4rem'
$.calc('%d / 2', $.someVar)
compilesTo
2rem
In jsheets hooks are simple arrays you can push functions to. They are stored in the hooks object, which is globally availible. Hooks get triggered at a certain point in the parsing process and then the functions stored in a hook array will get executed with certain parameters.
These hooks are executed without an argument, at the and of parsing a file. The return value of a onEOF
hook will get printed as CSS.
Extending jsheets is super straigt forward. If you want to add your own helpers, you can just add stuff to the object
.
$.myHelper = function () {
css('before: "YEY! I wrote my own helper :OO"')
}
You can also install and require npm modules. Autoprefixer for example
npm install autoprefixer
on('onEOF', require('autoprefixer'))
onAfterParse
hooks are the last thing that gets called. They receive the parsed CSS as an argument. Their return value replaces the parsed CSS. This makes it perfect for something like autoprefixer.
I'm pretty ok with the package as it stands right now. But there are a lot of things I plan to implement.
v0.3.0
This is still an early alpha, so everything can change
FAQs
A simple CSS preprocessor that interprets JavaScript
The npm package jsheets receives a total of 0 weekly downloads. As such, jsheets popularity was classified as not popular.
We found that jsheets 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.