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

Allow fractional tipping amounts in the tip dialog #8404

Merged
merged 1 commit into from
Apr 1, 2021
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
2 changes: 1 addition & 1 deletion browser/ui/webui/brave_tip_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void TipMessageHandler::OnTip(const base::ListValue* args) {

if (recurring && amount <= 0) {
rewards_service_->RemoveRecurringTip(publisher_key);
} else if (amount >= 1) {
} else if (amount > 0) {
rewards_service_->OnTip(publisher_key, amount, recurring);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export function MonthlyTipForm () {

const tipAmountOptions = tipOptions.map((value) => ({
value,
amount: value.toFixed(0),
currency: <BatString />,
exchangeAmount: formatExchangeAmount(value, rewardsParameters.rate)
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export function OneTimeTipForm () {

const tipAmountOptions = tipOptions.map((value) => ({
value,
amount: value.toFixed(0),
currency: <BatString />,
exchangeAmount: formatExchangeAmount(value, rewardsParameters.rate)
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as style from './tip_amount_selector.style'

interface TipAmountOption {
value: number
amount: React.ReactNode
amount?: React.ReactNode
currency: React.ReactNode
exchangeAmount: React.ReactNode
}
Expand All @@ -22,13 +22,16 @@ interface Props {
}

export function TipAmountSelector (props: Props) {
const options = props.options.map((item) => ({
value: item.value,
content: item.currency
? <><strong>{item.amount}</strong> {item.currency}</>
: <><strong>{item.amount}</strong></>,
caption: item.exchangeAmount || undefined
}))
const options = props.options.map((item) => {
const amount = item.amount || String(item.value)
return {
value: item.value,
content: item.currency
? <><strong>{amount}</strong> {item.currency}</>
: <><strong>{amount}</strong></>,
caption: item.exchangeAmount || undefined
}
})

return (
<style.root>
Expand Down
8 changes: 4 additions & 4 deletions components/brave_rewards/resources/tip/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function createHostState (): HostState {
'ecosystem of rewards. Join us. It’s time to fix the web together!',
background: '',
logo: 'https://rewards.brave.com/LH3yQwkb78iP28pJDSSFPJwU',
amounts: [1, 10, 100],
amounts: [0.25, 2, 10],
provider: '',
links: {
twitter: 'https://twitter.com/brave',
Expand All @@ -82,8 +82,8 @@ function createHostState (): HostState {
type: 'uphold'
},
rewardsParameters: {
tipChoices: [1, 2, 3],
monthlyTipChoices: [1, 2, 3],
tipChoices: [0.25, 2, 10],
monthlyTipChoices: [0.25, 2, 10],
rate: 0.333,
autoContributeChoices: [5, 15, 25, 50]
},
Expand All @@ -92,7 +92,7 @@ function createHostState (): HostState {
adsPerHour: 3,
autoContributeAmount: 15,
onlyAnonWallet: false,
showOnboarding: true,
showOnboarding: false,
tipProcessed: false,
currentMonthlyTip: 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export const localeStrings = {
monthlyContributionSet: 'Monthly contribution has been set.',
monthlyText: 'Monthly',
nextContributionDate: 'Next contribution date:',
notEnoughTokens: 'Not enough {{currency}}.',
notEnoughTokensLink: 'Not enough {{currency}}. Please',
notEnoughTokens: 'Not enough [[currency]].',
notEnoughTokensLink: 'Not enough [[currency]]. Please',
on: 'on',
oneTimeTip: 'One Time Tip',
oneTimeTipAmount: 'One time tip amount:',
optInRequired: 'Hold on, you can’t tip yet',
points: 'points',
postHeader: '{{user}}’s post',
postHeaderTwitter: '{{user}}’s tweet',
postHeader: '[[user]]’s post',
postHeaderTwitter: '[[user]]’s tweet',
rewardsBannerText1: 'You can support this content creator by sending a tip. It’s a way of thanking them for making great content. Verified creators get paid for their tips during the first week of each calendar month.',
sendDonation: 'Send Tip',
siteBannerConnectedText: 'This Brave Verified Creator has not yet configured their account to receive contributions from Brave users. Your browser will keep trying to contribute until they verify, or until 90 days have passed.',
Expand Down