
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@cssfn/cssfn
Advanced tools
A lib for generating Style Sheet (css) with JavaScript function.
Similar to React Hooks but for generating css dynamically.
By underlying JavaScript language, the css can be easily exported/imported as a regular JavaScript module.
The generated css can be exported to css toString()
or attached to DOM directly .attach()
.
export const usesAwesomeButton = () => composition([
imports([
stripoutControl(), // clear browser's default styles
usesButtonBase(), // imports css from a generic button
// imports any stuff here...
]),
layout({
display : 'flex',
flexDirection : 'row',
background : 'pink',
color : 'darkred',
// writes the css declaration similar to regular css
...children(['span', '.logo'], [ // target to <span> and class="logo"
imports([
// imports any stuff here...
]),
layout({
// writes the css declaration similar to regular css
}),
]),
}),
variants([
rule('.big', [
layout({
fontSize: 'xx-large',
// ....
}),
]),
rule('.dark', [
// ...
]),
]),
states([
rule([':disabled', '.disabled'], [
// ....
]),
]),
]);
// attach the css to DOM:
createSheet(() => [
globalDef([
rule('.awesome-btn', [
imports([
usesAwesomeButton(),
]),
]),
rule('.awesome-checkbox', [
// ....
]),
// ....
]),
])
.attach();
Then we can consume our generated css like this:
<script src="button-style.js">
</script>
<button class="awesome-btn">Awesome!</button>
Using npm:
npm i @cssfn/cssfn
If you feel our lib is useful for your projects,
please make a donation to avoid our project from extinction.
We always maintain our projects as long as we're still alive.
FAQs
Writes, imports, and exports css stylesheets as javascript modules.
The npm package @cssfn/cssfn receives a total of 8 weekly downloads. As such, @cssfn/cssfn popularity was classified as not popular.
We found that @cssfn/cssfn 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.