Skip to content

Commit

Permalink
feat(ArticleDetail): revise <SetAmount />
Browse files Browse the repository at this point in the history
  • Loading branch information
wlliaml committed Mar 5, 2024
1 parent 6909303 commit 57e703e
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 45 deletions.
10 changes: 7 additions & 3 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@
"defaultMessage": "Subscribers",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"TX5UzL": {
"defaultMessage": "Payment will be processed by Stripe, allowing your support to be unrestricted by region.",
"description": "src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx"
},
"TjWWxF": {
"defaultMessage": "Broadcast sent",
"description": "src/views/Circle/Broadcast/Broadcast.tsx"
Expand Down Expand Up @@ -1690,6 +1694,9 @@
"eY3YIa": {
"defaultMessage": "Copy comment"
},
"eZ0m39": {
"defaultMessage": "Enter the amount"
},
"enMIYK": {
"defaultMessage": "My Page"
},
Expand Down Expand Up @@ -2348,9 +2355,6 @@
"defaultMessage": "Pay",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"y1AhBH": {
"defaultMessage": "Enter a custom amount"
},
"y4Lyf1": {
"defaultMessage": "This name is already taken.",
"description": "NAME_EXISTS"
Expand Down
10 changes: 7 additions & 3 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@
"defaultMessage": "Subscribers",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"TX5UzL": {
"defaultMessage": "Payment will be processed by Stripe, allowing your support to be unrestricted by region.",
"description": "src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx"
},
"TjWWxF": {
"defaultMessage": "Broadcast sent",
"description": "src/views/Circle/Broadcast/Broadcast.tsx"
Expand Down Expand Up @@ -1690,6 +1694,9 @@
"eY3YIa": {
"defaultMessage": "Copy comment"
},
"eZ0m39": {
"defaultMessage": "Enter the amount"
},
"enMIYK": {
"defaultMessage": "My Page"
},
Expand Down Expand Up @@ -2348,9 +2355,6 @@
"defaultMessage": "Pay",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"y1AhBH": {
"defaultMessage": "Enter a custom amount"
},
"y4Lyf1": {
"defaultMessage": "This name is already taken.",
"description": "NAME_EXISTS"
Expand Down
10 changes: 7 additions & 3 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@
"defaultMessage": "付费人数",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"TX5UzL": {
"defaultMessage": "付款将由 Stripe 处理,让你的支持不受地域限制",
"description": "src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx"
},
"TjWWxF": {
"defaultMessage": "广播已送出",
"description": "src/views/Circle/Broadcast/Broadcast.tsx"
Expand Down Expand Up @@ -1690,6 +1694,9 @@
"eY3YIa": {
"defaultMessage": "复制评论"
},
"eZ0m39": {
"defaultMessage": "请输入金额"
},
"enMIYK": {
"defaultMessage": "我的"
},
Expand Down Expand Up @@ -2348,9 +2355,6 @@
"defaultMessage": "付费",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"y1AhBH": {
"defaultMessage": "输入金额"
},
"y4Lyf1": {
"defaultMessage": "该名称已被其他用户使用",
"description": "NAME_EXISTS"
Expand Down
10 changes: 7 additions & 3 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@
"defaultMessage": "付費人數",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"TX5UzL": {
"defaultMessage": "付款將由 Stripe 處理,讓你的支持不受地域限制",
"description": "src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx"
},
"TjWWxF": {
"defaultMessage": "廣播已送出",
"description": "src/views/Circle/Broadcast/Broadcast.tsx"
Expand Down Expand Up @@ -1690,6 +1694,9 @@
"eY3YIa": {
"defaultMessage": "複製評論"
},
"eZ0m39": {
"defaultMessage": "請輸入金額"
},
"enMIYK": {
"defaultMessage": "我的"
},
Expand Down Expand Up @@ -2348,9 +2355,6 @@
"defaultMessage": "付費",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
},
"y1AhBH": {
"defaultMessage": "輸入金額"
},
"y4Lyf1": {
"defaultMessage": "該名稱已被其他使用者使用",
"description": "NAME_EXISTS"
Expand Down
40 changes: 22 additions & 18 deletions src/components/Form/ComposedAmountInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ const AmountOption: React.FC<AmountOptionProps> = ({
return (
<li className={amountClasses}>
<label htmlFor={fieldId}>
{formatAmount(amount, decimals)}
<span className={styles.currency}>{currency}</span>
<span className={styles.amount}>{formatAmount(amount, decimals)}</span>

<VisuallyHidden>
<input
Expand Down Expand Up @@ -169,23 +170,26 @@ const ComposedAmountInput: React.FC<ComposedAmountInputProps> = ({

{customAmount && (
<section className={styles.customInput}>
<input
className={
customAmountError ? `error ${styles.input}` : styles.input
}
type="number"
name="customAmount"
placeholder={intl.formatMessage({
defaultMessage: 'Enter a custom amount',
id: 'y1AhBH',
})}
value={undefined}
autoComplete="nope"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
{...customAmountInputProps}
/>
<section className={styles.inputWrapper}>
<span className={styles.unit}>{currency}</span>
<input
className={
customAmountError ? `error ${styles.input}` : styles.input
}
type="number"
name="customAmount"
placeholder={intl.formatMessage({
defaultMessage: 'Enter the amount',
id: 'eZ0m39',
})}
value={undefined}
autoComplete="nope"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
{...customAmountInputProps}
/>
</section>

{customAmountHint && (
<div className={styles.hint}>{customAmountHint}</div>
Expand Down
42 changes: 35 additions & 7 deletions src/components/Form/ComposedAmountInput/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
font-size: var(--font-size-lg);
font-weight: var(--font-weight-medium);
color: var(--color-black);
background: var(--color-white);
border: 1px solid var(--color-line-grey-light);
background: var(--color-grey-lighter);
border: 1px solid var(--color-grey-lighter);
border-radius: var(--spacing-x-tight);
transition-property: color, border-color, background-color;

Expand All @@ -28,22 +28,50 @@
}

& label {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
padding-top: var(--spacing-base);
padding-bottom: var(--spacing-base);
padding-top: var(--spacing-x-tight);
padding-bottom: var(--spacing-x-tight);
text-align: center;

& .currency {
font-size: var(--font-size-xs);
font-weight: var(--font-weight-medium);
color: var(--color-grey-darker);
}

& .amount {
font-size: var(--font-size-lg);
font-weight: var(--font-weight-semibold);
color: var(--color-black);
}
}
}

.customInput {
margin-top: var(--spacing-base);

& .input {
& .inputWrapper {
@mixin form-input;
@mixin form-input-number;

text-align: center;
display: flex;
gap: var(--spacing-base);
text-align: left;

& .unit {
color: var(--color-grey-darker);
word-break: keep-all;
}

& .input {
@mixin form-input-number;
}

&:has(> .input:focus, > .input.focus) {
border-color: var(--color-grey);
}
}

& .hint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@ const SetAmountBalance: React.FC<SetAmountBalanceProps> = ({
return (
<section className={styles.setAmountBalance}>
<span className={styles.left}>
<FormattedMessage defaultMessage="Select amount" id="Z6Z1aN" />
<FormattedMessage
defaultMessage="Select amount"
description="src/components/Forms/PaymentForm/PayTo/SetAmount/SetAmountBalance/index.tsx"
id="7VSfs3"
/>
</span>

<span className={styles.right}>
{!isBalanceInsufficient && (
<>
<FormattedMessage defaultMessage="Balance:&nbsp;" id="y2IqUi" />
<FormattedMessage
defaultMessage="Balance:"
description="src/components/Forms/PaymentForm/PayTo/SetAmount/SetAmountBalance/index.tsx"
id="FKHNZb"
/>
{lang === 'en' && <>&nbsp;</>}
</>
)}
<span className={styles.balance}>
Expand All @@ -60,7 +69,8 @@ const SetAmountBalance: React.FC<SetAmountBalanceProps> = ({
{isHKD && isBalanceInsufficient && (
<FormattedMessage
defaultMessage="Insufficient balance"
id="kaPKOB"
description="src/components/Forms/PaymentForm/PayTo/SetAmount/SetAmountBalance/index.tsx"
id="wv08Xt"
/>
)}
</span>
Expand All @@ -76,7 +86,11 @@ const SetAmountBalance: React.FC<SetAmountBalanceProps> = ({
color="gold"
weight="md"
>
<FormattedMessage defaultMessage="Top up" id="Y47aYU" />
<FormattedMessage
defaultMessage="Top up"
description="src/components/Forms/PaymentForm/PayTo/SetAmount/SetAmountBalance/index.tsx"
id="JGLi9Y"
/>
</TextIcon>
</Button>
</section>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ const SetAmount: React.FC<FormProps> = ({
const hkdHint = isHKD ? (
<section>
<Spacer size="base" />
<Translate
zh_hant="付款將由 Stripe 處理,讓你的支持不受地域限制"
zh_hans="付款将由 Stripe 处理,让你的支持不受地域限制"
en="Stripe will process your payment, so you can support the author wherever you are."
<FormattedMessage
defaultMessage="Payment will be processed by Stripe, allowing your support to be unrestricted by region."
id="TX5UzL"
description="src/components/Forms/PaymentForm/PayTo/SetAmount/index.tsx"
/>
</section>
) : null
Expand Down

0 comments on commit 57e703e

Please sign in to comment.