Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Talk about namespace...
Stylesheet has namespace and defines semantic scope parts: Single declaration:
Namespace is prefixed to each class name in the stylesheet
Code:
new Stylesheet({
"@namespace": "App",
"redButton": { color: "red" },
"blueButton": { color: "blue" }
});
CSS output:
.App◼redButton { color: red; }
.App◼blueButton { color: blue; }
The main className that should be used as for the component root node.
Stylesheet with root:
new Stylesheet({
"@namespace": "Button",
"@define": {
"root": Stylesheet.root() // Declare a class as root
},
"root": { color: "red" }
});
CSS output:
/* result CSS class name: namespace + root name */
.Button◼root { color: red; }
Custom states in nscss are just mapping between an attribute selector to a name.
Root with custom states:
new Stylesheet({
"@define": {
"Button": Stylesheet.root({
mouseHover: "[data-state-hover]",
disabled: "[data-state-disabled]"
})
},
"Button": { color: "red" },
"Button:mouseHover": { color: "green" }
});
CSS output:
.Button◼Button { color: red; }
.Button◼Button[data-state-hover] { color: "green" }
Only affects the output css when used with component and scoped classes.
Customization is a way to target component type within your stylesheet The way to do it is to get the a reference to a stylesheet and use it as component or scoped override
Customize all labels under root stylesheet using component:
//this can be imported from the label stylesheet file.
const Label = new Stylesheet(...);
new Stylesheet({
"@define": {
"Button": Stylesheet.root(),
"Label": Stylesheet.component(Label) // use it as a component
},
"Label": { color: "red" },
"Label:hover": { color: "green" },
"Button:hover Label": { color: "blue" }
});
CSS output:
.Button◼Button .Label◼Label { color: red; }
.Button◼Button .Label◼Label:hover { color: green; }
.Button◼Button:hover > .Label◼Label { color: blue; }
Customize with local class that will be place on any of the components scoped
//this can be imported from the label stylesheet file.
const Label = new Stylesheet(...);
new Stylesheet({
"@define": {
"Button": Stylesheet.root(),
"Label": Stylesheet.scoped(Label) // use it as a scoped
},
"Label": { color: "red" },
"Label:hover": { color: "green" },
"Button:hover > Label": { color: "blue" }
});
CSS output:
.Button◼Button .Button◼Label { color: red; }
.Button◼Button .Button◼Label:hover { color: green; }
.Button◼Button:hover .Button◼Label { color: blue; }
Customization of inner parts is done with the :: operator and can be chained as many level that needed.
Target text class inside the label component:
//this can be imported from the label stylesheet file.
const Label = new Stylesheet({
"@define": {
"Label": Stylesheet.root(),
},
"text": { color: "red" } // label inner text class
});
new Stylesheet({
"@define": {
"Button": Stylesheet.root(),
"Label": Stylesheet.component(Label), // target with component
"MyLabel": Stylesheet.scoped(Label) // target with scoped
},
//target the ::text part
"Label::text": { color: "green" },
"MyLabel::text": { color: "blue" }
});
CSS output:
.Button◼Button .Label◼Label .Label◼text { color: red; }
.Button◼Button .Button◼MyLabel .Label◼text { color: green; }
Selector definition must start with a defined part and then it can target internal parts, states or other defined parts.
new Stylesheet({
"@define": {
"Button": Stylesheet.root()
},
"container": { ... },
"btn": { ... },
"container btn": {
color: "red"
},
"container[data-active] > label:hover": {
color: "red"
}
});
Possible markup
<div class="Button">
<div data-active class="container">
<button class="btn"></button>
</div>
<button class="btn"></button>
<div>
CSS output:
...
/* this is complex part only */
.Button◼container .Button◼btn { color: blue; }
.Button◼container[data-active] > .Button◼btn:hover { color: blue; }
All css values in nscss are actually part of a template engine the data for the variables comes when you attach the stylesheet to the dom
new Stylesheet({
"@define": {
"Button": Stylesheet.root()
},
"Button": {
color: "{{primaryColor}}" // this will be injected
}
});
//at the app entry
Stylesheet.attach({
primaryColor: "red"
});
CSS output:
.Button◼Button { color: red; }
FAQs
CSS for Components
The npm package nscss receives a total of 4 weekly downloads. As such, nscss popularity was classified as not popular.
We found that nscss 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.