diff --git a/packages/harmony/src/components/input/SelectablePill/SelectablePill.module.css b/packages/harmony/src/components/input/SelectablePill/SelectablePill.module.css index 3a58597cd59..fbf19ee61f2 100644 --- a/packages/harmony/src/components/input/SelectablePill/SelectablePill.module.css +++ b/packages/harmony/src/components/input/SelectablePill/SelectablePill.module.css @@ -40,11 +40,24 @@ border: 1px solid var(--harmony-s-400); } +.pill.disabled { + pointer-events: none; +} + .large:active, .large.selected { box-shadow: none; } +.disabled { + opacity: 0.45; +} + +.disabled:hover { + background-color: var(--harmony-white); + border: 1px solid var(--harmony-border-strong); +} + .icon path { fill: currentColor; } diff --git a/packages/harmony/src/components/input/SelectablePill/SelectablePill.tsx b/packages/harmony/src/components/input/SelectablePill/SelectablePill.tsx index a1b1aad82e8..c8eba14098c 100644 --- a/packages/harmony/src/components/input/SelectablePill/SelectablePill.tsx +++ b/packages/harmony/src/components/input/SelectablePill/SelectablePill.tsx @@ -16,6 +16,7 @@ export const SelectablePill = forwardRef< size = 'default', isSelected, label, + disabled, icon: IconComponent, className, ...restProps @@ -28,7 +29,8 @@ export const SelectablePill = forwardRef< styles.pill, { [styles.large]: size === 'large', - [styles.selected]: isSelected + [styles.selected]: isSelected, + [styles.disabled]: disabled }, className )} diff --git a/packages/harmony/src/components/input/SelectablePill/types.ts b/packages/harmony/src/components/input/SelectablePill/types.ts index 08a1199dba2..c043e65be61 100644 --- a/packages/harmony/src/components/input/SelectablePill/types.ts +++ b/packages/harmony/src/components/input/SelectablePill/types.ts @@ -6,5 +6,6 @@ export type SelectablePillProps = { size?: 'default' | 'large' isSelected: boolean label: string + disabled?: boolean icon?: IconComponent } & Omit, 'children'> diff --git a/packages/mobile/src/components/core/HarmonySelectablePill.tsx b/packages/mobile/src/components/core/HarmonySelectablePill.tsx index f1f5528aa76..732f982b4c8 100644 --- a/packages/mobile/src/components/core/HarmonySelectablePill.tsx +++ b/packages/mobile/src/components/core/HarmonySelectablePill.tsx @@ -78,6 +78,7 @@ export const HarmonySelectablePill = (props: HarmonySelectablePillProps) => { onPressIn, onPressOut, size, + disabled, style, ...other } = props @@ -110,14 +111,16 @@ export const HarmonySelectablePill = (props: HarmonySelectablePillProps) => { styles.pill, size === 'large' ? styles.pillLarge : undefined, isSelected ? styles.pressed : undefined, + disabled ? { opacity: 0.45 } : undefined, { transform: [{ scale }] }, style ]} > `$${Math.floor(val / 100)}` export type PayExtraFormSectionProps = { amountPresets: PayExtraAmountPresetValues + disabled?: boolean } export const PayExtraFormSection = ({ - amountPresets + amountPresets, + disabled }: PayExtraFormSectionProps) => { const [{ value: preset }, , { setValue: setPreset }] = useField(AMOUNT_PRESET) const [{ value: customAmount }, { error: customAmountError }] = @@ -69,6 +71,7 @@ export const PayExtraFormSection = ({ style={styles.pill} isSelected={preset === PayExtraPreset.LOW} label={formatPillAmount(amountPresets[PayExtraPreset.LOW])} + disabled={disabled} onPress={() => handleClickPreset(PayExtraPreset.LOW)} /> handleClickPreset(PayExtraPreset.MEDIUM)} /> handleClickPreset(PayExtraPreset.HIGH)} /> @@ -91,6 +96,7 @@ export const PayExtraFormSection = ({ style={styles.pill} isSelected={preset === PayExtraPreset.CUSTOM} label={messages.customAmount} + disabled={disabled} onPress={() => handleClickPreset(PayExtraPreset.CUSTOM)} /> diff --git a/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx b/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx index 7719841bb49..8d513f67763 100644 --- a/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx +++ b/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx @@ -217,6 +217,7 @@ const RenderForm = ({ track }: { track: PurchasableTrackMetadata }) => { const { amountDue } = purchaseSummaryValues const isPurchaseSuccessful = stage === PurchaseContentStage.FINISH + const isInProgress = isContentPurchaseInProgress(stage) // Navigate to track screen in the background if purchase is successful useEffect(() => { @@ -240,7 +241,10 @@ const RenderForm = ({ track }: { track: PurchasableTrackMetadata }) => { ) : null} {isPurchaseSuccessful ? null : ( - + )} `$${Math.floor(val / 100)}` export type PayExtraFormSectionProps = { amountPresets: PayExtraAmountPresetValues + disabled?: boolean } export const PayExtraFormSection = ({ - amountPresets + amountPresets, + disabled }: PayExtraFormSectionProps) => { const [{ value: preset }, , { setValue: setPreset }] = useField(AMOUNT_PRESET) @@ -47,6 +49,7 @@ export const PayExtraFormSection = ({ size='large' type='button' onClick={() => handleClickPreset(PayExtraPreset.LOW)} + disabled={disabled} /> handleClickPreset(PayExtraPreset.MEDIUM)} + disabled={disabled} /> handleClickPreset(PayExtraPreset.HIGH)} + disabled={disabled} /> handleClickPreset(PayExtraPreset.CUSTOM)} + disabled={disabled} /> {preset === PayExtraPreset.CUSTOM ? ( @@ -79,6 +85,7 @@ export const PayExtraFormSection = ({ placeholder={messages.placeholder} label={messages.customAmount} name={CUSTOM_AMOUNT} + disabled={disabled} /> ) : null} diff --git a/packages/web/src/components/premium-content-purchase-modal/components/PurchaseContentFormFields.tsx b/packages/web/src/components/premium-content-purchase-modal/components/PurchaseContentFormFields.tsx index 6c080812d58..46240736009 100644 --- a/packages/web/src/components/premium-content-purchase-modal/components/PurchaseContentFormFields.tsx +++ b/packages/web/src/components/premium-content-purchase-modal/components/PurchaseContentFormFields.tsx @@ -1,4 +1,8 @@ -import { PurchaseContentStage, usePayExtraPresets } from '@audius/common' +import { + PurchaseContentStage, + isContentPurchaseInProgress, + usePayExtraPresets +} from '@audius/common' import { IconCheck } from '@audius/stems' import { Icon } from 'components/Icon' @@ -27,6 +31,7 @@ export const PurchaseContentFormFields = ({ }: PurchaseContentFormFieldsProps) => { const payExtraAmountPresetValues = usePayExtraPresets(useRemoteVar) const isPurchased = stage === PurchaseContentStage.FINISH + const isInProgress = isContentPurchaseInProgress(stage) if (isPurchased) { return ( @@ -48,7 +53,10 @@ export const PurchaseContentFormFields = ({ } return ( <> - +