|
|
|
@ -1,12 +1,34 @@ |
|
|
|
|
import { CustomTooltip } from '@remix-ui/helper' |
|
|
|
|
import React from 'react' |
|
|
|
|
import axios from 'axios' |
|
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
|
|
|
|
|
|
export default function DidYouKnow () { |
|
|
|
|
const [tip, setTip] = useState<string>('') |
|
|
|
|
useEffect(() => { |
|
|
|
|
const abortController = new AbortController() |
|
|
|
|
const signal = abortController.signal |
|
|
|
|
async function showRemixTips() { |
|
|
|
|
const response = await axios.get('https://raw.githubusercontent.com/remix-project-org/remix-dynamics/main/ide/tips.json', { signal }) |
|
|
|
|
if (signal.aborted) return |
|
|
|
|
const tips = response.data |
|
|
|
|
const index = Math.floor(Math.random() * (tips.length - 1)) |
|
|
|
|
setTip(tips[index]) |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
showRemixTips() |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|
} |
|
|
|
|
return () => { |
|
|
|
|
abortController.abort() |
|
|
|
|
} |
|
|
|
|
}, []) |
|
|
|
|
return ( |
|
|
|
|
<CustomTooltip tooltipText={'Did you know'}> |
|
|
|
|
<div className="remixui_statusbar_didyouknow text-white small d-flex align-items-center"> |
|
|
|
|
<span className="pr-2 far fa-exclamation-triangle text-white fa-regular fa-lightbulb"></span> |
|
|
|
|
<div>Did you know?</div> |
|
|
|
|
<span className="pr-2 text-warning fa-solid fa-lightbulb"></span> |
|
|
|
|
<div className="mr-2">Did you know?</div> |
|
|
|
|
{ tip && tip.length > 0 ? <div>{tip}</div> : null } |
|
|
|
|
</div> |
|
|
|
|
</CustomTooltip> |
|
|
|
|
) |
|
|
|
|