Skip to content

Commit

Permalink
beta chip
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Dec 8, 2023
1 parent c0b7dad commit 9308250
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 31 deletions.
12 changes: 0 additions & 12 deletions centrifuge-app/src/components/DebugFlags/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export type Key =
| 'evmAddress'
| 'batchMintNFTs'
| 'persistDebugFlags'
| 'showBase'
| 'showArbitrum'
| 'showUnusedFlags'
| 'allowInvestBelowMin'
| 'alternativeTheme'
Expand Down Expand Up @@ -75,16 +73,6 @@ export const flagsConfig: Record<Key, DebugFlagConfig> = {
default: false,
alwaysShow: true,
},
showBase: {
type: 'checkbox',
default: false,
alwaysShow: true,
},
showArbitrum: {
type: 'checkbox',
default: false,
alwaysShow: true,
},
showTestNets: {
type: 'checkbox',
default: isTestEnv,
Expand Down
2 changes: 0 additions & 2 deletions centrifuge-app/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ export function Root() {
subscanUrl={import.meta.env.REACT_APP_SUBSCAN_URL}
walletConnectId={import.meta.env.REACT_APP_WALLETCONNECT_ID}
showAdvancedAccounts={debugState.showAdvancedAccounts as any}
showBase={debugState.showBase as any}
showArbitrum={debugState.showArbitrum as any}
showTestNets={debugState.showTestNets as any}
>
<OnboardingAuthProvider>
Expand Down
17 changes: 12 additions & 5 deletions centrifuge-react/src/components/WalletProvider/SelectButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Shelf, Spinner, Text } from '@centrifuge/fabric'
import { BetaChip, Box, Shelf, Spinner, Text } from '@centrifuge/fabric'
import * as React from 'react'
import styled, { useTheme } from 'styled-components'
import type { State } from './types'
Expand All @@ -10,6 +10,7 @@ type SelectButtonProps = {
href?: string
disabled?: boolean
muted?: boolean
beta?: boolean
loading?: boolean
logo?: React.ReactNode
children: React.ReactNode
Expand Down Expand Up @@ -53,10 +54,11 @@ export function SelectButton({
disabled={disabled}
p={2}
border={0}
borderRadius="input"
borderRadius="10px"
textAlign="center"
backgroundColor={active ? 'backgroundSecondary' : 'backgroundPrimary'}
muted={muted}
position="relative"
>
<Content {...restProps} />
</Root>
Expand All @@ -76,10 +78,11 @@ export function SelectAnchor({
href={href}
target="_blank"
p={2}
borderRadius="input"
borderRadius="10px"
disabled={disabled}
backgroundColor={active ? 'backgroundSecondary' : 'backgroundPrimary'}
muted={muted}
position="relative"
>
<Content {...restProps} />
</Root>
Expand Down Expand Up @@ -122,13 +125,12 @@ export function Logo({
return <Icon size={size} />
}

function Content({ loading = false, logo, children, iconRight }: SelectButtonProps) {
function Content({ loading, beta, logo, children, iconRight }: SelectButtonProps) {
const { sizes } = useTheme()

return (
<>
{loading ? <Spinner size={sizes.iconRegular} /> : logo ? logo : <FallbackLogo />}

{!iconRight ? (
<Label>{children}</Label>
) : (
Expand All @@ -137,6 +139,11 @@ function Content({ loading = false, logo, children, iconRight }: SelectButtonPro
{iconRight}
</Shelf>
)}
{beta && (
<Box position="absolute" right={1} top={1}>
<BetaChip />
</Box>
)}
</>
)
}
Expand Down
15 changes: 4 additions & 11 deletions centrifuge-react/src/components/WalletProvider/WalletDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { useCentEvmChainId, useWallet, wallets } from './WalletProvider'
type Props = {
evmChains: EvmChains
showAdvancedAccounts?: boolean
showBase?: boolean
showArbitrum?: boolean
showTestNets?: boolean
}

Expand All @@ -41,16 +39,8 @@ const title = {
accounts: 'Choose account',
}

export function WalletDialog({
evmChains: allEvmChains,
showAdvancedAccounts,
showBase,
showArbitrum,
showTestNets,
}: Props) {
export function WalletDialog({ evmChains: allEvmChains, showAdvancedAccounts, showTestNets }: Props) {
const evmChains = Object.keys(allEvmChains)
.filter((chain) => (!showBase ? !['8453', '84531'].includes(chain) : true))
.filter((chain) => (!showArbitrum ? !['42161', '421613'].includes(chain) : true))
.filter((chain) => (!showTestNets ? !['5', '84531', '421613', '43113'].includes(chain) : true))
.reduce((obj, key) => {
obj[key] = allEvmChains[key]
Expand All @@ -71,6 +61,8 @@ export function WalletDialog({
substrate: { evmChainId },
} = ctx

const betaChains = [8453, 84531, 42161, 421613] // Base and Arbitrum

const getNetworkName = useGetNetworkName()

const isCentChainSelected = selectedNetwork === 'centrifuge' || selectedNetwork === evmChainId
Expand Down Expand Up @@ -155,6 +147,7 @@ export function WalletDialog({
onClick={() => showWallets(chainId)}
active={selectedNetwork === chainId}
muted={isMuted(chainId)}
beta={betaChains.includes(chainId)}
>
{info.name}
</SelectButton>
Expand Down
19 changes: 19 additions & 0 deletions fabric/src/components/BetaChip/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import css from '@styled-system/css'
import styled from 'styled-components'
import { Text } from '../Text'

export const BetaChip = styled(Text)(
css({
display: 'inline-block',
px: 1,
bg: 'statusPromote',
borderRadius: 20,
fontSize: '10px',
color: 'white',
whiteSpace: 'nowrap',
lineHeight: '15px',
})
)
BetaChip.defaultProps = {
children: 'Beta',
}
1 change: 1 addition & 0 deletions fabric/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './components/Accordion'
export * from './components/Banner'
export * from './components/BetaChip'
export * from './components/Box'
export * from './components/Button'
export * from './components/Card'
Expand Down
3 changes: 3 additions & 0 deletions fabric/src/theme/tokens/modeDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const statusInfo = '#006ef5'
const statusOk = '#74B634'
const statusWarning = '#a86500'
const statusCritical = '#d43F2b'
const statusPromote = '#f81071'

const darkColors = {
textPrimary: 'white',
Expand All @@ -28,11 +29,13 @@ const darkColors = {
statusOk,
statusWarning,
statusCritical,
statusPromote,
statusDefaultBg: 'transparent',
statusInfoBg: 'transparent',
statusOkBg: 'transparent',
statusWarningBg: 'transparent',
statusCriticalBg: 'transparent',
statusPromoteBg: 'transparent',

backgroundButtonPrimary: altairYellow,
backgroundButtonPrimaryFocus: altairYellow,
Expand Down
4 changes: 4 additions & 0 deletions fabric/src/theme/tokens/modeLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const statusInfo = '#1253ff'
const statusOk = '#519b10'
const statusWarning = '#ffc012'
const statusCritical = '#d43f2b'
const statusPromote = '#f81071'

const statusDefaultBg = `${grayScale[800]}14`
const statusInfoBg = '#1253ff14'
const statusOkBg = '#519b1014'
const statusWarningBg = '#ffc01214'
const statusCriticalBg = '#d43f2b14'
const statusPromoteBg = '#f8107114'

const lightColors = {
textPrimary: 'black',
Expand All @@ -34,11 +36,13 @@ const lightColors = {
statusOk,
statusWarning,
statusCritical,
statusPromote,
statusDefaultBg,
statusInfoBg,
statusOkBg,
statusWarningBg,
statusCriticalBg,
statusPromoteBg,

backgroundButtonPrimary: centrifugeBlue,
backgroundButtonPrimaryFocus: centrifugeBlue,
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/theme/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ResponsiveValue } from 'styled-system'

type Status = 'Default' | 'Info' | 'Ok' | 'Warning' | 'Critical'
type Status = 'Default' | 'Info' | 'Ok' | 'Warning' | 'Critical' | 'Promote'

// Colors

Expand Down

0 comments on commit 9308250

Please sign in to comment.