Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
taro-css-to-react-native
Advanced tools
Convert CSS text to a React Native stylesheet object
fork from css-to-react-native-transform
A lightweight wrapper on top of css-to-react-native to allow valid CSS to be turned into React Native Stylesheet objects.
To keep things simple it only transforms class selectors (e.g. .myClass {}
) and grouped class selectors (e.g. .myClass, .myOtherClass {}
). Parsing of more complex selectors can be added as a new feature behind a feature flag (e.g. transform(css, { parseAllSelectors: true })
) in the future if needed.
Example:
.myClass {
font-size: 18px;
line-height: 24px;
color: red;
}
.other {
padding: 1rem;
}
is transformed to:
{
myClass: {
fontSize: 18,
lineHeight: 24,
color: "red"
},
other: {
paddingBottom: 16,
paddingLeft: 16,
paddingRight: 16,
paddingTop: 16
}
}
import transform from "taro-css-to-react-native";
// or const transform = require("taro-css-to-react-native").default;
transform(`
.foo {
color: #f00;
}
`);
↓ ↓ ↓ ↓ ↓ ↓
{
foo: {
color: "#f00";
}
}
Parsing the CSS Modules (ICSS) :export is supported. The :export
is often used to share variables from CSS or from a preprocessor like Sass/Less/Stylus to Javascript:
transform(`
.foo {
color: #f00;
}
:export {
myProp: #fff;
}
`);
↓ ↓ ↓ ↓ ↓ ↓
{
foo: {
color: "#f00";
},
myProp: "#fff";
}
The API and parsed syntax for CSS Media Queries might change in the future
transform(
`
.container {
background-color: #f00;
}
@media (orientation: landscape) {
.container {
background-color: #00f;
}
}
`,
{ parseMediaQueries: true },
);
↓ ↓ ↓ ↓ ↓ ↓
{
__mediaQueries: {
"@media (orientation: landscape)": [{
expressions: [
{
feature: "orientation",
modifier: undefined,
value: "landscape",
},
],
inverse: false,
type: "all",
}],
},
container: {
backgroundColor: "#f00",
},
"@media (orientation: landscape)": {
container: {
backgroundColor: "#00f",
},
},
}
You can also speficy a platform as the media query type ("android", "dom", "ios", "macos", "web", "windows"):
transform(
`
.container {
background-color: #f00;
}
@media android and (orientation: landscape) {
.container {
background-color: #00f;
}
}
`,
{ parseMediaQueries: true },
);
When CSS Viewport Units are used, a special __viewportUnits
feature flag is added to the result. This is done so that the implementation that transforms viewport units to pixels knows that the style object has viewport units inside it, and can avoid doing extra work if the style object does not contain any viewport units.
transform(`.foo { font-size: 1vh; }`);
↓ ↓ ↓ ↓ ↓ ↓
{
__viewportUnits: true,
foo: {
fontSize: "1vh";
}
}
rem
unit the root element font-size
is currently set to 16 pixels. A
setting needs to be implemented to allow the user to define the root element
font-size
.box-shadow
shorthand, and this converts into
shadow-
properties. Note that these only work on iOS.This library has the following packages as dependencies:
FAQs
Convert CSS text to a React Native stylesheet object
The npm package taro-css-to-react-native receives a total of 1,594 weekly downloads. As such, taro-css-to-react-native popularity was classified as popular.
We found that taro-css-to-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.