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

PLASMA-4660: feat(plasma-b2c, plasma-web): Add applyPaper mixin #1828

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/plasma-b2c/api/plasma-b2c.api.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/plasma-b2c/src/mixins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { createApplyPaperMixin } from '@salutejs/plasma-new-hope';
import * as allTokens from '@salutejs/plasma-themes/tokens/plasma_b2c';

export {
addFocus,
syntheticFocus,
Expand Down Expand Up @@ -34,3 +37,5 @@ export type {
SpacingProps,
BreakWordProps,
} from '@salutejs/plasma-core';

export const applyPaper = createApplyPaperMixin(allTokens);
9 changes: 9 additions & 0 deletions packages/plasma-web/api/plasma-web.api.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/plasma-web/src/mixins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { createApplyPaperMixin } from '@salutejs/plasma-new-hope';
import * as allTokens from '@salutejs/plasma-themes/tokens/plasma_web';

export {
addFocus,
syntheticFocus,
Expand Down Expand Up @@ -34,3 +37,5 @@ export type {
SpacingProps,
BreakWordProps,
} from '@salutejs/plasma-core';

export const applyPaper = createApplyPaperMixin(allTokens);
31 changes: 31 additions & 0 deletions website/plasma-b2c-docs/docs/functions/mixins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,34 @@ const ShortenedLine = styled.span`

<ShortenedLine>Текст сократится, если не поместится в строке</ShortenedLine>;
```

## `applyPaper`

:::caution
Данный миксин будет работать только если тема подключена [`новым способом`](../intro/#подключение-тем/)
:::

Позволяет создать базовый стиль подложки для любого блока, со следующим набором свойств, значения которых доступны из темы `plasma_b2c`:
- backgroundColor - отвечает за цвет подложки в котором можно выбрать токены цветов и градиентов;
- borderRadius - отвечает за скругление углов блока;
- shadow - отвечает за применение стилей теней для блока;
- styles - отвечает за все доступные css свойства.

```tsx
import { applyPaper } from '@salutejs/plasma-b2c';

<div
style={applyPaper({
backgroundColor: 'surfaceAccent',
borderRadius: 'borderRadiusM',
shadow: 'shadowDownHardM',
styles: {
color: 'white',
width: '10rem',
height: '10rem',
},
})}
>
Test card
</div>
```
31 changes: 31 additions & 0 deletions website/plasma-web-docs/docs/functions/mixins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,34 @@ const ShortenedLine = styled.span`

<ShortenedLine>Текст сократится, если не поместится в строке</ShortenedLine>;
```

## `applyPaper`

:::caution
Данный миксин будет работать только если тема подключена [`новым способом`](../intro/#подключение-тем/)
:::

Позволяет создать базовый стиль подложки для любого блока, со следующим набором свойств, значения которых доступны из темы `plasma_web`:
- backgroundColor - отвечает за цвет подложки в котором можно выбрать токены цветов и градиентов;
- borderRadius - отвечает за скругление углов блока;
- shadow - отвечает за применение стилей теней для блока;
- styles - отвечает за все доступные css свойства.

```tsx
import { applyPaper } from '@salutejs/plasma-web';

<div
style={applyPaper({
backgroundColor: 'surfaceAccent',
borderRadius: 'borderRadiusM',
shadow: 'shadowDownHardM',
styles: {
color: 'white',
width: '10rem',
height: '10rem',
},
})}
>
Test card
</div>
```