Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
npm install css-to-rn.macro
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
57 Stars
21 Commits
2 Forks
6 Watching
21 Branches
2 Contributors
Updated on 06 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-90%
1
Compared to previous day
Last week
28.6%
72
Compared to previous week
Last month
89.5%
235
Compared to previous month
Last year
-4.2%
3,551
Compared to previous year
Convert CSS to React Native style sheet at build time with babel macros, using
css-to-react-native-transform
.
css
template literal like vscode-styled-components
1$ npm install --save-dev css-to-rn.macro
You'll also need to install and configure babel-plugin-macros
if you haven't already.
Input:
1import { StyleSheet } from 'react-native' 2import css from 'css-to-rn.macro' 3 4const styles = StyleSheet.create( 5 css` 6 .container { 7 flex: 1; 8 justify-content: center; 9 align-items: center; 10 } 11 `, 12)
Output:
1import { StyleSheet } from 'react-native' 2 3const styles = StyleSheet.create({ 4 container: { 5 flexGrow: 1, 6 flexShrink: 1, 7 flexBasis: 0, 8 justifyContent: 'center', 9 alignItems: 'center', 10 }, 11})
The css-to-react-native-transform
allow parsing the CSS Media Queries, and you can use it with react-native-css-media-query-processor
This is example for change styles with platform:
1import { Dimensions, StyleSheet } from 'react-native' 2import css, { parseMedia } from 'css-to-rn.macro' 3 4const win = Dimensions.get('window') 5const matchObj = { 6 width: win.width, 7 height: win.height, 8 orientation: win.width > win.height ? 'landscape' : 'portrait', 9 'aspect-ratio': win.width / win.height, 10 type: 'screen', 11} 12const styles = StyleSheet.create( 13 parseMedia( 14 css` 15 .container { 16 flex: 1; 17 justify-content: center; 18 align-items: center; 19 } 20 @media not android { 21 .container { 22 background-color: #ccc; 23 } 24 } 25 `, 26 matchObj 27 ), 28)
1const height = Math.random() * 100 2css` 3 .container { 4 height: ${height}; 5 } 6`
Due to the height
is random number, so it's unknown value at build time.
It will just fallback to css-to-react-native-transform
with a warning, but you can still use this macro.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
66 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More