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

Fastlane flag to hide logo #2453

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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 dist/button.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/test/button.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/ui/buttons/buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
userIDToken,
vault,
wallet,
isFastlane,
} = normalizeButtonProps(props);
const { layout, shape, tagline } = style;

Expand Down Expand Up @@ -234,7 +235,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
!fundingSource &&
!message;

const showPoweredBy = calculateShowPoweredBy(layout, fundingSources);
const showPoweredBy = calculateShowPoweredBy(layout, fundingSources, isFastlane);

return (
<div
Expand Down
11 changes: 8 additions & 3 deletions src/ui/buttons/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export type RenderButtonProps = {|
displayOnly?: $ReadOnlyArray<$Values<typeof DISPLAY_ONLY_VALUES>>,
message?: ButtonMessage,
messageMarkup?: string,
isFastlane?: boolean,
|};

export type PrerenderDetails = {|
Expand Down Expand Up @@ -597,6 +598,7 @@ export type ButtonPropsInputs = {
message?: ButtonMessageInputs | void,
messageMarkup?: string | void,
renderedButtons: $ReadOnlyArray<$Values<typeof FUNDING>>,
isFastlane?: boolean
};

export const DEFAULT_STYLE = {
Expand Down Expand Up @@ -776,7 +778,8 @@ export function normalizeButtonStyle(
export function normalizeButtonMessage(
message: ButtonMessageInputs,
layout: $Values<typeof BUTTON_LAYOUT>,
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>,
isFastlane?: boolean,
): ButtonMessage {
const {
color = MESSAGE_COLOR.BLACK,
Expand Down Expand Up @@ -841,7 +844,7 @@ export function normalizeButtonMessage(
amount,
offer,
color,
position: calculateMessagePosition(fundingSources, layout, position),
position: calculateMessagePosition(fundingSources, layout, position, isFastlane),
align,
};
}
Expand Down Expand Up @@ -912,6 +915,7 @@ export function normalizeButtonProps(
message,
messageMarkup,
renderedButtons,
isFastlane,
} = props;

const { country, lang } = locale;
Expand Down Expand Up @@ -975,7 +979,7 @@ export function normalizeButtonProps(
const { layout } = style;

message = message
? normalizeButtonMessage(message, layout, renderedButtons)
? normalizeButtonMessage(message, layout, renderedButtons, isFastlane)
: undefined;

return {
Expand Down Expand Up @@ -1015,5 +1019,6 @@ export function normalizeButtonProps(
displayOnly,
message,
messageMarkup,
isFastlane,
};
}
10 changes: 6 additions & 4 deletions src/ui/buttons/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ export function isBorderRadiusNumber(borderRadius?: number): boolean {

export function calculateShowPoweredBy(
layout: $Values<typeof BUTTON_LAYOUT>,
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>,
isFastlane?: boolean,
): boolean {
return (
layout === BUTTON_LAYOUT.VERTICAL && fundingSources.includes(FUNDING.CARD)
layout === BUTTON_LAYOUT.VERTICAL && fundingSources.includes(FUNDING.CARD) && !isFastlane
);
}

export function calculateMessagePosition(
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>,
layout: $Values<typeof BUTTON_LAYOUT>,
position?: $Values<typeof MESSAGE_POSITION>
position?: $Values<typeof MESSAGE_POSITION>,
isFastlane?: boolean,
): $Values<typeof MESSAGE_POSITION> {
const showPoweredBy = calculateShowPoweredBy(layout, fundingSources);
const showPoweredBy = calculateShowPoweredBy(layout, fundingSources, isFastlane);

if (showPoweredBy && position === MESSAGE_POSITION.BOTTOM) {
// eslint-disable-next-line no-console
Expand Down