refactor: minor refactors

This commit is contained in:
Anurag
2021-05-07 00:49:43 +05:30
parent f8b0c8767e
commit fef8bc3a4a
11 changed files with 76 additions and 55 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
const { FlexLayout, encodeHTML } = require("../common/utils");
const { getAnimations } = require("../getStyles");
const { flexLayout, encodeHTML } = require("../common/utils");
class Card {
constructor({
@@ -85,7 +85,7 @@ class Card {
data-testid="card-title"
transform="translate(${this.paddingX}, ${this.paddingY})"
>
${FlexLayout({
${flexLayout({
items: [this.titlePrefixIcon && prefixIcon, titleText],
gap: 25,
}).join("")}
+4 -3
View File
@@ -97,7 +97,7 @@ function request(data, headers) {
* Auto layout utility, allows us to layout things
* vertically or horizontally with proper gaping
*/
function FlexLayout({ items, gap, direction }) {
function flexLayout({ items, gap, direction }) {
// filter() for filtering out empty strings
return items.filter(Boolean).map((item, i) => {
let transform = `translate(${gap * i}, 0)`;
@@ -120,7 +120,8 @@ function getCardColors({
}) {
const defaultTheme = themes[fallbackTheme];
const selectedTheme = themes[theme] || defaultTheme;
const defaultBorderColor = selectedTheme.border_color || defaultTheme.border_color;
const defaultBorderColor =
selectedTheme.border_color || defaultTheme.border_color;
// get the color provided by the user else the theme color
// finally if both colors are invalid fallback to default theme
@@ -239,7 +240,7 @@ module.exports = {
parseArray,
parseBoolean,
fallbackColor,
FlexLayout,
flexLayout,
getCardColors,
clampValue,
wrapTextMultiline,