1- import React from "react" ;
2-
3- type Action = "apply-patch" | "write" | "migrate-db" ;
1+ type Action = "apply-patch" | "migrate-db" ;
42
53/*
6-
74This component serves two purposes:
851. It provides metadata for the `tutorial-app-generator` on how to execute tutorial steps programmatically.
9- 2. It renders tutorial steps in a visually distinct way during development so it's easier to debug.
10-
6+ 2. It renders tutorial step names during development for easier debugging.
117*/
128export function TutorialAction ( {
13- children,
149 action,
1510 step,
16- } : React . PropsWithChildren < {
11+ } : {
1712 action : Action ;
1813 step : string ;
19- } > ) {
20- return process . env . NODE_ENV === "production" ? (
21- children
22- ) : action === "write" ? (
23- < div className = "relative mb-4 rounded border border-red-500 p-4" >
24- < div className = "absolute right-1 top-1" >
14+ } ) {
15+ return (
16+ process . env . NODE_ENV !== "production" && (
17+ < div style = { { marginBottom : "1rem" } } >
2518 < TutorialActionStep step = { step } action = { action } />
2619 </ div >
27- { children }
28- </ div >
29- ) : (
30- < div className = "mb-4" >
31- < TutorialActionStep step = { step } action = { action } />
32- </ div >
20+ )
3321 ) ;
3422}
3523
@@ -41,17 +29,47 @@ function TutorialActionStep({
4129 action : Action ;
4230} ) {
4331 return (
44- < div className = "flex gap-2" >
45- < div className = "rounded bg-gray-500 px-2 py-1 text-xs font-bold text-white" >
32+ < div style = { { display : "flex" , gap : "0.5rem" } } >
33+ < div
34+ style = { {
35+ borderRadius : "0.25rem" ,
36+ backgroundColor : "#6b7280" ,
37+ paddingLeft : "0.5rem" ,
38+ paddingRight : "0.5rem" ,
39+ paddingTop : "0.25rem" ,
40+ paddingBottom : "0.25rem" ,
41+ fontSize : "0.75rem" ,
42+ fontWeight : "bold" ,
43+ color : "white" ,
44+ } }
45+ >
4646 tutorial action: { action }
4747 </ div >
4848 < div
49- className = "cursor-pointer rounded bg-red-500 px-2 py-1 text-xs font-bold text-white active:bg-red-600"
50- onClick = { ( ) => {
51- navigator . clipboard . writeText ( step ) ;
49+ style = { {
50+ borderRadius : "0.25rem" ,
51+ backgroundColor : "#ef4444" ,
52+ paddingLeft : "0.5rem" ,
53+ paddingRight : "0.5rem" ,
54+ paddingTop : "0.25rem" ,
55+ paddingBottom : "0.25rem" ,
56+ fontSize : "0.75rem" ,
57+ fontWeight : "bold" ,
58+ color : "white" ,
59+ display : "flex" ,
60+ alignItems : "center" ,
61+ gap : "0.25rem" ,
5262 } }
5363 >
54- { step }
64+ { step } { " " }
65+ < span
66+ style = { { fontSize : "0.6rem" , cursor : "pointer" } }
67+ onClick = { ( ) => {
68+ navigator . clipboard . writeText ( step ) ;
69+ } }
70+ >
71+ [copy]
72+ </ span >
5573 </ div >
5674 </ div >
5775 ) ;
0 commit comments