Skip to content

Commit 529c233

Browse files
authored
fix tooltip opacity and add skip steps (#75)
Signed-off-by: JaeBrian <[email protected]>
1 parent 9748474 commit 529c233

File tree

3 files changed

+72
-23
lines changed

3 files changed

+72
-23
lines changed

src/components/ToolTipGuide.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.force-opacity-1 {
2+
opacity: 1 !important;
3+
}

src/components/TooltipGuide.tsx

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState, useEffect, type ReactNode } from 'react'
22
import { Tooltip } from 'react-tooltip'
3+
import './ToolTipGuide.css'
34

45
export interface TooltipStep {
56
id: string
@@ -43,13 +44,24 @@ const TooltipGuide = ({
4344
}
4445
}
4546

47+
const handleSkip = () => {
48+
setShowTooltips(false)
49+
onComplete?.()
50+
}
51+
4652
const renderTooltipContent = (content: string) => {
4753
return (
4854
<div className="flex flex-col gap-3">
4955
<div className="text-base leading-relaxed">
5056
{content}
5157
</div>
52-
<div className="flex justify-end">
58+
<div className="flex justify-between items-center">
59+
<button
60+
onClick={handleSkip}
61+
className="bg-transparent hover:bg-white/10 text-white/70 hover:text-white px-3 py-1.5 rounded-md text-sm transition-all duration-200 font-medium cursor-pointer border border-white/20"
62+
>
63+
Skip
64+
</button>
5365
<button
5466
onClick={handleNextStep}
5567
className="bg-white/20 hover:bg-white/30 text-white px-3 py-1.5 rounded-md text-sm transition-all duration-200 font-medium cursor-pointer"
@@ -64,27 +76,32 @@ const TooltipGuide = ({
6476
return (
6577
<>
6678
{children(showTooltips)}
67-
{showTooltips && steps.map((step, index) => (
68-
<Tooltip
69-
key={step.id}
70-
id={step.id}
71-
place={step.placement || 'top'}
72-
isOpen={showTooltips && currentStep === index}
73-
clickable={true}
74-
style={{
75-
backgroundColor: '#9400FF',
76-
color: 'white',
77-
borderRadius: '12px',
78-
padding: '16px',
79-
fontSize: '20px',
80-
maxWidth: '350px',
81-
zIndex: showTooltips && currentStep === index ? 10000 : 9999,
82-
boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1)'
83-
}}
84-
>
85-
{renderTooltipContent(step.content)}
86-
</Tooltip>
87-
))}
79+
{showTooltips && steps.map((step, index) => {
80+
const isCurrentStep = currentStep === index
81+
return (
82+
<Tooltip
83+
key={step.id}
84+
id={step.id}
85+
place={step.placement || 'top'}
86+
isOpen={isCurrentStep}
87+
clickable={true}
88+
className="force-opacity-1"
89+
style={{
90+
backgroundColor: '#9400FF',
91+
color: 'white',
92+
borderRadius: '12px',
93+
padding: '16px',
94+
fontSize: '20px',
95+
maxWidth: '350px',
96+
zIndex: isCurrentStep ? 10000 : -1,
97+
boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1)',
98+
opacity: 1,
99+
}}
100+
>
101+
{renderTooltipContent(step.content)}
102+
</Tooltip>
103+
)
104+
})}
88105
</>
89106
)
90107
}

src/stores/walletStore.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,36 @@ export const useWalletStore = create<WalletState>()(
7171

7272
const walletApi = await window.cardano[walletName].enable()
7373

74-
const stakeAddresses = await walletApi.getRewardAddresses()
74+
await new Promise(resolve => setTimeout(resolve, 100))
75+
76+
let stakeAddresses: string[] = []
77+
let retries = 3
78+
79+
while (retries > 0) {
80+
try {
81+
stakeAddresses = await walletApi.getRewardAddresses()
82+
break
83+
} catch (error: unknown) {
84+
retries--
85+
86+
if (error instanceof Error && (error.message.includes('account changed') || error.message.includes('Account changed'))) {
87+
console.warn(`Account changed error for ${walletName}, retrying... (${retries} attempts left)`)
88+
89+
if (retries > 0) {
90+
await new Promise(resolve => setTimeout(resolve, 500))
91+
continue
92+
} else {
93+
const newWalletApi = await window.cardano[walletName].enable()
94+
await new Promise(resolve => setTimeout(resolve, 200))
95+
stakeAddresses = await newWalletApi.getRewardAddresses()
96+
break
97+
}
98+
} else {
99+
throw error
100+
}
101+
}
102+
}
103+
75104
const stakeAddress = stakeAddresses?.[0] || null
76105

77106
set({

0 commit comments

Comments
 (0)