Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eliminate the lodash.get dependency #964

Merged
merged 3 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tonic-ui-963.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tonic-ui/react": minor
---

feat: eliminate the `lodash.get` dependency
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@tonic-ui/utils": "^2.1.1",
"date-fns": "2.x",
"ensure-type": "^1.5.1",
"lodash.get": "4.x",
"micro-memoize": "4.x",
"react-focus-lock": "2.x",
"react-is": "^16.14.0 || ^17 || ^18",
Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/css-baseline/base-css.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { css } from '@emotion/react';
import _get from 'lodash.get';

const baseCSS = theme => {
const baseFonts = theme?.fonts?.['base'] ?? 'inherit';

Check warning on line 4 in packages/react/src/css-baseline/base-css.js

View workflow job for this annotation

GitHub Actions / build

["base"] is better written in dot notation
const monoFonts = theme?.fonts?.['mono'] ?? 'inherit';

Check warning on line 5 in packages/react/src/css-baseline/base-css.js

View workflow job for this annotation

GitHub Actions / build

["mono"] is better written in dot notation

Check warning on line 5 in packages/react/src/css-baseline/base-css.js

View check run for this annotation

Codecov / codecov/patch

packages/react/src/css-baseline/base-css.js#L4-L5

Added lines #L4 - L5 were not covered by tests

return css`
/**
* Apply a natural box layout model to all elements, but allowing components to change.
Expand All @@ -14,14 +16,14 @@
}

html {
font-family: ${_get(theme, 'fonts.base')};
font-family: ${baseFonts};
}

pre,
code,
kbd,
samp {
font-family: ${_get(theme, 'fonts.mono')};
font-family: ${monoFonts};
}
`;
};
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/drawer/styles.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _get from 'lodash.get';
import { useColorMode } from '../color-mode';
import { useColorStyle } from '../color-style';
import { useIconButtonStyle } from '../shared/styles';
import { useTheme } from '../theme';
import pixelize from '../utils/pixelize';

const defaultPlacement = 'right';
const defaultSize = 'auto';
Expand Down Expand Up @@ -219,7 +219,7 @@
_firstOfType: {
// Sets the margin area on the top if it is the first child
// 4x (padding-top) + xl (line-height) + 3x (padding-bottom)
marginTop: `calc(${_get(sizes, '4x')} + ${_get(lineHeights, 'xl')} + ${_get(sizes, '3x')})`,
marginTop: `calc(${pixelize(sizes['4x'])} + ${pixelize(lineHeights['xl'])} + ${pixelize(sizes['3x'])})`,

Check warning on line 222 in packages/react/src/drawer/styles.js

View workflow job for this annotation

GitHub Actions / build

["xl"] is better written in dot notation
},
};
};
Expand All @@ -240,7 +240,7 @@
_firstOfType: {
// Sets the margin area on the top if it is the first child
// 4x (padding-top) + xl (line-height) + 3x (padding-bottom)
marginTop: `calc(${_get(sizes, '4x')} + ${_get(lineHeights, 'xl')} + ${_get(sizes, '3x')})`,
marginTop: `calc(${pixelize(sizes['4x'])} + ${pixelize(lineHeights['xl'])} + ${pixelize(sizes['3x'])})`,
},
};
};
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/modal/styles.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _get from 'lodash.get';
import { useColorMode } from '../color-mode';
import { useColorStyle } from '../color-style';
import { useIconButtonStyle } from '../shared/styles';
import { useTheme } from '../theme';
import pixelize from '../utils/pixelize';

const defaultSize = 'auto';

Expand Down Expand Up @@ -197,7 +197,7 @@ const useModalBodyStyle = ({
_firstOfType: {
// Sets the margin area on the top if it is the first child
// 4x (padding-top) + xl (line-height) + 3x (padding-bottom)
marginTop: `calc(${_get(sizes, '4x')} + ${_get(lineHeights, 'xl')} + ${_get(sizes, '3x')})`,
marginTop: `calc(${pixelize(sizes['4x'])} + ${pixelize(lineHeights['xl'])} + ${pixelize(sizes['3x'])})`,
},
};
};
Expand All @@ -220,7 +220,7 @@ const useModalFooterStyle = () => {
_firstOfType: {
// Sets the margin area on the top if it is the first child
// 4x (padding-top) + xl (line-height) + 3x (padding-bottom)
marginTop: `calc(${_get(sizes, '4x')} + ${_get(lineHeights, 'xl')} + ${_get(sizes, '3x')})`,
marginTop: `calc(${pixelize(sizes['4x'])} + ${pixelize(lineHeights['xl'])} + ${pixelize(sizes['3x'])})`,
},
};
};
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4727,7 +4727,6 @@ __metadata:
jest-axe: ^8.0.0
jest-environment-jsdom: ^29.0.0
jest-extended: ^4.0.0
lodash.get: 4.x
micro-memoize: 4.x
react: ^16.14.0 || ^17 || ^18
react-dom: ^16.14.0 || ^17 || ^18
Expand Down Expand Up @@ -11626,13 +11625,6 @@ __metadata:
languageName: node
linkType: hard

"lodash.get@npm:4.x":
version: 4.4.2
resolution: "lodash.get@npm:4.4.2"
checksum: e403047ddb03181c9d0e92df9556570e2b67e0f0a930fcbbbd779370972368f5568e914f913e93f3b08f6d492abc71e14d4e9b7a18916c31fa04bd2306efe545
languageName: node
linkType: hard

"lodash.isfunction@npm:^3.0.9":
version: 3.0.9
resolution: "lodash.isfunction@npm:3.0.9"
Expand Down
Loading