
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
jss-camel-case
Advanced tools
The jss-camel-case npm package is a plugin for JSS (JavaScript Style Sheets) that converts camelCased property names to dash-separated (kebab-case) names. This is useful for writing CSS-in-JS styles in a more JavaScript-friendly syntax while ensuring compatibility with CSS standards.
Convert camelCase to kebab-case
This feature allows you to write styles in camelCase and have them automatically converted to kebab-case. In the example, `backgroundColor` and `fontSize` are converted to `background-color` and `font-size` respectively.
const jss = require('jss').default;
const camelCase = require('jss-camel-case').default;
jss.use(camelCase());
const styles = {
button: {
backgroundColor: 'blue',
fontSize: '14px'
}
};
const sheet = jss.createStyleSheet(styles).attach();
console.log(sheet.toString());
PostCSS is a tool for transforming CSS with JavaScript plugins. It can be used to convert camelCase to kebab-case among many other transformations. Unlike jss-camel-case, PostCSS is a more general-purpose tool and can be used for a wide range of CSS manipulations.
Styled-components is a library for writing CSS-in-JS with a focus on React. It allows you to write actual CSS syntax within JavaScript and supports camelCase properties. While it doesn't convert camelCase to kebab-case, it provides a similar developer experience by allowing you to write styles in a JavaScript-friendly way.
Emotion is a performant and flexible CSS-in-JS library. It supports writing styles in camelCase and automatically converts them to kebab-case. Emotion offers more features and flexibility compared to jss-camel-case, including theming and server-side rendering support.
Internally it converts everything back to dash separated names.
Make sure you read how to use plugins in general.
const styles = {
container: {
fontSize: '20px',
zIndex: 1,
lineHeight: 1.2
}
}
.container-a24234 {
font-size: 20px;
z-index: 1;
line-height: 1.2;
}
File a bug against cssinjs/jss prefixed with [jss-camel-case].
npm i
npm run test
MIT
FAQs
JSS plugin that allows to write camel cased rule properties
The npm package jss-camel-case receives a total of 100,620 weekly downloads. As such, jss-camel-case popularity was classified as popular.
We found that jss-camel-case 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.