Skip to content

Commit

Permalink
set up a modal for onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Sep 18, 2024
1 parent 7a91132 commit 54a72e2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/onboarding/OnboardingModal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect, useRef } from 'react';
import styles from './style.module.scss';

const OnboardingModal = () => {
const dialogRef = useRef<HTMLDialogElement | null>(null);

useEffect(() => {
// Block interactions with the page
dialogRef.current?.showModal();
}, []);

return (
<dialog
className={styles.wrapper}
ref={dialogRef}
// Prevent closing dialog with escape key (TODO: on Chrome you can press
// escape twice to bypass)
onCancel={e => e.preventDefault()}
>
hey
</dialog>
);
};

export default OnboardingModal;
14 changes: 14 additions & 0 deletions src/components/onboarding/OnboardingModal/style.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use 'src/styles/vars.scss' as vars;

.wrapper {
background-color: var(--theme-background);
border: 0;
display: flex;
height: 100%;
left: 0;
max-height: unset;
max-width: unset;
overscroll-behavior: contain;
top: 0;
width: 100%;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type Styles = {
wrapper: string;
};

export type ClassNames = keyof Styles;

declare const styles: Styles;

export default styles;
2 changes: 2 additions & 0 deletions src/components/onboarding/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/prefer-default-export
export { default as OnboardingModal } from './OnboardingModal';
7 changes: 7 additions & 0 deletions src/pages/debug.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Button, Typography } from '@/components/common';
import { OnboardingModal } from '@/components/onboarding';
import { config, showToast } from '@/lib';
import withAccessType from '@/lib/hoc/withAccessType';
import { PermissionService } from '@/lib/services';
import { setClientCookie } from '@/lib/services/CookieService';
import { CookieCartItem } from '@/lib/types/client';
import { CookieType } from '@/lib/types/enums';
import { GetServerSideProps } from 'next';
import { useState } from 'react';

const DebugPage = () => {
const [showOnboarding, setShowOnboarding] = useState(false);

return (
<div>
<Typography variant="h1/bold">Debug</Typography>
Expand Down Expand Up @@ -43,6 +47,9 @@ const DebugPage = () => {
>
Fill Cart
</Button>
<Typography variant="h2/medium">Onboarding</Typography>
<Button onClick={() => setShowOnboarding(true)}>Teach Me the Ways</Button>
{showOnboarding ? <OnboardingModal /> : null}
</div>
);
};
Expand Down

0 comments on commit 54a72e2

Please sign in to comment.