Skip to content

Commit b2b3ad4

Browse files
committed
Move to shared styles
1 parent 9ade3ae commit b2b3ad4

File tree

14 files changed

+235
-179
lines changed

14 files changed

+235
-179
lines changed

packages/clerk-js/src/core/clerk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ export class Clerk implements ClerkInterface {
715715
void this.#componentControls.ensureMounted().then(controls => controls.closeModal('userVerification'));
716716
};
717717

718-
public __internal_openEnableOrganizationsPrompt = (props?: __internal_EnableOrganizationsPromptProps): void => {
718+
public __internal_openEnableOrganizationsPrompt = (props: __internal_EnableOrganizationsPromptProps): void => {
719719
this.assertComponentsReady(this.#componentControls);
720720
void this.#componentControls
721721
.ensureMounted({ preloadHint: 'EnableOrganizationsPrompt' })

packages/clerk-js/src/ui/Components.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
import { MountedCheckoutDrawer, MountedPlanDetailDrawer, MountedSubscriptionDetailDrawer } from './lazyModules/drawers';
4343
import {
4444
LazyComponentRenderer,
45+
LazyEnableOrganizationsPromptProvider,
4546
LazyImpersonationFabProvider,
4647
LazyModalRenderer,
4748
LazyOneTapRenderer,
@@ -351,7 +352,7 @@ const Components = (props: ComponentsProps) => {
351352
};
352353

353354
componentsControls.openModal = (name, props) => {
354-
// Prevent opening enableOrganizations modal if it's already open
355+
// Prevent opening enableOrganizations prompt if it's already open
355356
// to avoid duplicate mounting when component is called multiple times
356357
if (name === 'enableOrganizationsPrompt') {
357358
setState(s => {
@@ -634,12 +635,9 @@ const Components = (props: ComponentsProps) => {
634635
)}
635636

636637
{state.enableOrganizationsPromptModal && (
637-
<LazyImpersonationFabProvider globalAppearance={state.appearance}>
638-
<EnableOrganizationsPrompt
639-
callerString='useOrganization'
640-
{...state.enableOrganizationsPromptModal}
641-
/>
642-
</LazyImpersonationFabProvider>
638+
<LazyEnableOrganizationsPromptProvider globalAppearance={state.appearance}>
639+
<EnableOrganizationsPrompt {...state.enableOrganizationsPromptModal} />
640+
</LazyEnableOrganizationsPromptProvider>
643641
)}
644642

645643
{state.options?.__internal_keyless_claimKeylessApplicationUrl &&

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

Lines changed: 125 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,12 @@ import { css } from '@emotion/react';
33
import { Modal } from '@/ui/elements/Modal';
44
import { InternalThemeProvider } from '@/ui/styledSystem';
55

6-
import { Button, Flex } from '../../customizables';
7-
import { Portal } from '../../elements/Portal';
8-
9-
const baseElementStyles = css`
10-
box-sizing: border-box;
11-
padding: 0;
12-
margin: 0;
13-
background: none;
14-
border: none;
15-
line-height: 1.5;
16-
font-family:
17-
-apple-system,
18-
BlinkMacSystemFont,
19-
avenir next,
20-
avenir,
21-
segoe ui,
22-
helvetica neue,
23-
helvetica,
24-
Cantarell,
25-
Ubuntu,
26-
roboto,
27-
noto,
28-
arial,
29-
sans-serif;
30-
text-decoration: none;
31-
`;
32-
33-
const mainCTAStyles = css`
34-
${baseElementStyles};
35-
display: flex;
36-
align-items: center;
37-
justify-content: center;
38-
width: 100%;
39-
height: 1.75rem;
40-
max-width: 14.625rem;
41-
padding: 0.25rem 0.625rem;
42-
border-radius: 0.375rem;
43-
font-size: 0.75rem;
44-
font-weight: 500;
45-
letter-spacing: 0.12px;
46-
color: 'white';
47-
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.32);
48-
white-space: nowrap;
49-
user-select: none;
50-
cursor: pointer;
51-
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30.5%, rgba(0, 0, 0, 0.05) 100%), #454545;
52-
box-shadow:
53-
0px 0px 0px 1px rgba(255, 255, 255, 0.04) inset,
54-
0px 1px 0px 0px rgba(255, 255, 255, 0.04) inset,
55-
0px 0px 0px 1px rgba(0, 0, 0, 0.12),
56-
0px 1.5px 2px 0px rgba(0, 0, 0, 0.48),
57-
0px 0px 4px 0px rgba(243, 107, 22, 0) inset;
58-
`;
6+
import { Flex } from '../../../customizables';
7+
import { Portal } from '../../../elements/Portal';
8+
import { basePromptElementStyles, PromptContainer } from '../shared';
599

6010
type EnableOrganizationsPromptProps = {
61-
callerString: string;
11+
callerName: string;
6212
};
6313

6414
const EnableOrganizationsPromptInternal = (_props: EnableOrganizationsPromptProps) => {
@@ -68,30 +18,24 @@ const EnableOrganizationsPromptInternal = (_props: EnableOrganizationsPromptProp
6818
canCloseModal={false}
6919
contentSx={() => ({ animation: 'unset' })}
7020
>
71-
<Flex
72-
sx={t => ({
73-
position: 'fixed',
21+
<PromptContainer
22+
sx={() => ({
7423
top: '50%',
7524
left: '50%',
25+
bottom: 'auto',
26+
right: 'auto',
27+
padding: 'unset',
7628
transform: 'translate(-50%, -50%)',
7729
flexDirection: 'column',
78-
gap: t.space.$1,
79-
width: 'fit-content',
80-
maxWidth: '25rem',
81-
borderRadius: '1.25rem',
82-
overflow: 'hidden',
83-
fontFamily: t.fonts.$main,
84-
background: 'linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 100%), #1f1f1f',
85-
boxShadow:
86-
'0px 0px 0px 0.5px #2F3037 inset, 0px 1px 0px 0px rgba(255, 255, 255, 0.08) inset, 0px 0px 0.8px 0.8px rgba(255, 255, 255, 0.20) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.72), 0px 16px 36px -6px rgba(0, 0, 0, 0.36), 0px 6px 16px -2px rgba(0, 0, 0, 0.20);',
87-
transition: 'all 195ms cubic-bezier(0.2, 0.61, 0.1, 1)',
30+
height: 'fit-content',
8831
})}
8932
>
9033
<Flex
9134
sx={t => ({
9235
display: 'flex',
9336
flexDirection: 'column',
94-
padding: `${t.space.$3} ${t.space.$4}`,
37+
padding: `${t.space.$5} ${t.space.$6}`,
38+
paddingBottom: t.space.$4,
9539
gap: t.space.$2,
9640
})}
9741
>
@@ -137,96 +81,167 @@ const EnableOrganizationsPromptInternal = (_props: EnableOrganizationsPromptProp
13781

13882
<h1
13983
css={css`
140-
${baseElementStyles};
84+
${basePromptElementStyles};
14185
color: white;
142-
font-size: 0.9rem;
86+
font-size: 0.875rem;
14387
font-weight: 500;
14488
`}
14589
>
14690
Organizations feature required
14791
</h1>
14892
</Flex>
14993

150-
<p
151-
css={css`
152-
${baseElementStyles};
153-
color: #c3c3c6;
154-
font-size: 0.88rem;
155-
font-weight: 400;
156-
line-height: 1.125rem;
157-
`}
94+
<Flex
95+
sx={t => ({
96+
display: 'flex',
97+
flexDirection: 'column',
98+
gap: t.space.$0x5,
99+
})}
158100
>
159-
To use the{' '}
160-
<code
101+
<span
161102
css={css`
162-
${baseElementStyles};
163-
color: white;
103+
${basePromptElementStyles};
104+
color: #b4b4b4;
105+
font-size: 0.8125rem;
106+
font-weight: 400;
107+
line-height: 1rem;
164108
`}
165109
>
166-
useOrganization
167-
</code>{' '}
168-
hook,
169-
<br />
170-
you’ll need to enable the Organizations feature
171-
<br />
172-
for your app first.
173-
<br />
110+
To use the{' '}
111+
<code
112+
css={css`
113+
${basePromptElementStyles};
114+
color: white;
115+
`}
116+
>
117+
useOrganization
118+
</code>{' '}
119+
hook,
120+
<br />
121+
you’ll need to enable the Organizations feature
122+
<br />
123+
for your app first.
124+
</span>
125+
174126
<a
175127
css={css`
176-
${baseElementStyles};
128+
${basePromptElementStyles};
177129
color: #a8a8ff;
178130
font-size: inherit;
179131
font-weight: 500;
180132
line-height: 1rem;
133+
font-size: 0.8125rem;
181134
`}
182135
href='https://clerk.com/docs/guides/organizations'
183136
target='_blank'
184137
rel='noopener noreferrer'
138+
tabIndex={-1}
185139
>
186140
Learn more about this add-on.
187141
</a>
188-
</p>
142+
</Flex>
189143
</Flex>
190144

191-
<Flex
192-
sx={() => ({
193-
borderBottom: '1px solid rgba(255, 255, 255, 0.10)',
194-
background: 'rgba(0, 0, 0, 0.80)',
195-
overflow: 'hidden',
196-
width: '100%',
197-
height: '1px',
198-
})}
145+
<span
146+
css={css`
147+
height: 1px;
148+
background-color: #151515;
149+
width: 100%;
150+
box-shadow: 0px 1px 0px 0px #424242;
151+
`}
199152
/>
200153

201154
<Flex
202155
sx={t => ({
203-
paddingLeft: `${t.space.$4}`,
204-
paddingRight: `${t.space.$4}`,
205-
paddingTop: `${t.space.$3}`,
206-
paddingBottom: `${t.space.$5}`,
156+
padding: `${t.space.$4} ${t.space.$6}`,
207157
flexDirection: 'column',
208158
gap: t.space.$3,
209159
justifyContent: 'center',
210160
})}
211161
>
212-
<Button variant='solid'>Enable Organizations</Button>
213-
<Button
214-
variant='bordered'
215-
sx={t => ({ color: t.colors.$white })}
162+
<button
163+
type='button'
164+
css={css`
165+
${mainCTAStyles};
166+
min-width: 100%;
167+
color: white;
168+
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30.5%, rgba(0, 0, 0, 0.05) 100%), #454545;
169+
box-shadow:
170+
0px 0px 0px 1px rgba(255, 255, 255, 0.04) inset,
171+
0px 1px 0px 0px rgba(255, 255, 255, 0.04) inset,
172+
0px 0px 0px 1px rgba(0, 0, 0, 0.12),
173+
0px 1.5px 2px 0px rgba(0, 0, 0, 0.48),
174+
0px 0px 4px 0px rgba(243, 107, 22, 0) inset;
175+
176+
&:hover {
177+
box-shadow:
178+
0px 0px 6px 0px rgba(255, 255, 255, 0.04) inset,
179+
0px 0px 0px 1px rgba(255, 255, 255, 0.04) inset,
180+
0px 1px 0px 0px rgba(255, 255, 255, 0.04) inset,
181+
0px 0px 0px 1px rgba(0, 0, 0, 0.1),
182+
0px 1.5px 2px 0px rgba(0, 0, 0, 0.48);
183+
}
184+
`}
185+
>
186+
Enable Organizations
187+
</button>
188+
189+
<button
190+
type='button'
191+
css={css`
192+
${mainCTAStyles};
193+
min-width: 100%;
194+
color: white;
195+
background: rgba(69, 69, 69, 0.1);
196+
border: 1px solid rgba(118, 118, 132, 0.25);
197+
198+
&:hover {
199+
box-shadow:
200+
0px 0px 6px 0px rgba(255, 255, 255, 0.04) inset,
201+
0px 0px 0px 1px rgba(255, 255, 255, 0.04) inset,
202+
0px 1px 0px 0px rgba(255, 255, 255, 0.04) inset,
203+
0px 0px 0px 1px rgba(0, 0, 0, 0.1),
204+
0px 1.5px 2px 0px rgba(0, 0, 0, 0.48);
205+
}
206+
`}
216207
>
217208
I&apos;ll remove it myself
218-
</Button>
209+
</button>
219210
</Flex>
220-
</Flex>
211+
</PromptContainer>
221212
</Modal>
222213
</Portal>
223214
);
224215
};
225216

217+
/**
218+
* A prompt that allows the user to enable the Organizations feature for their development instance
219+
* @internal
220+
*/
226221
export const EnableOrganizationsPrompt = (props: EnableOrganizationsPromptProps) => {
227222
return (
228223
<InternalThemeProvider>
229224
<EnableOrganizationsPromptInternal {...props} />
230225
</InternalThemeProvider>
231226
);
232227
};
228+
229+
const mainCTAStyles = css`
230+
${basePromptElementStyles};
231+
cursor: pointer;
232+
display: flex;
233+
align-items: center;
234+
justify-content: center;
235+
width: 100%;
236+
height: 1.75rem;
237+
max-width: 14.625rem;
238+
padding: 0.25rem 0.625rem;
239+
border-radius: 0.375rem;
240+
font-size: 0.75rem;
241+
font-weight: 500;
242+
letter-spacing: 0.12px;
243+
color: white;
244+
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.32);
245+
white-space: nowrap;
246+
user-select: none;
247+
`;

0 commit comments

Comments
 (0)