-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from gear-foundation/vt-digit-recognition-frontend
digit-recognition frontend
- Loading branch information
Showing
53 changed files
with
7,225 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
VITE_WALLET_CONNECT_PROJECT_ID= | ||
VITE_GEAR_API_NODE= | ||
VITE_ETH_NODE_ADDRESS= | ||
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
.env | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM node:18-alpine | ||
|
||
WORKDIR /opt | ||
|
||
RUN apk add --no-cache xsel | ||
|
||
COPY package.json yarn.lock ./ | ||
|
||
RUN yarn install --frozen-lockfile | ||
|
||
COPY . . | ||
|
||
ARG VITE_WALLET_CONNECT_PROJECT_ID \ | ||
VITE_GEAR_API_NODE \ | ||
VITE_ETH_NODE_ADDRESS \ | ||
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION | ||
|
||
ENV VITE_WALLET_CONNECT_PROJECT_ID=${VITE_WALLET_CONNECT_PROJECT_ID} \ | ||
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION=${VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION} \ | ||
VITE_GEAR_API_NODE=${VITE_GEAR_API_NODE} \ | ||
VITE_ETH_NODE_ADDRESS=${VITE_ETH_NODE_ADDRESS} \ | ||
DISABLE_ESLINT_PLUGIN=true | ||
|
||
RUN yarn build | ||
|
||
RUN npm install --global serve | ||
|
||
EXPOSE 4173 | ||
|
||
CMD ["serve", "-s", "/opt/dist"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# AI Image Recognition | ||
|
||
## Description | ||
|
||
React application of AI Image Recognition. | ||
|
||
## Getting started | ||
|
||
### Install packages: | ||
|
||
```sh | ||
yarn install | ||
``` | ||
|
||
### Declare environment variables: | ||
|
||
Create `.env` file, `.env.example` will let you know what variables are expected. | ||
|
||
### Run the app: | ||
|
||
```sh | ||
yarn start | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en" class="dark"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/png" href="/favicon.png" sizes="any" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>AI Image Recognition</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "distributed-computation", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"lint": "eslint .", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@polkadot/types": "14.3.1", | ||
"@reown/appkit": "^1.6.0", | ||
"@reown/appkit-adapter-wagmi": "^1.6.0", | ||
"@tanstack/react-query": "^5.59.20", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"wagmi": "^2.12.29" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.13.0", | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"@vitejs/plugin-react": "^4.3.3", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-react-hooks": "^5.0.0", | ||
"eslint-plugin-react-refresh": "^0.4.14", | ||
"globals": "^15.11.0", | ||
"typescript": "~5.6.2", | ||
"typescript-eslint": "^8.11.0", | ||
"vite": "^5.4.10", | ||
"vite-plugin-checker": "0.8.0", | ||
"vite-plugin-svgr": "^4.3.0", | ||
"sass": "1.62.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.connectionWrapper { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 48px; | ||
padding-top: 0; | ||
min-height: calc(100vh - 78px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import "./index.css"; | ||
import { useAccount } from "wagmi"; | ||
|
||
import { WalletButton, Header, Layout } from "@/components"; | ||
import { Recognition } from "./components/recognition/Recognition"; | ||
import { ETH_CHAIN_ID } from "./consts"; | ||
import styles from "./App.module.scss"; | ||
|
||
function App() { | ||
const ethAccount = useAccount(); | ||
const isConnected = Boolean( | ||
ethAccount.chain && ethAccount.chain.id === ETH_CHAIN_ID | ||
); | ||
|
||
return ( | ||
<> | ||
<Header /> | ||
{!isConnected && ( | ||
<Layout className={styles.connectionWrapper}> | ||
<h1>AI Image Recognition</h1> | ||
|
||
<WalletButton /> | ||
</Layout> | ||
)} | ||
{isConnected && <Recognition />} | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
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.
5 changes: 5 additions & 0 deletions
5
digit-recognition/frontend/src/assets/icons/document-copy.svg
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.
14 changes: 14 additions & 0 deletions
14
digit-recognition/frontend/src/components/header/Header.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.container { | ||
width: 100vw; | ||
max-width: 1440px; | ||
margin: 0 auto; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 16px 24px; | ||
height: 78px; | ||
} | ||
|
||
.logo { | ||
width: 107px; | ||
} |
13 changes: 13 additions & 0 deletions
13
digit-recognition/frontend/src/components/header/Header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import logo from "@/assets/logo.png"; | ||
import { WalletButton } from "../wallet/WalletButton"; | ||
import styles from "./Header.module.scss"; | ||
|
||
export const Header = () => { | ||
return ( | ||
<header className={styles.container}> | ||
<img src={logo} className={styles.logo} alt="Gear logo" /> | ||
|
||
<WalletButton /> | ||
</header> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { Header } from "./header/Header"; | ||
export { Layout } from "./layout/Layout"; | ||
export { WalletButton } from "./wallet/WalletButton"; | ||
export { Button } from "./ui/button/Button"; | ||
export { Card } from "./ui/card/Card"; |
5 changes: 5 additions & 0 deletions
5
digit-recognition/frontend/src/components/layout/Layout.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.container { | ||
max-width: 946px; | ||
margin: 0 auto; | ||
padding: 97px 20px 20px; | ||
} |
11 changes: 11 additions & 0 deletions
11
digit-recognition/frontend/src/components/layout/Layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { clsx } from "clsx"; | ||
import { PropsWithChildren } from "react"; | ||
import styles from "./Layout.module.scss"; | ||
|
||
type Props = PropsWithChildren & { | ||
className?: string; | ||
}; | ||
|
||
export const Layout = ({ children, className }: Props) => { | ||
return <div className={clsx(styles.container, className)}>{children}</div>; | ||
}; |
21 changes: 21 additions & 0 deletions
21
digit-recognition/frontend/src/components/recognition/Recognition.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.title { | ||
padding: 0 8px; | ||
} | ||
|
||
.description { | ||
padding: 0 8px; | ||
margin-top: 40px; | ||
margin-bottom: 56px; | ||
} | ||
|
||
.list { | ||
display: flex; | ||
justify-content: space-between; | ||
gap: 32px; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.list { | ||
flex-direction: column; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
digit-recognition/frontend/src/components/recognition/Recognition.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { DigitRecognizer, CatIdentifier } from "@/features"; | ||
import { Layout } from "@/components"; | ||
import styles from "./Recognition.module.scss"; | ||
|
||
export const Recognition = () => { | ||
return ( | ||
<Layout> | ||
<h1 className={styles.title}>AI Image Recognition</h1> | ||
|
||
<p className={styles.description}> | ||
//_Draw a digit or upload an image to experience the power of AI. | ||
Gear.EXE recognition model identifies handwritten numbers (0–9) or | ||
determines if an image contains cats. Submit, see results instantly, and | ||
start again. | ||
</p> | ||
|
||
<div className={styles.list}> | ||
<DigitRecognizer /> | ||
|
||
<CatIdentifier /> | ||
</div> | ||
</Layout> | ||
); | ||
}; |
Oops, something went wrong.