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

Add new tip dialog user interface #6626

Merged
merged 2 commits into from
Oct 16, 2020
Merged

Add new tip dialog user interface #6626

merged 2 commits into from
Oct 16, 2020

Conversation

zenparsing
Copy link
Collaborator

@zenparsing zenparsing commented Sep 11, 2020

Resolves brave/brave-browser#11361
Resolves brave/brave-browser#11393

Submitter Checklist:

Test Plan:

(All tests should be executed for both verified and unverified publishers.)

Case 1: One-time tipping

  • Navigate to a publisher page.
  • Open the Rewards panel and click "Send a tip".
  • Verify that banner matches designs for one time tip flow.
    • NOTE: Credit card option is not currently displayed.
  • Verify banner functionality (see below).
  • Verify tipping options:
    • If custom one-time tipping options have been set for the publisher, then those amounts are displayed
    • Otherwise, a default set of amounts are displayed.
  • Verify that "add funds" link is displayed if the user does not have sufficient BAT in their wallet.
  • Select a valid amount and click "Send Tip".
  • Verify tip completion display matches designs.
  • Verify that tip was successfully sent.
  • Click the "tweet" button.
  • Verify that a new tab is opened to twitter with the correct messaging.

Case 2: Setting a monthly contribution

  • Ensure that a monthly contribution has not been set for a publisher.
  • Open the Rewards panel and click the monthly contribution "Set" button.
  • Verify that "Monthly" is the selected tip kind.
  • Verify that monthly tip options are displayed.
  • Select a tip option and click the submit button.
  • Verify that tip completion display matches designs.
  • Verify that monthly contribution has been correctly set.

Case 3: One-time tipping with existing monthly contribution

  • Ensure that a monthly contribution has been set for a publisher.
  • Open the Rewards panel and click "Send a tip".
  • Verify that an asterisk is displayed next to the "Monthly" option and the correct messaging is displayed about the "tip kind" selector.
  • Click the "Monthly" option.
  • Verify that "cancel/change amount" display matches designs.
  • Verify that the asterisk and corresponding messaging has been hidden.
  • Test "cancel" flow:
    • Click the "Cancel" button.
    • Verify that the confirmation display matches designs.
    • Click the "Confirm" button.
    • Verify that display matches design.
    • Verify that monthly contribution has been removed.
  • Test "change amount" flow:
    • Click the "Change amount" button.
    • Verify that monthly tip options are displayed.
    • Select a tip option and click the submit button.
    • Verify that tip completion display matches designs.
    • Verify that monthly contribution has been removed.

Case 3: Inline tipping

  • Navigate to a verified publisher page on twitter.
  • Click an inline tipping button.
  • Verify that dialog matches designs for inline tipping flow.
  • Verify that social media post is correctly displayed.
  • Verify that monthly tipping option is not displayed.
  • Verify that one time tip is successfully processed.

Banner functionality:

  • Background image:
  • Logo:
    • Custom logo is displayed if available
    • Otherwise, the first letter of the publisher name is displayed
    • If the publisher is verified or connected, a checkmark is displayed
    • Otherwise, an x-mark is displayed
  • Unverified notice:
    • Unverified notice is displayed if the publisher is not verified.
  • Title (site tipping only):
    • If a custom title has been set, the custom title is displayed
    • Otherwise, a default title (e.g. "Welcome!") is displayed.
  • Description (site tipping only):
    • If a custom message has been set, the custom message is displayed
    • Otherwise, a default message is displayed.
  • Social media post (twitter/reddit inline tipping only):
    • The social media post text is displayed in a box.
    • The post date or relative time is displayed in the box header.
    • The correct social media icon is displayed in the box header.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@zenparsing zenparsing self-assigned this Sep 11, 2020
@zenparsing zenparsing force-pushed the ksmith-tip-dialog branch 3 times, most recently from 5d33e22 to c0eeb37 Compare September 11, 2020 20:12
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

For events, please call FireWebUIListener('event-name', data). We should not add any more places where we hope JS function names exist at the time.

In JS, you would subscribe to the event with

window.cr.addWebUIListener('event-name', function(data) { ... })

Alternatively just give this WebUI access to the chrome.braveRewards API since we're not showing this page on Android.

@zenparsing zenparsing force-pushed the ksmith-tip-dialog branch 14 times, most recently from 7f42a7d to e7ec8b9 Compare September 28, 2020 03:40
@NejcZdovc NejcZdovc requested a review from emerick September 28, 2020 16:56
@zenparsing zenparsing requested a review from petemill September 28, 2020 20:45
Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

  1. Probably would be good to add index.tsx in components folder so that we can just do this
import { PublisherBanner, TipForm } from './index'

instead of

import { PublisherBanner } from './publisher_banner'
import { TipForm } from './tip_form'
  1. we should add OnUnblindedTokensReady observer, so that if you have banner open and you claim promotion in another tab we fetch balance in open banner

  2. probably this should be 3 decimal points as well based on the fact that we have BAT with 3 points in every other place
    image

  3. page favicon is not shown for verified publisher
    image

  4. border shouldn't be shown
    image
    image

  5. 3 deciaml points for the amount
    image
    image

  6. X here should probably just switch back to defaul tip screen and not hide banner
    image

  7. probably it would be good to add some shadow/border around logo
    image

  8. remove duplicated username in the title for inline tipping. It's listed bellow as well and we don't have it regular tip flow
    image
    image
    image

browser/ui/webui/brave_tip_ui.cc Show resolved Hide resolved
browser/ui/webui/brave_tip_ui.cc Outdated Show resolved Hide resolved
browser/ui/webui/brave_tip_ui.cc Show resolved Hide resolved
browser/ui/webui/brave_tip_ui.cc Outdated Show resolved Hide resolved
components/brave_rewards/resources/tip/components/app.tsx Outdated Show resolved Hide resolved
@zenparsing
Copy link
Collaborator Author

Working on one more potential design change to better deal with custom banner backgrounds that are different sizes.

Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

  1. clicking add funds doesn't do anything and return error in console [3005:775:1012/145517.242542:ERROR:CONSOLE(0)] "Not allowed to load local resource: brave://rewards/#add-funds", source: chrome://tip/ (0)
    image

@NejcZdovc NejcZdovc dismissed their stale review October 12, 2020 13:03

is not working correctly on master either. Even though that it opens new window in which you can see rewards page nothing happens. Should be fixed with new flow for ads opt in that will be part of follow up

@NejcZdovc NejcZdovc added this to the 1.17.x - Nightly milestone Oct 12, 2020
export function injectThemeVariables (element: HTMLElement) {
for (const [key, value] of Object.entries(defaultTheme.color)) {
element.style.setProperty(`--brave-color-${key}`, String(value))
}
Copy link
Member

Choose a reason for hiding this comment

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

This is great.

  1. Could you put it in components/common/ so that we can use it for other UI. I for certain would.

  2. I'm not sure that we should be using defaultTheme directly. We should be ascertaining what the current theme is based on whether we're in light or dark mode, and then switching the theme (and replacing the variable values) when the user selected theme changes. We used to have elaborate listeners, but I think these days we can use window.matchMedia('(prefers-color-scheme: dark)') and put a listener on that. The idea is that you can either use the default dark and light themes, or subclass them and make specific overrides for each for your specific UI, if applicable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving this out so that other UIs can use it was part of the plan (hope?), but I think we should do it as a follow-on, so that we'll have a bit more time to think about how to generalize it properly. We should be able to easily migrate the code in here to use a helper that we promote to "common".

Really interesting point about matchMedia!

@zenparsing
Copy link
Collaborator Author

@petemill I've updated the "tip completed" animation gif - it's been reduced from 1.4MB to ~600kb.

@zenparsing
Copy link
Collaborator Author

CI failure on "SonarCloud Code Analysis" is due to the tip dialog HTML page not have a "lang" attribute on the html tag, but the "lang" attribute is set correctly for WebUI via:

<html i18n-values="dir:textdirection;lang:language">

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM, one minor nit.

components/resources/brave_components_strings.grd Outdated Show resolved Hide resolved
@zenparsing zenparsing force-pushed the ksmith-tip-dialog branch 2 times, most recently from 1abac91 to cb1324e Compare October 13, 2020 20:45
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

This is awesome. Thanks for bringing some new ideas to code organization and both state and API management. Looking forward to sharing and evolving some of these.

Just some minor accessibility feedback.
And needs a test plan.

But 1 issue that's preventing me approving is that nothing is happening when I click "Add funds" if I try to tip an amount higher than I have.

  • Clean profile
  • Visit petemill.com (or any site that has 100BAT option $$$)
  • Choose 100BAT
  • Click Add Funds
  • Observe nothing happens

- Gif bundling is required for updated rewards tip dialog designs.
- Webpack was previously bundling a polyfill for Node's stream module
  due to a detected dependency in "styled-components".
- Removed unused variables.
@NejcZdovc
Copy link
Contributor

@petemill add funds on master doesn't do anything either. This will be fixed in brave/brave-browser#12138 when we add new flows

@zenparsing zenparsing requested a review from a team as a code owner October 15, 2020 22:10
@zenparsing
Copy link
Collaborator Author

@petemill The "add funds" link was pointed to a "brave://" url which was blocked. Changing it to a "chrome://" url works and matches the behavior on master (it opens the rewards page).

@zenparsing zenparsing requested a review from petemill October 15, 2020 22:14
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Nice work. Thanks for addressing feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Desktop] Implement design for tipping banner Remove node "stream" shim from webui webpack bundles
4 participants