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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 15 additions & 4 deletions
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

Lines changed: 15 additions & 4 deletions
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

Lines changed: 10 additions & 3 deletions
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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 16 additions & 3 deletions
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

Lines changed: 16 additions & 4 deletions
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)}

0 commit comments

Comments
 (0)