Skip to content

Commit f28cc65

Browse files
Merge pull request #322 from adaptui/refactoring
2 parents cbf9d91 + c3b30be commit f28cc65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+757
-585
lines changed

.storybook/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const NEXT_JS_CODESANDBOX: CodeSandboxTemplate = (
150150
"README.md":
151151
"# next-tailwind-jit\n\n[View on Vercel](https://next-tailwind-jit.vercel.app/)\n\n[Edit on StackBlitz ⚡️](https://stackblitz.com/edit/next-tailwind-jit-evzkdg)\n",
152152
"adaptui.config.js":
153-
'import { extendTheme } from "@adaptui/react-tailwind";\n\nexport const theme = extendTheme({\n // This only affected the Storybook, doesn\'t go or merge when used this config as preset\n extend: {\n button: {\n variant: {\n default: {\n tertiary: "bg-purple-600 text-white",\n },\n },\n size: {\n default: {\n xxl: "h-14 min-w-14 px-6 rounded-xl text-xl",\n },\n },\n },\n },\n});\n\nexport default theme;\n',
153+
'import { extendTheme } from "@adaptui/react-tailwind";\n\nexport const theme = extendTheme({\n // This only affected the Storybook, doesn\'t go or merge when used this config as preset\n extend: {\n button: {\n variant: {\n default: {\n tertiary: "bg-purple-600 text-white-900",\n },\n },\n size: {\n default: {\n xxl: "h-14 min-w-14 px-6 rounded-xl text-xl",\n },\n },\n },\n },\n});\n\nexport default theme;\n',
154154
"tailwind.config.js":
155155
'module.exports = {\n presets: [require("@adaptui/react-tailwind/preset")],\n content: [\n "./components/**/*",\n "./pages/**/*",\n "./adaptui.config.ts",\n "node_modules/@adaptui/react-tailwind/**/*",\n ],\n theme: {},\n variants: {},\n plugins: [],\n};\n',
156156
...files,
@@ -207,7 +207,7 @@ const NEXT_TS_CODESANDBOX: CodeSandboxTemplate = (
207207
"README.md":
208208
"# next-tailwind-jit-ts\n\n[View on Vercel](https://next-tailwind-jit-ts.vercel.app/)\n\n[Edit on StackBlitz ⚡️](https://stackblitz.com/edit/github-jntzof)\n",
209209
"adaptui.config.js":
210-
'import { extendTheme } from "@adaptui/react-tailwind";\n\nexport const theme = extendTheme({\n // This only affected the Storybook, doesn\'t go or merge when used this config as preset\n extend: {\n button: {\n variant: {\n default: {\n tertiary: "bg-purple-600 text-white",\n },\n },\n size: {\n default: {\n xxl: "h-14 min-w-14 px-6 rounded-xl text-xl",\n },\n },\n },\n },\n});\n\nexport default theme;\n',
210+
'import { extendTheme } from "@adaptui/react-tailwind";\n\nexport const theme = extendTheme({\n // This only affected the Storybook, doesn\'t go or merge when used this config as preset\n extend: {\n button: {\n variant: {\n default: {\n tertiary: "bg-purple-600 text-white-900",\n },\n },\n size: {\n default: {\n xxl: "h-14 min-w-14 px-6 rounded-xl text-xl",\n },\n },\n },\n },\n});\n\nexport default theme;\n',
211211
"tailwind.config.js":
212212
'module.exports = {\n presets: [require("@adaptui/react-tailwind/preset")],\n content: [\n "./components/**/*",\n "./pages/**/*",\n "./adaptui.config.ts",\n "node_modules/@adaptui/react-tailwind/**/*",\n ],\n theme: {},\n variants: {},\n plugins: [],\n};\n',
213213
"tsconfig.json":

adaptui.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const theme = extendTheme({
66
button: {
77
themeColor: {
88
base: {
9-
tertiary: { default: "bg-purple-600 text-white" },
9+
tertiary: { default: "bg-purple-600 text-white-900" },
1010
},
1111
},
1212
size: {

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
"dependencies": {
9999
"@adaptui/react": "^1.0.0-alpha.7",
100100
"@react-aria/live-announcer": "^3.1.0",
101-
"ariakit": "2.0.0-next.30",
102-
"ariakit-utils": "0.17.0-next.21",
101+
"ariakit": "2.0.0-next.31",
102+
"ariakit-utils": "0.17.0-next.22",
103103
"tailwind-merge": "^1.3.0"
104104
},
105105
"devDependencies": {
@@ -111,8 +111,8 @@
111111
"@babel/preset-env": "7.18.2",
112112
"@babel/preset-react": "7.17.12",
113113
"@babel/preset-typescript": "7.17.12",
114-
"@commitlint/cli": "17.0.2",
115-
"@commitlint/config-conventional": "17.0.2",
114+
"@commitlint/cli": "17.0.3",
115+
"@commitlint/config-conventional": "17.0.3",
116116
"@release-it/conventional-changelog": "5.0.0",
117117
"@size-limit/preset-big-lib": "5.0.5",
118118
"@storybook/addon-a11y": "6.5.9",
@@ -123,19 +123,19 @@
123123
"@storybook/manager-webpack5": "6.5.9",
124124
"@storybook/react": "6.5.9",
125125
"@swc/cli": "0.1.57",
126-
"@swc/core": "1.2.204",
126+
"@swc/core": "1.2.205",
127127
"@tailwindcss/forms": "0.5.2",
128128
"@testing-library/dom": "8.14.0",
129129
"@testing-library/jest-dom": "5.16.4",
130130
"@testing-library/react": "13.3.0",
131131
"@testing-library/react-hooks": "8.0.1",
132132
"@testing-library/user-event": "14.2.1",
133-
"@types/jest": "28.1.2",
133+
"@types/jest": "28.1.3",
134134
"@types/jest-axe": "3.5.4",
135135
"@types/node": "18.0.0",
136136
"@types/react": "18.0.14",
137137
"@types/react-dom": "18.0.5",
138-
"@types/testing-library__jest-dom": "5.14.4",
138+
"@types/testing-library__jest-dom": "5.14.5",
139139
"all-contributors-cli": "6.20.0",
140140
"autoprefixer": "10.4.7",
141141
"axe-core": "4.4.2",
@@ -151,15 +151,15 @@
151151
"eslint-config-react-app": "7.0.1",
152152
"eslint-plugin-prettier": "4.0.0",
153153
"eslint-plugin-simple-import-sort": "7.0.0",
154-
"eslint-plugin-storybook": "0.5.12",
154+
"eslint-plugin-storybook": "0.5.13",
155155
"focus-visible": "5.2.0",
156156
"gacp": "3.0.2",
157157
"glob-fs": "0.1.7",
158158
"husky": "8.0.1",
159159
"jest": "28.1.1",
160160
"jest-axe": "6.0.0",
161161
"jest-environment-jsdom": "28.1.1",
162-
"lint-staged": "13.0.2",
162+
"lint-staged": "13.0.3",
163163
"node-fetch": "2.6.7",
164164
"outdent": "0.8.0",
165165
"patch-package": "6.4.7",
@@ -172,14 +172,14 @@
172172
"prettier-plugin-tailwindcss": "0.1.11",
173173
"react": "18.2.0",
174174
"react-dom": "18.2.0",
175-
"react-hook-form": "7.32.2",
175+
"react-hook-form": "7.33.0",
176176
"react-icons": "4.4.0",
177-
"release-it": "15.0.0",
177+
"release-it": "15.1.0",
178178
"rimraf": "3.0.2",
179179
"size-limit": "5.0.5",
180180
"sort-package-json": "1.57.0",
181181
"storybook-addon-preview": "2.2.0",
182-
"tailwindcss": "3.1.3",
182+
"tailwindcss": "3.1.4",
183183
"ts-node": "10.8.1",
184184
"tslib": "2.4.0",
185185
"typescript": "4.7.4",

preset.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ module.exports = {
7272
...defaultTheme.spacing,
7373
},
7474
boxShadow: {
75+
DEFAULT:
76+
"0px 1px 3px rgba(0, 0, 0, 0.1), 0px 1px 2px -1px rgba(0, 0, 0, 0.1)",
7577
sm: "0px 1px 2px rgba(0, 0, 0, 0.05)",
7678
csm: "0px 0px 1px rgba(0, 0, 0, 0.4), 0px 1px 2px rgba(0, 0, 0, 0.15)",
7779
lg: "0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -4px rgba(0, 0, 0, 0.1)",

scripts/generateCsb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const getSandboxContents = (files, extraDeps) => {
106106
button: {
107107
variant: {
108108
default: {
109-
tertiary: "bg-purple-600 text-white",
109+
tertiary: "bg-purple-600 text-white-900",
110110
},
111111
},
112112
size: {

src/avatar-group/AvatarGroupWrapper.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ import {
66
} from "ariakit-utils/system";
77
import { As, Props } from "ariakit-utils/types";
88

9-
import { BoxOptions, useBox } from "../box";
9+
import { BoxOptions } from "../box";
1010
import { useTheme } from "../theme";
11-
import { cx } from "../utils";
11+
import { tcm } from "../utils";
1212

1313
import { AvatarGroupUIProps } from "./AvatarGroupProps";
1414

1515
export const useAvatarGroupWrapper = createHook<AvatarGroupWrapperOptions>(
1616
({ size, squared, showRing, ringColor, max, ...props }) => {
1717
const theme = useTheme("avatar");
18-
const className = cx(
18+
const className = tcm(
1919
theme.group.base,
2020
size ? theme.group.size[size] : "",
2121
props.className,
2222
);
2323

2424
props = { "aria-label": "avatar group", ...props, className };
25-
props = useBox(props);
2625
props = useGroup(props);
2726

2827
return props;

src/avatar/AvatarDefaultStatusIndicators.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { runIfFn } from "@chakra-ui/utils";
2-
31
import {
42
ActiveStatusIcon,
53
AwayStatusIcon,
@@ -13,18 +11,19 @@ import { passProps, tcm } from "../utils";
1311

1412
import { AvatarUIProps } from "./AvatarProps";
1513

16-
export const AvatarDefaultStatusIndicators = (props: AvatarUIProps) => {
17-
const { size, status, parentsBackground } = props;
14+
export const AvatarDefaultStatusIndicators: AvatarUIProps["statusIndicators"] =
15+
props => {
16+
const { size, status, parentsBackground } = props;
1817

19-
const theme = useTheme("avatar");
20-
const className = tcm(
21-
theme.statusIndicators[status].base,
22-
theme.statusIndicators[status].size[size],
23-
...parentsBackground,
24-
);
18+
const theme = useTheme("avatar");
19+
const className = tcm(
20+
theme.statusIndicators[status].base,
21+
theme.statusIndicators[status].size[size],
22+
...parentsBackground,
23+
);
2524

26-
return passProps(runIfFn(<StatusIndicators {...props} />), { className });
27-
};
25+
return passProps(<StatusIndicators {...props} />, props, { className });
26+
};
2827

2928
export type StatusIndicatorsProps = AvatarUIProps & {
3029
className?: string;

src/avatar/AvatarProps.tsx

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useMemo } from "react";
22

3-
import { getComponentProps, RenderProp, runIfFn, withIconA11y } from "../utils";
3+
import { getComponentProps, RenderProp, withIconA11y } from "../utils";
44

55
import { AvatarIconProps } from "./AvatarIcon";
66
import { AvatarImageProps } from "./AvatarImage";
@@ -77,41 +77,66 @@ export const useAvatarProps = ({
7777
statusIndicators: _statusIndicators,
7878
};
7979

80-
const wrapperProps: AvatarWrapperProps = {
81-
...uiProps,
82-
...restProps,
83-
...componentProps.wrapperProps,
84-
};
80+
const wrapperProps: AvatarWrapperProps = useMemo(
81+
() => ({
82+
...uiProps,
83+
...restProps,
84+
...componentProps.wrapperProps,
85+
}),
86+
[componentProps.wrapperProps, restProps, uiProps],
87+
);
8588

86-
const iconProps: AvatarIconProps = {
87-
...uiProps,
88-
...componentProps.iconProps,
89-
children: withIconA11y(runIfFn(uiProps.icon, uiProps)),
90-
};
89+
const iconProps: AvatarIconProps = useMemo(
90+
() => ({
91+
...uiProps,
92+
...componentProps.iconProps,
93+
children: withIconA11y(uiProps.icon, uiProps),
94+
}),
95+
[componentProps.iconProps, uiProps],
96+
);
9197

92-
const initialsProps: AvatarInitialsProps = {
93-
...uiProps,
94-
...componentProps.initialsProps,
95-
children: uiProps.initials,
96-
};
98+
const initialsProps: AvatarInitialsProps = useMemo(
99+
() => ({
100+
...uiProps,
101+
...componentProps.initialsProps,
102+
children: uiProps.initials,
103+
}),
104+
[componentProps.initialsProps, uiProps],
105+
);
97106

98-
const imageProps: AvatarImageProps = {
99-
...uiProps,
100-
src,
101-
srcSet,
102-
sizes,
103-
loading,
104-
crossOrigin,
105-
onLoad,
106-
onError,
107-
...componentProps.imageProps,
108-
};
107+
const imageProps: AvatarImageProps = useMemo(
108+
() => ({
109+
...uiProps,
110+
src,
111+
srcSet,
112+
sizes,
113+
loading,
114+
crossOrigin,
115+
onLoad,
116+
onError,
117+
...componentProps.imageProps,
118+
}),
119+
[
120+
componentProps.imageProps,
121+
crossOrigin,
122+
loading,
123+
onError,
124+
onLoad,
125+
sizes,
126+
src,
127+
srcSet,
128+
uiProps,
129+
],
130+
);
109131

110-
const statusIndicatorProps: AvatarStatusIndicatorProps = {
111-
...uiProps,
112-
...componentProps.statusIndicatorProps,
113-
children: withIconA11y(runIfFn(uiProps.statusIndicators, uiProps)),
114-
};
132+
const statusIndicatorProps: AvatarStatusIndicatorProps = useMemo(
133+
() => ({
134+
...uiProps,
135+
...componentProps.statusIndicatorProps,
136+
children: withIconA11y(uiProps.statusIndicators, uiProps),
137+
}),
138+
[componentProps.statusIndicatorProps, uiProps],
139+
);
115140

116141
return {
117142
uiProps,

src/avatar/AvatarUIState.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function useAvatarUIState(props: AvatarUIStateProps): AvatarUIState {
1818
parentsBackground = ["bg-white-900", "ring-white-900"],
1919
getInitialsFromName = getInitialsFromNameDefault,
2020
showRing = false,
21-
ringColor = "ring-white",
21+
ringColor = "ring-white-900",
2222
} = props;
2323

2424
const initials = getInitialsFromName(name, size);
@@ -73,7 +73,7 @@ export type AvatarUIStateProps = UseImageProps &
7373

7474
export type AvatarUIState = {
7575
/**
76-
* If `true`, Avatar looks like a round.
76+
* If `true`, Avatar looks like a squared.
7777
*
7878
* @default true
7979
*/
@@ -127,7 +127,7 @@ export type AvatarUIState = {
127127
/**
128128
* StatusIndicator's Background Color & StatusIndicator Ring Color.
129129
*
130-
* @default ["bg-white", "ring-white"]"
130+
* @default ["bg-white-900", "ring-white-900"]"
131131
*/
132132
parentsBackground: string[];
133133

@@ -143,7 +143,7 @@ export type AvatarUIState = {
143143
/**
144144
* Color of the `border` to match it's parent background.
145145
*
146-
* @default ring-white
146+
* @default ring-white-900
147147
*/
148148
ringColor: string;
149149

src/avatar/stories/AvatarBasic.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const FallbackIcon: Story = {
6868
size: "xl",
6969
src: "https://i.pravatar.c/300??img=61",
7070
icon: <CircledCheckIcon />,
71-
onError: () => console.log("Provide a valid src url"),
71+
onError: () => console.warn("Provide a valid src url"),
7272
},
7373
};
7474

0 commit comments

Comments
 (0)