Create the app

This commit is contained in:
Lucàs
2022-08-29 16:54:33 +02:00
parent 125469a876
commit d82ca9a0b7
14 changed files with 3105 additions and 91 deletions
+58
View File
@@ -0,0 +1,58 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="RIGHT_MARGIN" value="80" />
<option name="SOFT_MARGINS" value="80" />
<JSCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
</JSCodeStyleSettings>
<TypeScriptCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="USE_PUBLIC_MODIFIER" value="true" />
<option name="PREFER_AS_TYPE_CAST" value="true" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="PREFER_EXPLICIT_TYPES_VARS_FIELDS" value="true" />
<option name="PREFER_EXPLICIT_TYPES_FUNCTION_RETURNS" value="true" />
<option name="PREFER_EXPLICIT_TYPES_FUNCTION_EXPRESSION_RETURNS" value="true" />
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
<option name="CHAINED_CALL_DOT_ON_NEW_LINE" value="false" />
</TypeScriptCodeStyleSettings>
<codeStyleSettings language="JavaScript">
<option name="RIGHT_MARGIN" value="80" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<option name="RIGHT_MARGIN" value="80" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EslintConfiguration">
<option name="fix-on-save" value="true" />
</component>
</project>
Generated
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/bin2dec" vcs="Git" />
</component>
</project>
+19 -37
View File
@@ -1,46 +1,28 @@
# Getting Started with Create React App <h1 align="center">Welcome to Bin2Dec 👋</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-0.1.0-blue.svg?cacheSeconds=2592000" />
<a href="https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
</p>
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). > Web App that convert binary values into decimal.
## Available Scripts ## Author
In the project directory, you can run: 👤 **LucasVbr**
### `npm start` * Github: [@LucasVbr](https://github.com/LucasVbr)
* LinkedIn: [@lucasvbr](https://linkedin.com/in/lucasvbr)
Runs the app in the development mode.\ ## Show your support
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\ Give a ⭐️ if this project helped you!
You will also see any lint errors in the console.
### `npm test` ## 📝 License
Launches the test runner in the interactive watch mode.\ Copyright © 2022 [LucasVbr](https://github.com/LucasVbr).<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. This project is [MIT](https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt) licensed.
### `npm run build` ***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
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.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent 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 youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt 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/).
+2918
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -3,6 +3,10 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@chakra-ui/icons": "^2.0.9",
"@chakra-ui/react": "^2.2.9",
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0", "@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
@@ -10,6 +14,7 @@
"@types/node": "^16.11.56", "@types/node": "^16.11.56",
"@types/react": "^18.0.17", "@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6", "@types/react-dom": "^18.0.6",
"framer-motion": "^7.2.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
+3 -33
View File
@@ -1,38 +1,8 @@
.App { .App {
text-align: center; width: 100vw;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; justify-content: space-between;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
} }
+14 -20
View File
@@ -1,26 +1,20 @@
import React from 'react'; import React from 'react';
import logo from './logo.svg';
import './App.css'; import './App.css';
function App() { import Header from './components/Header';
import Footer from './components/Footer';
import Content from './components/Content';
import {ChakraProvider, Flex, Spacer} from '@chakra-ui/react';
export default function App() {
return ( return (
<div className="App"> <ChakraProvider>
<header className="App-header"> <Flex width="100vw" minHeight="100vh"
<img src={logo} className="App-logo" alt="logo" /> flexDirection="column" justifyContent="space-between">
<p> <Header/>
Edit <code>src/App.tsx</code> and save to reload. <Content/>
</p> <Footer/>
<a </Flex>
className="App-link" </ChakraProvider>
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
); );
} }
export default App;

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

+42
View File
@@ -0,0 +1,42 @@
import React, {useState} from 'react';
import {Box, Center, Flex, Input, Text} from '@chakra-ui/react';
import {ArrowDownIcon} from '@chakra-ui/icons';
export default function Content() {
// States
const [input, setInput] = useState('');
const [output, setOutput] = useState('');
// Actions
const handleInput = (event: any) => {
const inputAfterChange: string = event.target.value as string;
if (inputAfterChange.length < 8 && isBinary(inputAfterChange)) {
setInput(inputAfterChange);
handleOutput(inputAfterChange);
}
};
const handleOutput = (binaryValue: string) => {
const outputAfterChange = (binaryValue.length)
? `${parseInt(binaryValue, 2)}` : '';
setOutput(outputAfterChange);
};
const isBinary = (value: string) => {
const BINARY_CHAR = ['0', '1'];
for (let char of value) {
if (!BINARY_CHAR.includes(char)) return false;
}
return true;
};
// Render
return (
<Flex align={'center'} flexDirection={'column'} marginX={10}>
<Input variant="filled" placeholder={"Binary"} value={input} onChange={handleInput}/>
<ArrowDownIcon marginY={5} boxSize={8} rounded={'rounded'}/>
<Text fontSize={'2xl'} align={'center'}>{output}</Text>
</Flex>
);
}
+12
View File
@@ -0,0 +1,12 @@
import {Box, Divider, Link, Text} from '@chakra-ui/react';
export default function Footer() {
return (
<Box m={4}>
<Divider/>
<Text align={'center'} marginTop={4}>
MIT Licence © 2022 - <Link>See code on GitHub</Link>
</Text>
</Box>
);
}
+9
View File
@@ -0,0 +1,9 @@
import {Box, Button} from '@chakra-ui/react';
export default function Header() {
return (
<Box margin={2}>
<Button>Bin2Dec</Button>
</Box>
);
}