Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 46 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"not op_mini all"
],
"dependencies": {
"@types/classnames": "2.2.8",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm install --save-dev @types/*

"@types/react": "16.8.22",
"@types/react-dom": "16.8.4",
"classnames": "2.2.6",
"react": "16.8.6",
"react-dom": "16.8.6"
},
Expand Down
41 changes: 16 additions & 25 deletions src/app/app.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
.app {
text-align: center;
body {
height: 600px;
background-color: #e5eaf0;
margin: 0;
/*background-color: black;*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не оставляй мёртвый код

}

.app-header {
display: flex;
min-height: 100vh;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #282c34;
color: #fff;
font-size: calc(10px + 2vmin);
}

.app-link {
color: #61dafb;
}

@keyframes app-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/*@font-face {*/
/* font-family: 'HelveticaNeueCyr-Medium';*/
/* src: url('./src/sourse/fonts/HelveticaNeueCyr-Medium.eot');*/
/* src: url('sourse/fonts/HelveticaNeueCyr-Medium.eot?#iefix') format('embedded-opentype'),*/
/* url('./sourse/fonts/HelveticaNeueCyr-Medium.svg#HelveticaNeueCyr-Medium') format('svg'),*/
/* url('./sourse/fonts/HelveticaNeueCyr-Medium.ttf') format('truetype'),*/
/* url('./sourse/fonts/HelveticaNeueCyr-Medium.woff') format('woff'),*/
/* url('./sourse/fonts/HelveticaNeueCyr-Medium.woff2') format('woff2');*/
/* font-weight: normal;*/
/* font-style: normal;*/
/*}*/
15 changes: 2 additions & 13 deletions src/app/app.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import React, { Component } from 'react';

import './app.css';
import { Main } from '../main/Main';

export class App extends Component {
render() {
return (
<div className="app">
<header className="app-header">
<p>
Edit <code>src/app/app.jsx</code> and save to reload.
</p>
<a
className="app-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<Main />
</div>
);
}
Expand Down
19 changes: 19 additions & 0 deletions src/article/Article.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.article {
/*background: url("../../../src/background.jpg");*/
background-attachment: fixed;
background-size: 15%;
/*background-repeat: space;*/
/*background-color: #FFFFDD;*/
margin-left: -40px;
height: inherit;
}

.articleCancelSign {
float: right;
margin-top: 20px;
margin-right: 20px;
}

.inp {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо бы добавить немного творчества при именовании переменных)

display: none;
}
27 changes: 27 additions & 0 deletions src/article/Article.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { Component } from 'react';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Импорты можно делить на группы:

  1. Встроенные модули в браузер (таких пока нет) / батарейки Node.js
  2. Сторонние библиотеки
  3. JS импорты внутри проекта
  4. Импорт ресурсов (css, font, images)

import styles from './Article.module.css';

interface IProps {
id: string;
openLetters: () => void;
letterText: string;
}

export class Article extends Component<IProps> {
public render() {
return (
<div>
<input
id={this.props.id}
type="checkbox"
className={styles.inp}
onChange={() => this.props.openLetters()}
/>
<article className={styles.article}>
<label htmlFor={this.props.id} className={styles.articleCancelSign}>&#9747;</label>
{this.props.letterText}
</article>
</div>
);
}
}
52 changes: 52 additions & 0 deletions src/functions/Functions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const senders = ['Mom', 'Dad', 'Cat', 'Dog', 'Apple', 'Teacher', 'Homie', 'Mole',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsx -> ts

'Hare', 'BB-8', 'Porg', 'Totoro'];

const actions = ['runs', 'waits', 'flies', 'sleeps', 'lays', 'jumps', 'sings',
'writes', 'reads', 'executes', 'exists', 'builds', 'tests'];

const adverbs = ['rapidly', 'at home', 'at school', 'at the university', 'on bed',
'highly', 'alone', 'sadly', 'today'];

const punctuationMarks = ['.', '...', '!', '?', '?!'];

export function getRandomFromRange(minTime: number, maxTime: number) {
return Math.random() * (maxTime - minTime) + minTime;
}

function getRandomInt(minRange: number, maxRange: number) {
return Math.trunc(getRandomFromRange(minRange, maxRange));
}

function genColor() {
const n = getRandomInt(0, 255);
let res = n.toString(16);
while (res.length < 2) {
res = `0${res}`;
}
return res;
}

export function genLetterText() {
const letterLen = getRandomInt(0, 10);
let answer = '';
for (let i = 0; i < letterLen; i++) {
const send = senders[getRandomInt(0, senders.length)];
const act = actions[getRandomInt(0, actions.length)];
const adv = adverbs[getRandomInt(0, adverbs.length)];
const punMark = punctuationMarks[getRandomInt(0, punctuationMarks.length)];
answer += `${send} ${act} ${adv}${punMark} `;
}
const curDate = new Date();
const letterDate = `${curDate.getDate()} ${curDate.toLocaleString('ru', { month: 'short' })}`;
const senderOne = senders[getRandomInt(0, senders.length)];
const colorLetter = `#${genColor()}${genColor()}${genColor()}`;
return {
deleted: false,
letterText: answer,
sender: senderOne,
date: letterDate,
color: colorLetter,
chose: false,
isVisible: true
};
}
Loading