1- import { domAnimation , LazyMotion , m } from 'framer-motion'
21import { useState } from 'react'
32import { FaExternalLinkAlt } from 'react-icons/fa'
43import keepItImage from '@/assets/keep-it.png'
@@ -11,32 +10,10 @@ interface ExtensionInstalledModalProps {
1110 onClose : ( ) => void
1211 onGetStarted : ( ) => void
1312}
14-
15- type Step = number
16-
1713export function ExtensionInstalledModal ( {
1814 show,
1915 onGetStarted,
2016} : ExtensionInstalledModalProps ) {
21- const [ currentStep , setCurrentStep ] = useState < Step > ( 1 )
22- const totalSteps = 3
23-
24- const renderStepContent = ( ) => {
25- switch ( currentStep ) {
26- case 1 :
27- if ( import . meta. env . FIREFOX ) {
28- return < StepFirefoxConsent setCurrentStep = { setCurrentStep } />
29- }
30- return < StepOne setCurrentStep = { setCurrentStep } />
31- case 2 :
32- return < StepFooterDisable setCurrentStep = { setCurrentStep } />
33- case 3 :
34- return < StepThree onGetStarted = { onGetStarted } />
35- default :
36- return null
37- }
38- }
39-
4017 return (
4118 < Modal
4219 isOpen = { show }
@@ -46,59 +23,23 @@ export function ExtensionInstalledModal({
4623 showCloseButton = { false }
4724 closeOnBackdropClick = { false }
4825 >
49- < LazyMotion features = { domAnimation } >
50- < m . div
51- className = { 'flex flex-col items-center p-2 text-center w-full' }
52- initial = { { opacity : 0 } }
53- animate = { { opacity : 1 } }
54- transition = { { duration : 0.4 } }
55- >
56- { renderStepContent ( ) }
57- </ m . div >
58- </ LazyMotion >
59-
60- < StepIndicator totalSteps = { totalSteps } currentStep = { currentStep } />
26+ { import . meta. env . FIREFOX ? (
27+ < StepFirefoxConsent onGetStarted = { onGetStarted } />
28+ ) : (
29+ < StepOne onGetStarted = { onGetStarted } />
30+ ) }
6131 </ Modal >
6232 )
6333}
64- interface StepIndicatorProps {
65- totalSteps : number
66- currentStep : Step
67- }
68- const StepIndicator = ( { totalSteps, currentStep } : StepIndicatorProps ) => (
69- < div
70- className = "flex items-center justify-center gap-3"
71- role = "progressbar"
72- aria-valuenow = { currentStep }
73- aria-valuemin = { 1 }
74- aria-valuemax = { totalSteps }
75- >
76- { Array . from ( { length : totalSteps } ) . map ( ( _ , index ) => (
77- < button
78- key = { index }
79- aria-label = { `رفتن به گام ${ index + 1 } ` }
80- aria-current = { index + 1 === currentStep ? 'step' : undefined }
81- className = { `w-10 h-2 cursor-default rounded-full transition-all duration-300 ${
82- index + 1 === currentStep
83- ? 'bg-blue-500 shadow-lg shadow-blue-500/30'
84- : index + 1 < currentStep
85- ? 'bg-blue-600'
86- : 'bg-gray-700 hover:bg-gray-600'
87- } `}
88- />
89- ) ) }
90- </ div >
91- )
92-
9334interface StepOneProps {
94- setCurrentStep : ( step : Step ) => void
35+ onGetStarted : ( ) => void
9536}
96- const StepOne = ( { setCurrentStep } : StepOneProps ) => {
37+ const StepOne = ( { onGetStarted } : StepOneProps ) => {
9738 return (
9839 < >
9940 < div className = "mb-3" >
10041 < h3 className = { 'mb-0 text-2xl font-bold text-content' } >
101- به ویجتیفای خوش آمدید! 🎉
42+ به ویجتیفای خوش آمدید! 🎉
10243 </ h3 >
10344 </ div >
10445
@@ -119,7 +60,7 @@ const StepOne = ({ setCurrentStep }: StepOneProps) => {
11960
12061 < div
12162 className = {
122- 'p-3 mb-3 text-content rounded-lg border border-content bg-content'
63+ 'p-3 mb-2 text-content rounded-lg border border-content bg-content'
12364 }
12465 >
12566 < p className = "font-bold text-muted" >
@@ -129,135 +70,20 @@ const StepOne = ({ setCurrentStep }: StepOneProps) => {
12970
13071 < Button
13172 size = "md"
132- onClick = { ( ) => setCurrentStep ( 2 ) }
133- className = "!px-4 !py-2 mx-auto font-light shadow w-52 rounded-2xl shadow-primary"
73+ onClick = { onGetStarted }
74+ className = "w-full text-base font-light shadow-sm rounded-2xl shadow-primary outline-none! "
13475 isPrimary = { true }
13576 >
136- Keep It رو زدم!
77+ شروع کنید
13778 </ Button >
13879 </ >
13980 )
14081}
14182
142- interface StepFooterDisableProps {
143- setCurrentStep : ( step : Step ) => void
144- }
145- const StepFooterDisable = ( { setCurrentStep } : StepFooterDisableProps ) => {
146- const [ counter , setCounter ] = useState < number > ( 5 )
147-
148- useEffect ( ( ) => {
149- const interval = setInterval ( ( ) => {
150- setCounter ( ( prev ) => {
151- if ( prev <= 1 ) {
152- clearInterval ( interval )
153- return 0
154- }
155- return prev - 1
156- } )
157- } , 1000 )
158- return ( ) => clearInterval ( interval )
159- } , [ ] )
160-
161- return (
162- < >
163- < div className = "mb-3" >
164- < h3 className = { 'mb-0 text-2xl font-bold text-content' } >
165- مخفی کردن نوار پایین مرورگر
166- </ h3 >
167- </ div >
168-
169- < div
170- className = {
171- 'relative p-1 mt-1 mb-3 border rounded-xl border-content bg-content'
172- }
173- >
174- < div className = "flex items-center justify-center" >
175- < img
176- src = "https://cdn.widgetify.ir/extension/how-to-disable-footer.png"
177- alt = "نحوه مخفی کردن نوار پایین مرورگر"
178- className = "h-auto max-w-full rounded-lg shadow-xl"
179- style = { { maxHeight : '220px' } }
180- />
181- </ div >
182- </ div >
183-
184- < div
185- className = {
186- 'p-3 mb-3 text-content rounded-lg border border-content bg-content'
187- }
188- >
189- < p className = "font-bold text-muted" >
190- 💡 برای زیبایی بیشتر، میتونید نوار خاکستری پایین مرورگر رو مانند این
191- تصویر مخفی کنید
192- </ p >
193- </ div >
194-
195- { counter === 0 ? (
196- < Button
197- size = "sm"
198- onClick = { ( ) => setCurrentStep ( 3 ) }
199- className = "!px-4 !py-2 mx-auto font-light shadow w-52 rounded-2xl shadow-primary"
200- isPrimary = { true }
201- >
202- گام بعدی
203- </ Button >
204- ) : (
205- < div className = "px-4 py-2 mx-auto text-sm text-center border w-52 text-muted rounded-2xl border-content" >
206- لطفاً صبر کنید... { counter } ثانیه
207- </ div >
208- ) }
209- </ >
210- )
211- }
212-
213- interface StepThreeProps {
214- onGetStarted : ( ) => void
215- }
216- const StepThree = ( { onGetStarted } : StepThreeProps ) => {
217- return (
218- < >
219- < m . div
220- className = "mb-6"
221- initial = { { y : - 20 } }
222- animate = { { y : 0 } }
223- transition = { { duration : 0.5 , delay : 0.2 } }
224- >
225- < h3 className = { 'mb-3 text-2xl font-bold text-content' } >
226- آماده شروع هستید؟
227- </ h3 >
228- </ m . div >
229-
230- < m . div
231- className = {
232- 'p-3 mb-6 border rounded-lg bg-content backdrop-blur-sm border-content'
233- }
234- initial = { { opacity : 0 , y : 10 } }
235- animate = { { opacity : 1 , y : 0 } }
236- transition = { { duration : 0.5 , delay : 0.3 } }
237- >
238- < p className = "text-muted" >
239- بریم که یک تجربه جدید و جذاب را شروع کنیم! 😎
240- </ p >
241- </ m . div >
242-
243- < div className = "flex flex-col w-full gap-4 mt-4 sm:flex-row" >
244- < Button
245- onClick = { onGetStarted }
246- className = "w-full font-light sm:flex-1 rounded-2xl"
247- size = "md"
248- isPrimary = { true }
249- >
250- شروع کنید
251- </ Button >
252- </ div >
253- </ >
254- )
255- }
256-
25783interface StepFirefoxConsentProps {
258- setCurrentStep : ( step : Step ) => void
84+ onGetStarted : ( ) => void
25985}
260- const StepFirefoxConsent = ( { setCurrentStep } : StepFirefoxConsentProps ) => {
86+ const StepFirefoxConsent = ( { onGetStarted } : StepFirefoxConsentProps ) => {
26187 const [ isAccepted , setIsAccepted ] = useState ( false )
26288 const handleDecline = ( ) => {
26389 if ( browser . management ?. uninstallSelf ) {
@@ -273,7 +99,7 @@ const StepFirefoxConsent = ({ setCurrentStep }: StepFirefoxConsentProps) => {
27399 return (
274100 < div className = "w-full overflow-clip" >
275101 < h3 className = "mb-3 text-2xl font-bold text-content" > Privacy Notice</ h3 >
276- < p className = "mb-2 font-semibold" > خلاصه سیاست حریم خصوصی ویجتیفای :</ p >
102+ < p className = "mb-2 font-semibold" > خلاصه سیاست حریم خصوصی ویجتیفای :</ p >
277103 < div className = "w-full px-2" >
278104 < ul className = "w-full h-56 space-y-1 overflow-y-auto text-xs list-disc list-inside border border-content rounded-2xl" >
279105 < li > هیچ داده شخصی بهطور پیشفرض جمعآوری نمیشود.</ li >
@@ -296,7 +122,7 @@ const StepFirefoxConsent = ({ setCurrentStep }: StepFirefoxConsentProps) => {
296122 میشود. این مورد کاملاً اختیاری است و میتوانید آن را رد کنید.
297123 </ li >
298124 < li > هیچ دادهای با اشخاص ثالث به اشتراک گذاشته نمیشود.</ li >
299- < li > ویجتیفای متنباز است و کد آن روی GitHub قابل بررسی است.</ li >
125+ < li > ویجتیفای متنباز است و کد آن روی GitHub قابل بررسی است.</ li >
300126 < li >
301127 درخواست حذف کامل دادهها در هر زمان از طریق{ ' ' }
302128 < a
@@ -332,7 +158,7 @@ const StepFirefoxConsent = ({ setCurrentStep }: StepFirefoxConsentProps) => {
332158 onChange = { ( ) => setIsAccepted ( ! isAccepted ) }
333159 />
334160 < span className = "mr-2 text-sm" >
335- با سیاست حریم خصوصی ویجتیفای موافقم.
161+ با سیاست حریم خصوصی ویجتیفای موافقم.
336162 </ span >
337163 </ div >
338164 </ div >
@@ -346,7 +172,7 @@ const StepFirefoxConsent = ({ setCurrentStep }: StepFirefoxConsentProps) => {
346172 🚫 حذف افزونه
347173 </ Button >
348174 < Button
349- onClick = { ( ) => setCurrentStep ( 2 ) }
175+ onClick = { onGetStarted }
350176 size = "md"
351177 className = "w-40 btn btn-success rounded-xl"
352178 disabled = { ! isAccepted }
0 commit comments