-
Notifications
You must be signed in to change notification settings - Fork 1
Routing Implementation #28
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
Conversation
cherkasovaa
commented
May 9, 2025
- Implement basic routing for navigation between login, registration, and main pages.
- Implement a 404 (Not Found) page for invalid route requests
- Implement routing for navigation between login, registration, and main pages. - Add page stubs for main, login, register, and not-found pages.
- Add `dotlottie-react` plugin - Update Vite config for Lottie support - Add clear message for the user - Add Lottie animation - Add back to home page button
- Create Layout component for page structure - Use Layout in router for main and not-found pages Currently, Layout is applied only to the main and 404 pages, as only these pages require the site header. Other pages (such as login and registration) do not use the header at this stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется не стоит добавлять лейаут в апп, тут инициализирующий код, я бы кинула его в shared/ui,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за обратную связь!
Я подумала над этим и возможно соглашусь, что Layout может не совсем подходит для слоя app.
Согласно документации, shared/ui предназначен для атомарных, переиспользуемых компонентов (кнопки, инпуты, иконки), а Layout - это композиционный компонент, который объединяет другие компоненты (в данном случае Header и основной контент).
Слой App - это самый верхний, инициализирующий слой, который содержит корневой компонент, глобальные типы, стили, стейт и оборачивает приложение в провайдеры и контексты — то, что присуще проекту в общем.
В принципе, Layout можно было бы рассмотреть для слоя pages, но, в shared его положить вряд ли можно.
https://feature-sliced.github.io/documentation/ru/docs/reference/layers#pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот что нашла по офф доке: https://feature-sliced.design/docs/guides/examples/page-layout#simple-layout
(почему то офф ссылку не могу открыть даже с впн, поэтмоу открыла другим методом - https://web.archive.org/web/20241108110427/https://feature-sliced.design/docs/guides/examples/page-layout#simple-layout через таймлайн)
по факту мы обе правы:
Simple layout
The simplest layout can be seen on this page. It has a header with site navigation, two sidebars, and a footer with external links. There is no complicated business logic, and the only dynamic parts are sidebars and the switchers on the right side of the header. Such a layout can be placed entirely in shared/ui or in app/layouts, with props filling in the content for the sidebars:
Но все же, имхо, будто в роутах хочется оставить только чистые роуты. Будет чище, если мы обернем страницу в pages и будем использовать из shared, ибо при использовании из app сломается иерархия
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
размещение в shared/ui не вяжется с концепцией "от меньшего к большему", ведь по сути Layout - это можно сказать, второй компонент после App (в данном случае).
В документации сказано "Модуль в слайсе может импортировать другие слайсы только в том случае, если они расположены на слоях строго ниже.", а мы не можем по этой концепции импортировать в Layout страницы, если Layout будет в shared. В простой структуре, которая приведена, нет четкого деления на слои (нет импортов), это один сплошной компонент, поэтому Layout там расположен в shared, но у нас есть странички, которые импортируются в Layout, поэтому этот вариант не подходит.
Мы можем перенести Layout в слой pages, и то, это тоже будет нарушать структуру,
Корректная ссылочка на доку:
https://feature-sliced.github.io/documentation/ru/docs/guides/examples/page-layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почитала больше источников, поняла в чем была моя проблема - я видела лейаут как более абстрактный из ui/, к которму для определенных страниц мы бы добавляли определенные виджеты и изменяли по разному (при необходимости) на страницах через пропсы хедеров, футеров итд
Но наверно необходимости в таком нет,
В таком случае, лейаут может полностью обертывать весь роут, передав element={} или обернуть по классике, не за чем повторять его на каждую страницу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
идея была в том, что хедер и футер отображаются на всех страницах, кроме регистрации и логирования. В целом, можно и так сделать, как ты предлагаешь 🤷♀️😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Следовательно и интерфейсы будут рядом с лейаутом
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ассетам тоже место в shared/ui наверно, но точно не в страницах
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для ассетов в структуре выделяется отдельная папка "public", на уровне с src, но это дело вкуса и договоренностей в команде.
В некоторых случаях (например, как в этом), где ассеты не будут использоваться больше нигде, можно оставить рядом со слоем. Сейчас быстро не найду, где именно я это вычитала, но вот еще одна небольшая статья статья:
https://www.hackfrontend.com/docs/architecture/fsd
в которой написано: FSD предлагает хранить весь код, относящийся к функционалу (UI-компоненты, логику, стили, тесты), в одной фиче., учитывая, что тут только одна анимация, то можно или ее оставить в слое, как сопутствующее, или вынести в отдельную директорию public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, действительно так, но сейчас assets вынесен как отдельный слайс, а тут говорится про хранение функционала рядом внутри слайса, ибо относится к нему
то есть структурнее было бы pages/not-found/assets ибо относится только к этой странице, так согласна
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, я так тоже изначально хотела сделать, потом у кого то у видела в структуре вынесенные assets наверх и расположила директорию в самом верху. В принципе, да, можно действительно ее перенести в pages/not-found/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь тоже думаю, что лучше не выносить далеко assets и хранить их рядом с местом использования (в случае без переиспользования)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Типы определенной кнопки лучше пусть будут с определенной кнопкой, если они нигде больше не используются
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что касается структуры, я ориентировалась на примеры из документации и других проектов, например:
https://github.com/UmttikhinaDasha/IT-Bookstore/tree/main/src/shared/types
https://github.com/Yar56/cryptolight/tree/main/src/shared/types/modal
В обоих проектах типы выделены в отдельный сегмент и копируют название компонента.
Но готова к обсуждению этого вопроса.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется, если типы не переиспользуются в других местах, имеет смысл определить их рядом с местом использования, чтобы сохранить изоляцию
src/app/router/Router.tsx
Outdated
| <Layout> | ||
| <NotFoundPage /> | ||
| </Layout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и тогда обертка останется в самих pages, а здесь останется чистый роутинг без ui
aissatsana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все хорошо, будет здорово поправить структуру по оставленным комментам
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется, если типы не переиспользуются в других местах, имеет смысл определить их рядом с местом использования, чтобы сохранить изоляцию
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь тоже думаю, что лучше не выносить далеко assets и хранить их рядом с местом использования (в случае без переиспользования)