-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Separator): add direction, size, padding and align props (#7720)
* feat(Separator): add direction, size and align props * feat: add e2e tests * fix eslint issues * feat: add align e2e test * docs clean up * fix review notes * feat: replace wide with padding prop * feat: update screenshots * fix e2e tests * add direction=block and align e2e
- Loading branch information
1 parent
fcf6f8e
commit 6039bdc
Showing
34 changed files
with
331 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
Используется для разделения какого-либо контента. Отступы справа и слева контролируются свойством `noPadding`. | ||
Используется для разделения какого-либо контента. | ||
|
||
Добавить стандартные отступы можно через свойство `padding`. | ||
Изменить цветовое представление компонента можно при помощи свойства `appearance`. | ||
Свойство `size` позволяет задать размеры контейнера, внутри которого располагается `Separator`. Управлять выравниванием внутри контейнера можно через свойство `align`. | ||
|
||
> Обратите внимание, если вы используете компонент `Separator` с `direction="block"`, | ||
> то родительский элемент должен быть `flex`-контейнером. | ||
```jsx | ||
<View activePanel="separator"> | ||
<Panel id="separator"> | ||
<PanelHeader>Separator</PanelHeader> | ||
|
||
<Group> | ||
<Group header={<Header mode="secondary">direction="inline"</Header>}> | ||
<Cell before={<Icon28Notifications />}>Уведомления</Cell> | ||
<Cell before={<Icon28BlockOutline />}>Не беспокоить</Cell> | ||
|
||
<Spacing size={24}> | ||
<Separator /> | ||
</Spacing> | ||
<Separator size="4xl" /> | ||
|
||
<Cell before={<Icon28UserOutline />}>Учётная запись</Cell> | ||
<Cell before={<Icon28SlidersOutline />}>Основные</Cell> | ||
</Group> | ||
<Group header={<Header mode="secondary">direction="block"</Header>}> | ||
<Flex margin="auto"> | ||
<Link>Новости</Link> | ||
<Separator direction="block" size="xl" /> | ||
<Link>Звонки</Link> | ||
<Separator direction="block" size="xl" /> | ||
<Link>Друзья</Link> | ||
</Flex> | ||
</Group> | ||
</Panel> | ||
</View> | ||
``` |
47 changes: 47 additions & 0 deletions
47
packages/vkui/src/components/Separator/Separator.e2e-playground.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ComponentPlayground, type ComponentPlaygroundProps } from '@vkui-e2e/playground-helpers'; | ||
import { type SpacingSize, spacingSizeClassNames } from '../../lib/spacings/sizes'; | ||
import { Separator, type SeparatorProps } from './Separator'; | ||
|
||
const sizes = Object.keys(spacingSizeClassNames) as SpacingSize[]; | ||
|
||
export const SeparatorPlayground = (props: ComponentPlaygroundProps) => { | ||
return ( | ||
<ComponentPlayground | ||
{...props} | ||
propSets={[ | ||
{ | ||
size: [undefined, ...sizes, 8, 24], | ||
}, | ||
{ | ||
appearance: ['primary', 'primary-alpha', 'secondary'], | ||
}, | ||
{ | ||
direction: ['inline'], | ||
size: [undefined, 'xl'], | ||
padding: [true, false], | ||
}, | ||
{ | ||
direction: ['block'], | ||
size: ['xl'], | ||
}, | ||
{ | ||
align: ['start', 'center', 'end'], | ||
size: ['3xl'], | ||
}, | ||
{ | ||
direction: ['block'], | ||
align: ['start', 'center', 'end'], | ||
size: ['3xl'], | ||
}, | ||
]} | ||
> | ||
{(props: SeparatorProps) => ( | ||
<div style={props.direction === 'block' ? { display: 'flex' } : undefined}> | ||
First Item | ||
<Separator {...props} /> | ||
Second Item | ||
</div> | ||
)} | ||
</ComponentPlayground> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { test } from '@vkui-e2e/test'; | ||
import { SeparatorPlayground } from './Separator.e2e-playground'; | ||
|
||
test('Separator', async ({ mount, expectScreenshotClippedToContent, componentPlaygroundProps }) => { | ||
await mount(<SeparatorPlayground {...componentPlaygroundProps} />); | ||
await expectScreenshotClippedToContent(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.