Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
jss-nested
Advanced tools
The jss-nested package is a plugin for JSS (JavaScript Style Sheets) that allows you to use nested selectors in your styles. This makes it easier to write and manage complex styles by mimicking the nesting capabilities found in preprocessors like Sass and Less.
Nested Selectors
This feature allows you to nest selectors within a style rule, making it easier to manage styles that depend on parent elements or states like hover.
const styles = {
button: {
'&:hover': {
backgroundColor: 'blue'
},
'& .icon': {
color: 'red'
}
}
};
Media Queries
You can nest media queries within your style rules, allowing for responsive design directly within your JSS styles.
const styles = {
container: {
width: '100%',
'@media (min-width: 600px)': {
width: '50%'
}
}
};
Nested Conditional Styles
This feature allows you to apply different styles based on class names or other conditions, making it easier to manage variations of a component.
const styles = {
button: {
color: 'black',
'&.primary': {
color: 'blue'
},
'&.secondary': {
color: 'green'
}
}
};
styled-components is a library for React and React Native that allows you to use component-level styles in your application. It uses tagged template literals to style your components. Unlike jss-nested, styled-components is more focused on React and offers a more integrated approach to styling components.
Emotion is a performant and flexible CSS-in-JS library. It allows you to style applications quickly with string or object styles. Emotion also supports nested selectors and media queries, similar to jss-nested, but it offers a broader range of features and better performance optimizations.
Aphrodite is a CSS-in-JS library that allows you to write styles in JavaScript and apply them to your components. It supports media queries and pseudo-classes, similar to jss-nested, but it focuses more on performance and critical CSS extraction.
Make sure you read how to use plugins in general.
Demo - JSS ![Gitter](https://badges.gitter.im/Join Chat.svg)
&
to reference selector of the parent rule.const sheet = jss.createStyleSheet({
container: {
padding: 20,
'&:hover': {
background: 'blue'
},
// Add a global .clear class to the container.
'&.clear': {
clear: 'both'
},
// Reference a global .button scoped to the container.
'& .button': {
background: 'red'
},
// Use multiple container refs in one selector
'&.selected, &.active': {
border: '1px solid red'
}
}
})
.container-3775999496 {
padding: 20px;
}
.container-3775999496:hover {
background: blue;
}
.container-3775999496.clear {
clear: both;
}
.container-3775999496 .button {
background: red;
}
.container-3775999496.selected, .container-3775999496.active {
border: 1px solid red;
}
$ruleName
to reference a local rule within the same style sheet.const sheet = jss.createStyleSheet({
container: {
// Reference the local rule "button".
'& $button': {
padding: '10px'
},
// Multiple local refs in one rule.
'&:hover $button, &:active $button': {
color: 'red',
},
'&:focus $button': {
color: 'blue'
}
},
button: {
color: 'grey'
}
})
.button-3940538223 {
color: grey;
}
.container-2645419599 .button-3940538223 {
padding: 10px;
}
.container-2645419599:hover .button-3940538223, .container-2645419599:active .button-3940538223 {
color: red;
}
.container-2645419599:focus .button-3940538223 {
color: blue;
}
const sheet = jss.createStyleSheet({
button: {
color: 'red',
'@media (min-width: 1024px)': {
width: 200
}
}
})
.button-2683044438 {
color: red;
}
@media (min-width: 1024px) {
.button-2683044438 {
width: 200px;
}
}
Deep nesting is not supported for multiple reasons:
If you can provide a real life example where you really need deep nesting - we would love to know it.
File a bug against cssinjs/jss prefixed with [jss-nested].
npm i
npm run test
MIT
FAQs
JSS plugin that enables support for nested selectors
The npm package jss-nested receives a total of 83,856 weekly downloads. As such, jss-nested popularity was classified as popular.
We found that jss-nested 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.