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

Add UI monorepo package #56

Draft
wants to merge 9 commits into
base: release
Choose a base branch
from
Draft

Conversation

egorprnn
Copy link

@egorprnn egorprnn commented Jan 13, 2024

Приводим UI в порядок, все компоненты должны лежать отдельно и не знать ничего про сам клиент - отвечать только за отображние UI

Copy link
Owner

@zardoy zardoy left a comment

Choose a reason for hiding this comment

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

Overall I really like the idea of extracting all current dumb components (that are used in the storybook) to another monorepo package so we can publish it to npm and if needed move it to another repo at some point. However, I don't understand the current structure: you added a few random components and nothing was removed from the old location. I don't see previous components, try to make a bit fewer changes to actual components implementation / naming, otherwise provide the motivation. I'd be more than happy to see old + new components like scoreboard UI (or improvements in current ones).
Overall having this structure is good, but I think its too complicated. The reason I don't really like the current file structure is that it looks like you were inspired by the mui structure which is a bad sign. It now more looks like a company project with a heavy structure & a lot of not-needed requirements imo. If it goes this way we will eventually have generators (just like in angular). But, again, it's a good direction!

I haven't really looked at the component implementation or tested it yet for now...

@@ -0,0 +1,11 @@
{
Copy link
Owner

Choose a reason for hiding this comment

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

my standard prettier config that i use across all projects (also aligns with this project)

Suggested change
{
{
"semi": false,
"singleQuote": true,
"proseWrap": "never",
"tabWidth": 4,
"trailingComma": "all",
"arrowParens": "avoid",
"printWidth": 160,
"endOfLine": "auto"
}

Copy link
Author

@egorprnn egorprnn Jan 14, 2024

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.

i dont really understand what the problem is on your side...
unfortunately, i can't use prettier for the whole project because of its specifics e.g. in some files it makes code less readable

"files": ["packages/**/*"],
"rules": {
"semi": [
"error",
Copy link
Owner

Choose a reason for hiding this comment

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

why add? not clear. half of the project uses it and the other doesn't.


--ui_font_weight_bold: 900;

--ui_color_black: #000000;
Copy link
Owner

Choose a reason for hiding this comment

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

whats all that? why we cant just color and currentColor if needed in other component that seems more logical, the same for font size

Copy link
Author

Choose a reason for hiding this comment

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

Это реализация базовой возможности изменять темы UI компонентов использую css-переменные.
Например на телефонах, возможно, шрифт нужно сделать покрупнее. Тут мы просто возьмем и поменяем css переменную в файле с темой для телефона, и во всем проекте поменяется размер шрифта.
Если нужен другой размер шрифта для всех платформ - то нужно создать и новый компонент типографики

Copy link
Author

Choose a reason for hiding this comment

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

Те базовые цвета которые Minecraft реализует у себя внесены отдельно, все компоненты типографики будут иметь возможность перекрашиваться относительно hex который передается внешне

font-weight: var(--ui_font_weight_bold);
}

.rootBlack {
Copy link
Owner

Choose a reason for hiding this comment

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

jeez, can we simplify these styles somehow? Let's do a smarter approach with some sort of single map here rather than a lot copy-pasting (I mean code duplication). I'll look at it once again later to provide more specific thoughts about that

Copy link
Author

Choose a reason for hiding this comment

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

Кажется css решения будут всегда производительнее, gzip и brotli хорошо ужимают повторяющиеся части


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

export interface AppRootProps extends HTMLAttributes<HTMLDivElement> {}
Copy link
Owner

Choose a reason for hiding this comment

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

I think it is better to use ComponentType<'div'> for singularity.

For the same reason, I think its better to not export these interfaces and in other files do something like ComponentType<typeof AppRoot> since its a recommended react approach IMO. Overall this would be more logical and easier to understand

Copy link
Owner

Choose a reason for hiding this comment

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

My bad, i mean ComponentProps

"prettier:check": "prettier --check './**/*.{ts,tsx}'"
},
"peerDependencies": {
"classnames": "^2.5.1",
Copy link
Owner

Choose a reason for hiding this comment

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

why peer

Copy link
Author

Choose a reason for hiding this comment

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

Базовый проект уже имеет эту зависимость - при обновлении в базовом проекте, можем забыть обновить здесь, тогда будет установлено две зависимости одного пакета с разными версиями - возникнет дубль

Component?: ElementType;
}

export type StylesMap<T extends string> = Record<T, string>;
Copy link
Owner

Choose a reason for hiding this comment

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

Did you mean Dictionary?

"name": "@prismarine-web-client/ui",
"version": "1.0.0",
"main": "./src/index.ts",
"scripts": {
Copy link
Owner

Choose a reason for hiding this comment

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

Add private: true for now we're not going to publish it since I don't own @prismarine-web-client

@zardoy
Copy link
Owner

zardoy commented Jan 14, 2024

Приводим UI в порядок, все компоненты должны лежать отдельно и не знать ничего про сам клиент - отвечать только за отображние UI

yes, that's what the current dumb ui components do! they are used in storybook, I really liked it when you have base component + provider and they are together. let's see what we can do next and what profit we will have from it! also see my comment above

@zardoy
Copy link
Owner

zardoy commented Jan 14, 2024

but again, try to focus on actually needed components rather than copying or using someone else pattern for the common web application, this project is different. For example mui uses Typography because of their heavy css-in-js system, but why do we need it? just like the Text component (unless its the formatted text)

@egorprnn
Copy link
Author

Угу, этот код пока в драфте, я планирую перенести все те компоненты которые уже сделаны и удалить из базовой директории в рамках этого же PR

@egorprnn
Copy link
Author

egorprnn commented Jan 14, 2024

По поводу структуры директорий: как по мне она очень простая - для каждой сущности своя папка - components, hooks, etc.
Тут нет чего-то сложного. Даже если отойти от ui библиотек, то многие open source проекты именно так организовывают работу с компонентами в проекте.
Как раз если не класть сами компоненты в подпапки будет возникать хаос, что если у компонента будут свои специфичные внутренние хуки? Для них будут нужны отдельные файлы, чтобы не делать из файла компонента помойку. Хук нужно будет располагать в отдельном файле, тогда вообще становится непонятно, какой код к какому компоненту относится - если брать текущую структуру папки react в клиенте.

@zardoy zardoy changed the title UI Workspace Add UI monorepo package Jan 14, 2024
@zardoy
Copy link
Owner

zardoy commented Jan 15, 2024

По поводу структуры директорий: как по мне она очень простая - для каждой сущности своя папка - components, hooks, etc. Тут нет чего-то сложного. Даже если отойти от ui библиотек, то многие open source проекты именно так организовывают работу с компонентами в проекте. Как раз если не класть сами компоненты в подпапки будет возникать хаос, что если у компонента будут свои специфичные внутренние хуки? Для них будут нужны отдельные файлы, чтобы не делать из файла компонента помойку. Хук нужно будет располагать в отдельном файле, тогда вообще становится непонятно, какой код к какому компоненту относится - если брать текущую структуру папки react в клиенте.

im totally fine with the current component structure I like it when everything is split across modules and the structure is clear, but can we somehow have fewer index.ts files? This is a clear boilerplate that is repeated many times. On the other hand I don't really see a way to avoid it myself. So we need to have a boilerplate (template) for creating new components (I'll try to do it myself if you can't). Also, we need a few common snippets while developing new react components.
Im so excited to see what system and the great ui we can build here!

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