Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/clean-taxes-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Update SocialButtons layout to be consistent across desktop and mobile.
13 changes: 5 additions & 8 deletions packages/clerk-js/src/ui/elements/SocialButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import {
useAppearance,
} from '../customizables';
import { useEnabledThirdPartyProviders } from '../hooks';
import { mqu, type PropsOfComponent } from '../styledSystem';
import { type PropsOfComponent } from '../styledSystem';
import { sleep } from '../utils/sleep';
import { LastAuthenticationStrategyBadge } from './Badge';
import { useCardState } from './contexts';
import { distributeStrategiesIntoRows } from './utils';

const SOCIAL_BUTTON_BLOCK_THRESHOLD = 2;
const SOCIAL_BUTTON_PRE_TEXT_THRESHOLD = 1;
const MAX_STRATEGIES_PER_ROW = 6;
const MAX_STRATEGIES_PER_ROW = 5;

export type SocialButtonsProps = React.PropsWithChildren<{
enableOAuthProviders: boolean;
Expand Down Expand Up @@ -150,18 +150,15 @@ export const SocialButtons = React.memo((props: SocialButtonsRootProps) => {
gap={2}
sx={t => ({
justifyContent: 'center',
[mqu.sm]: {
gridTemplateColumns: 'repeat(1, 1fr)',
},
gridTemplateColumns:
strategies.length < 1
? `repeat(1, 1fr)`
? `repeat(1, minmax(0, 1fr))`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minmax usage fixes a bug that prevented truncation from working correctly

BEFORE AFTER
Image Image

: `repeat(${row.length}, ${
rowIndex === 0
? `1fr`
? `minmax(0, 1fr)`
: // Calculate the width of each button based on the width of the buttons within the first row.
// t.sizes.$2 is used here to represent the gap defined on the Grid component.
`calc((100% - (${strategyRowOneLength} - 1) * ${t.sizes.$2}) / ${strategyRowOneLength})`
`minmax(0, calc((100% - (${strategyRowOneLength} - 1) * ${t.sizes.$2}) / ${strategyRowOneLength}))`
})`,
})}
>
Expand Down
Loading