Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
styletron-engine-atomic
Advanced tools
Atomic implementation of the styletron-standard
engine interface.
Check our documentation at styletron.org.
yarn add styletron-engine-atomic
This package provides two named exports:
Client
import {Client} from "styletron-engine-atomic";
.constructor(opts?: {prefix?: string, hydrate?: HTMLStyleElement[], container: Element})
prefix?: string
The prefix to be used for all generated atomic identifiers (e.g. class names, @keyframes
names, etc.)hydrate?: HTMLStyleElement[]
Collection of server-rendered style elements. Hydration is required when server-side rendering.container?: Element
The element that new stylesheets should be appended to. Defaults to the parent element of the first stylesheet passed via hydrate
, otherwise defaults to document.head
.const instance = new Client();
.renderStyle(style) => string
.renderKeyframes(keyframes) => string
.renderFontFace(fontFace) => string
Server
import {Server} from "styletron-engine-atomic";
.constructor(opts?: {prefix?: string})
prefix?: string
The prefix to be used for all generated atomic identifiers (e.g. class names, @keyframes
names, etc.)const instance = new Server();
.getStylesheets() => Array<{css: string, attrs: {[string]: string}}>
Returns styles as an array of stylesheet objects.
.getStylesheetsHtml(className: string) => string
Returns styles as a string of HTML that can also be used for client-side hydration.
.getCss() => string
Returns styles as a string of CSS for purely server-side rendering use cases where no client-side hydration is needed.
.renderStyle(style) => string
.renderKeyframes(keyframes) => string
.renderFontFace(fontFace) => string
These methods exist on both the server and client instances.
.renderStyle(style) => string
Renders a given style object, returning the corresponding generated class name.
instance.renderStyle({
color: "red",
fontSize: "12px"
});
// → "a b"
.renderKeyframes(keyframes) => string
Renders a given keyframes object, returning the corresponding generated @keyframes
rule name.
const animationName = instance.renderKeyframes({
from: {color: "red"},
to: {color: "blue"}
});
// → "a"
.renderFontFace(fontFace) => string
Renders a given font face object, returning the font-family name from the corresponding generated @font-face
rule.
const fontFamily = instance.renderFontFace({
src: "..."
});
// → "a"
See TRADEOFFS.md
FAQs
Universal, high-performance JavaScript styles
The npm package styletron-engine-atomic receives a total of 25,604 weekly downloads. As such, styletron-engine-atomic popularity was classified as popular.
We found that styletron-engine-atomic 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.