Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 4 #9

Merged
merged 29 commits into from
Apr 14, 2020
Merged

Lesson 4 #9

merged 29 commits into from
Apr 14, 2020

Conversation

vvscode
Copy link
Collaborator

@vvscode vvscode commented Apr 12, 2020

Что сделано:

  • Добавлены компоненты для отображения поля / ячейки (в. двух вариантах - на реакт-элементах и на jsx)
  • Добавлен компонент для управления состоянием у поля
  • подключен react-docgen аддон для сторибука, для отображения свойств компонентов

@@ -0,0 +1 @@
import 'storybook-addon-react-docgen/register';
Copy link
Owner

Choose a reason for hiding this comment

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

main.js в "новых" рекомендациях указано проводить настройки в данный файл, давай сделаем все в одном стиле?

Copy link
Owner

Choose a reason for hiding this comment

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

@@ -23,7 +23,21 @@ module.exports = {
],
enforce: 'pre',
});

config.module.rules.push({
Copy link
Owner

Choose a reason for hiding this comment

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

А это заработало?

// 2b. Run `source-loader` on story files to show their source code
//     automatically in `DocsPage` or the `Source` doc block.

https://github.com/storybookjs/storybook/tree/master/addons/docs#manual-configuration

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

у нас это и так есть
image

поэтому я не настраивал

Или там какие-то особые плюшки будут?

Copy link
Owner

Choose a reason for hiding this comment

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

Можно будет посмотреть исходный код прямо в addon )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ну я подключил, но видимо из-за того что docs не подключен - никаких изменений не вижу

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

подключил - но плюсов не увидел, если поможешь с mdx будет круто )

@@ -1 +1,5 @@
import 'loki/configure-react';
import { addDecorator } from '@storybook/react';
Copy link
Owner

Choose a reason for hiding this comment

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

Можно обойтись без декораторов

https://github.com/storybookjs/storybook/tree/master/addons/docs#manual-configuration

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

это другой аддон, на сколько я вижу
у меня используется https://www.npmjs.com/package/storybook-addon-react-docgen

Copy link
Owner

Choose a reason for hiding this comment

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

Я конечно не настаиваю, хотя популярность и возможности сильно отличаются )

https://github.com/storybookjs/storybook/tree/master/addons/docs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

честно - я потратил часов 5, но mdx у меня так и не заработал ))

я помню, что ты его хотел

@@ -0,0 +1,3 @@
// https://jestjs.io/docs/en/webpack#handling-static-assets
Copy link
Owner

Choose a reason for hiding this comment

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

Можно использовать директорию internals для такого рода настроек и конфигов

@@ -0,0 +1,20 @@
.cell {
Copy link
Owner

Choose a reason for hiding this comment

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

Предлагаю сделать как обсуждали

  1. перенести калькулятор из директории src/lesson2 на уровень выше и назвать эту директорию чем то вроде calc
  2. удалить все тестовые компоненты из src
  3. добавить код в директорию src/components

Дальше будем разрабатывать шаг за шагом приложение)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Тогда сначала нужно поставить теги и обновить README (потому что это поломает примеры, которые ты давал)

Copy link
Owner

@nickovchinnikov nickovchinnikov Apr 12, 2020

Choose a reason for hiding this comment

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

Согласен, с меня теги по первым урокам)
По поводу обновления readme, у нас же там ссылка на pull request, соответственно изменения ничего не поломают, можно будет переключиться по истории изменений на нужное состояние.
Так же можно открыть сам pull request и посмотреть изменения

x={x}
y={y}
onClick={props.onClick}
key={`${x}_${y}`}
Copy link
Owner

Choose a reason for hiding this comment

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

Может стоит сделать key первым свойством?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

оно сделано последним, потому что он нем речи еще не было

Copy link
Owner

Choose a reason for hiding this comment

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

Принял - понял)


export default Field;

export function getField(props: FieldProps) {
Copy link
Owner

Choose a reason for hiding this comment

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

Short arrow functions notation ? export getField = () => <Field {...props} />

...row.map((filled, x) => {
return getCell({
onClick: props.onClick,
filled: filled ? filled : undefined,
Copy link
Owner

Choose a reason for hiding this comment

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

filled?: string; насколько я вижу из интерфейса, почему бы не использовать это?
в этом случае, если он потенциально undefined

{
            onClick: props.onClick,
            filled,
//...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

это сделано чтобы пустая строка обрабатывалась как undefined

/**
* x-size for field
*/
xSize: number;
Copy link
Owner

Choose a reason for hiding this comment

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

sizes: { x: number, y: number } ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ну тут тот же аргумент что и с x,y (хотя здесь мы вроде менять не собираемся часто)

https://stackoverflow.com/questions/52621169/react-props-should-i-pass-the-object-or-its-properties-does-it-make-much-diffe


public onClick(x: number, y: number) {
if (
y >= 0 &&
Copy link
Owner

Choose a reason for hiding this comment

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

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

const playerCanPutMark =  y >= 0 &&
      y < this.state.fieldState.length &&
      x >= 0 &&
      x < this.state.fieldState[0].length`

README.md Outdated
[Pull request](https://github.com/nickovchinnikov/react-js-tutorial/pull/9)

[Presentation](https://docs.google.com/presentation/d/1TVkOviAfORwmYncUL51g2UboNtj8kczWoLIRL3hO7AE/edit?usp=sharing)
Copy link
Owner

Choose a reason for hiding this comment

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

А можем презентации хранить в одном спейсе?
Можешь переместить на нашу общую папку, плиз?

README.md Outdated Show resolved Hide resolved
@vvscode vvscode merged commit 0fa00b1 into master Apr 14, 2020
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.

None yet

2 participants