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

feat(widget): hide bridge info #4992

Merged
merged 2 commits into from
Oct 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import styled from 'styled-components/macro'

import { useDarkModeManager } from 'legacy/state/user/hooks'

import { useInjectedWidgetParams } from 'modules/injectedWidget'

const HideSmall = styled.span`
${Media.upToSmall()} {
display: none;
Expand Down Expand Up @@ -61,7 +63,9 @@ const StyledArrowUpRight = styled(ArrowUpRight)`

const ContentWrapper = styled.div<{ chainId: NetworkAlertChains; darkMode: boolean; logoUrl: string }>`
background: var(${UI.COLOR_PAPER_DARKER});
transition: color var(${UI.ANIMATION_DURATION}) ease-in-out, background var(${UI.ANIMATION_DURATION}) ease-in-out; // MOD
transition:
color var(${UI.ANIMATION_DURATION}) ease-in-out,
background var(${UI.ANIMATION_DURATION}) ease-in-out; // MOD
border-radius: 20px;
display: flex;
flex-direction: row;
Expand All @@ -88,7 +92,9 @@ const ContentWrapper = styled.div<{ chainId: NetworkAlertChains; darkMode: boole
color: inherit;
stroke: currentColor;
text-decoration: none;
transition: transform var(${UI.ANIMATION_DURATION}) ease-in-out, stroke var(${UI.ANIMATION_DURATION}) ease-in-out,
transition:
transform var(${UI.ANIMATION_DURATION}) ease-in-out,
stroke var(${UI.ANIMATION_DURATION}) ease-in-out,
color var(${UI.ANIMATION_DURATION}) ease-in-out;
}

Expand Down Expand Up @@ -136,7 +142,9 @@ export function NetworkAlert() {

const theme = useTheme()

if (!shouldShowAlert(chainId) || !isActive) {
const { hideBridgeInfo } = useInjectedWidgetParams()

if (!shouldShowAlert(chainId) || !isActive || hideBridgeInfo) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function useWidgetParams(configuratorState: ConfiguratorState): CowSwapWi
standaloneMode,
disableToastMessages,
disableProgressBar,
hideBridgeInfo,
} = configuratorState

const themeColors = {
Expand Down Expand Up @@ -84,6 +85,7 @@ export function useWidgetParams(configuratorState: ConfiguratorState): CowSwapWi
recipient: partnerFeeRecipient,
}
: undefined,
hideBridgeInfo,
}

return params
Expand Down
17 changes: 14 additions & 3 deletions apps/widget-configurator/src/app/configurator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ export function Configurator({ title }: { title: string }) {
const firstToast = toasts?.[0]

const [disableProgressBar, setDisableProgressBar] = useState<boolean>(false)
const toggleDisableProgressBar = useCallback(() => {
setDisableProgressBar((curr) => !curr)
}, [])
const toggleDisableProgressBar = useCallback(() => setDisableProgressBar((curr) => !curr), [])

const [hideBridgeInfo, setHideBridgeInfo] = useState<boolean | undefined>(false)
const toggleHideBridgeInfo = useCallback(() => setHideBridgeInfo((curr) => !curr), [])

const LINKS = [
{ icon: <CodeIcon />, label: 'View embed code', onClick: () => handleDialogOpen() },
Expand Down Expand Up @@ -161,6 +162,7 @@ export function Configurator({ title }: { title: string }) {
standaloneMode,
disableToastMessages,
disableProgressBar,
hideBridgeInfo,
}

const computedParams = useWidgetParams(state)
Expand Down Expand Up @@ -283,6 +285,7 @@ export function Configurator({ title }: { title: string }) {
<FormControlLabel value="true" control={<Radio />} label="Dapp mode" />
</RadioGroup>
</FormControl>

<FormControl component="fieldset">
<FormLabel component="legend">Progress bar:</FormLabel>
<RadioGroup row aria-label="mode" name="mode" value={disableProgressBar} onChange={toggleDisableProgressBar}>
Expand All @@ -291,6 +294,14 @@ export function Configurator({ title }: { title: string }) {
</RadioGroup>
</FormControl>

<FormControl component="fieldset">
<FormLabel component="legend">Hide bridge info:</FormLabel>
<RadioGroup row aria-label="mode" name="mode" value={hideBridgeInfo} onChange={toggleHideBridgeInfo}>
<FormControlLabel value="false" control={<Radio />} label="Show bridge info" />
<FormControlLabel value="true" control={<Radio />} label="Hide bridge info" />
</RadioGroup>
</FormControl>

{isDrawerOpen && (
<Fab
size="small"
Expand Down
1 change: 1 addition & 0 deletions apps/widget-configurator/src/app/configurator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export interface ConfiguratorState {
standaloneMode: boolean
disableToastMessages: boolean
disableProgressBar: boolean
hideBridgeInfo: boolean | undefined
}
5 changes: 5 additions & 0 deletions libs/widget-lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ export interface CowSwapWidgetParams {
*/
hideNetworkSelector?: boolean

/**
* Option to hide bridge info
*/
hideBridgeInfo?: boolean

/**
* Defines the widget mode.
* - `true` (standalone mode): The widget is standalone, so it will use its own Ethereum provider. The user can connect from within the widget.
Expand Down
Loading