Skip to content

feat(trade): display Limit orders promo banner in trading widgets#5325

Merged
fairlighteth merged 18 commits intodevelopfrom
feat/limit-ui-promo-banner
Jan 24, 2025
Merged

feat(trade): display Limit orders promo banner in trading widgets#5325
fairlighteth merged 18 commits intodevelopfrom
feat/limit-ui-promo-banner

Conversation

@fairlighteth
Copy link
Copy Markdown
Contributor

@fairlighteth fairlighteth commented Jan 22, 2025

Add Limit Orders Promotional Banner Across Trading Modes

Overview

Added a new promotional banner for limit orders that appears across various trading modes (Swap, Limit, TWAP, and Yield). The banner highlights new limit order features and can be dismissed by users, with the dismissal state persisted in local storage.

Screenshot 2025-01-22 at 17 11 28

Key Changes

1. Feature Flag Implementation

  • Added SHOW_LIMIT_ORDERS_PROMO feature flag to control the banner's visibility globally
  • Banner respects both the feature flag and user's dismissal state
  • ⚠️ Important: Feature flag is currently implemented as a hardcoded constant (true), deliberately bypassing the LaunchDarkly feature flag system (from useFeatureFlags hook) for initial testing

2. Banner Component Updates

  • Created LimitOrdersPromoBanner pure component with:
    • Bullet points highlighting new limit order features
    • CTA button to navigate to limit orders
    • Dismissible via close button or "Maybe next time" link
    • Conditional rendering of "Maybe next time" link based on current tab
  • Added container component to handle:
    • Dismissal state management using limitOrdersPromoDismissedAtom
    • Navigation to limit orders page
    • Prop management for child components

3. Integration Across Trading Modes

  • Swap Mode:

    • Added banner to TradeWidgetForm
    • Ensured regular UI is visible when banner is dismissed
  • Limit Orders Mode:

    • Added banner with isLimitOrdersTab={true}
    • Hides "Maybe next time" link in this mode
    • Shows regular UI content when dismissed
  • TWAP/Advanced Orders Mode:

    • Added banner with isLimitOrdersTab={false}
    • Shows full banner with all elements
    • Maintains existing unlock screen behavior
  • Yield Mode:

    • Added banner with isLimitOrdersTab={false}
    • Integrated with existing widget structure
    • Preserves vampire attack banner logic

4. UI/UX Improvements

  • Banner takes precedence over unlock screens when feature flag is enabled
  • Consistent dismissal behavior across all modes
  • Smooth transition between banner and regular UI content
  • Maintains existing widget functionality when banner is dismissed

5. State Management

  • Implemented limitOrdersPromoDismissedAtom for persistent dismissal state
  • Proper state handling for feature flag and dismissal combinations
  • Consistent state management across all trading modes

Testing Notes

  • Verify banner appears correctly in all trading modes
  • Check dismissal persistence works across page reloads
  • Ensure proper navigation when clicking CTA button
  • Verify "Maybe next time" link only appears in appropriate contexts
  • Test interaction with unlock screens and other UI elements

Technical Debt

  • Removed debug console logs
  • Maintained consistent prop passing patterns
  • Cleaned up unused imports and variables

Future Work

  • Replace hardcoded SHOW_LIMIT_ORDERS_PROMO constant with LaunchDarkly feature flag
  • Integrate with useFeatureFlags hook for proper feature flag management

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Jan 24, 2025 4:07pm
explorer-dev ✅ Ready (Inspect) Visit Preview Jan 24, 2025 4:07pm
swap-dev ✅ Ready (Inspect) Visit Preview Jan 24, 2025 4:07pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2025 4:07pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2025 4:07pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2025 4:07pm

Copy link
Copy Markdown
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, are these text final. They felt a bit long. I was thinking sth like:

Limit Order just got better
We heard you! here are some features you've asked for:

  • Lock/unlock price for finer control
  • Set your price in USD or tokens
  • Personalise your interface
  • Estimate fill price estimation before placing the order
  • More spacious, and enhanced design!

Comment thread apps/cowswap-frontend/src/common/containers/LimitOrdersPromoBanner/index.tsx Outdated
const rateInfoParams = useRateInfoParams(inputCurrencyAmount, outputCurrencyAmount)
const widgetActions = useLimitOrdersWidgetActions()
const isWrapOrUnwrap = useIsWrapOrUnwrap()
const { chainId: _chainId, account: _account } = useWalletInfo()
Copy link
Copy Markdown
Collaborator

@shoom3301 shoom3301 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those variables look unused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and removed some more unused.

Copy link
Copy Markdown
Collaborator

@shoom3301 shoom3301 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this solution should be different.
The new banner is supposed to be a part of modules/trade or modules/tradeWidgetAddons and be injected in TradeWidgetForm component.
Following this way we can avoid multiple adding of the banner in different places.

Copy link
Copy Markdown
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fairlighteth , great, thank you!
However, some issues:

  1. I cannot check cases related to the 'switched off flag' (and there is no such flag in the launchdarkly)

  2. Hooks tab appears to be abandoned with this change
    hoks with banner

  3. I notice, that when I dismiss (press on later) then navigate to the Limit orders page, or press on the 'place limit order' button, then refresh the page, the banner may blinks (1 time). Might it be possible to fix it?

  4. Should we show this banner in the widget?
    image

import { TradeWidgetUpdaters } from './TradeWidgetUpdaters'
import { TradeWidgetProps } from './types'

import { useTradeFlowContext } from '../../../limitOrders/hooks/useTradeFlowContext'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trade module cannot depend on limitOrders module

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it in limit orders widget

Copy link
Copy Markdown
Collaborator

@shoom3301 shoom3301 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…otocol/cowswap into feat/limit-ui-promo-banner

# Conflicts:
#	apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/index.tsx
@shoom3301
Copy link
Copy Markdown
Collaborator

@elena-zh I know, there is a new skipLockScreen key in URL, just ignore it...

@shoom3301 shoom3301 changed the title Add Limit Orders Promotional Banner Across Trading Modes feat(trade): display Limit orders promotional banner across trading modes Jan 24, 2025
@shoom3301 shoom3301 changed the title feat(trade): display Limit orders promotional banner across trading modes feat(trade): display Limit orders promo banner in trading widgets Jan 24, 2025
@elena-zh
Copy link
Copy Markdown
Contributor

elena-zh commented Jan 24, 2025

I see an 'old' unlock screen on Limit orders page when I close the new one (the flag is ON)
image

Reproducible when:

  1. I'm no TWAP
  2. I press on the 'Maybe next time'
  3. Then navigate to the limit order page

@alfetopito
Copy link
Copy Markdown
Collaborator

I see an 'old' unlock screen on Limit orders page when I close the new one (the flag is ON) image

Reproducible when:

1. I'm no TWAP

2. I press on the 'Maybe next time'

3. Then navigate to the limit order page

If that's the only problem left, let's merge it and address it in another PR

@fairlighteth fairlighteth merged commit 0fe6ed5 into develop Jan 24, 2025
@fairlighteth fairlighteth deleted the feat/limit-ui-promo-banner branch January 24, 2025 16:56
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants