Skip to content

Commit

Permalink
fix: code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
apurv-wednesday committed Apr 26, 2024
1 parent 2958741 commit 2a52566
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/themes/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ const borderRadiusTop = (topRadius = 0) => css`
border-top-right-radius: ${topRadius}px;
`;

const borderRadius = radius =>
css`
border-radius: ${radius + `${typeof radius === `string` ? `;` : `px`}`};
const borderRadius = (radius: string | number) => {
const unit = typeof radius === 'string' ? '' : 'px';
return css`
border-radius: ${radius}${unit};
`;
};

const borderWithRadius = (width = 1, type = "solid", color = "#ccc", radius = 0) =>
css`
Expand Down
25 changes: 14 additions & 11 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import pickBy from "lodash-es/pickBy";
import camelCase from "lodash-es/camelCase";

export const mapKeysDeep = (obj, fn) =>
Array.isArray(obj)
? obj.map(val => mapKeysDeep(val, fn))
: typeof obj === "object"
? Object.keys(obj).reduce((acc, current) => {
const key = fn(current);
const val = obj[current];
acc[key] = val !== null && typeof val === "object" ? mapKeysDeep(val, fn) : val;
return acc;
}, {})
: obj;
export const mapKeysDeep = (obj, fn) => {
if (Array.isArray(obj)) {
return obj.map(val => mapKeysDeep(val, fn));
} else if (typeof obj === "object") {
return Object.keys(obj).reduce((acc, current) => {
const key = fn(current);
const val = obj[current];
acc[key] = val !== null && typeof val === "object" ? mapKeysDeep(val, fn) : val;
return acc;
}, {});
} else {
return obj;
}
};

export const isLocal = () => {
try {
Expand Down

0 comments on commit 2a52566

Please sign in to comment.