Skip to content

Попыркина Мария, М3337#19

Open
mashajuventus wants to merge 4 commits intoitmo2019:masterfrom
mashajuventus:Maria-Popyrkina-Task-6
Open

Попыркина Мария, М3337#19
mashajuventus wants to merge 4 commits intoitmo2019:masterfrom
mashajuventus:Maria-Popyrkina-Task-6

Conversation

@mashajuventus
Copy link
Copy Markdown

Реализованы поиск по письмам и темная тема.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 24, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://task-5-git-fork-mashajuventus-maria-popyrkina-task-6.itmo-yandex.now.sh

Comment thread package.json
"not op_mini all"
],
"dependencies": {
"@types/classnames": "2.2.8",
Copy link
Copy Markdown

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/*

Comment thread src/app/app.css
height: 600px;
background-color: #e5eaf0;
margin: 0;
/*background-color: black;*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

margin-right: 20px;
}

.inp {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/article/Article.tsx
@@ -0,0 +1,27 @@
import React, { Component } from 'react';
Copy link
Copy Markdown

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)

Comment thread src/main/Main.tsx
import { Header } from '../header/Header';
import { Menu } from '../menu/Menu';
import { LettersList } from '../lettersList/LettersList';
import { ILetter } from '../letter/ILetter';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно рядом держать файлик types.ts

Comment thread src/main/Main.tsx
template: string;
}

export class Main extends Component<{}, IState> {
Copy link
Copy Markdown

@evgenymarkov evgenymarkov Jun 25, 2019

Choose a reason for hiding this comment

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

Можно так:

public readonly state: IState = {
  isDark: false,
  letters: [],
  openId: -1,
  template: ''
}

Comment thread src/main/Main.tsx
this.searchLetters = this.searchLetters.bind(this);
this.setLetters = this.setLetters.bind(this);
this.changeColor = this.changeColor.bind(this);
this.curMin = 10;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно вынести из конструктора в поле класса.
И назвать чуть понятнее :)

public static CUR_MIN = 10;

Comment thread src/main/Main.tsx
openId: -1,
template: ''
};
this.letterAdded = this.letterAdded.bind(this);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно удалить т.к ты используешь стрелочные функции сохранённые в поля класса

Comment thread src/main/Main.tsx
isDark: false,
letters: [],
openId: -1,
template: ''
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Убирай мёртвый код

Comment thread src/main/Main.tsx
openId={this.state.openId}
openLetters={this.openLetters}
markNotNew={this.markNotNew}
isDark={this.state.isDark}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Для того чтобы в дерево компонентов глубоко прокидывать пропсы можно использовать контексты

Comment thread src/main/Main.tsx
<Menu />
<LettersList
letterAdded={this.letterAdded}
letterChose={this.letterChose}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

onLetterChose

Comment thread src/main/Main.tsx
lettersS[i].isVisible =
lettersS[i].letterText.includes(template) || lettersS[i].sender.includes(template);
}
this.setState({ template: template, letters: lettersS });
Copy link
Copy Markdown

@evgenymarkov evgenymarkov Jun 25, 2019

Choose a reason for hiding this comment

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

template: template -> template

Copy link
Copy Markdown

@evgenymarkov evgenymarkov Jun 25, 2019

Choose a reason for hiding this comment

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

lettersS -> letters

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this.setState(oldState => {
  // Your code
});

Comment thread src/main/Main.tsx
const lettersS = this.state.letters;
for (let i = 0; i < lettersS.length; i++) {
if (lettersS[i].id === id) {
lettersS[i].classS = "notNew";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Держи в голове, что изменение чего-то внутри стейта может привести к сложновоспроизводимым багам

Comment thread src/main/Main.tsx
delay += genDelay;
}
this.diff = delay;
console.log(delay);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ата-та

Comment thread src/menu/Menu.tsx

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

export class Menu extends Component {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Попробуй функциональные компоненты, для начала в местах где есть только вёрстка без логики

openId: number;
letters: ILetter[];
openLetters: () => void;
markNotNew: (a: number) => void;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

id or index

allLettersChose={this.props.allLettersChose}
changeColor={this.props.changeColor}
/>
<ul className={styles.lettersList}>{code}</ul>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Внутри ul не может быть других детей кроме li

return (
<section className={darkClass}>
<LetterHeader
letterAdded={this.props.letterAdded}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

const { lettersDeleted, allLettersChose } = this.props;

}

export class LetterHeader extends Component<IProps> {
public constructor(props: IProps) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

private markerRef = React.createRef();

private markerRef: RefObject<HTMLInputElement>;

public render() {
const sqBut = cn(styles.squareForButton, stylesHead.headerPart);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sqBut

<input
ref={this.markerRef}
type="checkbox"
name="CCC"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

???

type="checkbox"
name="CCC"
className={styles.inputButton}
onClick={() => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно вынести в отдельный обработчик в классе, никаких доп. аргументов ты в обработчики не передаёшь

name="resendButton"
value="Переслать"
className={stylesHead.headerButtons}
onClick={() => this.props.letterAdded(0)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тоже можно вынести

/>
</li>
<li className={stylesHead.headerPart}>
<input
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

button type="button"

outline: none;
background-color: inherit;
font-weight: 500;
color: #cccccc;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно сокращать до #ccc

Comment thread src/letter/Letter.tsx
}, // .bind(this)
1000);
} else if (this.props.classS === 'delete') {
this.markerRef.current.className = styles.letter_delete;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Юзай classList

Comment thread src/letter/Letter.tsx
import styles from './Letter.module.css';

interface IProps {
classS: string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cls, modifier

Comment thread src/letter/Letter.tsx
<input
type="checkbox"
className={styles.inputButton}
onChange={() => this.props.letterChose(this.props.id)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Постарайся сокращать использование lambda функций в render, это плохо влияет на производительность

/*background-color: black;*/
}

.selectButton:after {
Copy link
Copy Markdown

@evgenymarkov evgenymarkov Jun 25, 2019

Choose a reason for hiding this comment

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

Отделяй псевдоэлементы от псевдоклассов
::

border-right: 2px solid;
border-bottom: 2px solid;
color: #000000;
-webkit-transform: scale(0.85) rotate(47deg) skewX(12deg);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Есть тулза, которая сама проставляет префиксы: Autoprefixer

.letterDate {
float: right;
margin-right: 20px;
font-family: HelveticaNeueCyr-Medium;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Надо писать fallback

}

.letterDate {
float: right;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот это древности)) Используй float только для обтекания

Comment thread src/index.css
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'),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Актуальны только woff2, woff

Comment thread src/header/Header.tsx
<img
className={styles.yandexMail_picture}
alt="yandexMailPicture"
src={actualLogo}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно было прост isDark ? darkLogo : logo

@@ -0,0 +1,52 @@
const senders = ['Mom', 'Dad', 'Cat', 'Dog', 'Apple', 'Teacher', 'Homie', 'Mole',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tsx -> ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants