Skip to content

Commit

Permalink
fix(ui-private): remove premature optimization and dependencies (#390)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
	- Removed unused dependencies to streamline the project.
- **Refactor**
- Simplified utility functions for better performance and
maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
aversini authored Mar 10, 2024
1 parent 6f40fbd commit 55e9818
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
6 changes: 1 addition & 5 deletions packages/ui-private/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@
},
"dependencies": {
"@floating-ui/react": "0.26.9",
"@tailwindcss/typography": "0.5.10",
"@versini/ui-hooks": "workspace:../ui-hooks",
"clsx": "2.1.0",
"fast-equals": "5.0.1",
"micro-memoize": "4.1.2",
"tailwindcss": "3.4.1"
"clsx": "2.1.0"
},
"sideEffects": [
"**/*.css"
Expand Down
24 changes: 2 additions & 22 deletions packages/ui-private/src/common/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import { deepEqual } from "fast-equals";
import memoize from "micro-memoize";

// import type { SpacingType } from ".";

// export type SpacingProps = {
// spacing?: SpacingType;
// };

export type SpacingType =
| undefined
| string
Expand All @@ -31,17 +22,6 @@ export type SpacingProps = {
spacing?: SpacingType;
};

/**
* Memoize function calls with arguments that are
* complex objects (hence "deep"). Do not use for
* standard types.
* @param {Function} fct - the function to optimize.
* @returns the optimized function.
*/
export function memoizeDeep(fct: any) {
return memoize(fct, { isEqual: deepEqual });
}

/**
* This method returns a string that can be used as a tailwind class relying
* on margins definitions (m, mt, mb, etc.).
Expand All @@ -54,7 +34,7 @@ export function memoizeDeep(fct: any) {
* { t: 4, r: 1, b: 3, l: 5} => "mt-4 mr-1 mb-3 ml-5"
*
*/
export const getSpacing = memoizeDeep((spacing: SpacingType): string => {
export const getSpacing = (spacing: SpacingType): string => {
let spacingClass = "";
/**
* In this case, spacing is a number or a string. For example:
Expand Down Expand Up @@ -89,4 +69,4 @@ export const getSpacing = memoizeDeep((spacing: SpacingType): string => {
}

return spacingClass;
});
};
12 changes: 0 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55e9818

Please sign in to comment.