Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
react-themeable
Advanced tools
Utility for making React components easily themeable.
This project is still experimental, so feedback from component authors would be greatly appreciated!
The React community is highly fragmented when it comes to styling. How do we write components that can happily co-exist with all of these competing approaches?
With react-themeable, you can support custom themes provided by CSS Modules, Radium, Aphrodite, React Style, JSS, global CSS or inline styles as easily as this:
<MyComponent theme={theme} />
npm install --save react-themeable
react-themeable
exposes just a single function.
This function is designed to accept a theme
prop inside of your render
method. This then returns a small helper function that accepts a key and a series of style names.
const theme = themeable(this.props.theme);
...
<div {...theme(key, ...styleNames)} />
Note: A unique key for each themed element is required for Radium to work correctly.
This helper function detects whether a theme is class or style based, and creates the appropriate attributes for you.
For example:
import React, { Component } from 'react';
import themeable from 'react-themeable';
class MyComponent extends Component {
render() {
const theme = themeable(this.props.theme);
return (
<div {...theme(1, 'root')}>
<div {...theme(2, 'foo', 'bar')}>Foo Bar</div>
<div {...theme(3, 'baz')}>Baz</div>
</div>
);
}
}
A theme can now be passed to your component like so:
.foo { color: red; }
.foo:hover { color: green; }
.bar { color: blue; }
import theme from './MyComponentTheme.css';
...
<MyComponent theme={theme} />
import Radium from 'radium';
const theme = {
foo: {
color: 'red',
':hover': {
color: 'green'
}
},
bar: {
color: 'blue'
}
};
const ThemedMyComponent = Radium(MyComponent);
...
<ThemedMyComponent theme={theme} />
import { StyleSheet, css } from 'aphrodite';
const theme = StyleSheet.create({
foo: {
color: 'red',
':hover': {
color: 'green'
}
},
bar: {
color: 'blue'
}
});
...
<MyComponent theme={[ theme, css ]} />
import StyleSheet from 'react-style';
const theme = StyleSheet.create({
foo: {
color: 'red'
},
bar: {
color: 'blue'
}
});
...
<MyComponent theme={theme} />
import jss from 'jss';
const sheet = jss.createStyleSheet({
foo: {
color: 'red'
},
bar: {
color: 'blue'
}
}).attach();
...
<MyComponent theme={sheet.classes} />
.MyComponent__foo { color: red; }
.MyComponent__foo:hover { color: green; }
.MyComponent__bar { color: blue; }
const theme = {
foo: 'MyComponent__foo',
bar: 'MyComponent__bar'
};
...
<MyComponent theme={theme} />
const theme = {
foo: {
color: 'red'
},
bar: {
color: 'blue'
}
};
...
<MyComponent theme={theme} />
FAQs
Utility for making React components easily themeable
The npm package react-themeable receives a total of 207,442 weekly downloads. As such, react-themeable popularity was classified as popular.
We found that react-themeable 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.