Skip to content

Commit c882495

Browse files
feat: animate height of switch (#7263)
Co-authored-by: Laura Beatris <[email protected]>
1 parent c76b11d commit c882495

File tree

2 files changed

+32
-12
lines changed
  • packages

2 files changed

+32
-12
lines changed

packages/clerk-js/src/ui/components/devPrompts/EnableOrganizationsPrompt/index.tsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Modal } from '@/ui/elements/Modal';
1111
import { common, InternalThemeProvider } from '@/ui/styledSystem';
1212

1313
import { DevTools } from '../../../../core/resources/DevTools';
14-
import { Flex, Span } from '../../../customizables';
14+
import { Box, Flex, Span } from '../../../customizables';
1515
import { Portal } from '../../../elements/Portal';
1616
import { basePromptElementStyles, handleDashboardUrlParsing, PromptContainer, PromptSuccessIcon } from '../shared';
1717

@@ -291,15 +291,35 @@ const EnableOrganizationsPromptInternal = ({
291291
)}
292292
</Flex>
293293

294-
{!isEnabled && hasPersonalAccountsEnabled && (
295-
<Flex sx={t => ({ marginTop: t.sizes.$3 })}>
296-
<Switch
297-
label='Allow personal account'
298-
description='This is an uncommon setting, meant for applications that sell to both organizations and individual users. Most B2B applications require users to be part of an organization, and should keep this setting disabled.'
299-
checked={allowPersonalAccount}
300-
onChange={() => setAllowPersonalAccount(prev => !prev)}
301-
/>
302-
</Flex>
294+
{hasPersonalAccountsEnabled && (
295+
<Box
296+
sx={t => ({
297+
display: 'grid',
298+
gridTemplateRows: isEnabled ? '0fr' : '1fr',
299+
transition: `grid-template-rows ${t.transitionDuration.$slower} ${t.transitionTiming.$slowBezier}`,
300+
marginInline: '-0.5rem',
301+
overflow: 'hidden',
302+
})}
303+
{...(isEnabled && { inert: '' })}
304+
>
305+
<Flex
306+
sx={t => ({
307+
minHeight: 0,
308+
paddingInline: '0.5rem',
309+
opacity: isEnabled ? 0 : 1,
310+
transition: `opacity ${t.transitionDuration.$slower} ${t.transitionTiming.$slowBezier}`,
311+
})}
312+
>
313+
<Flex sx={t => ({ marginTop: t.sizes.$2 })}>
314+
<Switch
315+
label='Allow personal account'
316+
description='Allow users to work outside of an organization by providing a personal account. We do not recommend for B2B SaaS apps.'
317+
checked={allowPersonalAccount}
318+
onChange={() => setAllowPersonalAccount(prev => !prev)}
319+
/>
320+
</Flex>
321+
</Flex>
322+
</Box>
303323
)}
304324
</Flex>
305325

packages/shared/src/react/hooks/useCheckout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ export const useCheckout = (options?: UseCheckoutParams): __experimental_UseChec
134134
throw new Error('Clerk: Ensure that `useCheckout` is inside a component wrapped with `<SignedIn />`.');
135135
}
136136

137-
if (forOrganization === 'organization' && !organizationCtx.organization) {
137+
if (forOrganization === 'organization' && !organizationCtx?.organization) {
138138
throw new Error(
139139
'Clerk: Ensure your flow checks for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object',
140140
);
141141
}
142142

143143
const manager = useMemo(
144144
() => clerk.__experimental_checkout({ planId, planPeriod, for: forOrganization }),
145-
[user.id, organizationCtx.organization?.id, planId, planPeriod, forOrganization],
145+
[user.id, organizationCtx?.organization?.id, planId, planPeriod, forOrganization],
146146
);
147147

148148
const managerProperties = useSyncExternalStore(

0 commit comments

Comments
 (0)