Skip to content

Commit 419f22b

Browse files
committed
feat: login popup dialog style
1 parent 6e00e57 commit 419f22b

File tree

6 files changed

+117
-42
lines changed

6 files changed

+117
-42
lines changed

apps/codeimage/src/components/Toolbar/LoginDialog.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {themeTokens, themeVars} from '@codeui/kit';
2+
import {globalStyle, keyframes, style} from '@vanilla-extract/css';
3+
4+
export const titleLogin = style({
5+
fontSize: '2rem',
6+
textAlign: 'center',
7+
fontWeight: themeTokens.fontWeight.bold,
8+
display: 'flex',
9+
flexDirection: 'column',
10+
gap: themeTokens.spacing['4'],
11+
alignItems: 'center',
12+
marginTop: themeTokens.spacing['8'],
13+
});
14+
15+
export const loginBox = style({
16+
display: 'flex',
17+
flexDirection: 'column',
18+
gap: themeTokens.spacing['2'],
19+
marginTop: themeTokens.spacing['12'],
20+
marginBottom: themeTokens.spacing['12'],
21+
});
22+
23+
export const closeIcon = style({
24+
width: '100%',
25+
display: 'flex',
26+
justifyContent: 'flex-end',
27+
});
28+
29+
const backdropFilter = keyframes({
30+
'0%': {
31+
backdropFilter: 'blur(0px) saturate(180%)',
32+
},
33+
'100%': {
34+
backdropFilter: 'blur(20px) saturate(180%)',
35+
},
36+
});
37+
38+
globalStyle('div[data-panel-size]:has(div[id=loginDialog-content])', {
39+
animation: `${backdropFilter} 150ms normal forwards ease-in-out`,
40+
});
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import {AuthState} from '@codeimage/store/auth/auth';
2+
import {provideAppState} from '@codeimage/store/index';
3+
import {Box, VStack} from '@codeimage/ui';
4+
import {
5+
Button,
6+
Dialog,
7+
DialogPanelContent,
8+
IconButton,
9+
SvgIcon,
10+
} from '@codeui/kit';
11+
import {ControlledDialogProps} from '@core/hooks/createControlledDialog';
12+
import {GithubLoginButton} from '@ui/GithubLoginButton/GithubLoginButton';
13+
import {CloseIcon} from '../../Icons/CloseIcon';
14+
import {CodeImageLogoV2} from '../../Icons/CodeImageLogoV2';
15+
import {closeIcon, loginBox, titleLogin} from './LoginDialog.css';
16+
17+
export function LoginDialog(props: ControlledDialogProps) {
18+
const authState = provideAppState(AuthState);
19+
return (
20+
<Dialog
21+
open={props.isOpen}
22+
onOpenChange={props.onOpenChange}
23+
size={'xs'}
24+
id={'loginDialog'}
25+
>
26+
<DialogPanelContent>
27+
<div class={closeIcon}>
28+
<IconButton aria-label={'close'} theme={'secondary'} pill size={'xs'}>
29+
<CloseIcon />
30+
</IconButton>
31+
</div>
32+
<div class={titleLogin}>
33+
<CodeImageLogoV2 width={180} />
34+
</div>
35+
36+
<div class={loginBox}>
37+
<GithubLoginButton />
38+
39+
<Button
40+
size={'lg'}
41+
theme={'secondary'}
42+
leftIcon={
43+
<SvgIcon
44+
xmlns="http://www.w3.org/2000/svg"
45+
width="24"
46+
height="24"
47+
viewBox="0 0 24 24"
48+
fill="none"
49+
stroke="currentColor"
50+
stroke-width="2"
51+
stroke-linecap="round"
52+
stroke-linejoin="round"
53+
size={'1.15rem'}
54+
>
55+
<path d="M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z" />
56+
<circle cx="16.5" cy="7.5" r=".5" />
57+
</SvgIcon>
58+
}
59+
onClick={() => authState.providers.hanko.login()}
60+
>
61+
Login with Passkey
62+
</Button>
63+
</div>
64+
</DialogPanelContent>
65+
</Dialog>
66+
);
67+
}

apps/codeimage/src/components/UserBadge/UserBadge.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ import {
1010
DropdownMenuPortal,
1111
DropdownMenuTrigger,
1212
} from '@codeui/kit';
13-
import {createControlledDialog} from '@core/hooks/createControlledDialog';
1413
import {Show} from 'solid-js';
15-
import {LoginDialog} from '../Toolbar/LoginDialog';
1614
import * as styles from './UserBadge.css';
1715

1816
export function UserBadge() {
1917
const authState = provideAppState(AuthState);
2018
const user = () => authState().user;
2119
const profileImage = () => user()?.picture;
2220

23-
const openDialog = createControlledDialog();
24-
2521
const initials = () => {
2622
const userValue = user();
2723
if (!userValue) return;
@@ -35,7 +31,7 @@ export function UserBadge() {
3531
return (
3632
<Show
3733
fallback={
38-
<Button theme={'secondary'} onClick={() => openDialog(LoginDialog, {})}>
34+
<Button theme={'secondary'} onClick={() => authState.openLoginPopup()}>
3935
Login
4036
</Button>
4137
}

apps/codeimage/src/state/auth/auth.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {Auth0Provider} from '@codeimage/store/auth/providers/auth0.provider';
22
import {HankoPasskeyAuthProvider} from '@codeimage/store/auth/providers/hanko-passkey.provider';
3-
import {auth0, createAuth0Client} from '@core/constants/auth0';
3+
import {createAuth0Client} from '@core/constants/auth0';
44
import {createControlledDialog} from '@core/hooks/createControlledDialog';
55
import {defineSignal} from 'statebuilder';
6-
import {LoginDialog} from '../../components/Toolbar/LoginDialog';
6+
import {LoginDialog} from '../../components/Toolbar/LoginDialog/LoginDialog';
77
import {UserInfoResponse} from '../../data-access/user';
88

99
export interface AuthState {
@@ -63,6 +63,8 @@ export const AuthState = defineSignal<AuthState>(() => ({
6363
}
6464
};
6565

66+
const openDialog = createControlledDialog();
67+
6668
return {
6769
init,
6870
getToken: () => currentProvider().getJwt(),
@@ -72,7 +74,6 @@ export const AuthState = defineSignal<AuthState>(() => ({
7274
localStorage.removeItem('auth_strategy');
7375
},
7476
openLoginPopup() {
75-
const openDialog = createControlledDialog();
7677
return openDialog(LoginDialog, {});
7778
},
7879
providers: {

apps/codeimage/src/ui/GithubLoginButton/GithubLoginButton.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ export function GithubLoginButton() {
1919
const modality = useModality();
2020
return (
2121
<Button
22-
size={'sm'}
22+
size={'lg'}
2323
class={styles.button}
24+
leftIcon={<GithubIcon size={'md'} />}
2425
onClick={() => appState.providers.auth0.loginWithGithub()}
2526
>
26-
<GithubIcon size={'md'} />
27-
<Box as={'span'} marginLeft={2}>
28-
<Show fallback={'Sign in'} when={modality === 'full'} keyed={true}>
29-
Sign in with GitHub
30-
</Show>
31-
</Box>
27+
<Show fallback={'Sign in'} when={modality === 'full'} keyed={true}>
28+
Login with GitHub
29+
</Show>
3230
</Button>
3331
);
3432
}

0 commit comments

Comments
 (0)