@pradip1995/segment-animation-login 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,427 @@
1
+ /* Motion / Lumière login — centered form, no brand image, no footer (layout hides it) */
2
+
3
+ .anim-login {
4
+ --al-ink: #0a0a0a;
5
+ --al-muted: #737373;
6
+ --al-line: #e5e5e5;
7
+ --al-accent: #e23b00;
8
+ --al-sans: var(--font-sans, "DM Sans", sans-serif);
9
+ --al-serif: var(--font-heading, "Cormorant Garamond", Georgia, serif);
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ width: 100%;
14
+ min-height: calc(100svh - var(--header-height, 80px) - var(--promo-bar-height, 40px));
15
+ background: #ffffff;
16
+ color: var(--al-ink);
17
+ font-family: var(--al-sans);
18
+ }
19
+
20
+ body:has([data-login-viewport].anim-login) {
21
+ background: #ffffff;
22
+ }
23
+
24
+ /* Safety: hide footer if layout still renders one */
25
+ body:has([data-login-viewport].anim-login) footer,
26
+ body:has([data-login-viewport].anim-login) [data-testid="footer"],
27
+ body:has([data-login-viewport].anim-login) .storefront-footer,
28
+ body:has([data-login-viewport].anim-login) .anim-footer,
29
+ body:has([data-login-viewport].anim-login) .segment-footer {
30
+ display: none !important;
31
+ }
32
+
33
+ .anim-login__form {
34
+ display: flex;
35
+ flex-direction: column;
36
+ justify-content: center;
37
+ width: 100%;
38
+ max-width: 28rem;
39
+ padding: 2.5rem 1.5rem 3rem;
40
+ background: #ffffff;
41
+ }
42
+
43
+ .anim-login__form-inner {
44
+ width: 100%;
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 1rem;
48
+ }
49
+
50
+ .anim-login__header {
51
+ text-align: center;
52
+ margin-bottom: 0.5rem;
53
+ }
54
+
55
+ .anim-login__kicker {
56
+ margin: 0 0 0.5rem;
57
+ font-size: 0.6875rem;
58
+ font-weight: 600;
59
+ letter-spacing: 0.22em;
60
+ text-transform: uppercase;
61
+ color: var(--al-accent);
62
+ }
63
+
64
+ .anim-login__title {
65
+ margin: 0;
66
+ font-family: var(--al-sans);
67
+ font-size: clamp(1.5rem, 3.5vw, 1.85rem);
68
+ font-weight: 600;
69
+ letter-spacing: -0.01em;
70
+ line-height: 1.2;
71
+ color: var(--al-ink);
72
+ text-transform: none;
73
+ }
74
+
75
+ .anim-login__subtitle {
76
+ margin: 0.5rem 0 0;
77
+ font-size: 0.8125rem;
78
+ line-height: 1.5;
79
+ letter-spacing: 0.06em;
80
+ text-transform: uppercase;
81
+ color: var(--al-muted);
82
+ }
83
+
84
+ .anim-login__google {
85
+ width: 100%;
86
+ }
87
+
88
+ .anim-login__google button,
89
+ .anim-login__google a {
90
+ border-radius: 0 !important;
91
+ }
92
+
93
+ .anim-login__divider {
94
+ display: flex;
95
+ align-items: center;
96
+ gap: 0.75rem;
97
+ margin: 0.25rem 0;
98
+ color: var(--al-muted);
99
+ font-size: 0.625rem;
100
+ font-weight: 600;
101
+ letter-spacing: 0.16em;
102
+ text-transform: uppercase;
103
+ }
104
+
105
+ .anim-login__divider::before,
106
+ .anim-login__divider::after {
107
+ content: "";
108
+ flex: 1;
109
+ height: 1px;
110
+ background: var(--al-line);
111
+ }
112
+
113
+ .anim-login__tabs {
114
+ display: grid;
115
+ grid-template-columns: 1fr 1fr;
116
+ gap: 0;
117
+ border-bottom: 1px solid var(--al-line);
118
+ }
119
+
120
+ .anim-login__tab {
121
+ appearance: none;
122
+ background: transparent;
123
+ border: none;
124
+ border-bottom: 2px solid transparent;
125
+ margin-bottom: -1px;
126
+ padding: 0.75rem 0.5rem;
127
+ font-size: 0.75rem;
128
+ font-weight: 600;
129
+ letter-spacing: 0.14em;
130
+ text-transform: uppercase;
131
+ color: var(--al-muted);
132
+ cursor: pointer;
133
+ transition: color 0.2s ease, border-color 0.2s ease;
134
+ }
135
+
136
+ .anim-login__tab.is-active {
137
+ color: var(--al-ink);
138
+ border-bottom-color: var(--al-ink);
139
+ }
140
+
141
+ .anim-login__identifier {
142
+ position: relative;
143
+ min-height: 4.75rem;
144
+ }
145
+
146
+ .anim-login__phone,
147
+ .anim-login__field {
148
+ width: 100%;
149
+ }
150
+
151
+ .anim-login__phone.is-inactive,
152
+ .anim-login__field.is-inactive {
153
+ position: absolute;
154
+ inset: 0;
155
+ opacity: 0;
156
+ pointer-events: none;
157
+ visibility: hidden;
158
+ }
159
+
160
+ .anim-login__label {
161
+ display: block;
162
+ margin-bottom: 0.4rem;
163
+ font-size: 0.6875rem;
164
+ font-weight: 600;
165
+ letter-spacing: 0.14em;
166
+ text-transform: uppercase;
167
+ color: var(--al-muted);
168
+ }
169
+
170
+ .anim-login__input {
171
+ width: 100%;
172
+ min-height: 3rem;
173
+ padding: 0.75rem 0.9rem;
174
+ border: 1px solid var(--al-line);
175
+ border-radius: 0;
176
+ background: #ffffff;
177
+ color: var(--al-ink);
178
+ font-size: 0.9375rem;
179
+ font-family: var(--al-sans);
180
+ outline: none;
181
+ transition: border-color 0.2s ease;
182
+ }
183
+
184
+ .anim-login__input:focus {
185
+ border-color: var(--al-ink);
186
+ }
187
+
188
+ .anim-login__phone input,
189
+ .anim-login__phone select,
190
+ .anim-login__phone button {
191
+ border-radius: 0 !important;
192
+ font-family: var(--al-sans) !important;
193
+ }
194
+
195
+ .anim-login__error {
196
+ margin: 0;
197
+ min-height: 1.25rem;
198
+ font-size: 0.8125rem;
199
+ line-height: 1.4;
200
+ color: #c1272d;
201
+ }
202
+
203
+ .anim-login__submit {
204
+ appearance: none;
205
+ width: 100%;
206
+ min-height: 3rem;
207
+ padding: 0.85rem 1.25rem;
208
+ border: 1px solid #000000;
209
+ border-radius: 0;
210
+ background: #000000;
211
+ color: #ffffff;
212
+ font-size: 0.75rem;
213
+ font-weight: 600;
214
+ letter-spacing: 0.14em;
215
+ text-transform: uppercase;
216
+ cursor: pointer;
217
+ transition: background 0.2s ease, border-color 0.2s ease;
218
+ }
219
+
220
+ .anim-login__submit:hover:not(:disabled) {
221
+ background: #222222;
222
+ border-color: #222222;
223
+ }
224
+
225
+ .anim-login__submit:disabled {
226
+ opacity: 0.45;
227
+ cursor: not-allowed;
228
+ }
229
+
230
+ .anim-login__legal {
231
+ margin: 0;
232
+ font-size: 0.75rem;
233
+ line-height: 1.55;
234
+ color: var(--al-muted);
235
+ text-align: center;
236
+ }
237
+
238
+ .anim-login__link {
239
+ color: var(--al-ink);
240
+ text-decoration: underline;
241
+ text-underline-offset: 2px;
242
+ }
243
+
244
+ .anim-login__guest {
245
+ appearance: none;
246
+ width: 100%;
247
+ min-height: 3rem;
248
+ padding: 0.85rem 1.25rem;
249
+ border: 1px solid #000000;
250
+ border-radius: 0;
251
+ background: transparent;
252
+ color: #000000;
253
+ font-size: 0.75rem;
254
+ font-weight: 600;
255
+ letter-spacing: 0.14em;
256
+ text-transform: uppercase;
257
+ cursor: pointer;
258
+ transition: background 0.2s ease, color 0.2s ease;
259
+ }
260
+
261
+ .anim-login__guest:hover {
262
+ background: #000000;
263
+ color: #ffffff;
264
+ }
265
+
266
+ .anim-login__guest-status {
267
+ margin: 0.75rem 0 0;
268
+ text-align: center;
269
+ font-size: 0.75rem;
270
+ letter-spacing: 0.12em;
271
+ text-transform: uppercase;
272
+ color: var(--al-muted);
273
+ }
274
+
275
+ .anim-login__otp-hint {
276
+ margin: 0.65rem auto 0;
277
+ max-width: 22rem;
278
+ font-size: 0.875rem;
279
+ line-height: 1.55;
280
+ color: var(--al-muted);
281
+ text-transform: none;
282
+ letter-spacing: 0;
283
+ }
284
+
285
+ .anim-login__otp-target {
286
+ color: var(--al-ink);
287
+ font-weight: 600;
288
+ word-break: break-all;
289
+ }
290
+
291
+ .anim-login__verify {
292
+ display: flex;
293
+ flex-direction: column;
294
+ gap: 1.15rem;
295
+ }
296
+
297
+ .anim-login__otp {
298
+ width: 100%;
299
+ padding: 0.35rem 0 0.15rem;
300
+ }
301
+
302
+ /* OTP cells — Motion square, black focus (override rounded/blue defaults) */
303
+ .anim-login__otp > div {
304
+ gap: 0.5rem !important;
305
+ }
306
+
307
+ .anim-login__otp > div > div {
308
+ width: 2.65rem !important;
309
+ height: 3.15rem !important;
310
+ border-radius: 0 !important;
311
+ border-width: 1px !important;
312
+ border-color: #e5e5e5 !important;
313
+ background: #ffffff !important;
314
+ box-shadow: none !important;
315
+ font-family: var(--al-sans) !important;
316
+ font-size: 1.125rem !important;
317
+ font-weight: 600 !important;
318
+ color: #0a0a0a !important;
319
+ }
320
+
321
+ /* Active / focused digit slot */
322
+ .anim-login__otp > div > div[class*="ring-"],
323
+ .anim-login__otp > div > div[class*="border-brand"] {
324
+ border-color: #000000 !important;
325
+ background: #fafafa !important;
326
+ box-shadow: none !important;
327
+ }
328
+
329
+ .anim-login__otp > div > input:focus {
330
+ outline: none !important;
331
+ }
332
+
333
+ .anim-login__verify .anim-login__submit {
334
+ margin-top: 0.25rem;
335
+ }
336
+
337
+ .anim-login__verify-actions {
338
+ display: flex;
339
+ justify-content: space-between;
340
+ align-items: center;
341
+ gap: 1rem;
342
+ padding-top: 0.15rem;
343
+ }
344
+
345
+ .anim-login__text-btn {
346
+ appearance: none;
347
+ background: transparent;
348
+ border: none;
349
+ padding: 0.35rem 0;
350
+ font-size: 0.75rem;
351
+ font-weight: 600;
352
+ letter-spacing: 0.08em;
353
+ text-transform: uppercase;
354
+ color: var(--al-muted);
355
+ cursor: pointer;
356
+ }
357
+
358
+ .anim-login__text-btn:hover:not(:disabled) {
359
+ color: var(--al-ink);
360
+ }
361
+
362
+ .anim-login__text-btn:disabled {
363
+ opacity: 0.45;
364
+ cursor: not-allowed;
365
+ }
366
+
367
+ .anim-login__text-btn--block {
368
+ display: block;
369
+ width: 100%;
370
+ margin-top: 0.75rem;
371
+ text-align: center;
372
+ }
373
+
374
+ .anim-guest {
375
+ position: fixed;
376
+ inset: 0;
377
+ z-index: 80;
378
+ display: flex;
379
+ align-items: center;
380
+ justify-content: center;
381
+ padding: 1.25rem;
382
+ }
383
+
384
+ .anim-guest__backdrop {
385
+ position: absolute;
386
+ inset: 0;
387
+ border: none;
388
+ background: rgba(0, 0, 0, 0.45);
389
+ cursor: pointer;
390
+ }
391
+
392
+ .anim-guest__panel {
393
+ position: relative;
394
+ z-index: 1;
395
+ width: 100%;
396
+ max-width: 24rem;
397
+ padding: 1.75rem;
398
+ background: #ffffff;
399
+ border: 1px solid var(--al-line);
400
+ }
401
+
402
+ .anim-guest__title {
403
+ margin: 0 0 0.5rem;
404
+ font-family: var(--al-sans);
405
+ font-size: 1.35rem;
406
+ font-weight: 600;
407
+ }
408
+
409
+ .anim-guest__text {
410
+ margin: 0 0 1.25rem;
411
+ font-size: 0.875rem;
412
+ line-height: 1.55;
413
+ color: var(--al-muted);
414
+ }
415
+
416
+ @media (min-width: 640px) {
417
+ .anim-login__form {
418
+ padding: 3rem 1.5rem 4rem;
419
+ }
420
+ }
421
+
422
+ .anim-login__google [role="alert"],
423
+ .anim-login__google .text-red-600,
424
+ .anim-login__google p[class*="red"] {
425
+ font-size: 0.75rem !important;
426
+ line-height: 1.45 !important;
427
+ }
@@ -0,0 +1,216 @@
1
+ "use client"
2
+
3
+ import { useEffect, useRef, useState } from "react"
4
+ import { sendOTP, verifyOTP } from "@pradip1995/segment-login-template/auth-server"
5
+ import OtpVerificationModal from "@pradip1995/segment-login-template/otp-verification-modal"
6
+ import type { OtpVerificationComponent } from "@pradip1995/segment-login-template/otp-component"
7
+ import {
8
+ isNextRedirect,
9
+ safeErrorMessage,
10
+ } from "@pradip1995/segment-primitives/is-next-redirect"
11
+
12
+ type GuestOrderModalProps = {
13
+ open: boolean
14
+ onClose: () => void
15
+ countryCode: string
16
+ initialEmail?: string
17
+ autoStart?: boolean
18
+ OtpComponent?: OtpVerificationComponent
19
+ }
20
+
21
+ export default function AnimationGuestOrderModal({
22
+ open,
23
+ onClose,
24
+ countryCode,
25
+ initialEmail = "",
26
+ autoStart = false,
27
+ OtpComponent = OtpVerificationModal,
28
+ }: GuestOrderModalProps) {
29
+ const [email, setEmail] = useState(initialEmail)
30
+ const [otp, setOtp] = useState("")
31
+ const [otpToken, setOtpToken] = useState<string | null>(null)
32
+ const [step, setStep] = useState<"email" | "otp">("email")
33
+ const [pending, setPending] = useState(false)
34
+ const [error, setError] = useState<string | null>(null)
35
+ const [success, setSuccess] = useState(false)
36
+ const autoStartedRef = useRef(false)
37
+
38
+ useEffect(() => {
39
+ if (initialEmail) setEmail(initialEmail)
40
+ }, [initialEmail])
41
+
42
+ useEffect(() => {
43
+ if (open && autoStart && initialEmail && !autoStartedRef.current) {
44
+ autoStartedRef.current = true
45
+ void handleSendOtp(initialEmail)
46
+ }
47
+ if (!open) {
48
+ autoStartedRef.current = false
49
+ }
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ }, [open, autoStart, initialEmail])
52
+
53
+ async function handleSendOtp(emailToSend = email) {
54
+ if (!emailToSend.trim()) return
55
+ setPending(true)
56
+ setError(null)
57
+
58
+ try {
59
+ const res = await sendOTP(emailToSend.trim())
60
+ if (!res.success && (res as { error?: string }).error) {
61
+ throw new Error((res as { error?: string }).error)
62
+ }
63
+ setOtpToken((res as { token?: string }).token || "guest")
64
+ setOtp("")
65
+ setStep("otp")
66
+ } catch (err) {
67
+ if (isNextRedirect(err)) throw err
68
+ setError(safeErrorMessage(err, "Failed to send code"))
69
+ setStep("email")
70
+ } finally {
71
+ setPending(false)
72
+ }
73
+ }
74
+
75
+ async function handleVerifyOtp() {
76
+ if (!otp || otp.length < 6) return
77
+ setPending(true)
78
+ setError(null)
79
+
80
+ try {
81
+ const res = await verifyOTP(email.trim(), otpToken || "", otp)
82
+ if (!res.success) {
83
+ throw new Error((res as { error?: string }).error || "Invalid code")
84
+ }
85
+ setSuccess(true)
86
+ window.setTimeout(() => {
87
+ window.location.href = `/${countryCode}/account/guest-orders`
88
+ }, 900)
89
+ } catch (err) {
90
+ if (isNextRedirect(err)) throw err
91
+ setError(safeErrorMessage(err, "Verification failed"))
92
+ setPending(false)
93
+ }
94
+ }
95
+
96
+ async function handleResend() {
97
+ await handleSendOtp(email)
98
+ }
99
+
100
+ function handleClose() {
101
+ setEmail(initialEmail || "")
102
+ setOtp("")
103
+ setOtpToken(null)
104
+ setStep("email")
105
+ setError(null)
106
+ setSuccess(false)
107
+ setPending(false)
108
+ autoStartedRef.current = false
109
+ onClose()
110
+ }
111
+
112
+ if (!open) return null
113
+
114
+ if (step === "otp" || success) {
115
+ return (
116
+ <OtpComponent
117
+ open
118
+ preventClose={!success}
119
+ title={success ? "Verified" : "Verify your email"}
120
+ description={
121
+ success
122
+ ? "Opening your guest orders…"
123
+ : `Enter the 6-digit code sent to ${email || "your email"}.`
124
+ }
125
+ otp={otp}
126
+ onOtpChange={setOtp}
127
+ error={error}
128
+ pending={pending}
129
+ success={success}
130
+ successTitle="Verification successful"
131
+ successMessage="Redirecting to your guest orders…"
132
+ verifyLabel="Verify & view orders"
133
+ onVerify={handleVerifyOtp}
134
+ onResend={handleResend}
135
+ onClose={handleClose}
136
+ extraContent={
137
+ !success ? (
138
+ <button
139
+ type="button"
140
+ onClick={() => {
141
+ setStep("email")
142
+ setOtp("")
143
+ setError(null)
144
+ }}
145
+ className="anim-login__text-btn anim-login__text-btn--block"
146
+ >
147
+ Change email
148
+ </button>
149
+ ) : undefined
150
+ }
151
+ />
152
+ )
153
+ }
154
+
155
+ return (
156
+ <div className="anim-guest">
157
+ <button
158
+ type="button"
159
+ className="anim-guest__backdrop"
160
+ aria-label="Close guest order dialog"
161
+ onClick={handleClose}
162
+ />
163
+ <div className="anim-guest__panel" role="dialog" aria-modal="true" aria-labelledby="anim-guest-title">
164
+ <form
165
+ onSubmit={(e) => {
166
+ e.preventDefault()
167
+ void handleSendOtp()
168
+ }}
169
+ >
170
+ <h2 id="anim-guest-title" className="anim-guest__title">
171
+ Track your order
172
+ </h2>
173
+ <p className="anim-guest__text">
174
+ Enter the email used at checkout. We&apos;ll send a one-time code to view guest
175
+ orders.
176
+ </p>
177
+
178
+ <label className="anim-login__field">
179
+ <span className="anim-login__label">Email</span>
180
+ <input
181
+ type="email"
182
+ value={email}
183
+ onChange={(e) => setEmail(e.target.value)}
184
+ required
185
+ autoComplete="email"
186
+ placeholder="you@example.com"
187
+ className="anim-login__input"
188
+ />
189
+ </label>
190
+
191
+ {error ? (
192
+ <p className="anim-login__error" role="alert">
193
+ {error}
194
+ </p>
195
+ ) : null}
196
+
197
+ <button
198
+ type="submit"
199
+ disabled={pending || !email.trim()}
200
+ className="anim-login__submit"
201
+ >
202
+ {pending ? "Sending…" : "Send OTP"}
203
+ </button>
204
+
205
+ <button
206
+ type="button"
207
+ onClick={handleClose}
208
+ className="anim-login__text-btn anim-login__text-btn--block"
209
+ >
210
+ Cancel
211
+ </button>
212
+ </form>
213
+ </div>
214
+ </div>
215
+ )
216
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from "./segment"
2
+ export { default as manifest } from "./manifest"