├── src
├── const
│ ├── index.ts
│ └── color.ts
├── types
│ ├── index.ts
│ └── type.ts
├── pages
│ ├── index.ts
│ └── DashboardPage
│ │ └── index.tsx
├── containers
│ ├── index.ts
│ └── DashboardContainer
│ │ └── index.tsx
├── react-app-env.d.ts
├── components
│ ├── index.ts
│ ├── view
│ │ ├── DashboardView
│ │ │ ├── index.tsx
│ │ │ ├── BombView
│ │ │ │ ├── style.tsx
│ │ │ │ └── index.tsx
│ │ │ └── SidebarView
│ │ │ │ ├── style.tsx
│ │ │ │ └── index.tsx
│ │ └── index.ts
│ └── common
│ │ ├── index.tsx
│ │ ├── Layout
│ │ ├── styles.tsx
│ │ └── index.tsx
│ │ ├── StyledComponent
│ │ └── index.tsx
│ │ ├── Select
│ │ ├── style.tsx
│ │ └── index.tsx
│ │ ├── BetInput
│ │ ├── style.tsx
│ │ └── index.tsx
│ │ ├── BtcInput
│ │ ├── style.tsx
│ │ └── index.tsx
│ │ └── Card
│ │ ├── index.tsx
│ │ └── style.tsx
├── assets
│ ├── 1.png
│ ├── bomb.png
│ ├── usd.png
│ ├── jewel.png
│ ├── explosion.gif
│ ├── gem.svg
│ └── bomb.svg
├── setupTests.ts
├── App.test.tsx
├── index.css
├── reportWebVitals.ts
├── index.tsx
├── App.css
├── App.tsx
└── logo.svg
├── public
├── favicon.ico
├── logo192.png
├── logo512.png
├── robots.txt
├── manifest.json
└── index.html
├── .gitignore
├── tsconfig.json
├── package.json
└── README.md
/src/const/index.ts:
--------------------------------------------------------------------------------
1 | export * from './color'
--------------------------------------------------------------------------------
/src/types/index.ts:
--------------------------------------------------------------------------------
1 | export * from './type';
--------------------------------------------------------------------------------
/src/pages/index.ts:
--------------------------------------------------------------------------------
1 | export * from './DashboardPage'
--------------------------------------------------------------------------------
/src/containers/index.ts:
--------------------------------------------------------------------------------
1 | export * from './DashboardContainer'
--------------------------------------------------------------------------------
/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/src/components/index.ts:
--------------------------------------------------------------------------------
1 | export * from './view'
2 | export * from './common'
--------------------------------------------------------------------------------
/src/types/type.ts:
--------------------------------------------------------------------------------
1 | export type Dispatcher = React.Dispatch>;
--------------------------------------------------------------------------------
/src/assets/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/src/assets/1.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/assets/bomb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/src/assets/bomb.png
--------------------------------------------------------------------------------
/src/assets/usd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/src/assets/usd.png
--------------------------------------------------------------------------------
/src/assets/jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/src/assets/jewel.png
--------------------------------------------------------------------------------
/src/assets/explosion.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akatsukione/betting-bomb/HEAD/src/assets/explosion.gif
--------------------------------------------------------------------------------
/src/components/view/DashboardView/index.tsx:
--------------------------------------------------------------------------------
1 | export * from './BombView'
2 | export * from './SidebarView'
3 |
--------------------------------------------------------------------------------
/src/components/view/index.ts:
--------------------------------------------------------------------------------
1 | // export * from './DashboardView/SidebarView'
2 | export * from './DashboardView'
--------------------------------------------------------------------------------
/src/components/common/index.tsx:
--------------------------------------------------------------------------------
1 | export * from './Layout'
2 | export * from './BetInput'
3 | export * from './BetInput'
4 | export * from './Card'
5 | export * from './Select'
6 | export * from './StyledComponent'
--------------------------------------------------------------------------------
/src/components/common/Layout/styles.tsx:
--------------------------------------------------------------------------------
1 | import styled from 'styled-components';
2 |
3 | export const LayoutContainer = styled.main`
4 | width: 100%;
5 | position: fixed;
6 | top: 0px;
7 | bottom: 0px;
8 | background-color: rgb(191 219 254);
9 | `;
--------------------------------------------------------------------------------
/src/setupTests.ts:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/src/pages/DashboardPage/index.tsx:
--------------------------------------------------------------------------------
1 | import { DashboardContainer } from 'containers';
2 | import React from 'react';
3 | import { WithLayout } from 'components';
4 |
5 | const Dashboard: React.FC = () => {
6 | return ;
7 | };
8 |
9 | export const DashboardPage = WithLayout(Dashboard);
10 |
--------------------------------------------------------------------------------
/src/App.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render, screen } from '@testing-library/react';
3 | import {App} from './App';
4 |
5 | test('renders learn react link', () => {
6 | render();
7 | const linkElement = screen.getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/src/components/common/StyledComponent/index.tsx:
--------------------------------------------------------------------------------
1 | import styled from 'styled-components';
2 | import { basicColor } from 'const';
3 |
4 | export const DashboardStyledComponent = styled.div`
5 | width: 100%;
6 | display: flex;
7 | position: fixed;
8 | top: 0px;
9 | bottom: 0px;
10 | background-color:${basicColor};
11 | `;
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/const/color.ts:
--------------------------------------------------------------------------------
1 | export const sidebarColor = 'rgb(33 55 67)';
2 | export const basicColor = 'rgb(15 33 46)';
3 | export const tileColor = 'rgb(47 69 83)';
4 | export const fontColor = `rgb(177 186 211)`
5 | export const darkBtnColor = `rgb(0 231 1)`
6 | export const lightBtnColor = `rgb(31 255 32)`
7 | export const hoverColor = `rgb(85 112 134)`
8 | export const hoverButtonColor = `rgb(61 85 100)`
9 | export const tileBackgroundColor = `rgb(7 24 36)`
--------------------------------------------------------------------------------
/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | import { ReportHandler } from 'web-vitals';
2 |
3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4 | if (onPerfEntry && onPerfEntry instanceof Function) {
5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6 | getCLS(onPerfEntry);
7 | getFID(onPerfEntry);
8 | getFCP(onPerfEntry);
9 | getLCP(onPerfEntry);
10 | getTTFB(onPerfEntry);
11 | });
12 | }
13 | };
14 |
15 | export default reportWebVitals;
16 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import { App } from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | const root = ReactDOM.createRoot(
8 | document.getElementById('root') as HTMLElement
9 | );
10 | root.render(
11 |
12 |
13 |
14 | );
15 |
16 | // If you want to start measuring performance in your app, pass a function
17 | // to log results (for example: reportWebVitals(console.log))
18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19 | reportWebVitals();
20 |
--------------------------------------------------------------------------------
/src/components/common/Layout/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import { LayoutContainer } from './styles';
4 |
5 | interface LayoutProps {
6 | children?: React.ReactNode;
7 | }
8 |
9 | export const LayoutComponent: React.FC = ({ children }) => {
10 | return (
11 |
12 | {children}
13 |
14 | );
15 | };
16 |
17 | // HOC WithLayout (Higher Order Component)
18 | // eslint-disable-next-line @typescript-eslint/naming-convention
19 | export const WithLayout = (Component: React.FC) => () => {
20 | return (
21 |
22 |
23 |
24 | );
25 | };
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react-jsx",
22 | "baseUrl": "src"
23 | },
24 | "include": [
25 | "src"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.tsx:
--------------------------------------------------------------------------------
1 | // import { PATH } from 'consts';
2 | import React from 'react';
3 | // import { Provider } from 'react-redux';
4 | // import { BrowserRouter, Routes, Route } from 'react-router-dom';
5 | // import { store } from 'store';
6 | import { DashboardPage } from 'pages';
7 |
8 | export const App: React.FC = () => {
9 | return (
10 |
11 | //
12 | //
13 | //
14 | // } />
15 | // {/* } />
16 | // } /> */}
17 | //
18 | //
19 | //
20 | );
21 | };
--------------------------------------------------------------------------------
/src/components/common/Select/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | import { basicColor, tileColor, fontColor } from "const";
3 |
4 | export const InputComponentContainer = styled.div`
5 | position:relative;
6 | width:100%;
7 | box-sizing:border-box;
8 | `;
9 | export const MineSelectComponent = styled.select<
10 | React.InputHTMLAttributes
11 | >`
12 | border-bottom-left-radius: 0.25rem;
13 | border-top-left-radius: 0.25rem;
14 | padding: 0.625rem;
15 | font-weight: 500;
16 | // cursor: not-allowed;
17 | font-size: 0.875rem;
18 | line-height: 1.25rem;
19 | background-color: ${basicColor};
20 | border: 2px solid ${tileColor};
21 | outline: 2px solid transparent;
22 | outline-offset: 2px;
23 | width:100%;
24 | color: ${fontColor};
25 | `;
26 |
--------------------------------------------------------------------------------
/src/components/common/Select/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { MineSelectComponent, InputComponentContainer } from "./style";
3 | import { Dispatcher } from "types";
4 | interface SelectComponentProps {
5 | bombNum: number,
6 | setBombNum: Dispatcher
7 | }
8 | export const SelectComponent: React.FC = (props) => {
9 | const onSelectAction = (value:number) => {
10 | props.setBombNum(value)
11 | }
12 | return (
13 |
14 | onSelectAction(parseInt(e.target.value))}>
15 | {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24].map((i) => {
16 | return
17 | })}
18 |
19 |
20 | );
21 | };
22 |
--------------------------------------------------------------------------------
/src/components/common/BetInput/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | import { tileColor, fontColor, hoverButtonColor } from "const";
3 | export const InputContainer = styled.div`
4 | display: flex;
5 | width: 100%;
6 | &.disableInput > *:hover{
7 | cursor: not-allowed;
8 | }
9 | &:not(.disableInput) button:hover{
10 | background-color: ${hoverButtonColor}
11 | }
12 | `;
13 |
14 | export const BetbtnComponent = styled.button`
15 | padding: 0.625rem;
16 | font-size: 0.875rem;
17 | line-height: 1.25rem;
18 | font-weight: 500;
19 | outline: 2px solid transparent;
20 | outline-offset: 2px;
21 | background-color: ${tileColor};
22 | color: ${fontColor};
23 | border-width: 0;
24 | width: 3.5rem;
25 | &.double-bet{
26 | position:relative;
27 | border-bottom-right-radius: 0.25rem;
28 | border-top-right-radius: 0.25rem;
29 | }
30 | &.double-bet::before {
31 | width: 0.125rem;
32 | bottom: 25%;
33 | top: 25%;
34 | left: -1px;
35 | position: absolute;
36 | background-color: rgb(15 33 46);
37 | content: " ";
38 | }
39 | `;
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "betting-bomb",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.17.0",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "@types/jest": "^27.5.2",
10 | "@types/node": "^16.18.58",
11 | "@types/react": "^18.2.28",
12 | "@types/react-dom": "^18.2.13",
13 | "react": "^18.2.0",
14 | "react-dom": "^18.2.0",
15 | "react-router-dom": "^6.17.0",
16 | "react-scripts": "5.0.1",
17 | "styled-components": "^6.1.0",
18 | "typescript": "^4.9.5",
19 | "web-vitals": "^2.1.4"
20 | },
21 | "scripts": {
22 | "start": "react-scripts start",
23 | "build": "react-scripts build",
24 | "test": "react-scripts test",
25 | "eject": "react-scripts eject"
26 | },
27 | "eslintConfig": {
28 | "extends": [
29 | "react-app",
30 | "react-app/jest"
31 | ]
32 | },
33 | "browserslist": {
34 | "production": [
35 | ">0.2%",
36 | "not dead",
37 | "not op_mini all"
38 | ],
39 | "development": [
40 | "last 1 chrome version",
41 | "last 1 firefox version",
42 | "last 1 safari version"
43 | ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/components/common/BtcInput/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | import {hoverColor, tileColor } from "const";
3 |
4 | interface InputComponentProps {
5 | backgroundcolor: string;
6 | }
7 |
8 | export const InputComponentContainer = styled.div`
9 | position:relative;
10 | box-sizing:border-box;
11 | `;
12 |
13 | export const InputComponent = styled.input<
14 | InputComponentProps
15 | >`
16 | border-top-left-radius: 0.25rem;
17 | border-bottom-left-radius: 0.25rem;
18 | border-color: rgb(47 69 83);
19 | padding: 0.625rem;
20 | padding-right: 2rem;
21 | font-weight: 500;
22 | font-size: 0.875rem;
23 | line-height: 1.25rem;
24 | border: 2px solid ${tileColor};
25 | outline: 2px solid transparent;
26 | outline-offset: 2px;
27 | color:${(props) => props.color};
28 | background-color:${(props) => props.backgroundcolor};
29 | width: 100%;
30 | box-shadow: 0 1px 3px 0 rgba(0,0,0,0.2),0 1px 2px 0 rgba(0,0,0,0.12);
31 | box-sizing:border-box;
32 | &.disableInput{
33 | pointer-events: none;
34 | }
35 | &:not(.bet-amount){
36 | border-radius: 0.25rem;
37 | }
38 | &:hover {
39 | border-color: ${hoverColor}
40 | }
41 | `;
42 |
43 | export const InputIconContainer = styled.div`
44 | top: 0;
45 | bottom: 0;
46 | padding-right: 0.75rem;
47 | right: 0;
48 | position:absolute;
49 | display: flex;
50 | align-items: center;
51 | `;
52 |
53 | export const IconImage = styled.img`
54 | height: 1rem
55 | `;
56 |
--------------------------------------------------------------------------------
/src/components/common/BtcInput/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | InputComponent,
4 | InputIconContainer,
5 | InputComponentContainer,
6 | IconImage,
7 | } from "./style";
8 |
9 | type Dispatcher = React.Dispatch>;
10 |
11 | interface InputComponentType {
12 | icon?: string;
13 | color: string;
14 | type: string;
15 | background: string;
16 | disable?: boolean;
17 | classname?: string;
18 | setAction?: Dispatcher;
19 | initialValue: number;
20 | }
21 | export const BtcInputComponent: React.FC> = (
22 | props
23 | ) => {
24 | const changeValue = (amount:number) => {
25 | if (props.setAction) {
26 | props.setAction(amount)
27 | }
28 | }
29 | return (
30 |
31 | {
41 | changeValue(parseFloat(e.target.value))
42 | }}
43 | readOnly = {props.type === 'text'}
44 | />
45 |
46 |
47 |
48 |
49 | );
50 | };
51 |
--------------------------------------------------------------------------------
/src/components/common/BetInput/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { BtcInputComponent } from "../BtcInput";
3 | import { InputContainer, BetbtnComponent } from "./style";
4 | import dollarSignImg from "assets/usd.png";
5 | import { fontColor, basicColor } from "const";
6 |
7 | type Dispatcher = React.Dispatch>;
8 |
9 | interface BetGroupComponentProps {
10 | disableInput: boolean;
11 | betAmount: number;
12 | setBetAmount?: Dispatcher;
13 | }
14 | export const BetGroupComponent: React.FC = (props:BetGroupComponentProps) => {
15 | const onClickBetAmount = (multi:number) =>{
16 | if (props.setBetAmount) {
17 | props.setBetAmount(props.betAmount*multi)
18 | console.log(props.betAmount)
19 | }
20 | }
21 | React.useEffect(()=>{
22 | console.log(props.betAmount)
23 | },[props.betAmount])
24 | return (
25 |
26 |
36 | onClickBetAmount(0.5)}>½
37 | onClickBetAmount(2)} className="double-bet">2×
38 |
39 | );
40 | };
41 |
--------------------------------------------------------------------------------
/src/components/common/Card/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { CardItem, ExplosionContainer, ItemContainer } from "./style";
3 | import { Dispatcher } from "types";
4 |
5 | import bomb from "assets/bomb.svg";
6 | import jewel from "assets/gem.svg";
7 | import explosion from "assets/explosion.gif";
8 | interface CardComponentProps {
9 | isBet: boolean;
10 | isBoom: boolean;
11 | isBomb: boolean;
12 | openedArray: number[];
13 | setBoom: Dispatcher;
14 | setOpenedArray: Dispatcher;
15 | order: number;
16 | isCashable: boolean;
17 | setCashable: Dispatcher;
18 | setBet: Dispatcher;
19 | }
20 | export const CardComponent: React.FC = (props) => {
21 | const onCardClick = (i: number) => {
22 | if (props.isBet) {
23 | props.setOpenedArray((oldArray) => [...oldArray, props.order]);
24 | props.setCashable(true);
25 | }
26 | if (props.isBomb) {
27 | props.setBoom(true);
28 | props.setBet(false);
29 | }
30 | };
31 |
32 | return (
33 | onCardClick(props.order)}
39 | >
40 |
45 |
57 |
58 | );
59 | };
60 |
--------------------------------------------------------------------------------
/src/components/view/DashboardView/BombView/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | // import { sidebarColor, fontColor, darkBtnColor, lightBtnColor, tileColor, hoverButtonColor } from "const";
3 |
4 | export const CardContainer = styled.div`
5 | position: relative;
6 | width: 100%;
7 | display: grid;
8 | justify-content: center;
9 | align-content: center;
10 | grid-template-columns: auto auto auto auto auto;
11 | grid-template-reows: auto auto auto auto auto;
12 | gap: 0.5rem;
13 | `;
14 | export const NotifycationStyleComponent = styled.div`
15 | z-index:2;
16 | position: absolute;
17 | display: align;
18 | padding: 0.875rem 2rem;
19 | background-color: rgb(33 55 67);
20 | border: 3px solid rgb(0 231 1);
21 | border-radius: 0.375rem;
22 | justify-content: center;
23 | align-content: center;
24 | top: 50%; /* position the top edge of the element at the middle of the parent */
25 | left: 50%; /* position the left edge of the element at the middle of the parent */
26 | transform: translate(-50%, -50%);
27 | `;
28 | export const BetTimesStyleComponent = styled.span`
29 | color: rgb(0 231 1);
30 | font-weight: 500;
31 | font-size: 1.5rem;
32 | line-height: 2rem;
33 | `;
34 | export const HorizontalBar = styled.div`
35 | display: block;
36 | background-color: rgb(47 69 83);
37 | width: 50%;
38 | height: 3px;
39 | margin: auto;
40 | margin-bottom: 0.5rem;
41 | margin-top: 0.5rem;
42 | box-sizing: border-box;
43 | `;
44 | export const ProfitStyleContainer = styled.div`
45 | display: flex;
46 | justify-content: center;
47 | align-items: center;
48 | `;
49 | export const ProfitStyleComponent = styled.span`
50 | color: rgb(0 231 1);
51 | font-weight: 500;
52 | font-size: 0.875rem;
53 | line-height: 1.25rem;
54 | margin-right: 0.25rem;
55 | `;
56 | export const DollarStyleComponent = styled.img`
57 | width: 1rem;
58 | `;
59 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/components/view/DashboardView/BombView/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { CardComponent } from "components";
3 | import DollarImg from 'assets/usd.png'
4 | import {
5 | CardContainer,
6 | NotifycationStyleComponent,
7 | HorizontalBar,
8 | BetTimesStyleComponent,
9 | ProfitStyleContainer,
10 | ProfitStyleComponent,
11 | DollarStyleComponent
12 | } from "./style";
13 | import { Dispatcher } from "types";
14 | interface BombViewProps {
15 | isBet: boolean;
16 | bombNum: number;
17 | openedArray: number[];
18 | setOpenedArray: Dispatcher;
19 | isBoom: boolean;
20 | setBoom: Dispatcher;
21 | bombs: number[];
22 | isCashable: boolean;
23 | setCashable: Dispatcher;
24 | isCashed:boolean;
25 | setBet: Dispatcher;
26 | }
27 |
28 | export const BombView: React.FC = (props) => {
29 | const numbers: number[] = Array.from({ length: 25 }, (_, i) => i + 1);
30 | return (
31 |
32 | {numbers.map((i) => {
33 | return (
34 |
47 | );
48 | })}
49 |
50 | {0.04*Array.from(new Set(props.openedArray)).length}×
51 |
52 |
53 | 0.00
54 |
55 |
56 |
57 |
58 | );
59 | };
60 |
--------------------------------------------------------------------------------
/src/assets/gem.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | 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.
37 |
38 | 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.
39 |
40 | 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.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
--------------------------------------------------------------------------------
/src/containers/DashboardContainer/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { DashboardStyledComponent, SidebarView, BombView } from "components";
3 |
4 | export const DashboardContainer: React.FC = () => {
5 | const [betAmount, setBetAmount] = React.useState(0.0);
6 | const [bombNum, setBombNum] = React.useState(3);
7 | const [isBet, setBet] = React.useState(false);
8 | const [isCashable, setCashable] = React.useState(false);
9 | const [openedArray, setOpenedArray] = React.useState([]);
10 | const [isBoom, setBoom] = React.useState(false);
11 | const [bombArray, setBombArray] = React.useState([])
12 | const [isCashed, setCashed] = React.useState(false)
13 |
14 | const numbers: number[] = Array.from({ length: 25 }, (_, i) => i + 1);
15 | // React.useEffect(()=>{
16 | // if (isBet) {
17 | // setBombArray(random_bombs([...numbers], bombNum))
18 | // }
19 | // },[bombNum])
20 | React.useEffect(()=>{
21 | if (isBet) {
22 | setBombArray(random_bombs([...numbers], bombNum))
23 | }
24 | },[isBet])
25 |
26 | function random_bombs(range: number[], n: number) {
27 | const sample: number[] = [];
28 | for (let i = 0; i < n; i++) {
29 | const index = Math.floor(Math.random() * range.length);
30 | const removedValue = range.splice(index, 1)[0];
31 | sample.push(removedValue);
32 | }
33 | return sample;
34 | }
35 |
36 | return (
37 |
38 |
53 |
66 |
67 | );
68 | };
69 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/view/DashboardView/SidebarView/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | import {
3 | sidebarColor,
4 | fontColor,
5 | darkBtnColor,
6 | lightBtnColor,
7 | tileColor,
8 | hoverButtonColor,
9 | } from "const";
10 |
11 | export const SidebarContainer = styled.div`
12 | width: 24rem;
13 |
14 | padding: 0.75rem;
15 | background-color: ${sidebarColor};
16 | `;
17 | export const SidebarSection = styled.div`
18 | width: 100%;
19 | margin-bottom: 0.75rem;
20 | `;
21 | export const SettingGroup = styled.div``;
22 | export const LabelFlexContainer = styled.label`
23 | width: 100%;
24 | display: flex;
25 | justify-content: space-between;
26 | margin-bottom: 4px;
27 | `;
28 | export const LabelComponent = styled.label`
29 | color: ${fontColor};
30 | font-weight: 500;
31 | font-size: 0.875rem;
32 | &.${(props) => props.className} {
33 | padding-top: 4px;
34 | display: inline-block;
35 | font-size: 0.75rem;
36 | line-height: 1rem;
37 | vertical-align: bottom;
38 | }
39 | `;
40 | export const InputContainer = styled.div`
41 | width: 100%;
42 | display: flex;
43 | justify-content: space-between;
44 | `;
45 | export const BetBtn = styled.button`
46 | padding: 10px;
47 | `;
48 | export const FlexContainer = styled.div`
49 | display: flex;
50 | gap: 0.5rem;
51 | margin-bottom: 0.75rem;
52 | // justify-content: space-between;
53 | `;
54 | export const RandomBtn = styled.button`
55 | border-radius: 0.25rem;
56 | border-color: rgb(47 69 83);
57 | padding: 0.625rem;
58 | padding-right: 2rem;
59 | font-weight: 500;
60 | font-size: 0.875rem;
61 | line-height: 1.25rem;
62 | border: 2px solid ${tileColor};
63 | outline: 2px solid transparent;
64 | outline-offset: 2px;
65 | color: ${fontColor};
66 | background-color: ${tileColor};
67 | box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.2), 0 1px 2px 0 rgba(0, 0, 0, 0.12);
68 | width: 100%;
69 | box-sizing: border-box;
70 | &:hover {
71 | background-color: ${hoverButtonColor};
72 | border-color: ${hoverButtonColor};
73 | cursor: pointer;
74 | }
75 | &:active {
76 | animation: random-click 0.5s ease;
77 |
78 | @keyframes random-click {
79 | 0% {
80 | font-size:0.875rem;
81 | }
82 | 100% {
83 | font-size:0.7rem;
84 | }
85 | }
86 | cursor: pointer;
87 | }
88 | `;
89 | export const ButtonComponent = styled.button`
90 | background-color: ${darkBtnColor};
91 | font-weight: 500;
92 | font-size: 0.875rem;
93 | line-height: 1.25rem;
94 | border-radius: 0.25rem;
95 | width: 100%;
96 | height: 3.5rem;
97 | border-width: 0;
98 |
99 | &:not(.disable):hover {
100 | background-color: ${lightBtnColor};
101 | cursor: pointer;
102 | }
103 |
104 | &:not(.disable):active {
105 | background-color: ${lightBtnColor};
106 | cursor: pointer;
107 | }
108 | &.disable:hover {
109 | background-color: red;
110 | cursor: not-allowed;
111 | }
112 | &.disable {
113 | opacity: 0.5;
114 | pointer-events: none;
115 | }
116 | `;
117 |
--------------------------------------------------------------------------------
/src/assets/bomb.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/view/DashboardView/SidebarView/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | SidebarSection,
4 | SidebarContainer,
5 | LabelFlexContainer,
6 | LabelComponent,
7 | ButtonComponent,
8 | FlexContainer,
9 | SettingGroup,
10 | RandomBtn,
11 | } from "./style";
12 | import { BetGroupComponent } from "components/common";
13 | import { SelectComponent } from "components";
14 | import { BtcInputComponent } from "components/common/BtcInput";
15 | import bombImg from "assets/bomb.png";
16 | import jewelImg from "assets/jewel.png";
17 | import dollarImg from "assets/usd.png";
18 | import { fontColor, tileColor } from "const";
19 |
20 | type Dispatcher = React.Dispatch>;
21 |
22 | interface SidebarProps {
23 | openedArray: number[],
24 | setOpenedArray: Dispatcher,
25 | isBet: boolean,
26 | betAmount: number,
27 | bombArray: number[],
28 | bombNum: number,
29 | setBombNum: Dispatcher,
30 | setBetAmount?: Dispatcher,
31 | setBet: Dispatcher,
32 | setBoom: Dispatcher,
33 | isCashable:boolean,
34 | setCashable: Dispatcher,
35 | setCashed: Dispatcher,
36 | }
37 |
38 | export const SidebarView:React.FC = (props:SidebarProps) => {
39 |
40 | const onBetClicked = () => {
41 | props.setBet((prevState) => !prevState);
42 | props.setBoom(false)
43 | props.setCashable(false)
44 | props.setOpenedArray([])
45 | props.setCashed(false)
46 | };
47 | const onCashClicked = () => {
48 | props.setBet((prevState) => !prevState);
49 | props.setBoom(true)
50 | props.setCashable(false)
51 | // props.setOpenedArray([])
52 | props.setCashed(true)
53 | };
54 | const generateRandom = () =>{
55 | var arr = props.openedArray;
56 | var r = Math.floor(Math.random() * 25) + 1;
57 |
58 | if(arr.indexOf(r) === -1){
59 | props.setOpenedArray(oldArray => [...oldArray, r])
60 | if (props.bombArray.includes(r)) {
61 | props.setBoom(true)
62 | props.setBet(false)
63 | }
64 | props.setCashable(true)
65 | }else{
66 | generateRandom()
67 | }
68 | }
69 | return (
70 |
71 |
72 |
73 | Bet Amount
74 | BTC {Number(0.000048*props.betAmount).toFixed(8)}
75 |
76 |
77 |
78 | {!props.isBet && (
79 |
80 |
81 | Mines
82 |
83 |
84 |
85 | )}
86 | {props.isBet && (
87 | <>
88 |
89 |
90 |
91 | Mines
92 |
93 |
100 |
101 |
102 |
103 | Gems
104 |
105 |
112 |
113 |
114 |
115 |
116 |
117 | Total profit ({0.04*Array.from(new Set(props.openedArray)).length}×)
118 |
119 | BTC {0.000048*props.betAmount*Array.from(new Set(props.openedArray)).length}
120 |
121 |
122 |
129 |
130 |
131 | Pick random tile
132 |
133 | >
134 | )}
135 |
136 |
140 | Bet
141 |
142 |
147 | Cashout
148 |
149 |
150 |
151 | );
152 | };
153 |
--------------------------------------------------------------------------------
/src/components/common/Card/style.tsx:
--------------------------------------------------------------------------------
1 | import styled from "styled-components";
2 | import {
3 | tileColor,
4 | sidebarColor,
5 | hoverColor,
6 | tileBackgroundColor,
7 | } from "const";
8 |
9 | export const CardItem = styled.div`
10 | position: relative;
11 | width: 7rem;
12 | height: 7rem;
13 | box-shadow: 0 0.3em 0 0 ${sidebarColor};
14 | background-color: ${tileColor};
15 | border-radius: 0.5rem;
16 | margin-bottom: 0.5rem;
17 | animation: initial-load 0.15s ease;
18 |
19 | @keyframes initial-load {
20 | 0% {
21 | transform: scale(0, 0);
22 | }
23 |
24 | 100% {
25 | transform: scale(1, 1);
26 | }
27 | }
28 |
29 | &:hover {
30 | background-color: ${hoverColor};
31 | cursor: pointer;
32 | transform: translateY(-0.15rem);
33 | }
34 | &.open-card {
35 | z-index: 1;
36 | // background-color: ${tileBackgroundColor};
37 | animation: container-click 1s forwards;
38 |
39 | @keyframes container-click {
40 | 0% {
41 | transform: scale(1);
42 | background-color: ${tileColor};
43 | }
44 | 40% {
45 | transform: scale(1.1);
46 | background-color: ${tileColor};
47 | }
48 | 80% {
49 | transform: scale(1);
50 | background-color: ${tileColor};
51 | }
52 | 99% {
53 | transform: scale(0);
54 | background-color: ${tileColor};
55 | }
56 | 100% {
57 | transform: scale(1);
58 | background-color: ${tileBackgroundColor};
59 | }
60 | }
61 | box-shadow: none;
62 | }
63 |
64 |
65 | &.boomed:not(.open-card) {
66 | // background-color: ${tileBackgroundColor};
67 | animation: boomeed-animation 1s forwards;
68 |
69 | @keyframes boomeed-animation {
70 | 0% {
71 | transform: scale(1);
72 | background-color: ${tileColor};
73 | }
74 | 40% {
75 | transform: scale(1);
76 | background-color: ${tileColor};
77 | }
78 | 80% {
79 | transform: scale(1);
80 | background-color: ${tileColor};
81 | }
82 | 99% {
83 | transform: scale(0);
84 | background-color: ${tileColor};
85 | }
86 | 100% {
87 | transform: scale(1);
88 | background-color: ${tileBackgroundColor};
89 | }
90 | }
91 | box-shadow: none;
92 | pointer-events: none;
93 | }
94 | &.boomed:hover {
95 | transform: translateY(0);
96 | }
97 | `;
98 |
99 | export const ExplosionContainer = styled.img`
100 | visibility: hidden;
101 | top: 50%;
102 | left: 50%;
103 | transform: translate(-50%, -50%);
104 | position: absolute;
105 | &:not(.covered) {
106 | display: none;
107 | }
108 | &.covered {
109 | z-index: 2;
110 |
111 | opacity: 1;
112 | width: 9rem;
113 | pointer-events: auto;
114 |
115 |
116 | animation: boom-action 1s forwards;
117 | animation-delay:0.3s;
118 |
119 | @keyframes boom-action {
120 | 0% {
121 | visibility:visible;
122 | transform: scale(0);
123 | opacity: 0;
124 | }
125 | 50% {
126 | visibility:visible;
127 | transform: scale(0);
128 | opacity: 0;
129 | }
130 | 100% {
131 | top: 50%;
132 | left: 50%;
133 | transform: translate(-50%, -50%) scale(1);
134 | opacity: 1;
135 | visibility:visible;
136 | }
137 | }
138 | }
139 |
140 | `;
141 |
142 | export const ItemContainer = styled.img`
143 | visibility: hidden;
144 | &.covered {
145 | width: 5rem;
146 | pointer-events: auto;
147 | animation: item-click 1s forwards;
148 | animation-delay:0.3s;
149 |
150 | @keyframes item-click {
151 | 0% {
152 | visibility:visible;
153 | transform: scale(0);
154 | opacity: 0;
155 | }
156 | 50% {
157 | visibility:visible;
158 | transform: scale(0);
159 | opacity: 0;
160 | }
161 | 100% {
162 | top: 50%;
163 | left: 50%;
164 | transform: translate(-50%, -50%) scale(1);
165 | opacity: 1;
166 | visibility:visible;
167 | }
168 | }
169 | }
170 |
171 | &.boomed:not(.covered){
172 | opacity:0.5;
173 | animation: others-boom-action 1s forwards;
174 | animation-delay:0.3s;
175 |
176 | @keyframes others-boom-action {
177 | 0% {
178 | visibility:visible;
179 | transform: scale(0);
180 | opacity: 0;
181 | }
182 | 50% {
183 | visibility:visible;
184 | transform: scale(0);
185 | opacity: 0;
186 | }
187 | 100% {
188 | top: 50%;
189 | left: 50%;
190 | transform: translate(-50%, -50%) scale(1);
191 | opacity: 0.5;
192 | visibility:visible;
193 | }
194 | }
195 |
196 | }
197 | &.covered.boomed {
198 | width: 5rem;
199 | opacity: 3;
200 | pointer-events: auto;
201 | animation: bomb-click 1s forwards;
202 | animation-delay:0.3s;
203 | // animation
204 | @keyframes bomb-click {
205 | 0% {
206 | visibility:visible;
207 | transform: scale(0);
208 | opacity: 0;
209 | }
210 | 50% {
211 | visibility:visible;
212 | transform: scale(0);
213 | opacity: 0;
214 | }
215 | 100% {
216 | top: 50%;
217 | left: 50%;
218 | transform: translate(-50%, -50%) scale(1);
219 | opacity: 1;
220 | visibility:visible;
221 | }
222 | }
223 | }
224 | opacity: 0.5;
225 | z-index: 2;
226 | top: 50%;
227 | left: 50%;
228 | transform: translate(-50%, -50%);
229 | position: absolute;
230 | `;
231 |
--------------------------------------------------------------------------------