1
0
Fork 0
mirror of synced 2024-09-18 02:08:34 +12:00
budibase/packages/builder/src/helpers.js
Keviin Åberg Kultalahti 4ec2e7d01f lint:fix
2021-05-03 09:31:09 +02:00

25 lines
632 B
JavaScript

import { last, flow } from "lodash/fp"
export const buildStyle = (styles) => {
let str = ""
for (let s in styles) {
if (styles[s]) {
let key = convertCamel(s)
str += `${key}: ${styles[s]}; `
}
}
return str
}
export const convertCamel = (str) => {
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)
}
export const pipe = (arg, funcs) => flow(funcs)(arg)
export const capitalise = (s) =>
s.substring(0, 1).toUpperCase() + s.substring(1)
export const get_name = (s) => (!s ? "" : last(s.split("/")))
export const get_capitalised_name = (name) => pipe(name, [get_name, capitalise])