@@ -3,20 +3,30 @@ import { H4 } from "@/components/ui/heading-with-anchor";
3
3
import { cn } from "@/lib/utils" ;
4
4
import CodeHighlight from "@/app/(docs)/docs/components/code-card/parts/code-highlight" ;
5
5
import fs from "fs/promises" ;
6
+ import { InlineCode } from "./inline-code" ;
6
7
7
8
interface StepperProps {
8
9
children ?: React . ReactNode ;
9
10
title ?: string ;
10
11
step ?: number ;
11
12
}
13
+
12
14
const Stepper = ( { title, children, step } : StepperProps ) => {
13
15
return (
14
16
< div >
15
17
< div className = "flex items-center gap-3" >
16
- < span className = "flex h-10 w-10 items-center justify-center rounded-full bg-zinc-800 text-white p-3 " >
18
+ < span className = "flex h-10 w-10 items-center justify-center rounded-full bg-zinc-800 text-white p-3" >
17
19
{ step }
18
20
</ span >
19
- < H4 > { title } </ H4 >
21
+ < H4 >
22
+ { title === "Extend tailwind.config.js" ? (
23
+ < span >
24
+ Extend < InlineCode > tailwind.config.js</ InlineCode >
25
+ </ span >
26
+ ) : (
27
+ title
28
+ ) }
29
+ </ H4 >
20
30
</ div >
21
31
< div className = "my-3 ml-5 border-l-2 border-l-gray-200 pl-8" >
22
32
{ children }
@@ -31,28 +41,38 @@ interface SteppersBaseProps {
31
41
withEnd ?: boolean ;
32
42
}
33
43
44
+ interface TailwindConfigStep {
45
+ tailwindConfig ?: boolean ;
46
+ code ?: string ;
47
+ }
48
+
34
49
interface SteppersWithInstallProps extends SteppersBaseProps {
35
50
withInstall ?: true ;
36
- /** 要複製的程式碼 */
37
51
codePath ?: string ;
38
- /** npm install script */
39
52
installScript ?: string ;
53
+ tailwindConfig ?: TailwindConfigStep ;
40
54
}
41
55
42
56
interface SteppersWithoutInstallProps extends SteppersBaseProps {
43
57
withInstall ?: false ;
58
+ tailwindConfig ?: TailwindConfigStep ;
44
59
}
45
60
46
61
type SteppersProps = SteppersWithInstallProps | SteppersWithoutInstallProps ;
47
62
48
63
export const Steppers = async ( props : SteppersProps ) => {
49
- const { steps, className, withEnd, withInstall } = props ;
64
+ const { steps, className, withEnd, withInstall, tailwindConfig } = props ;
50
65
51
66
let installCode = "" ;
52
67
if ( withInstall && props . codePath ) {
53
68
installCode = await fs . readFile ( props . codePath , "utf8" ) ;
54
69
}
55
- const withInstallOffset = withInstall ? ( props . installScript ? 2 : 1 ) : 0 ;
70
+
71
+ // Calculate the offset based on install steps and tailwind config
72
+ const installStepsCount = withInstall ? ( props . installScript ? 2 : 1 ) : 0 ;
73
+ const tailwindStepCount = tailwindConfig ?. tailwindConfig ? 1 : 0 ;
74
+ const totalOffset = installStepsCount + tailwindStepCount ;
75
+
56
76
return (
57
77
< >
58
78
< div className = { cn ( className ) } >
@@ -61,30 +81,44 @@ export const Steppers = async (props: SteppersProps) => {
61
81
{ props . installScript && (
62
82
< Stepper
63
83
title = "Install the package if you do not have it."
64
- step = { withInstallOffset - 1 }
84
+ step = { 1 }
65
85
>
66
86
< CodeHighlight lang = "shell" code = { props . installScript } />
67
87
</ Stepper >
68
88
) }
69
89
< Stepper
70
90
title = "Copy and paste the following code into your project."
71
- step = { withInstallOffset }
91
+ step = { props . installScript ? 2 : 1 }
72
92
>
73
93
< CodeHighlight code = { installCode } withExpand = { false } />
74
94
</ Stepper >
75
95
</ >
76
96
) }
97
+
98
+ { tailwindConfig ?. tailwindConfig && (
99
+ < Stepper
100
+ title = "Extend tailwind.config.js"
101
+ step = { installStepsCount + 1 }
102
+ >
103
+ < CodeHighlight
104
+ code = { tailwindConfig . code || "" }
105
+ withExpand = { false }
106
+ />
107
+ </ Stepper >
108
+ ) }
109
+
77
110
{ steps ?. map ( ( props , index ) => (
78
111
< Stepper
79
112
key = { props . title }
80
113
{ ...props }
81
- step = { index + 1 + withInstallOffset }
114
+ step = { index + 1 + totalOffset }
82
115
/>
83
116
) ) }
117
+
84
118
{ withEnd && (
85
119
< Stepper
86
120
title = "Update the import paths to match your project setup."
87
- step = { ( steps ?. length || 0 ) + 1 + withInstallOffset }
121
+ step = { ( steps ?. length || 0 ) + 1 + totalOffset }
88
122
/>
89
123
) }
90
124
</ div >
0 commit comments