File size: 1,840 Bytes
1abfaca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | const isPlainObject = require("lodash/isPlainObject")
const defaults = require("lodash/defaults")
const hPile = require("../reaks-layout/hPile")
const label = require("../reaks/label").reaks
const ctxComponent = require("../reaks/ctx-level-helpers/component")
const seq = require("reaks/seq")
const clickable = require("../reaks/clickable").reaksMixin
const style = require("reaks/style")
const innerMargin = require("../reaks-layout/innerMargin")
const align = require("../reaks-layout/align")
const hoverable = require("../reaks/hoverable")
const size = require("reaks/size")
const svgIcon = require("reaks/svgIcon")
const colors = require("material-colors")
module.exports = ctxComponent(
(arg, action) => {
if (!isPlainObject(arg)) {
arg = { label: arg }
}
const {
label: text,
color = colors.black,
icon,
height = 40,
fontSize = 14,
} = arg
return seq([
hoverable.reaksMixin({
over: style({ backgroundColor: "rgba(0,0,0,0.1)" }),
}),
clickable(action),
icon
? hPile([
svgIcon(icon, { size: { h: 24, w: 24 }, color }),
size({ w: 8 }),
label(text),
])
: label(text),
align({ h: "center", v: "center" }),
size({ h: height }),
innerMargin(icon ? { l: 8, r: 16 } : { h: 16 }),
style({
color,
backgroundColor: "rgba(0,0,0,0.03)",
textTransform: "uppercase",
fontSize,
fontWeight: 500,
borderRadius: 2,
}),
])
},
function(arg, action) {
if (!isPlainObject(arg)) {
arg = { label: arg }
}
const { primary = true } = arg
return [
defaults({}, arg, {
color: ctx =>
primary ? ctx.colors.secondary : ctx.colors.fadedDarkText,
}),
action,
]
}
)
|