Skip to content

Commit e9ab272

Browse files
committed
apply all args to resolveTheme #2
1 parent ba54036 commit e9ab272

16 files changed

+150
-44
lines changed

packages/ui/src/components/Accordion/Accordion.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const AccordionComponent: FC<AccordionProps> = ({
6767
const provider = useThemeProvider();
6868
const theme = resolveTheme(
6969
[accordionTheme.root, provider.theme?.accordion?.root, customTheme],
70-
[get(provider.resetTheme, "accordion.root"), get(resetTheme, "root")],
71-
[get(provider.applyTheme, "accordion.root"), get(applyTheme, "root")],
70+
[get(provider.resetTheme, "accordion.root"), resetTheme],
71+
[get(provider.applyTheme, "accordion.root"), applyTheme],
7272
);
7373

7474
return (

packages/ui/src/components/Accordion/AccordionContent.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import type { ComponentProps, FC } from "react";
4+
import { get } from "../../helpers/get";
45
import { resolveTheme } from "../../helpers/resolve-theme";
56
import { twMerge } from "../../helpers/tailwind-merge";
67
import { useThemeProvider } from "../../theme/provider";
@@ -27,8 +28,8 @@ export const AccordionContent: FC<AccordionContentProps> = ({
2728
const provider = useThemeProvider();
2829
const theme = resolveTheme(
2930
[accordionTheme.content, provider.theme?.accordion?.content, customTheme],
30-
[get(provider.resetTheme, "carousel"), resetTheme],
31-
[get(provider.applyTheme, "carousel"), applyTheme],
31+
[get(provider.resetTheme, "accordion.content"), resetTheme],
32+
[get(provider.applyTheme, "accordion.content"), applyTheme],
3233
);
3334

3435
return (

packages/ui/src/components/Accordion/AccordionTitle.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import type { ComponentProps, FC } from "react";
4+
import { get } from "../../helpers/get";
45
import { resolveTheme } from "../../helpers/resolve-theme";
56
import { twMerge } from "../../helpers/tailwind-merge";
67
import { useThemeProvider } from "../../theme/provider";
@@ -40,8 +41,8 @@ export const AccordionTitle: FC<AccordionTitleProps> = ({
4041
const provider = useThemeProvider();
4142
const theme = resolveTheme(
4243
[accordionTheme.title, provider.theme?.accordion?.title, customTheme],
43-
[get(provider.resetTheme, "carousel"), resetTheme],
44-
[get(provider.applyTheme, "carousel"), applyTheme],
44+
[get(provider.resetTheme, "accordion.title"), resetTheme],
45+
[get(provider.applyTheme, "accordion.title"), applyTheme],
4546
);
4647

4748
return (

packages/ui/src/components/Button/ButtonGroup.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type { ComponentProps, FC, ReactElement, ReactNode } from "react";
44
import { Children, cloneElement, isValidElement, useMemo } from "react";
5+
import { get } from "../../helpers/get";
56
import { resolveTheme } from "../../helpers/resolve-theme";
67
import { twMerge } from "../../helpers/tailwind-merge";
78
import { useThemeProvider } from "../../theme/provider";
@@ -71,8 +72,8 @@ export const ButtonGroup: FC<ButtonGroupProps> = ({
7172
const provider = useThemeProvider();
7273
const theme = resolveTheme(
7374
[buttonGroupTheme, provider.theme?.buttonGroup, customTheme],
74-
[get(provider.resetTheme, "carousel"), resetTheme],
75-
[get(provider.applyTheme, "carousel"), applyTheme],
75+
[get(provider.resetTheme, "buttonGroup"), resetTheme],
76+
[get(provider.applyTheme, "buttonGroup"), applyTheme],
7677
);
7778

7879
const items = useMemo(() => processChildren(children, outline, pill), [children, outline, pill]);

packages/ui/src/components/Table/TableCell.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@ export interface TableCellTheme {
1717
export interface TableCellProps extends ComponentPropsWithRef<"td">, ThemingProps<TableCellTheme> {}
1818

1919
export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
20-
({ children, className, theme: customTheme, resetTheme, ...props }, ref) => {
21-
const { theme: rootTheme, resetTheme: rootResetTheme } = useTableContext();
22-
const { theme: bodyTheme, resetTheme: bodyResetTheme } = useTableBodyContext();
20+
({ children, className, theme: customTheme, resetTheme, applyTheme, ...props }, ref) => {
21+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme } = useTableContext();
22+
const { theme: bodyTheme, resetTheme: bodyResetTheme, applyTheme: bodyApplyTheme } = useTableBodyContext();
2323

2424
const provider = useThemeProvider();
2525
const theme = resolveTheme(
2626
[tableTheme.body.cell, provider.theme?.table?.body?.cell, rootTheme?.body?.cell, bodyTheme?.cell, customTheme],
27-
[get(rootResetTheme, "body.cell"), get(bodyResetTheme, "cell"), resetTheme],
27+
[
28+
get(provider.resetTheme, "table.body.cell"),
29+
get(rootResetTheme, "body.cell"),
30+
get(bodyResetTheme, "cell"),
31+
resetTheme,
32+
],
33+
[
34+
get(provider.applyTheme, "table.body.cell"),
35+
get(rootApplyTheme, "body.cell"),
36+
get(bodyApplyTheme, "cell"),
37+
applyTheme,
38+
],
2839
);
2940

3041
return (

packages/ui/src/components/Table/TableHeadCell.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@ export interface TableHeadCellTheme {
1717
export interface TableHeadCellProps extends ComponentPropsWithRef<"th">, ThemingProps<TableHeadCellTheme> {}
1818

1919
export const TableHeadCell = forwardRef<HTMLTableCellElement, TableHeadCellProps>(
20-
({ children, className, theme: customTheme, resetTheme, ...props }, ref) => {
21-
const { theme: rootTheme, resetTheme: rootResetTheme } = useTableContext();
22-
const { theme: headTheme, resetTheme: headResetTheme } = useTableHeadContext();
20+
({ children, className, theme: customTheme, resetTheme, applyTheme, ...props }, ref) => {
21+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme } = useTableContext();
22+
const { theme: headTheme, resetTheme: headResetTheme, applyTheme: headApplyTheme } = useTableHeadContext();
2323

2424
const provider = useThemeProvider();
2525
const theme = resolveTheme(
2626
[tableTheme.head.cell, provider.theme?.table?.head?.cell, rootTheme?.head?.cell, headTheme?.cell, customTheme],
27-
[get(rootResetTheme, "head.cell"), get(headResetTheme, "cell"), resetTheme],
27+
[
28+
get(provider.resetTheme, "table.head.cell"),
29+
get(rootResetTheme, "head.cell"),
30+
get(headResetTheme, "cell"),
31+
resetTheme,
32+
],
33+
[
34+
get(provider.applyTheme, "table.head.cell"),
35+
get(rootApplyTheme, "head.cell"),
36+
get(headApplyTheme, "cell"),
37+
applyTheme,
38+
],
2839
);
2940

3041
return (

packages/ui/src/components/Table/TableRow.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ export interface TableRowTheme {
1818
export interface TableRowProps extends ComponentPropsWithRef<"tr">, ThemingProps<TableRowTheme> {}
1919

2020
export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
21-
({ children, className, theme: customTheme, resetTheme, ...props }, ref) => {
22-
const { theme: rootTheme, resetTheme: rootResetTheme, hoverable, striped } = useTableContext();
21+
({ children, className, theme: customTheme, resetTheme, applyTheme, ...props }, ref) => {
22+
const {
23+
theme: rootTheme,
24+
resetTheme: rootResetTheme,
25+
applyTheme: rootApplyTheme,
26+
hoverable,
27+
striped,
28+
} = useTableContext();
2329

2430
const provider = useThemeProvider();
2531
const theme = resolveTheme(
2632
[tableTheme.row, provider.theme?.table?.row, rootTheme?.row, customTheme],
27-
[get(rootResetTheme, "row"), resetTheme],
33+
[get(provider.resetTheme, "table.row"), get(rootResetTheme, "row"), resetTheme],
34+
[get(provider.applyTheme, "table.row"), get(rootApplyTheme, "row"), applyTheme],
2835
);
2936

3037
return (

packages/ui/src/components/Timeline/Timeline.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import type { ComponentProps, FC } from "react";
4+
import { get } from "../../helpers/get";
45
import { resolveTheme } from "../../helpers/resolve-theme";
56
import { twMerge } from "../../helpers/tailwind-merge";
67
import { useThemeProvider } from "../../theme/provider";
@@ -34,13 +35,18 @@ const TimelineComponent: FC<TimelineProps> = ({
3435
horizontal,
3536
theme: customTheme,
3637
resetTheme,
38+
applyTheme,
3739
...props
3840
}) => {
3941
const provider = useThemeProvider();
40-
const theme = resolveTheme([timelineTheme, provider.theme?.timeline, customTheme], [resetTheme]);
42+
const theme = resolveTheme(
43+
[timelineTheme, provider.theme?.timeline, customTheme],
44+
[get(provider.resetTheme, "timeline"), resetTheme],
45+
[get(provider.applyTheme, "timeline"), applyTheme],
46+
);
4147

4248
return (
43-
<TimelineContext.Provider value={{ theme: customTheme, resetTheme, horizontal }}>
49+
<TimelineContext.Provider value={{ theme: customTheme, resetTheme, applyTheme, horizontal }}>
4450
<ol
4551
data-testid="timeline-component"
4652
className={twMerge(

packages/ui/src/components/Timeline/TimelineBody.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ export const TimelineBody: FC<TimelineBodyProps> = ({
2222
className,
2323
theme: customTheme,
2424
resetTheme,
25+
applyTheme,
2526
...props
2627
}) => {
27-
const { theme: rootTheme, resetTheme: rootResetTheme } = useTimelineContext();
28-
const { theme: itemTheme, resetTheme: itemResetTheme } = useTimelineItemContext();
29-
const { theme: contentTheme, resetTheme: contentResetTheme } = useTimelineContentContext();
28+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme } = useTimelineContext();
29+
const { theme: itemTheme, resetTheme: itemResetTheme, applyTheme: itemApplyTheme } = useTimelineItemContext();
30+
const {
31+
theme: contentTheme,
32+
resetTheme: contentResetTheme,
33+
applyTheme: contentApplyTheme,
34+
} = useTimelineContentContext();
3035

3136
const provider = useThemeProvider();
3237
const theme = resolveTheme(
@@ -39,11 +44,19 @@ export const TimelineBody: FC<TimelineBodyProps> = ({
3944
customTheme,
4045
],
4146
[
47+
get(provider.resetTheme, "timeline.item.content.body"),
4248
get(rootResetTheme, "item.content.body"),
4349
get(itemResetTheme, "content.body"),
4450
get(contentResetTheme, "body"),
4551
resetTheme,
4652
],
53+
[
54+
get(provider.applyTheme, "timeline.item.content.body"),
55+
get(rootApplyTheme, "item.content.body"),
56+
get(itemApplyTheme, "content.body"),
57+
get(contentApplyTheme, "body"),
58+
applyTheme,
59+
],
4760
);
4861

4962
return (

packages/ui/src/components/Timeline/TimelineContent.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ export const TimelineContent: FC<TimelineContentProps> = ({
3232
className,
3333
theme: customTheme,
3434
resetTheme,
35+
applyTheme,
3536
...props
3637
}) => {
37-
const { theme: rootTheme, resetTheme: rootResetTheme, horizontal } = useTimelineContext();
38-
const { theme: itemTheme, resetTheme: itemResetTheme } = useTimelineItemContext();
38+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme, horizontal } = useTimelineContext();
39+
const { theme: itemTheme, resetTheme: itemResetTheme, applyTheme: itemApplyTheme } = useTimelineItemContext();
3940

4041
const provider = useThemeProvider();
4142
const theme = resolveTheme(
@@ -46,11 +47,22 @@ export const TimelineContent: FC<TimelineContentProps> = ({
4647
itemTheme?.content,
4748
customTheme,
4849
],
49-
[get(rootResetTheme, "item.content"), get(itemResetTheme, "content"), resetTheme],
50+
[
51+
get(provider.resetTheme, "timeline.item.content"),
52+
get(rootResetTheme, "item.content"),
53+
get(itemResetTheme, "content"),
54+
resetTheme,
55+
],
56+
[
57+
get(provider.applyTheme, "timeline.item.content"),
58+
get(rootApplyTheme, "item.content"),
59+
get(itemApplyTheme, "content"),
60+
applyTheme,
61+
],
5062
);
5163

5264
return (
53-
<TimelineContentContext.Provider value={{ theme: customTheme, resetTheme }}>
65+
<TimelineContentContext.Provider value={{ theme: customTheme, resetTheme, applyTheme }}>
5466
<div
5567
data-testid="timeline-content"
5668
className={twMerge(theme.root.base, horizontal ? theme.root.horizontal : theme.root.vertical, className)}

packages/ui/src/components/Timeline/TimelineItem.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ export const TimelineItem: FC<TimelineItemProps> = ({
2828
className,
2929
theme: customTheme,
3030
resetTheme,
31+
applyTheme,
3132
...props
3233
}) => {
33-
const { theme: rootTheme, resetTheme: rootResetTheme, horizontal } = useTimelineContext();
34+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme, horizontal } = useTimelineContext();
3435

3536
const provider = useThemeProvider();
3637
const theme = resolveTheme(
3738
[timelineTheme.item, provider.theme?.timeline?.item, rootTheme?.item, customTheme],
38-
[get(rootResetTheme, "item"), resetTheme],
39+
[get(provider.resetTheme, "timeline.item"), get(rootResetTheme, "item"), resetTheme],
40+
[get(provider.applyTheme, "timeline.item"), get(rootApplyTheme, "item"), applyTheme],
3941
);
4042

4143
return (
42-
<TimelineItemContext.Provider value={{ theme: customTheme, resetTheme }}>
44+
<TimelineItemContext.Provider value={{ theme: customTheme, resetTheme, applyTheme }}>
4345
<li
4446
data-testid="timeline-item"
4547
className={twMerge(horizontal && theme.root.horizontal, !horizontal && theme.root.vertical, className)}

packages/ui/src/components/Timeline/TimelinePoint.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ export const TimelinePoint: FC<TimelnePointProps> = ({
3636
icon: Icon,
3737
theme: customTheme,
3838
resetTheme,
39+
applyTheme,
3940
...props
4041
}) => {
41-
const { theme: rootTheme, resetTheme: rootResetTheme, horizontal } = useTimelineContext();
42-
const { theme: itemTheme, resetTheme: itemResetTheme } = useTimelineItemContext();
42+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme, horizontal } = useTimelineContext();
43+
const { theme: itemTheme, resetTheme: itemResetTheme, applyTheme: itemApplyTheme } = useTimelineItemContext();
4344

4445
const provider = useThemeProvider();
4546
const theme = resolveTheme(
@@ -50,7 +51,18 @@ export const TimelinePoint: FC<TimelnePointProps> = ({
5051
itemTheme?.point,
5152
customTheme,
5253
],
53-
[get(rootResetTheme, "item.point"), get(itemResetTheme, "point"), resetTheme],
54+
[
55+
get(provider.resetTheme, "timeline.item.point"),
56+
get(rootResetTheme, "item.point"),
57+
get(itemResetTheme, "point"),
58+
resetTheme,
59+
],
60+
[
61+
get(provider.applyTheme, "timeline.item.point"),
62+
get(rootApplyTheme, "item.point"),
63+
get(itemApplyTheme, "point"),
64+
applyTheme,
65+
],
5466
);
5567

5668
return (

packages/ui/src/components/Timeline/TimelineTime.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ export const TimelineTime: FC<TimelineTimeProps> = ({
2222
className,
2323
theme: customTheme,
2424
resetTheme,
25+
applyTheme,
2526
...props
2627
}) => {
27-
const { theme: rootTheme, resetTheme: rootResetTheme } = useTimelineContext();
28-
const { theme: itemTheme, resetTheme: itemResetTheme } = useTimelineItemContext();
29-
const { theme: contentTheme, resetTheme: contentResetTheme } = useTimelineContentContext();
28+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme } = useTimelineContext();
29+
const { theme: itemTheme, resetTheme: itemResetTheme, applyTheme: itemApplyTheme } = useTimelineItemContext();
30+
const {
31+
theme: contentTheme,
32+
resetTheme: contentResetTheme,
33+
applyTheme: contentApplyTheme,
34+
} = useTimelineContentContext();
3035

3136
const provider = useThemeProvider();
3237
const theme = resolveTheme(
@@ -39,11 +44,19 @@ export const TimelineTime: FC<TimelineTimeProps> = ({
3944
customTheme,
4045
],
4146
[
47+
get(provider.resetTheme, "timeline.item.content.time"),
4248
get(rootResetTheme, "item.content.time"),
4349
get(itemResetTheme, "content.time"),
4450
get(contentResetTheme, "time"),
4551
resetTheme,
4652
],
53+
[
54+
get(provider.applyTheme, "timeline.item.content.time"),
55+
get(rootApplyTheme, "item.content.time"),
56+
get(itemApplyTheme, "content.time"),
57+
get(contentApplyTheme, "time"),
58+
applyTheme,
59+
],
4760
);
4861

4962
return (

packages/ui/src/components/Timeline/TimelineTitle.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ export const TimelineTitle: FC<TimelineTitleProps> = ({
2626
className,
2727
theme: customTheme,
2828
resetTheme,
29+
applyTheme,
2930
...props
3031
}) => {
31-
const { theme: rootTheme, resetTheme: rootResetTheme } = useTimelineContext();
32-
const { theme: itemTheme, resetTheme: itemResetTheme } = useTimelineItemContext();
33-
const { theme: contentTheme, resetTheme: contentResetTheme } = useTimelineContentContext();
32+
const { theme: rootTheme, resetTheme: rootResetTheme, applyTheme: rootApplyTheme } = useTimelineContext();
33+
const { theme: itemTheme, resetTheme: itemResetTheme, applyTheme: itemApplyTheme } = useTimelineItemContext();
34+
const {
35+
theme: contentTheme,
36+
resetTheme: contentResetTheme,
37+
applyTheme: contentApplyTheme,
38+
} = useTimelineContentContext();
3439

3540
const provider = useThemeProvider();
3641
const theme = resolveTheme(
@@ -43,11 +48,19 @@ export const TimelineTitle: FC<TimelineTitleProps> = ({
4348
customTheme,
4449
],
4550
[
51+
get(provider.resetTheme, "timeline.item.content.title"),
4652
get(rootResetTheme, "item.content.title"),
4753
get(itemResetTheme, "content.title"),
4854
get(contentResetTheme, "title"),
4955
resetTheme,
5056
],
57+
[
58+
get(provider.applyTheme, "timeline.item.content.title"),
59+
get(rootApplyTheme, "item.content.title"),
60+
get(itemApplyTheme, "content.title"),
61+
get(contentApplyTheme, "title"),
62+
applyTheme,
63+
],
5164
);
5265

5366
return (

0 commit comments

Comments
 (0)