Skip to content

Commit

Permalink
feat(Header): rename prop aside to padding (#7764)
Browse files Browse the repository at this point in the history
h2. Описание

Переименовал в компоненте `Header` свойство  `aside` to `after`


h2. Release notes
h2. BREAKING CHANGE
- Header: свойство `aside` переименовано в `after`
  ```diff
  <Header
    mode="primary"
    subtitle="SOHN — Conrad"
    subtitleComponent="h3"
  - aside={
  + after={
      <Link>
        Показать все
        {<Icon12ChevronOutline />}
      </Link>
    }
  />
  ```
  • Loading branch information
EldarMuhamethanov authored Oct 21, 2024
1 parent bd64cef commit 596d928
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
import { Header } from '@vkontakte/vkui';
import { Header, Icon12ChevronOutline, Link } from '@vkontakte/vkui';
import React from 'react';

const App = () => {
const aside = (
<Link>
Показать все
{<Icon12ChevronOutline />}
</Link>
)

return (
<React.Fragment>
{/* Проверка изменения size */}
<Header mode="primary" multiline size="large">
Кто может писать мне личные сообщения
</Header>
<Header mode="secondary" multiline size="regular">
Кто может писать мне личные сообщения
</Header>

{/* Проверка замены aside на after */}
<Header
mode="primary"
subtitle="SOHN — Conrad"
subtitleComponent="h3"
aside={
<Link>
Показать все
{<Icon12ChevronOutline />}
</Link>
}
/>
<Header
mode="primary"
subtitle="SOHN — Conrad"
subtitleComponent="h3"
aside={aside}
/>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`header transforms correctly 1`] = `
"import { Header } from '@vkontakte/vkui';
"import { Header, Icon12ChevronOutline, Link } from '@vkontakte/vkui';
import React from 'react';
const App = () => {
const aside = (
<Link>
Показать все
{<Icon12ChevronOutline />}
</Link>
)
return (
(<React.Fragment>
{/* Проверка изменения size */}
<Header mode="primary" multiline size="l">
Кто может писать мне личные сообщения
</Header>
<Header mode="secondary" multiline size="m">
Кто может писать мне личные сообщения
</Header>
{/* Проверка замены aside на after */}
<Header
mode="primary"
subtitle="SOHN — Conrad"
subtitleComponent="h3"
after={
<Link>
Показать все
{<Icon12ChevronOutline />}
</Link>
}
/>
<Header
mode="primary"
subtitle="SOHN — Conrad"
subtitleComponent="h3"
after={aside}
/>
</React.Fragment>)
);
};"
Expand Down
4 changes: 3 additions & 1 deletion packages/codemods/src/transforms/v7/header.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { API, FileInfo } from 'jscodeshift';
import { remapSizePropValue } from './common/remapSizePropValue';
import { getImportInfo } from '../../codemod-helpers';
import { getImportInfo, renameProp } from '../../codemod-helpers';
import { JSCodeShiftOptions } from '../../types';

export const parser = 'tsx';
Expand All @@ -25,5 +25,7 @@ export default function transformer(file: FileInfo, api: API, options: JSCodeShi
},
});

renameProp(j, source, localName, { aside: 'after' });

return source.toSource();
}
4 changes: 2 additions & 2 deletions packages/vkui/src/components/Header/Header.e2e-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const HeaderPlayground = (props: ComponentPlaygroundProps) => {
},
{
mode: ['primary'],
aside: [<Link key="link">Показать все</Link>],
after: [<Link key="link">Показать все</Link>],
},
{
mode: ['primary', 'secondary'],
Expand All @@ -40,7 +40,7 @@ export const HeaderPlayground = (props: ComponentPlaygroundProps) => {
{
mode: ['primary'],
subtitle: ['SOHN — Conrad'],
aside: [<Link key="link">Показать все</Link>],
after: [<Link key="link">Показать все</Link>],
indicator: [12],
},
{
Expand Down
12 changes: 6 additions & 6 deletions packages/vkui/src/components/Header/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@
margin-inline-start: 8px;
}

.aside {
.after {
display: flex;
white-space: nowrap;
}

/* stylelint-disable selector-max-universal */
.aside.aside > * {
.after.after > * {
margin-block: 13px 7px;
margin-inline-start: 12px;
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.aside > :global(.vkuiIcon) {
.after > :global(.vkuiIcon) {
position: relative;
color: var(--vkui--color_icon_secondary);
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.aside > :global(.vkuiIcon--24) {
.after > :global(.vkuiIcon--24) {
margin-block: 11px 5px;
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.aside > :global(.vkuiIcon--16) {
.after > :global(.vkuiIcon--16) {
margin-block: 15px 9px;
}

Expand Down Expand Up @@ -206,6 +206,6 @@
* Impact:
* Link
*/
.aside {
.after {
--vkui_internal--link-color: var(--vkui--color_text_accent);
}
6 changes: 3 additions & 3 deletions packages/vkui/src/components/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const story: Meta<HeaderProps> = {
iconSizes: ['12'],
requiredIcons: ['Icon12Fire'],
}),
aside: createFieldWithPresets({
after: createFieldWithPresets({
iconSizes: [],
additionalPresets: {
Link: <Link>Показать все</Link>,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const WithAside: Story = {
...Playground,
args: {
...Playground.args,
aside: 'Link',
after: 'Link',
},
};

Expand Down Expand Up @@ -114,6 +114,6 @@ export const WithAllFeatures: Story = {
beforeSubtitle: 'Icon12Tag',
afterSubtitle: 'Icon12Fire',
subtitle: 'SOHN — Conrad',
aside: <Link>Показать все</Link>,
after: <Link>Показать все</Link>,
},
};
6 changes: 3 additions & 3 deletions packages/vkui/src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ describe('Header', () => {
render(
<Fragment>
<ConfigProvider platform="android">
<Header aside="Русский" />
<Header after="Русский" />
</ConfigProvider>
<ConfigProvider platform="ios">
<Header aside="English" />
<Header after="English" />
</ConfigProvider>
<ConfigProvider platform="vkcom">
<Header aside="Espanõl" />
<Header after="Espanõl" />
</ConfigProvider>
</Fragment>,
);
Expand Down
10 changes: 5 additions & 5 deletions packages/vkui/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface HeaderProps extends HTMLAttributesWithRootRef<HTMLElement>, Has
/**
* Допускаются иконки, текст, Link
*/
aside?: React.ReactNode;
after?: React.ReactNode;
/**
* Допускаются текст, Indicator
*/
Expand Down Expand Up @@ -103,7 +103,7 @@ export const Header = ({
subtitle,
subtitleComponent = 'span',
indicator,
aside,
after,
multiline,
before,
beforeTitle,
Expand Down Expand Up @@ -155,9 +155,9 @@ export const Header = ({
)}
</div>

{hasReactNode(aside) && (
<Paragraph className={styles.aside} Component="span">
{aside}
{hasReactNode(after) && (
<Paragraph className={styles.after} Component="span">
{after}
</Paragraph>
)}
</RootComponent>
Expand Down
18 changes: 9 additions & 9 deletions packages/vkui/src/components/Header/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Example = () => {
<Group>
<Header
mode="primary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -20,7 +20,7 @@ const Example = () => {
</Header>
<Header
mode="primary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -33,7 +33,7 @@ const Example = () => {
</Header>
<Header
mode="primary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -45,7 +45,7 @@ const Example = () => {
</Header>
<Header
mode="primary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -63,7 +63,7 @@ const Example = () => {
<Group>
<Header
mode="secondary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -74,7 +74,7 @@ const Example = () => {
</Header>
<Header
mode="secondary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -86,7 +86,7 @@ const Example = () => {
</Header>
<Header
mode="secondary"
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand Down Expand Up @@ -135,7 +135,7 @@ const Example = () => {
3
</Counter>
}
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand All @@ -159,7 +159,7 @@ const Example = () => {
3
</Counter>
}
aside={
after={
<Link>
Показать все
{platform === 'vkcom' && <Icon12ChevronOutline />}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 596d928

Please sign in to comment.