-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add Mark * test(Mark): add * docs: review fix Co-authored-by: Inomdzhon Mirdzhamolov <i.mirdzhamolov@vk.team> * test(e2e): use name --------- Co-authored-by: Inomdzhon Mirdzhamolov <i.mirdzhamolov@vk.team>
- Loading branch information
1 parent
9918a9d
commit 03ab930
Showing
21 changed files
with
142 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react'; | ||
import { ComponentPlayground, type ComponentPlaygroundProps } from '@vkui-e2e/playground-helpers'; | ||
import { Mark, type MarkProps } from './Mark'; | ||
|
||
export const MarkPlayground = (props: ComponentPlaygroundProps) => { | ||
return ( | ||
<ComponentPlayground {...props}> | ||
{(props: MarkProps) => ( | ||
<div style={{ width: 300, padding: 10, lineHeight: '1.6' }}> | ||
Ведь тебе нужен <Mark {...props}>Марк</Mark>, чтоб <Mark {...props}>получился марк</Mark> | ||
етинг | ||
</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,9 @@ | ||
import * as React from 'react'; | ||
import { test } from '@vkui-e2e/test'; | ||
import { Mark } from './Mark'; | ||
import { MarkPlayground } from './Mark.e2e-playground'; | ||
|
||
test(Mark.name, async ({ mount, expectScreenshotClippedToContent, componentPlaygroundProps }) => { | ||
await mount(<MarkPlayground {...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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.Mark { | ||
border-radius: 4px; | ||
padding: 2px; | ||
margin: -2px; | ||
/* Перебиваем значения браузера */ | ||
background-color: var(--vkui--color_background_accent_themed_alpha); | ||
color: inherit; | ||
} |
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,30 @@ | ||
import * as React from 'react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { CanvasFullLayout, DisableCartesianParam } from '../../storybook/constants'; | ||
import { Group } from '../Group/Group'; | ||
import { Mark, MarkProps } from './Mark'; | ||
|
||
const story: Meta<MarkProps> = { | ||
title: 'Blocks/Mark', | ||
component: Mark, | ||
parameters: { ...CanvasFullLayout, ...DisableCartesianParam }, | ||
}; | ||
|
||
export default story; | ||
|
||
type Story = StoryObj<MarkProps>; | ||
|
||
export const Playground: Story = { | ||
render: (args) => ( | ||
<p> | ||
Это <Mark {...args}>выделенный</Mark> текст | ||
</p> | ||
), | ||
decorators: [ | ||
(Component) => ( | ||
<Group> | ||
<Component /> | ||
</Group> | ||
), | ||
], | ||
}; |
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,6 @@ | ||
import { baselineComponent } from '../../testing/utils'; | ||
import { Mark } from './Mark'; | ||
|
||
describe(Mark, () => { | ||
baselineComponent(Mark); | ||
}); |
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,17 @@ | ||
import * as React from 'react'; | ||
import { HTMLAttributesWithRootRef } from '../../types'; | ||
import { RootComponent } from '../RootComponent/RootComponent'; | ||
import styles from './Mark.module.css'; | ||
|
||
export type MarkProps = HTMLAttributesWithRootRef<HTMLDivElement>; | ||
|
||
/** | ||
* Компонент используется для выделения фрагментов текста, | ||
* например при поиске определенных слов или выделения текста в цитате. | ||
* | ||
* @since v6.1.0 | ||
* @see https://vkcom.github.io/VKUI/#/Mark | ||
*/ | ||
export const Mark = (props: MarkProps) => ( | ||
<RootComponent baseClassName={styles['Mark']} Component="mark" {...props} /> | ||
); |
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,17 @@ | ||
```jsx { "props": { "layout": false, "iframe": false } } | ||
<Search value="где" disabled/> | ||
<Div style={{lineHeight:'1.6'}}> | ||
Что? <Mark>Где</Mark>? Когда? | ||
<br /> | ||
Кто хочет стать миллионером? | ||
<br /> | ||
<Mark>Где</Mark> эта улица, <Mark>где</Mark> этот дом? | ||
<br /> | ||
<Mark>Где</Mark> лучшие тусовки? | ||
<br /> | ||
</Div> | ||
``` | ||
## Доступность | ||
Для данного компонента используется роль [mark](https://w3c.github.io/aria/#mark). |
3 changes: 3 additions & 0 deletions
3
...i/src/components/Mark/__image_snapshots__/mark-android-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
.../src/components/Mark/__image_snapshots__/mark-android-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...es/vkui/src/components/Mark/__image_snapshots__/mark-ios-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...s/vkui/src/components/Mark/__image_snapshots__/mark-ios-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...kui/src/components/Mark/__image_snapshots__/mark-vkcom-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ui/src/components/Mark/__image_snapshots__/mark-vkcom-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...vkui/src/components/Mark/__image_snapshots__/mark-vkcom-firefox-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...kui/src/components/Mark/__image_snapshots__/mark-vkcom-firefox-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
.../vkui/src/components/Mark/__image_snapshots__/mark-vkcom-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...vkui/src/components/Mark/__image_snapshots__/mark-vkcom-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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