![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@dokuhero/react-native-theme
Advanced tools
Theme and stylesheet manager for ReactNative.
Using npm:
npm i -S @dokuhero/react-native-theme
or yarn:
yarn add @dokuhero/react-native-theme
You'll use createTheme
function to create new theme. Call this function without any parameter will produce default theme values.
import { createTheme } from '@dokuhero/react-native-theme'
export const dark = createTheme({
id: 'dark',
name: 'dark',
color: {
primary: '#3878c7',
secondary: '#44d4fc'
}
// just follow intellisense to override default theme values...
// you may also create new key value here.
})
You may also override your existing theme as if needed
import { createTheme } from '@dokuhero/react-native-theme'
export const dark = createTheme(light, {
id: 'light',
name: 'light',
color: {
primary: '#ffff'
}
// ....
}
Put ThemeProvider
(a React context provider for theme) on your top View of application.
import { Theme, ThemeProvider } from '@dokuhero/react-native-theme'
export class MainScreen extends React.Component<Partial<StateProps>> {
render() {
return (
<ThemeProvider value={light}>
<View style={{ flex: 1 }}>{/* rest of code.. */}</View>
</ThemeProvider>
)
}
}
To consume theme, you can use ThemeConsumer
(a React context consumer), or use withTheme
HOC function or also withThemeClass
class decorator.
const TheComponent: React.SFC = (({children})) => (
<ThemeConsumer>
{({ color, space, radius }) => (
<View style={{
backgroundColor: color.dark,
padding: space.medium,
borderRadius: radius.small
}}>
{children}
</View>
)}
</ThemeConsumer>
)
interface TheComponentProps {
children?: React.ReactNode
}
const TheComponent: withTheme<TheComponentProps>(({children, color, space, radius}) => (
<View style={{
backgroundColor: color.dark,
padding: space.medium,
borderRadius: radius.small
}}>
{children}
</View>
))
import { withThemeClass, WithThemeProps } from '@dokuhero/react-native-theme'
interface TheComponentProps extends WithThemeProps {
children?: React.ReactNode;
}
@withThemeClass()
export class TheComponent extends React.Component<TheComponentProps> {
render() {
const {
theme: { children, color, space, radius }
} = this.props
return (
<View
style={{
backgroundColor: color.dark,
padding: space.medium,
borderRadius: radius.small
}}
>
{children}
</View>
)
}
}
We are using react-native-extended-stylesheet to build our Stylesheet module.
This is to define your style sheet.
// styles.ts
import {
ColorKeys,
createStyleSheet,
RadiusKeys,
SpaceKeys
} from '@dokuhero/react-native-theme'
export const styles = createStyleSheet({
container: {
flex: 1
},
form: {
backgroundColor: ColorKeys.primary,
paddingBottom: SpaceKeys.medium,
borderRadius: RadiusKeys.small,
alignContent: 'center'
},
formContainer: { width: '100%', padding: SpaceKeys.medium }
})
Using it as usually
import { styles } from './styles'
export class MyForm extends React.Component {
render() {
const { children } = this.props
return <View style={styles.form}>{children}</View>
}
}
To make it work, you need to call this function in the very beginning of your app.
buildStyleSheet(light)
And you may call this function again to change theme.
MIT
FAQs
Theme and stylesheet manager for ReactNative.
We found that @dokuhero/react-native-theme 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.