styled-components#ThemeContext TypeScript Examples
The following examples show how to use
styled-components#ThemeContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionPopup.tsx From cuiswap with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? <CheckCircle color={theme.green1} size={24} /> : <AlertCircle color={theme.red1} size={24} />}
</div>
<AutoColumn gap="8px">
<TYPE.body fontWeight={500}>{summary ?? 'Hash: ' + hash.slice(0, 8) + '...' + hash.slice(58, 65)}</TYPE.body>
<ExternalLink href={getEtherscanLink(chainId, hash, 'transaction')}>View on Etherscan</ExternalLink>
</AutoColumn>
</RowNoFlex>
)
}
Example #2
Source File: index.tsx From ecoleta with MIT License | 6 votes |
Header: React.FC = () => {
const { title } = useContext(ThemeContext);
const { toggleTheme } = useTheme();
return (
<Container>
<header>
{title === 'light' ? (
<img src={logo} alt="Ecoleta" />
) : (
<img src={logoDark} alt="Ecoleta" />
)}
<Toggle
checked={title === 'dark'}
onChange={toggleTheme}
className="toggle"
icons={{
checked: <FaMoon color="yellow" size={12} />,
unchecked: <FaSun color="yellow" size={12} />,
}}
/>
<nav>
<div>
<Link to="/create-point">
<strong className="text">Cadastrar novo ponto</strong>
<div className="icon">
<FiPlusSquare size={24} />
</div>
</Link>
</div>
</nav>
</header>
</Container>
);
}
Example #3
Source File: index.tsx From sybil-interface with GNU General Public License v3.0 | 6 votes |
export function SubmittedView({
children,
onDismiss,
hash,
}: {
children: any
onDismiss: () => void
hash: string | undefined
}): JSX.Element {
const theme = useContext(ThemeContext)
const { chainId } = useActiveWeb3React()
return (
<ConfirmOrLoadingWrapper>
<RowBetween>
<div />
<CloseIcon onClick={onDismiss} />
</RowBetween>
<ConfirmedIcon>
<ArrowUpCircle strokeWidth={0.5} size={90} color={theme.primary1} />
</ConfirmedIcon>
<AutoColumn gap="2rem" justify={'center'}>
{children}
{chainId && hash && (
<ExternalLink href={getEtherscanLink(chainId, hash, 'transaction')} style={{ marginLeft: '4px' }}>
<TYPE.subHeader>View transaction on Etherscan</TYPE.subHeader>
</ExternalLink>
)}
</AutoColumn>
</ConfirmOrLoadingWrapper>
)
}
Example #4
Source File: TransactionPopup.tsx From cheeseswap-interface with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.green1} size={24} />
) : (
<AlertCircle color={theme.colors.red1} size={24} />
)}
</div>
<AutoColumn gap="8px">
<TYPE.body fontWeight={700}>{summary ?? 'Hash: ' + hash.slice(0, 8) + '...' + hash.slice(58, 65)}</TYPE.body>
{chainId && <ExternalLink href={getEtherscanLink(chainId, hash, 'transaction')}>View on bscscan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #5
Source File: Apps.tsx From crust-apps with Apache License 2.0 | 6 votes |
function Apps ({ className = '' }: Props): React.ReactElement<Props> {
const { theme } = useContext<ThemeDef>(ThemeContext);
const { systemChain, systemName } = useApi();
const uiHighlight = useMemo(
() => getSystemChainColor(systemChain, systemName),
[systemChain, systemName]
);
return (
<>
<GlobalStyle uiHighlight={uiHighlight} />
<div className={`apps--Wrapper theme--${theme} ${className}`}>
<Menu />
<AccountSidebar>
<Signer>
<Content />
</Signer>
<ConnectingOverlay />
<div id={PORTAL_ID} />
</AccountSidebar>
</div>
<WarmUp />
</>
);
}
Example #6
Source File: Container.tsx From PolkaBridge-Farming with MIT License | 6 votes |
Container: React.FC<ContainerProps> = ({ children, size = 'md' }) => {
const { siteWidth } = useContext<{ siteWidth: number }>(ThemeContext)
let width: number
switch (size) {
case 'sm':
width = siteWidth / 2
break
case 'md':
width = siteWidth * 2 / 3
break
case 'lg':
default:
width = siteWidth
}
return (
<StyledContainer width={width}>
{children}
</StyledContainer>
)
}
Example #7
Source File: Container.tsx From polkabridge-launchpad with MIT License | 6 votes |
Container: React.FC<ContainerProps> = ({ children, size = 'md' }) => {
const { siteWidth } = useContext<{ siteWidth: number }>(ThemeContext)
let width: number
switch (size) {
case 'sm':
width = siteWidth / 2
break
case 'md':
width = (siteWidth * 2) / 3
break
case 'lg':
default:
width = siteWidth
}
return <StyledContainer width={width}>{children}</StyledContainer>
}
Example #8
Source File: index.tsx From dyp with Do What The F*ck You Want To Public License | 6 votes |
export function SubmittedView({
children,
onDismiss,
hash
}: {
children: any
onDismiss: () => void
hash: string | undefined
}) {
const theme = useContext(ThemeContext)
const { chainId } = useActiveWeb3React()
return (
<ConfirmOrLoadingWrapper>
<RowBetween>
<div />
<CloseIcon onClick={onDismiss} />
</RowBetween>
<ConfirmedIcon>
<ArrowUpCircle strokeWidth={0.5} size={90} color={theme.primary1} />
</ConfirmedIcon>
<AutoColumn gap="100px" justify={'center'}>
{children}
{chainId && hash && (
<ExternalLink href={getEtherscanLink(chainId, hash, 'transaction')} style={{ marginLeft: '4px' }}>
<TYPE.subHeader>View transaction on Etherscan</TYPE.subHeader>
</ExternalLink>
)}
</AutoColumn>
</ConfirmOrLoadingWrapper>
)
}
Example #9
Source File: Spacer.tsx From glide-frontend with GNU General Public License v3.0 | 6 votes |
Spacer: React.FC<SpacerProps> = ({ size = 'md' }) => {
const { spacing } = useContext(ThemeContext)
let s: number
switch (size) {
case 'lg':
s = spacing[6]
break
case 'sm':
s = spacing[2]
break
case 'md':
default:
s = spacing[4]
}
return <StyledSpacer size={s} />
}
Example #10
Source File: TransactionPopup.tsx From goose-frontend-amm with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary,
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.success} size={24} />
) : (
<AlertCircle color={theme.colors.failure} size={24} />
)}
</div>
<AutoColumn gap="8px">
<Body fontWeight={500}>{summary ?? `Hash: ${hash.slice(0, 8)}...${hash.slice(58, 65)}`}</Body>
{chainId && <ExternalLink href={getEtherscanLink(chainId, hash, 'transaction')}>View on bscscan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #11
Source File: index.tsx From vagasExplorer with MIT License | 6 votes |
Header: React.FC<HeaderProps> = ({ isLink, toggleTheme }) => {
const { colors, title } = useContext(ThemeContext);
return (
<S.Container>
<S.LogoContainer>
<S.LogoImage>
<Logo isDark={title === 'dark'} />
</S.LogoImage>
<h1>vagasExplorer</h1>
</S.LogoContainer>
<Switch
onChange={toggleTheme}
checked={title === 'dark'}
checkedIcon={false}
uncheckedIcon={false}
height={10}
width={40}
handleDiameter={20}
offColor={shade(0.15, colors.primary)}
onColor={colors.secundary}
/>
<S.ActionContainer>
{isLink && (
<Link to={isLink}>
<S.IconBack />
Voltar
</Link>
)}
</S.ActionContainer>
</S.Container>
);
}
Example #12
Source File: TransactionPopup.tsx From mozartfinance-swap-interface with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary,
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.success} size={24} />
) : (
<AlertCircle color={theme.colors.failure} size={24} />
)}
</div>
<AutoColumn gap="8px">
<Text>{summary ?? `Hash: ${hash.slice(0, 8)}...${hash.slice(58, 65)}`}</Text>
{chainId && <ExternalLink href={getBscScanLink(chainId, hash, 'transaction')}>View on bscscan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #13
Source File: DownloadButton.tsx From calendar-hack with MIT License | 6 votes |
DownloadButton: React.FC<Props> = ({ downloadHandler }) => {
const themeContext = useContext(ThemeContext);
const onClick = (e: React.MouseEvent<HTMLElement>) => {
downloadHandler();
}
return (
<IconContext.Provider value={{ color: themeContext.colors.buttonIcons }}>
<Root>
<Button onClick={onClick}>
Download iCal
</Button>
</Root>
</IconContext.Provider>
)
}
Example #14
Source File: TransactionPopup.tsx From pancake-swap-exchange-testnet with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary,
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.success} size={24} />
) : (
<AlertCircle color={theme.colors.failure} size={24} />
)}
</div>
<AutoColumn gap="8px">
<Text>{summary ?? `Hash: ${hash.slice(0, 8)}...${hash.slice(58, 65)}`}</Text>
{chainId && <ExternalLink href={getBscScanLink(chainId, hash, 'transaction')}>View on bscscan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #15
Source File: TransactionPopup.tsx From pancake-swap-testnet with MIT License | 6 votes |
export default function TransactionPopup({
hash,
success,
summary,
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.success} size={24} />
) : (
<AlertCircle color={theme.colors.failure} size={24} />
)}
</div>
<AutoColumn gap="8px">
<Text>{summary ?? `Hash: ${hash.slice(0, 8)}...${hash.slice(58, 65)}`}</Text>
{chainId && <ExternalLink href={getBscScanLink(chainId, hash, 'transaction')}>View on bscscan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #16
Source File: ProjectPicker.tsx From kratos-selfservice-ui-react-native with Apache License 2.0 | 6 votes |
ProjectPicker = () => {
const { project, setProject } = useContext(ProjectContext)
const [inner, setInner] = useState(project)
const theme = useContext(ThemeContext)
return (
<StyledCard>
<View testID={`field/project`}>
<StyledTextInput
testID="project-selector"
value={inner}
onChangeText={setInner}
onEndEditing={() => {
setProject(inner)
}}
/>
<Subtitle>
Currently using project "{project}". Type your project slug here to
use this app with your project. You do not have a Ory Project yet?{' '}
<StyledText
style={{ color: theme.primary60 }}
onPress={open('https://console.ory.sh/')}
>
Create one for free!
</StyledText>
</Subtitle>
</View>
</StyledCard>
)
}
Example #17
Source File: TransactionPopup.tsx From panther-frontend-dex with GNU General Public License v3.0 | 6 votes |
export default function TransactionPopup({
hash,
success,
summary,
}: {
hash: string
success?: boolean
summary?: string
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
return (
<RowNoFlex>
<div style={{ paddingRight: 16 }}>
{success ? (
<CheckCircle color={theme.colors.success} size={24} />
) : (
<AlertCircle color={theme.colors.failure} size={24} />
)}
</div>
<AutoColumn gap="8px">
<Body fontWeight={500}>{summary ?? `Hash: ${hash.slice(0, 8)}...${hash.slice(58, 65)}`}</Body>
{chainId && <ExternalLink href={getBscScanLink(chainId, hash, 'transaction')}>View on BscScan</ExternalLink>}
</AutoColumn>
</RowNoFlex>
)
}
Example #18
Source File: index.tsx From subscan-multisig-react with Apache License 2.0 | 6 votes |
function ModalBase(props: ModalProps): React.ReactElement<ModalProps> {
const { theme } = useContext<ThemeDef>(ThemeContext);
const { children, className = '', header, open = true } = props;
return (
<SUIModal {...props} className={`theme--${theme} ui--Modal ${className}`} header={undefined} open={open}>
{header && (
<div className="header">
<h1>{header}</h1>
</div>
)}
{children}
</SUIModal>
);
}
Example #19
Source File: index.tsx From sushiswap-exchange with GNU General Public License v3.0 | 6 votes |
export function TransactionErrorContent({ message, onDismiss }: { message: string; onDismiss: () => void }) {
const theme = useContext(ThemeContext)
return (
<Wrapper>
<Section>
<RowBetween>
<Text fontWeight={500} fontSize={20}>
Error
</Text>
<CloseIcon onClick={onDismiss} />
</RowBetween>
<AutoColumn style={{ marginTop: 20, padding: '2rem 0' }} gap="24px" justify="center">
<AlertTriangle color={theme.red1} style={{ strokeWidth: 1.5 }} size={64} />
<Text fontWeight={500} fontSize={16} color={theme.red1} style={{ textAlign: 'center', width: '85%' }}>
{message}
</Text>
</AutoColumn>
</Section>
<BottomSection gap="12px">
<ButtonPrimary onClick={onDismiss}>Dismiss</ButtonPrimary>
</BottomSection>
</Wrapper>
)
}
Example #20
Source File: index.tsx From luaswap-interface with GNU General Public License v3.0 | 6 votes |
export default function Container({ children, size = 'md' }: ContainerProps) {
const { siteWidth } = useContext(ThemeContext)
let width: number
switch (size) {
case 'sm':
width = siteWidth / 2
break
case 'md':
width = (siteWidth * 2) / 3
break
case 'lg':
default:
width = siteWidth
}
return <StyledContainer width={width}>{children}</StyledContainer>
}
Example #21
Source File: index.tsx From cuiswap with GNU General Public License v3.0 | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
event => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<TYPE.black color={theme.text2} fontWeight={500} fontSize={14}>
Recipient
</TYPE.black>
{address && (
<ExternalLink href={getEtherscanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on Etherscan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}
Example #22
Source File: index.tsx From sybil-interface with GNU General Public License v3.0 | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange,
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}): JSX.Element {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
(event) => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<TYPE.black color={theme.text2} fontWeight={500} fontSize={14}>
Delegate Address
</TYPE.black>
{address && chainId && (
<ExternalLink href={getEtherscanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on Etherscan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}
Example #23
Source File: index.tsx From cheeseswap-interface with GNU General Public License v3.0 | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
event => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<TYPE.black color={theme.colors.text2} fontWeight={700} fontSize={14}>
Recipient
</TYPE.black>
{address && chainId && (
<ExternalLink href={getEtherscanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on bscscan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}
Example #24
Source File: index.tsx From dyp with Do What The F*ck You Want To Public License | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
event => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<TYPE.black color={theme.text2} fontWeight={500} fontSize={14}>
Recipient
</TYPE.black>
{address && chainId && (
<ExternalLink href={getEtherscanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on Etherscan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}
Example #25
Source File: useTheme.ts From limit-orders-lib with GNU General Public License v3.0 | 5 votes |
export default function useTheme(): DefaultTheme {
return useContext(ThemeContext);
}
Example #26
Source File: index.tsx From goose-frontend-amm with GNU General Public License v3.0 | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange,
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
(event) => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<Black color={theme.colors.textSubtle} fontWeight={500} fontSize={14}>
Recipient
</Black>
{address && chainId && (
<ExternalLink href={getEtherscanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on bscscan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}
Example #27
Source File: LongPressButton.tsx From calendar-hack with MIT License | 5 votes |
LongPressButton: React.FC<Props> = ({ activeCb, doneCb, type }) => {
const timer = useCallback(
() => {
timerID = window.setInterval(function doCb() {
activeCb();
}, 100);
},
[activeCb],
);
function pressingDown(e: React.MouseEvent | React.TouchEvent) {
timer();
console.log(e);
e.preventDefault();
}
function notPressingDown(e: React.MouseEvent | React.TouchEvent) {
// Stop the timer
if (undefined !== timerID) {
clearInterval(timerID);
}
doneCb();
}
// create element ref
const innerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (innerRef && innerRef.current) {
const div = innerRef.current;
const cancel = (event: TouchEvent) => event.preventDefault();
div.addEventListener('touchstart', cancel, { passive: false });
div.addEventListener('touchend', cancel, { passive: false });
return () => {
div.removeEventListener('touchend', cancel);
}
}
}, []);
const themeContext = useContext(ThemeContext);
return (
<IconContext.Provider value={{ color: themeContext.colors.buttonIcons, size: "1.5em" }}>
<Root ref={innerRef} onMouseDown={pressingDown} onMouseUp={notPressingDown} onMouseLeave={notPressingDown}
onTouchStart={pressingDown} onTouchEnd={notPressingDown}>
{type === 'plus' && <FaPlus style={{ verticalAlign: 'middle' }} />}
{type === 'minus' && <FaMinus style={{ verticalAlign: 'middle' }} />}
</Root>
</IconContext.Provider>
)
}
Example #28
Source File: PopupItem.tsx From pancake-swap-exchange-testnet with GNU General Public License v3.0 | 5 votes |
export default function PopupItem({
removeAfterMs,
content,
popKey
}: {
removeAfterMs: number | null
content: PopupContent
popKey: string
}) {
const removePopup = useRemovePopup()
const removeThisPopup = useCallback(() => removePopup(popKey), [popKey, removePopup])
useEffect(() => {
if (removeAfterMs === null) return undefined
const timeout = setTimeout(() => {
removeThisPopup()
}, removeAfterMs)
return () => {
clearTimeout(timeout)
}
}, [removeAfterMs, removeThisPopup])
const theme = useContext(ThemeContext)
let popupContent
if ('txn' in content) {
const {
txn: { hash, success, summary }
} = content
popupContent = <TransactionPopup hash={hash} success={success} summary={summary} />
} else if ('listUpdate' in content) {
const {
listUpdate: { listUrl, oldList, newList, auto }
} = content
popupContent = <ListUpdatePopup popKey={popKey} listUrl={listUrl} oldList={oldList} newList={newList} auto={auto} />
}
const faderStyle = useSpring({
from: { width: '100%' },
to: { width: '0%' },
config: { duration: removeAfterMs ?? undefined }
})
return (
<Popup>
<StyledClose color={theme.colors.textSubtle} onClick={removeThisPopup} />
{popupContent}
{removeAfterMs !== null ? <AnimatedFader style={faderStyle} /> : null}
</Popup>
)
}
Example #29
Source File: index.tsx From panther-frontend-dex with GNU General Public License v3.0 | 5 votes |
export default function AddressInputPanel({
id,
value,
onChange,
}: {
id?: string
// the typed string value
value: string
// triggers whenever the typed value changes
onChange: (value: string) => void
}) {
const { chainId } = useActiveWeb3React()
const theme = useContext(ThemeContext)
const { address, loading, name } = useENS(value)
const handleInput = useCallback(
(event) => {
const input = event.target.value
const withoutSpaces = input.replace(/\s+/g, '')
onChange(withoutSpaces)
},
[onChange]
)
const error = Boolean(value.length > 0 && !loading && !address)
return (
<InputPanel id={id}>
<ContainerRow error={error}>
<InputContainer>
<AutoColumn gap="md">
<RowBetween>
<Black color={theme.colors.textSubtle} fontWeight={500} fontSize={14}>
Recipient
</Black>
{address && chainId && (
<ExternalLink href={getBscScanLink(chainId, name ?? address, 'address')} style={{ fontSize: '14px' }}>
(View on BscScan)
</ExternalLink>
)}
</RowBetween>
<Input
className="recipient-address-input"
type="text"
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
placeholder="Wallet Address or ENS name"
error={error}
pattern="^(0x[a-fA-F0-9]{40})$"
onChange={handleInput}
value={value}
/>
</AutoColumn>
</InputContainer>
</ContainerRow>
</InputPanel>
)
}