1
0
Fork 0
mirror of synced 2024-08-22 05:21:20 +12:00
budibase/packages/builder/src/helpers/helpers.js

27 lines
698 B
JavaScript
Raw Normal View History

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