Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
rn-stylenames
Advanced tools
A simple javascript utility for conditionally joining react native styles together
A simple JavaScript utility for conditionally joining react native styles together.
npm:
npm install rn-stylenames --save
Yarn:
yarn add rn-stylenames
The stylenames
function takes any number of arguments which can be a number, plain object or array.
The argument 51
is short for { 51: true }
.
If the value associated with a given key is falsy, that key won't be included in the output.
If the given key is not style object id, it will be passed as common key:value pair.
If the given value is array, it will be recursively walked through.
stylenames(51, 52); // => [51, 52]
stylenames(51, { 52: true }); // => [51, 52]
stylenames(51, { 52: false, fontSize: 18 }); // => [51, {fontSize: 18}]
stylenames(51, [{ 52: false, fontSize: 18 }]); // => [51, {fontSize: 18}]
import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import stylenames from 'react-native-stylenames';
const styles = StyleSheet.create({
text: {
fontSize: 14,
lineHeight: 20,
},
activeText: {
color: 'blue'
}
});
const Screen = (props) => {
const textStyles = stylenames(styles.text, {[styles.activeText]: props.isActive});
return (
<View>
<Text style={textStyles}>Hello World!</Text>
</View>
);
}
MIT. Copyright (c) 2018 Anton Bebnev.
FAQs
A simple javascript utility for conditionally joining react native styles together
We found that rn-stylenames 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.