@@ -25,7 +25,7 @@ export function SignUpForm() {
25
25
}
26
26
27
27
export function HeroActions ( ) {
28
- let [ isExpanded , setIsExpanded ] = useState ( false ) ;
28
+ let [ signUpState , setSignUpState ] = useState < "closed" | "open" | "subscribed" > ( "closed" ) ;
29
29
let input = useRef < HTMLInputElement > ( null ) ;
30
30
let getCourseButton = useRef ( null ) ;
31
31
let containerRef = useRef < HTMLInputElement > ( null ) ;
@@ -35,7 +35,7 @@ export function HeroActions() {
35
35
36
36
// Check if the related target (where focus is going) is within our container
37
37
if ( input . current . value . length === 0 && ! containerRef . current ?. contains ( e . relatedTarget ) ) {
38
- setIsExpanded ( false ) ;
38
+ setSignUpState ( "closed" ) ;
39
39
}
40
40
} ;
41
41
@@ -45,20 +45,22 @@ export function HeroActions() {
45
45
< motion . div
46
46
ref = { containerRef }
47
47
layout
48
- transition = { { duration : isExpanded ? 0.1 : 0.2 , ease : "circOut" } }
49
- className = "relative flex items-center bg-white data-expanded :overflow-hidden"
48
+ transition = { { duration : signUpState === "open" ? 0.1 : 0.2 , ease : "circOut" } }
49
+ className = "relative flex items-center bg-white data-[state=open] :overflow-hidden data-[state=subscribed]:bg-gray-950 "
50
50
style = { { borderRadius : 20 } }
51
- data-expanded = { isExpanded || undefined }
51
+ data-state = { signUpState }
52
52
>
53
53
< AnimatePresence mode = "popLayout" initial = { false } >
54
- { isExpanded ? (
55
- < motion . div
54
+ { signUpState === "open" && (
55
+ < motion . form
56
+ action = "https://app.kit.com/forms/7712177/subscriptions"
57
+ method = "POST"
56
58
className = "flex items-center"
57
59
layout
58
60
onKeyDown = { ( e ) => {
59
61
if ( e . key === "Escape" && input . current ) {
60
62
input . current . value = "" ;
61
- setIsExpanded ( false ) ;
63
+ setSignUpState ( "closed" ) ;
62
64
}
63
65
} }
64
66
exit = { {
@@ -80,22 +82,26 @@ export function HeroActions() {
80
82
ref = { input }
81
83
onBlur = { handleBlur }
82
84
type = "email"
83
- id = "email "
85
+ name = "email_address "
84
86
className = "w-3xs rounded-full bg-transparent px-4 py-2 text-sm/6 text-gray-950 focus:outline-none"
85
87
placeholder = "Enter your email"
86
88
aria-label = "Email address"
87
89
/>
88
- < button className = "mr-0.5 shrink-0 overflow-hidden rounded-full bg-gray-950 px-3 py-1.5 text-sm/6 font-semibold text-nowrap text-white hover:bg-gray-950/85" >
90
+ < button
91
+ type = "submit"
92
+ className = "mr-0.5 shrink-0 overflow-hidden rounded-full bg-gray-950 px-3 py-1.5 text-sm/6 font-semibold text-nowrap text-white hover:bg-gray-950/85"
93
+ >
89
94
Sign up
90
95
</ button >
91
- </ motion . div >
92
- ) : (
96
+ </ motion . form >
97
+ ) }
98
+ { signUpState === "closed" && (
93
99
< motion . button
94
100
layout
95
101
ref = { getCourseButton }
96
102
key = "get-course-button"
97
103
onClick = { ( ) => {
98
- setIsExpanded ( true ) ;
104
+ setSignUpState ( "open" ) ;
99
105
} }
100
106
type = "button"
101
107
className = "inline-flex rounded-full bg-transparent px-4 py-2 text-sm/6 font-semibold text-gray-950 hover:bg-gray-100 focus:outline-none focus-visible:outline focus-visible:outline-offset-2 focus-visible:outline-white focus-visible:outline-solid"
@@ -116,11 +122,38 @@ export function HeroActions() {
116
122
Get the free course →
117
123
</ motion . button >
118
124
) }
125
+ { signUpState === "subscribed" && (
126
+ < motion . button
127
+ onClick = { ( ) => setSignUpState ( "closed" ) }
128
+ layout
129
+ transition = { { duration : 0.3 } }
130
+ className = "inline-flex flex-nowrap items-baseline gap-1.5 self-center rounded-full bg-white/25 px-4 py-2 pl-3 text-sm/6 font-semibold whitespace-nowrap text-white hover:bg-white/30"
131
+ initial = { {
132
+ opacity : 0 ,
133
+ } }
134
+ animate = { {
135
+ opacity : 1 ,
136
+ } }
137
+ exit = { {
138
+ opacity : 0 ,
139
+ } }
140
+ >
141
+ < svg width = { 20 } height = { 20 } fill = "none" className = "self-center stroke-white" >
142
+ < path d = "M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
143
+ < path
144
+ d = "M13.91 9.67a.37.37 0 0 1 0 .66l-5.6 3.11a.38.38 0 0 1-.56-.33V6.9c0-.29.3-.47.56-.33l5.6 3.11Z"
145
+ strokeLinecap = "round"
146
+ strokeLinejoin = "round"
147
+ />
148
+ </ svg >
149
+ You're in
150
+ </ motion . button >
151
+ ) }
119
152
</ AnimatePresence >
120
153
</ motion . div >
121
154
</ div >
122
155
< AnimatePresence initial = { false } >
123
- { ! isExpanded && (
156
+ { signUpState === "closed" && (
124
157
< motion . button
125
158
layout
126
159
transition = { { duration : 0.3 } }
0 commit comments