-
Notifications
You must be signed in to change notification settings - Fork 23
chore(Title): update title stories and description #1316
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
Open
KrotovPetr
wants to merge
2
commits into
gravity-ui:main
Choose a base branch
from
KrotovPetr:update-title-story
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,79 @@ | ||
| # Title | ||
|
|
||
| `type: "title"` | ||
|
|
||
| `title:` | ||
| The **Title** component is used to display a section heading, optionally with a subtitle (description) and configurable styles, alignment, and link behavior. | ||
|
|
||
| --- | ||
|
|
||
| ## 🔧 Props | ||
|
|
||
| ### `title` | ||
|
|
||
| Defines the main title content. | ||
| It can be either a simple string or an object with the following structure: | ||
|
|
||
| | Property | Type | Default | Description | | ||
| | ------------- | ------------------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------ | | ||
| | `text` | `string` | — | Main title text. | | ||
| | `textSize` | `'s'` \| `'m'` \| `'l'` \|`'xs'` \| `'sm'` | `'m'` | Title font size. | | ||
| | `url` | `string` | — | Optional URL. When set, the title becomes a clickable link, and an arrow is automatically displayed at the end. | | ||
| | `resetMargin` | `boolean` | `true` | When `true`, removes automatic top margin. When `false`, the top margin depends on the `textSize` (see [_Margins_](#margins) below). | | ||
| | `anchor` | `string` | — | Optional anchor ID for navigation. | | ||
| | `justify` | `'start'` \| `'center'` \| `'end'` | `'start'` | Text alignment. | | ||
| | `urlTitle` | `string` | — | Accessibility title attribute for the link. | | ||
| | `onClick` | `() => void` | — | Optional click handler. | | ||
| | `custom` | `string \| React.ReactNode` | — | Custom React node or text appended to the title. | | ||
| | `navTitle` | `string` | — | Optional navigation title for use in table of contents. | | ||
|
|
||
| --- | ||
|
|
||
| ### `subtitle` | ||
|
|
||
| `subtitle?: string` | ||
|
|
||
| Optional subtitle (description) text. | ||
| Supports **YFM (Yandex Flavored Markdown)** formatting. | ||
|
|
||
| --- | ||
|
|
||
| ### `className` | ||
|
|
||
| `className?: string` | ||
|
|
||
| Optional CSS class name for the container. | ||
|
|
||
| --- | ||
|
|
||
| ### `colSizes` | ||
|
|
||
| - `text: string` - Title text | ||
| `colSizes?: GridColumnSizesType` | ||
|
|
||
| - `textSize?: 's' | 'm' | 'l'` — Title font size | ||
| Grid column size configuration for responsive layouts. | ||
| Default: `{ all: 12, sm: 8 }`. | ||
|
|
||
| - `url?: string` — URL for a redirect on clicking the title, an arrow is automatically added at the end. | ||
| --- | ||
|
|
||
| - `resetMargin?: boolean` - default `true`. Without this property `margin-top` will be proportional to `textSize` (see section _Margins_ below) | ||
| ### `id` | ||
|
|
||
| `description: string` - text (with YFM support) | ||
| `id?: string` | ||
|
|
||
| **Margins for title without reset:** | ||
| Optional HTML `id` attribute for the title container. | ||
|
|
||
| `textSize s - top: m` | ||
| --- | ||
|
|
||
| `textSize m - top: l` | ||
| ## 🧩 Example | ||
|
|
||
| `textSize l - top: xl` | ||
| ```tsx | ||
| <Title | ||
| title={{ | ||
| text: 'Section Heading', | ||
| textSize: 'l', | ||
| url: 'https://example.com', | ||
| urlTitle: 'Go to example', | ||
| resetMargin: false, | ||
| }} | ||
| subtitle="**This is** a subtitle with [YFM](https://example.com) support." | ||
| colSizes={{all: 12, sm: 6}} | ||
| /> | ||
| ``` |
This file contains hidden or 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
Binary file added
BIN
+18 KB
...al.test.tsx-snapshots/Title-render-stories-CustomTitle-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.1 KB
...sual.test.tsx-snapshots/Title-render-stories-CustomTitle-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.6 KB
...visual.test.tsx-snapshots/Title-render-stories-Default-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.1 KB
...e.visual.test.tsx-snapshots/Title-render-stories-Default-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.5 KB
...e.visual.test.tsx-snapshots/Title-render-stories-Sizes-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+157 KB
...tle.visual.test.tsx-snapshots/Title-render-stories-Sizes-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+78.2 KB
...test.tsx-snapshots/Title-render-stories-SizesWithLinks-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+165 KB
...l.test.tsx-snapshots/Title-render-stories-SizesWithLinks-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.9 KB
...sual.test.tsx-snapshots/Title-render-stories-TitleLink-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.7 KB
...visual.test.tsx-snapshots/Title-render-stories-TitleLink-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
...snapshots/Title-render-stories-TitleWithoutDescription-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.5 KB
...x-snapshots/Title-render-stories-TitleWithoutDescription-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30 KB
....tsx-snapshots/Title-render-stories-WithCustomColSizes-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64 KB
...st.tsx-snapshots/Title-render-stories-WithCustomColSizes-light-webkit-linux.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 hidden or 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 hidden or 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 hidden or 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,59 @@ | ||
| import {test} from '../../../../playwright/core/index'; | ||
|
|
||
| import { | ||
| CustomTitle, | ||
| Default, | ||
| Sizes, | ||
| SizesWithLinks, | ||
| TitleLink, | ||
| TitleWithoutDescription, | ||
| WithCustomColSizes, | ||
| } from './helpers'; | ||
|
|
||
| test.describe('Title', () => { | ||
| test('render stories <Default>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<Default />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <TitleLink>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<TitleLink />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <CustomTitle>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<CustomTitle />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <Sizes>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<Sizes />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <SizesWithLinks>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<SizesWithLinks />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <TitleWithoutDescription>', async ({ | ||
| mount, | ||
| expectScreenshot, | ||
| defaultDelay, | ||
| }) => { | ||
| await mount(<TitleWithoutDescription />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
|
|
||
| test('render stories <WithCustomColSizes>', async ({mount, expectScreenshot, defaultDelay}) => { | ||
| await mount(<WithCustomColSizes />); | ||
| await defaultDelay(); | ||
| await expectScreenshot({skipTheme: 'dark'}); | ||
| }); | ||
| }); |
This file contains hidden or 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,15 @@ | ||
| import {composeStories} from '@storybook/react'; | ||
|
|
||
| import * as TitleStories from '../__stories__/Title.stories'; | ||
|
|
||
| const composed = composeStories(TitleStories); | ||
|
|
||
| export const { | ||
| CustomTitle, | ||
| Default, | ||
| Sizes, | ||
| SizesWithLinks, | ||
| TitleLink, | ||
| TitleWithoutDescription, | ||
| WithCustomColSizes, | ||
| } = composed; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In this story and in "Sizes With Link" and in "Title Without Description"