1.0.0 • Published 9 years ago
fela-react-prop v1.0.0
fela-react-prop
fela helper that accepts a style rule and a property. it returns a function that accepts a component, that gets the generated style classnames applied as a property.
Installation
yarn add fela-react-propUsage
import React from 'react'
import { addPropertyStyles } from 'fela-react-prop'
// apply the style classes generated for a style rule to the "propName"
// property of the wrapped component (WrappedComponent).
const StyledLink = addPropertyStyles('propName', props => ({
display: 'block',
}), WrappedComponent)Use Cases
react-router Link
Set default and active styles of Link component from react-router.
import { NavLink } from 'react-router-dom'
import { addPropertyStyles } from 'fela-react-prop'
// apply the style classes generated for a style rule to the "activeClassName"
// property of the wrapped component (NavLink).
const StyledLink = addPropertyStyles('activeClassName', () => ({
color: '#bada55',
}), NavLink)`react-sticky Sticky
Set default and sticky styles of Sticky component from react-sticky.
import { Sticky } from 'react-sticky'
import { addPropertyStyles } from 'fela-react-prop'
// apply the style classes generated for a style rule to the "stickyClassName"
// property of the wrapped component (Sticky).
const StyledLink = addPropertyStyles('stickyClassName', () => ({
marginTop: '16px',
}), Sticky)`1.0.0
9 years ago