Skip to content

Commit 4cfab4a

Browse files
committed
init
1 parent d75be61 commit 4cfab4a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

packages/clerk-js/src/ui/elements/SocialButtons.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,15 @@ export const SocialButtons = React.memo((props: SocialButtonsRootProps) => {
9696
);
9797
const strategyRowOneLength = strategyRows.at(lastAuthenticationStrategyPresent ? 1 : 0)?.length ?? 0;
9898

99+
// When last auth strategy is present, check remaining strategies count for button type
100+
const remainingStrategiesCount = lastAuthenticationStrategyPresent ? strategies.length - 1 : strategies.length;
101+
99102
const preferBlockButtons =
100103
socialButtonsVariant === 'blockButton'
101104
? true
102105
: socialButtonsVariant === 'iconButton'
103106
? false
104-
: strategies.length <= SOCIAL_BUTTON_BLOCK_THRESHOLD;
107+
: remainingStrategiesCount <= SOCIAL_BUTTON_BLOCK_THRESHOLD;
105108

106109
const startOauth = async (strategy: OAuthStrategy | Web3Strategy) => {
107110
card.setLoading(strategy);
@@ -161,12 +164,12 @@ export const SocialButtons = React.memo((props: SocialButtonsRootProps) => {
161164
>
162165
{row.map(strategy => {
163166
const label =
164-
strategies.length === SOCIAL_BUTTON_PRE_TEXT_THRESHOLD
167+
remainingStrategiesCount <= SOCIAL_BUTTON_PRE_TEXT_THRESHOLD
165168
? `Continue with ${strategyToDisplayData[strategy].name}`
166169
: strategyToDisplayData[strategy].name;
167170

168171
const localizedText =
169-
strategies.length === SOCIAL_BUTTON_PRE_TEXT_THRESHOLD
172+
remainingStrategiesCount <= SOCIAL_BUTTON_PRE_TEXT_THRESHOLD
170173
? localizationKeys('socialButtonsBlockButton', {
171174
provider: strategyToDisplayData[strategy].name,
172175
})
@@ -224,15 +227,6 @@ type SocialButtonProps = PropsOfComponent<typeof Button> & {
224227
const SocialButtonIcon = forwardRef((props: SocialButtonProps, ref: Ref<HTMLButtonElement> | null): JSX.Element => {
225228
const { icon, label, id, textLocalizationKey, lastAuthenticationStrategy, ...rest } = props;
226229

227-
if (lastAuthenticationStrategy) {
228-
return (
229-
<SocialButtonBlock
230-
{...props}
231-
ref={ref}
232-
/>
233-
);
234-
}
235-
236230
return (
237231
<Button
238232
ref={ref}
@@ -245,9 +239,11 @@ const SocialButtonIcon = forwardRef((props: SocialButtonProps, ref: Ref<HTMLButt
245239
sx={t => ({
246240
minHeight: t.sizes.$8,
247241
width: '100%',
242+
position: 'relative',
248243
})}
249244
{...rest}
250245
>
246+
{lastAuthenticationStrategy && <LastAuthenticationStrategyBadge overlay />}
251247
{icon}
252248
</Button>
253249
);

0 commit comments

Comments
 (0)