Skip to content

Commit

Permalink
feat: ui sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Chkhikvadze committed Jan 10, 2024
1 parent cef1616 commit ffe5dfd
Show file tree
Hide file tree
Showing 58 changed files with 12,731 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store

npm-debug.log*
yarn-debug.log*
yarn-error.log*


.env
56 changes: 56 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Getting Started

This is an example of a React app demonstrating how to connect to a validator API.

## Available Scripts

In the project directory, you can run:

### `cd ui`

Change to the ui directory before running any of the following commands.

### `yarn install`

Installs all the dependencies required for the project. Make sure to run this command after changing to the ui directory and before starting the app.

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

**Note:** Before running the app, make sure to run the validator API. See details in [Run Validator API](../docs/running_a_validator.md).

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
65 changes: 65 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "chatbot-web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@microsoft/fetch-event-source": "^2.0.1",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"autoprefixer": "^10.4.16",
"axios": "^1.6.2",
"classnames": "^2.3.2",
"prettier": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.20.0",
"react-scripts": "5.0.1",
"react-syntax-highlighter": "^15.5.0",
"react-toastify": "^9.1.3",
"react-transition-group": "^4.4.5",
"recoil": "^0.7.7",
"showdown": "^2.1.0",
"tailwindcss": "^3.3.5",
"typescript": "^4.4.2",
"uuid": "^9.0.1",
"web-vitals": "^2.1.0",
"yup": "^1.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "CI=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/react-syntax-highlighter": "^15.5.11",
"@types/react-transition-group": "^4.4.10",
"@types/showdown": "^2.0.6",
"@types/uuid": "^9.0.7",
"tailwindcss": "^3.3.5"
}
}
6 changes: 6 additions & 0 deletions ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions ui/public/add-icon.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: 1 addition & 0 deletions ui/public/arrow-up-solid.svg
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 ui/public/black_t.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 ui/public/favicon.ico
Binary file not shown.
Binary file added ui/public/images/404.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 ui/public/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Smart scrape subnet on bittensor network"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Smart Scrape - Chatbot</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
25 changes: 25 additions & 0 deletions ui/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions ui/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
1 change: 1 addition & 0 deletions ui/public/user-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions ui/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
54 changes: 54 additions & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { useEffect } from "react";
import { RecoilRoot } from 'recoil';
import { ToastContainer } from 'react-toastify';
import ChatPage from "./components/chat/ChatPage";
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import NotFound from "./components/NotFound";
import { TransitionGroup, CSSTransition } from 'react-transition-group';

function App() {
useEffect(() => {
if(localStorage.getItem('theme') === 'light'){
document.documentElement.classList.remove("dark")
}
}, []);

return (
<div className="h-screen bg-regular">
<RecoilRoot>
<ToastContainer />
<Router>
<Routes>
<Route path="/" element={
<TransitionGroup>
<CSSTransition
in
timeout={500}
key={6}
classNames="page"
unmountOnExit>
<ChatPage />
</CSSTransition>
</TransitionGroup>
} />

<Route path="*" element={
<TransitionGroup>
<CSSTransition
in
timeout={500}
key={8}
classNames="page"
unmountOnExit>
<NotFound />
</CSSTransition>
</TransitionGroup>
} />
</Routes>
</Router>
</RecoilRoot>
</div>
);
}

export default App;
79 changes: 79 additions & 0 deletions ui/src/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
:root {
--primary: #ffffff;
--primary-2: #3c8083;
--brand-primary: #3c8083;
--secondary: #303030;
--secondary-2: #505050;
--selection: #303030;
--navbar: #f8f9fa;
--navbar-shadow-1: rgba(0, 0, 0, 0.2);
--navbar-shadow-2: rgba(0, 0, 0, 0.14);
--navbar-shadow-3: rgba(0, 0, 0, 0.12);
--svg-primary: rgba(0, 0, 0, 0.7);

--text-base: #505050;
--text-primary: #303030;
--text-secondary: #e5e5e5;
--text-darker-gray: #999999;

--hover: #18585b;
--hover-1: rgba(0, 0, 0, 0.15);
--hover-2: rgba(0, 0, 0, 0.25);
--hover-3: #737373;
--hover-secondary: #505050;
--cyan: #ced4da;
--green: #37b679;
--red: #ed3641;
--pink: #e64980;
--orange: #e9851b;
--purple: #f81ce5;
--blue: #4487b2;
--violet: #5f3dc4;
--violet-light: #7048e8;
--accents-0: #eeeeee;
--accents-1: #f6f6f6;
--accents-2: #f2f2f2;
--accents-3: #e2e2e2;
--accents-4: #f4f4f4;
--accents-5: #e4e4e4;
--accents-6: #868e96;
--accents-7: #959595;
--accents-8: #c3c3c3;
--accents-9: #212529;
--lighter-black: #111111;
--lighter-orange: #eaeaea;
--font-sans: "inter", "Helvetica", sans-serif;
}

.dark {
--primary: #1c1d1a;
--primary-2: #111;
--secondary: #e0e1dd;
--secondary-2: #f1f3f5;
--hover: rgba(255, 255, 255, 0.075);
--hover-1: rgba(255, 255, 255, 0.15);
--hover-2: rgba(255, 255, 255, 0.25);
--selection: var(--purple);
--navbar: #1c1d1a;
--navbar-shadow-1:rgb(255, 255, 255, 1);
/* --navbar-shadow-2:rgba(231, 231, 231, 0); */
/* --navbar-shadow-3:rgba(231, 231, 231, 0); */
--svg-primary: rgba(255, 255, 255, 0.7);

--text-base: white;
--text-primary: white;
--text-secondary: black;
--text-darker-gray: #ebebeb;

--accents-0: #212529;
--accents-1: #343a40;
--accents-2: #495057;
--accents-3: #adb5bd;
--accents-4: #343532;
--accents-5: #ced4da;
--accents-6: #dee2e6;
--accents-7: #e9ecef;
--accents-8: #f1f3f5;
--accents-9: #f8f9fa;
--lighter-black: #111111;
}
5 changes: 5 additions & 0 deletions ui/src/components/Closer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Closer = ({ className }: {className?: string}) => (
<svg xmlns="http://www.w3.org/2000/svg" height="22" width="18" viewBox="0 0 384 512"><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>
);

export default Closer;
Loading

0 comments on commit ffe5dfd

Please sign in to comment.