Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Alef is a fast and modular library to handle styling in JavaScript.
It is dynamic by design and renders your styles depending on your application state.
It generates CSS and therefore supports all common CSS features such as media queries, pseudo classes, keyframes and font-faces. It also renders on server-side with ease and ships with a powerful plugin API adding e.g. automatic vendor prefixing or fallback value support.
Alef can be used with React or with any other view library. React Native support has been removed.
We're busy refactoring and hitting the delete key, so you can't install it (yet).
Alef is all about rendering styles, especially so called rules. A universal renderer will help us to render styles of all kind. Once rendered into a DOM node, a change listener will subscribe to changes and automatically add new rules.
The following example illustrates the key parts of Alef though it only shows the very basics.
import { createRenderer } from 'alef'
import { render } from 'alef-dom'
// rules are just plain functions of props
// returning a valid object of style declarations
const rule = props => ({
fontSize: props.fontSize + 'px',
marginTop: props.margin ? '15px' : 0,
color: 'red',
lineHeight: 1.4,
':hover': {
color: 'blue',
fontSize: props.fontSize + 2 + 'px'
},
// nest media queries and pseudo classes
// inside the style object
'@media (min-height: 300px)': {
backgroundColor: 'gray',
':hover': {
color: 'black'
}
}
})
// creates a new renderer to render styles
const renderer = createRenderer()
// rendering the rule returns a className reference
// which can be attached to any element
const className = renderer.renderRule(rule, { fontSize: 12 })
// it uses atomic css design to reuse styles
// on declaration base and to keep the markup minimal
console.log(className) // => a b c d e f h
// renders all styles into the DOM
render(renderer)
The Fela documentation should be a good start, although don't actually try to use Alef unless you are me.
Nobody except for me...which should be a good thing.
Alef is licensed under the MIT License.
Documentation is licensed under Creative Common License.
Created by @as-com, based on excellent work by @rofrischmann and other contributors.
FAQs
Dynamic and high-performance CSS in JavaScript
We found that alef 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.