Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve powered by with dynamic configuration #332

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/widget/src/components/PoweredBy/PoweredBy.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { Box, Tooltip, Typography } from '@mui/material'
import { version } from '../../config/version.js'
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
import { Link } from './PoweredBy.style.js'

const poweredByConfig = {
default: {
url: 'https://li.fi',
text: 'LI.FI',
},
jumper: {
url: 'https://jumper.exchange',
text: 'Jumper',
},
}

export const PoweredBy: React.FC = () => {
const { poweredBy = 'default' } = useWidgetConfig()

return (
<Box
pt={1}
Expand All @@ -16,7 +30,7 @@ export const PoweredBy: React.FC = () => {
>
<Tooltip title={`v${version}`} enterDelay={1000}>
<Link
href="https://li.fi"
href={poweredByConfig[poweredBy].url}
target="_blank"
underline="none"
color="text.primary"
Expand All @@ -30,7 +44,7 @@ export const PoweredBy: React.FC = () => {
Powered by
</Typography>
<Typography color="text.primary" fontSize={12} fontWeight={600}>
LI.FI
{poweredByConfig[poweredBy].text}
</Typography>
</Link>
</Tooltip>
Expand Down
3 changes: 3 additions & 0 deletions packages/widget/src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ export type WidgetLanguages = {
default?: LanguageKey
} & AllowDeny<LanguageKey>

export type PoweredByType = 'default' | 'jumper'

export interface WidgetConfig {
fromChain?: number
toChain?: number
Expand Down Expand Up @@ -239,6 +241,7 @@ export interface WidgetConfig {
languageResources?: LanguageResources
explorerUrls?: Record<number, string[]> &
Partial<Record<'internal', string[]>>
poweredBy?: PoweredByType
}

export interface FormFieldOptions {
Expand Down