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

[DON'T MERGE] feat(ViewContainer): mvp of ViewContainer #1221

Closed
wants to merge 4 commits into from

Conversation

Yeti-or
Copy link
Contributor

@Yeti-or Yeti-or commented May 28, 2024

ViewContainer

Добавлен компонент ViewContainer , который позволяет пользователю явно указать, какой бэкграунд имеет контейнер, в котором лежат компоненты: onDark или onLight (если значение не передано, то по умолчанию токены переопределяться не будут).

Примеры

Код:

<div style={{ border: '1px solid coral' }}>
    <h3>Default view</h3>
    <ViewContainer>
        <Button {...props} />
    </ViewContainer>
</div>
<div style={{ border: '1px solid coral', background: 'black', color: 'white' }}>
    <h3>OnDark view</h3>
    <ViewContainer view="onDark">
        <Button {...props} />
    </ViewContainer>
</div>
<div style={{ border: '1px solid coral', background: 'white', color: 'black' }}>
    <h3>OnLight view</h3>
    <ViewContainer view="onLight">
        <Button {...props} />
    </ViewContainer>
</div>

Приведет к такому результату в светлой и темной теме

Screenshot 2024-07-17 at 13 43 48 Screenshot 2024-07-17 at 13 45 05

Примеры в живую лучше смотреть в new-hope-storybook

Объяснение работы

Достигается это за счёт переопределение токенов темы. Т.е. на ViewContainer в зависимости от пропса view применяется либо --text-primary: var(--on-dark-text-primary), либо --text-primary: var(--on-light-text-primary).
Такие мапинги планируется генерировать автоматически и поставлять вместе с темой (plasma_b2c, sdds_serv, и т.д.).

Текущие ограничения

  • Пока пары токенов заданы в ручную, но отдельной задачей нужно будет доработать генератор тем, чтобы эти объекты (tokens = { onDark: '...', onLight: '...' } формировались автоамтически

  • В библиотеках plasma-b2c и plasma-web в некоторых компонентах используются старые токены (с префиксом --plasma-colors-..., из-за чего механизм адаптации токенов не будет работать (ибо просто нет таких токенов как ---on-dark-plasma-colors). Поэтому отдельной задачей нужно будет перевести все компоненты в конифигах этих библиотек со старых - на новые

  • Пока не понятно на сколько необходим inverse режим, по этому на первых итерациях предлагается это не поддерживать. В том числе то связано с тем, что inverse токены не всегда заданы в теме.

What/why changed

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
npm install @salutejs/[email protected]
# or 
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]
yarn add @salutejs/[email protected]

Copy link
Contributor

Theme Builder app deployed!

https://plasma.sberdevices.ru/pr/plasma-theme-builder-pr-1221/

Copy link
Contributor

github-actions bot commented May 28, 2024

Copy link
Contributor

⚡ Component performance testing

Result: 🟢 OK

@Yeti-or Yeti-or removed the request for review from Yakutoc May 29, 2024 07:07
--text-paragraph-active: var(--inverse-text-paragraph-active);
--text-paragraph: var(--inverse-text-paragraph);

/* TODO: Вот это будет работать только если inverse / ondark / onlight / default имеют соотвтетствие */
Copy link
Collaborator

Choose a reason for hiding this comment

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

кажется, что эта ответственность пользователя (дизайнера), который создаёт цветовую схему. Но он должен как-то знать об этих требованиях

--inverse-text-paragraph: var(--on-dark-text-paragraph);
`,
inverse: css`
/* А где токен inverse background ?? */
Copy link
Collaborator

Choose a reason for hiding this comment

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

для plasma_b2c они выключены, по этому в итоговую тему не попали. Надо обговорить этот момент с дизайнерами

Copy link
Contributor

github-actions bot commented Jul 8, 2024

⚡ Component performance testing

Result: 🟢 OK

Copy link
Contributor

⚡ Component performance testing

Result: 💀 WASTED

Performance tests are broken.
If the current changes are the cause, please fix it immediately in this PR. If not, please schedule their repair.
For any questions, come to the Speed team.

@neretin-trike neretin-trike force-pushed the yeti-or.try-container-tokens branch from b9d5448 to 75b3da1 Compare July 17, 2024 08:06
@neretin-trike neretin-trike requested review from denivladislav and removed request for TitanKuzmich July 17, 2024 08:38
@neretin-trike neretin-trike changed the title feat(ViewContainer): mvp of ViewContainer [DON'T MERGE] feat(ViewContainer): mvp of ViewContainer Jul 17, 2024
Copy link
Contributor

⚡ Component performance testing

Result: 🟢 OK

@neretin-trike neretin-trike self-assigned this Jul 17, 2024
@neretin-trike neretin-trike requested review from Yakutoc and shuga2704 and removed request for shuga2704 July 17, 2024 09:21
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.

5 participants