This commit is contained in:
Adam 2023-01-17 02:41:58 -05:00
parent 9bb9c6e0ea
commit ec3a72cf07
28 changed files with 210 additions and 231 deletions

23
.gitignore vendored
View file

@ -1,2 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/package-lock.json
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -1 +1 @@
# enigma
[https://doordesk.net/enigma](https://doordesk.net/enigma)

23
enigma/.gitignore vendored
View file

@ -1,23 +0,0 @@
# 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
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -1,70 +0,0 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm 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.
### `npm run 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.
### `npm run 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/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

View file

@ -1,39 +0,0 @@
{
"name": "enigma",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.2",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "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"
]
}
}

View file

@ -1,6 +0,0 @@
.machine {
margin: .5em;
width: 11.5em;
outline-style: solid;
outline-color: #DA9475;
}

View file

@ -1,41 +0,0 @@
import { Component } from 'react';
import './Machine.css';
import Rotorbox from './components/Rotorbox.js';
function Lightbox() {
return (
<div>
<div>&nbsp;Q W E R T Z U I O</div>
<div>&nbsp;&nbsp;A S D F G H J K</div>
<div>&nbsp;P Y X C V B N M L</div>
</div>
);
}
class Keyboard extends Component{
render() {
return (
<div>
<div>&nbsp;Q W E R T Z U I O</div>
<div>&nbsp;&nbsp;A S D F G H J K</div>
<div>&nbsp;P Y X C V B N M L</div>
</div>
);
}
}
class Machine extends Component {
render() {
return (
<div className='machine'>
<Rotorbox/>
<hr/>
<Lightbox/>
<hr/>
<Keyboard/>
</div>
);
}
}
export default Machine;

View file

@ -1,5 +1,40 @@
{
"homepage": "https://doordesk.net/enigma",
"name": "enigma",
"version": "0.1.0",
"private": true,
"dependencies": {
"create-react-app": "^5.0.1"
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.2",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "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"
]
}
}

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "Enigma",
"name": "Enigma",
"icons": [
{
"src": "favicon.ico",

7
src/Machine.css Normal file
View file

@ -0,0 +1,7 @@
.Machine {
margin: auto;
width: 350px;
outline-style: solid;
outline-color: #DA9475;
background-color: #111;
}

21
src/Machine.js Normal file
View file

@ -0,0 +1,21 @@
import { Component } from 'react';
import './Machine.css';
import Rotorbox from './components/Rotorbox.js';
import Lightbox from './components/Lightbox.js';
import Keyboard from './components/Keyboard.js';
class Machine extends Component {
render() {
return (
<div className='Machine'>
<Rotorbox/>
<hr/>
<Lightbox/>
<hr/>
<Keyboard/>
</div>
);
}
}
export default Machine;

View file

@ -0,0 +1,20 @@
:root {
--keysize: 1.3em;
--keyspacing: .2em;
--keyback: #353535;
--keytext: #ddd;
}
.Keyboard {
margin: auto;
}
.Key {
text-align: center;
width: var(--keysize);
height: var(--keysize);
border-radius: var(--keysize);
margin: var(--keyspacing);
background-color: var(--keyback);
color: var(--keytext);
outline-style: solid;
outline-color: #555;
}

View file

@ -0,0 +1,34 @@
import { Component } from 'react';
import './Keyboard.css';
class Keyboard extends Component{
bulb(i) {
return (
<span className='Key'>
{i}
</span>
);}
row(letters) {
const buffer = [];
for (const i of letters) {
buffer.push(
this.bulb(i)
)}
return (
<div className='row'>
{buffer}
</div>
);
}
render() {
return (
<div className='Keyboard'>
{this.row('QWERTZUIO')}
{this.row('ASDFGHJK')}
{this.row('PYXCVBNML')}
</div>
);
}
}
export default Keyboard;

View file

@ -0,0 +1,23 @@
:root {
--bulbsize: 1.3em;
--spacing: .1em;
--bulbdim: #151515;
--textdim: #454545;
}
.Lightbox {
margin: auto;
}
.row {
display: flex;
justify-content:center;
padding: var(--spacing);
}
.Bulb {
margin: var(--spacing);
width: var(--bulbsize);
height: var(--bulbsize);
border-radius: var(--bulbsize);
text-align: center;
background-color: var(--bulbdim);
color: var(--textdim);
}

View file

@ -0,0 +1,34 @@
import { Component } from 'react';
import './Lightbox.css';
class Lightbox extends Component{
bulb(i) {
return (
<span className='Bulb'>
{i}
</span>
);}
row(letters) {
const buffer = [];
for (const i of letters) {
buffer.push(
this.bulb(i)
)}
return (
<div className='row'>
{buffer}
</div>
);
}
render() {
return (
<div className='Lightbox'>
{this.row('QWERTZUIO')}
{this.row('ASDFGHJK')}
{this.row('PYXCVBNML')}
</div>
);
}
}
export default Lightbox;

View file

@ -2,9 +2,6 @@ import React from 'react';
import './Rotor.css';
class Rotor extends React.Component {
constructor(props) {
super(props)
}
letter(i) {
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
if (i > 25) {
@ -17,14 +14,6 @@ class Rotor extends React.Component {
return alphabet[i]
}
}
tick() {
if (this.state.pos === 25) {
this.setState((state) => ({pos: 0}));
}
else {
this.setState((state) => ({pos: state.pos + 1}));
}
}
render() {
return (
<span className='Rotor'>

View file

@ -1,5 +1,4 @@
.Rotorbox {
padding-left: 20%;
background: #010101;
display: flex;
}

View file

@ -10,8 +10,8 @@ class Rotorbox extends React.Component {
rotor0: 11,
rotor1: 8,
rotor2: 6,
rotor3: 12,
rotor4: 0
rotor3: 11,
rotor4: 23
};
}
tick() {
@ -19,60 +19,37 @@ class Rotorbox extends React.Component {
audio.loop = false;
audio.playbackRate = 3.0;
audio.play();
if (this.state.rotor4 > 24) {
this.setState(state => ({
rotor4: state.rotor4 +1
}));
if (this.state.rotor4 === 25) {
this.setState(state => ({
rotor3: state.rotor3 +1,
rotor4: 0
}));
}
if (this.state.rotor3 > 24) {
if (this.state.rotor3 === 25) {
this.setState(state => ({
rotor2: state.rotor2 +1,
rotor3: 0
}));
}
if (this.state.rotor2 > 24) {
if (this.state.rotor2 === 25) {
this.setState(state => ({
rotor1: state.rotor1 +1,
rotor2: 0
}));
}
if (this.state.rotor1 > 24) {
if (this.state.rotor1 === 25) {
this.setState(state => ({
rotor0: state.rotor0 +1,
rotor1: 0
}));
}
else {
this.setState(state => ({
rotor4: state.rotor4 +1
}));
}
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
200
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
lulz() {
let balls = {
rotor0: 2,
rotor1: 0,
rotor2: 11,
rotor3: 11,
rotor4: 25
}
if (this.state !== balls) {
}
}
render() {
return (
<div className='Rotorbox'>
<div className='Rotorbox' onClick={() => this.tick()}>
<Rotor pos={this.state.rotor0}/>
<Rotor pos={this.state.rotor1}/>
<Rotor pos={this.state.rotor2}/>

View file

@ -3,7 +3,6 @@ html {
}
body {
margin: 0;
font-family: monospace;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

View file

@ -1,4 +1,3 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';