first commit
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
export function objectWithKey(key, value) {
|
||||
return (Array.isArray(value) && value.length > 0) || (!Array.isArray(value) && value) ? { [key]: value } : {}
|
||||
}
|
||||
|
||||
export function classList(props) {
|
||||
let classes = {
|
||||
'fa-spin': props.spin,
|
||||
'fa-pulse': props.pulse,
|
||||
// the fixedWidth property has been deprecated as of version 7.0.0
|
||||
'fa-fw': props.fixedWidth,
|
||||
'fa-border': props.border,
|
||||
'fa-li': props.listItem,
|
||||
'fa-inverse': props.inverse,
|
||||
'fa-flip': props.flip === true,
|
||||
'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both',
|
||||
'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both',
|
||||
[`fa-${props.size}`]: props.size !== null,
|
||||
[`fa-rotate-${props.rotation}`]: props.rotation !== null,
|
||||
'fa-rotate-by': props.rotateBy,
|
||||
[`fa-pull-${props.pull}`]: props.pull !== null,
|
||||
'fa-swap-opacity': props.swapOpacity,
|
||||
'fa-bounce': props.bounce,
|
||||
'fa-shake': props.shake,
|
||||
'fa-beat': props.beat,
|
||||
'fa-fade': props.fade,
|
||||
'fa-beat-fade': props.beatFade,
|
||||
'fa-flash': props.flash,
|
||||
'fa-spin-pulse': props.spinPulse,
|
||||
'fa-spin-reverse': props.spinReverse,
|
||||
// the widthAuto property is only supported in version 7.0.0 and later
|
||||
'fa-width-auto': props.widthAuto,
|
||||
// the canvasSquare and canvasRoomy properties are only supported in version 7.3.0 and later
|
||||
'fa-canvas-square': props.canvasSquare,
|
||||
'fa-canvas-roomy': props.canvasRoomy,
|
||||
// the following animations are only supported in version 7.3.0 and later
|
||||
'fa-flip-360': props.flip360,
|
||||
'fa-buzz': props.buzz,
|
||||
'fa-float': props.float,
|
||||
'fa-jello': props.jello,
|
||||
'fa-spin-snap': props.spinSnap,
|
||||
'fa-spin-snap-4': props.spinSnap4,
|
||||
'fa-spin-snap-8': props.spinSnap8,
|
||||
'fa-swing': props.swing,
|
||||
'fa-wag': props.wag
|
||||
}
|
||||
|
||||
return Object.keys(classes)
|
||||
.map((key) => (classes[key] ? key : null))
|
||||
.filter((key) => key)
|
||||
}
|
||||
|
||||
export function addStaticClass(to, what) {
|
||||
const val = (to || '').length === 0 ? [] : [to]
|
||||
|
||||
return val.concat(what).join(' ')
|
||||
}
|
||||
Reference in New Issue
Block a user