Skip to content

Commit

Permalink
V1.0.0 (#36)
Browse files Browse the repository at this point in the history
# Overview
onboarding과 웹뷰를 위한 falling 페이지 구현

---------

Co-authored-by: Jonghyeon Ko <[email protected]>
  • Loading branch information
deli-ght and manudeli authored Aug 6, 2023
1 parent d42b1f0 commit cb126a3
Show file tree
Hide file tree
Showing 122 changed files with 9,181 additions and 805 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.vscode
.eslintrc.js
packlint.config.mjs
node_modules
node_modules
esm
dist
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ yarn-error.log*

# vercel
.vercel

# bundled
dist
esm

stats.html
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.packageManager": "pnpm",
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"cSpell.words": ["packlint", "nextjs", "sulsul"],
"cSpell.words": ["packlint", "nextjs", "sulsul", "jsxcss"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
2 changes: 1 addition & 1 deletion apps/falling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@tanstack/react-query-devtools": "^4.29.3",
"axios": "^1.3.6",
"framer-motion": "^10.12.4",
"next": "13.4.4",
"next": "13.4.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.43.9",
Expand Down
Binary file added apps/falling/public/images/bubble-beer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/falling/public/images/bubble-goryanju.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/falling/public/images/bubble-soju.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/falling/public/images/bubble-whisky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/falling/public/images/bubble-wine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions apps/falling/src/app/components/Falling.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client';

import { StackView, useStackBall } from '@sulsul/ui';
import { useEffect, useState } from 'react';
import { drinkImage, drinks } from '../constants/drinks';

export const Falling = () => {
const [isFirstTouch, setIsFirstTouch] = useState(false);
const { addBall, boxRef, canvasRef } = useStackBall();

useEffect(() => {
const addItem = (event: any) => {
if (!isFirstTouch) {
setIsFirstTouch(true);
return;
}

if (event.detail.data === undefined) {
throw new Error('event.detail.data is undefined');
}

const { image, size } = drinkImage[event.detail.data as drinks];
addBall(image, size);

window.sulsulBridge.onAddBallSuccess(event.detail.data as drinks);
};
window.addEventListener('addBall', addItem);

return () => {
window.removeEventListener('addBall', addItem);
};
}, [addBall, isFirstTouch]);

return (
<div style={{ width: '100%', height: '100dvh' }}>
<StackView boxRef={boxRef} canvasRef={canvasRef} isTouched={isFirstTouch} />
</div>
);
};
24 changes: 24 additions & 0 deletions apps/falling/src/app/constants/drinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const drinkImage = {
소주: {
image: '/images/bubble-soju.png',
size: 80,
},
맥주: {
image: '/images/bubble-beer.png',
size: 100,
},
와인: {
image: '/images/bubble-wine.png',
size: 92,
},
고량주: {
image: '/images/bubble-goryanju.png',
size: 68,
},
위스키: {
image: '/images/bubble-whisky.png',
size: 68,
},
} as const;

export type drinks = keyof typeof drinkImage;
29 changes: 19 additions & 10 deletions apps/falling/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import { SuspensiveConfigs, SuspensiveProvider } from '@suspensive/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { Inter } from 'next/font/google';
import { AndroidWebviewProvider } from '~/contexts/androidWeview';
import RootStyleRegistry from '../../emotion';

import './globals.css';

declare global {
interface Window {
sulsulBridge: any;
}
}

const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand All @@ -34,16 +41,18 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html lang="en">
<body className={inter.className}>
<RootStyleRegistry>
<MediaQueryProvider pxs={[0, 768, 1440]}>
<SuspensiveProvider configs={suspensiveConfigs}>
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={token}>{children}</ThemeProvider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</SuspensiveProvider>
</MediaQueryProvider>
</RootStyleRegistry>
<AndroidWebviewProvider>
<RootStyleRegistry>
<MediaQueryProvider pxs={[0, 768, 1440]}>
<SuspensiveProvider configs={suspensiveConfigs}>
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={token}>{children}</ThemeProvider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</SuspensiveProvider>
</MediaQueryProvider>
</RootStyleRegistry>
</AndroidWebviewProvider>
</body>
</html>
);
Expand Down
4 changes: 3 additions & 1 deletion apps/falling/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import { Falling } from './components/Falling';

export default function Home() {
return <main>explore amplify test</main>;
return <Falling />;
}
72 changes: 72 additions & 0 deletions apps/falling/src/contexts/androidWeview/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
createContext,
PropsWithChildren,
ReactNode,
Suspense,
useContext,
useEffect,
useState,
} from 'react';

const AndroidWebviewContext = createContext<AndroidWebview | null>(null);
export const AndroidWebviewProvider = (props: PropsWithChildren) => {
const [androidWebview, setAndroidWebview] = useState<AndroidWebview | null>(null);
useEffect(() => {
if ((window as any).android) {
setAndroidWebview((window as any).android);
}
}, []);
return <AndroidWebviewContext.Provider {...props} value={androidWebview} />;
};

export const AndroidWebviewGuaranteed = ({
render,
fallback,
}: {
render: (androidWebview: AndroidWebview) => ReactNode;
fallback?: ReactNode;
}) => {
const androidWebviewContextValue = useContext(AndroidWebviewContext);

if (androidWebviewContextValue === null) {
return <>{fallback}</>;
}
const androidWebview = androidWebviewContextValue;
return <>{render(androidWebview)}</>;
};

interface AndroidWebview {
showToastMessage(): void;
}

export const useAndroidWebview = (): AndroidWebview => {
const androidWebviewContextValue = useContext(AndroidWebviewContext);

if (androidWebviewContextValue === null) {
throw new Promise(() => {});
}

return androidWebviewContextValue;
};

export const Comp = () => {
return (
<>
hihihih jijojooj
<Suspense fallback={<>loading...</>}>
<AndroidWebviewUser />
</Suspense>
<AndroidWebviewGuaranteed
render={(webview) => <button onClick={webview.showToastMessage}>hi</button>}
/>
</>
);
};

const AndroidWebviewUser = () => {
const androidWebview = useAndroidWebview();

const handleClick = () => androidWebview.showToastMessage();

return <button onClick={handleClick}></button>;
};
3 changes: 3 additions & 0 deletions apps/onboarding/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
root: true,
extends: ['@sulsul/eslint-config/react-ts-noimport', 'plugin:@next/next/recommended'],
rules: {
'react/no-unknown-property': ['error', { ignore: ['css'] }],
},
};
26 changes: 0 additions & 26 deletions apps/onboarding/emotion.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions apps/onboarding/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare namespace NodeJS {
interface ProcessEnv {
readonly NODE_ENV: 'development' | 'production' | 'test';
readonly NEXT_PUBLIC_DOMAIN: string;
}
}
11 changes: 9 additions & 2 deletions apps/onboarding/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ const nextConfig = {
'@suspensive/react',
'@suspensive/react-query',
],
compiler: {
emotion: true,
webpack: (config) => {
config.module.rules.push({
test: /\.svg$/i,
use: ['@svgr/webpack'],
});
return config;
},
images: {
formats: ['image/avif', 'image/webp'],
},
};

Expand Down
3 changes: 3 additions & 0 deletions apps/onboarding/openapi-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"allowUnicodeIdentifiers": true
}
7 changes: 7 additions & 0 deletions apps/onboarding/openapitools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
}
}
11 changes: 9 additions & 2 deletions apps/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"build": "next build",
"dev": "next dev --port 3000",
"lint": "next lint",
"start": "next start"
"spec:api": "openapi-generator-cli generate -g typescript-axios -i ../../openapispec.json -o ./src/api -c openapi-config.json",
"start": "next start",
"type:check": "tsc --noEmit"
},
"dependencies": {
"@emotion/react": "^11.11.0",
Expand All @@ -18,21 +20,26 @@
"@sulsul/ui": "workspace:*",
"@suspensive/react": "^1.11.2",
"@suspensive/react-query": "^1.11.2",
"@svgr/webpack": "^8.0.1",
"@tanstack/react-query": "^4.29.3",
"@tanstack/react-query-devtools": "^4.29.3",
"axios": "^1.3.6",
"framer-motion": "^10.12.4",
"next": "13.4.4",
"next": "13.4.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.43.9",
"react-hook-step": "workspace:*",
"tss-react": "^4.8.8",
"zod": "^3.21.4"
},
"devDependencies": {
"@emotion/babel-plugin": "^11.11.0",
"@next/eslint-plugin-next": "13.4.6",
"@openapitools/openapi-generator-cli": "^2.6.0",
"@sulsul/eslint-config": "workspace:*",
"@sulsul/tsconfig": "workspace:*",
"@svgr/webpack": "^8.0.1",
"@types/node": "^17.0.12",
"@types/react": "18.2.8",
"@types/react-dom": "18.2.4",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/favicons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/favicons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions apps/onboarding/public/favicons/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "sulsul",
"short_name": "sulsul",
"icons": [
{
"src": "/favicons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/favicons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added apps/onboarding/public/images/bubble-beer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/images/bubble-goryanju.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/images/bubble-soju.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/images/bubble-whisky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/images/bubble-wine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/onboarding/public/metadata/images/baby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 0 additions & 1 deletion apps/onboarding/public/next.svg

This file was deleted.

11 changes: 11 additions & 0 deletions apps/onboarding/public/svgs/grainy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion apps/onboarding/public/vercel.svg

This file was deleted.

8 changes: 8 additions & 0 deletions apps/onboarding/src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"env": {
"production": {
"plugins": ["@emotion"]
}
},
"plugins": ["@emotion"]
}
Loading

0 comments on commit cb126a3

Please sign in to comment.