2020-10-27 10:10:20 +01:00
|
|
|
import { last, flow } from "lodash/fp"
|
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
export const buildStyle = styles => {
|
2020-05-29 11:45:19 +02:00
|
|
|
let str = ""
|
|
|
|
for (let s in styles) {
|
|
|
|
if (styles[s]) {
|
2020-05-30 19:48:20 +02:00
|
|
|
let key = convertCamel(s)
|
|
|
|
str += `${key}: ${styles[s]}; `
|
2020-05-29 11:45:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
export const convertCamel = str => {
|
|
|
|
return str.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)
|
2020-05-29 11:45:19 +02:00
|
|
|
}
|
2020-06-04 19:08:50 +02:00
|
|
|
|
2020-10-27 10:10:20 +01:00
|
|
|
export const pipe = (arg, funcs) => flow(funcs)(arg)
|
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
2020-06-04 19:08:50 +02:00
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
export const get_name = s => (!s ? "" : last(s.split("/")))
|
2020-06-04 19:08:50 +02:00
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
export const get_capitalised_name = name => pipe(name, [get_name, capitalise])
|