Skip to content

Commit

Permalink
fix(react): update social button styling and behavior logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gregfromstl committed Jul 29, 2024
1 parent 77b852a commit 8e03dee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-snails-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix wallet social login button styling
1 change: 1 addition & 0 deletions apps/playground-web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const WALLETS = [
"passkey",
"phone",
"farcaster",
"facebook",
],
mode: "redirect",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const ConnectWalletSocialOptions = (
props.select();
}

const showOnlyIcons = socialLogins.length > 1;
const showOnlyIcons = socialLogins.length > 2;

Check warning on line 237 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L237

Added line #L237 was not covered by tests

return (
<Container
Expand All @@ -247,22 +247,33 @@ export const ConnectWalletSocialOptions = (
{/* Social Login */}
{hasSocialLogins && (
<Container
flex={showOnlyIcons ? "row" : "column"}
flex="row"

Check warning on line 250 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L250

Added line #L250 was not covered by tests
center="x"
gap="sm"
gap={socialLogins.length > 4 ? "xs" : "sm"}

Check warning on line 252 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L252

Added line #L252 was not covered by tests
style={{
justifyContent: "space-between",
display: "grid",
gridTemplateColumns: `repeat(${socialLogins.length}, 1fr)`,

Check warning on line 256 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L255-L256

Added lines #L255 - L256 were not covered by tests
}}
>
{socialLogins.map((loginMethod) => {
const imgIconSize = showOnlyIcons ? iconSize.lg : iconSize.md;
const imgIconSize = (() => {
if (!showOnlyIcons) {
return iconSize.md;
} else {
if (socialLogins.length > 4) {
return iconSize.md;
}
return iconSize.lg;
}
})();

Check warning on line 270 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L260-L270

Added lines #L260 - L270 were not covered by tests
return (
<SocialButton
aria-label={`Login with ${loginMethod}`}
data-variant={showOnlyIcons ? "icon" : "full"}
key={loginMethod}
variant={"outline"}
fullWidth={!showOnlyIcons}
onClick={() => {
handleSocialLogin(loginMethod as SocialAuthOption);
}}
Expand All @@ -274,7 +285,7 @@ export const ConnectWalletSocialOptions = (
client={props.client}
/>
{!showOnlyIcons &&
loginMethodsLabel[loginMethod as SocialAuthOption]}
`${socialLogins.length === 1 ? "Continue with " : ""}${loginMethodsLabel[loginMethod as SocialAuthOption]}`}

Check warning on line 288 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L288

Added line #L288 was not covered by tests
</SocialButton>
);
})}
Expand Down Expand Up @@ -379,11 +390,12 @@ export const ConnectWalletSocialOptions = (
};

const SocialButton = /* @__PURE__ */ styled(Button)({
flexGrow: 1,
"&[data-variant='full']": {
display: "flex",
justifyContent: "flex-start",
padding: spacing.md,
gap: spacing.md,
gap: spacing.sm,
fontSize: fontSize.md,
fontWeight: 500,
transition: "background-color 0.2s ease",
Expand All @@ -393,6 +405,5 @@ const SocialButton = /* @__PURE__ */ styled(Button)({
},
"&[data-variant='icon']": {
padding: spacing.sm,
flexGrow: 1,
},
});

0 comments on commit 8e03dee

Please sign in to comment.