commit
9237095434
@ -0,0 +1,17 @@ |
||||
import React, { createContext } from 'react' |
||||
import { defaultStatusBarContext, StatusBarContextType, StatusBarInterface } from '../lib/types' |
||||
|
||||
export const StatusBarContext = createContext<StatusBarContextType>(defaultStatusBarContext) |
||||
|
||||
export function StatusBarContextProvider ({ children }) { |
||||
const statusBarProviderValues = { |
||||
test: true |
||||
} |
||||
return ( |
||||
<> |
||||
<StatusBarContext.Provider value={statusBarProviderValues}> |
||||
{children} |
||||
</StatusBarContext.Provider> |
||||
</> |
||||
) |
||||
} |
@ -0,0 +1,35 @@ |
||||
import { CustomTooltip } from '@remix-ui/helper' |
||||
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 text-success fa-solid fa-lightbulb"></span> |
||||
<div className="mr-2">Did you know?</div> |
||||
{ tip && tip.length > 0 ? <div>{tip}</div> : null } |
||||
</div> |
||||
</CustomTooltip> |
||||
) |
||||
} |
Loading…
Reference in new issue