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

feat(SimpleCell, MiniInfoCell, SubnavigationButton): rename expandable prop to chevron #7787

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Cell } from '@vkontakte/vkui';
import React from 'react';

const App = () => {
return (
<React.Fragment>
<Cell
onClick={() => {}}
expandable="auto"
indicator="При использовании"
>
Геолокация
</Cell>

<Cell
onClick={() => {}}
expandable="always"
indicator="При использовании"
>
Геолокация
</Cell>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Icon20WorkOutline, MiniInfoCell } from '@vkontakte/vkui';
import React from 'react';

const App = () => {
return (
<React.Fragment>
<MiniInfoCell
before={<Icon20WorkOutline />}
mode="add"
onClick={() => console.log('Указать место учёбы')}
textWrap="short"
expandable
>
Укажите место учёбы
</MiniInfoCell>

<MiniInfoCell
before={<Icon20WorkOutline />}
mode="add"
onClick={() => console.log('Указать место учёбы')}
textWrap="short"
expandable={false}
>
Укажите место учёбы
</MiniInfoCell>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { SimpleCell } from '@vkontakte/vkui';
import React from 'react';

const App = () => {
return (
<React.Fragment>
<SimpleCell
onClick={() => {}}
expandable="auto"
indicator="При использовании"
>
Геолокация
</SimpleCell>

<SimpleCell
onClick={() => {}}
expandable="always"
indicator="При использовании"
>
Геолокация
</SimpleCell>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SubnavigationButton } from '@vkontakte/vkui';
import React from 'react';

const App = () => {
return (
<React.Fragment>
<SubnavigationButton
expandable={true}
selected={true}
onClick={() => {}}
>
Button
</SubnavigationButton>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cell transforms correctly 1`] = `
"import { Cell } from '@vkontakte/vkui';
import React from 'react';
const App = () => {
return (
(<React.Fragment>
<Cell
onClick={() => {}}
chevron="auto"
indicator="При использовании"
>
Геолокация
</Cell>
<Cell
onClick={() => {}}
chevron="always"
indicator="При использовании"
>
Геолокация
</Cell>
</React.Fragment>)
);
};"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`mini-info-cell transforms correctly 1`] = `
"import { Icon20WorkOutline, MiniInfoCell } from '@vkontakte/vkui';
import React from 'react';
const App = () => {
return (
(<React.Fragment>
<MiniInfoCell
before={<Icon20WorkOutline />}
mode="add"
onClick={() => console.log('Указать место учёбы')}
textWrap="short"
chevron
>
Укажите место учёбы
</MiniInfoCell>
<MiniInfoCell
before={<Icon20WorkOutline />}
mode="add"
onClick={() => console.log('Указать место учёбы')}
textWrap="short"
chevron={false}
>
Укажите место учёбы
</MiniInfoCell>
</React.Fragment>)
);
};"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`simple-cell transforms correctly 1`] = `
"import { SimpleCell } from '@vkontakte/vkui';
import React from 'react';
const App = () => {
return (
(<React.Fragment>
<SimpleCell
onClick={() => {}}
chevron="auto"
indicator="При использовании"
>
Геолокация
</SimpleCell>
<SimpleCell
onClick={() => {}}
chevron="always"
indicator="При использовании"
>
Геолокация
</SimpleCell>
</React.Fragment>)
);
};"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`subnavigation-button transforms correctly 1`] = `
"import { SubnavigationButton } from '@vkontakte/vkui';
import React from 'react';
const App = () => {
return (
(<React.Fragment>
<SubnavigationButton
chevron={true}
selected={true}
onClick={() => {}}
>
Button
</SubnavigationButton>
</React.Fragment>)
);
};"
`;
12 changes: 12 additions & 0 deletions packages/codemods/src/transforms/v7/__tests__/cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jest.autoMockOff();

import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper';

const name = 'cell';
const fixtures = ['basic'] as const;

describe(name, () => {
fixtures.forEach((test) =>
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`),
);
});
12 changes: 12 additions & 0 deletions packages/codemods/src/transforms/v7/__tests__/mini-info-cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jest.autoMockOff();

import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper';

const name = 'mini-info-cell';
const fixtures = ['basic'] as const;

describe(name, () => {
fixtures.forEach((test) =>
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`),
);
});
12 changes: 12 additions & 0 deletions packages/codemods/src/transforms/v7/__tests__/simple-cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jest.autoMockOff();

import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper';

const name = 'simple-cell';
const fixtures = ['basic'] as const;

describe(name, () => {
fixtures.forEach((test) =>
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`),
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jest.autoMockOff();

import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper';

const name = 'subnavigation-button';
const fixtures = ['basic'] as const;

describe(name, () => {
fixtures.forEach((test) =>
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`),
);
});
20 changes: 20 additions & 0 deletions packages/codemods/src/transforms/v7/cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { API, FileInfo } from 'jscodeshift';
import { getImportInfo, renameProp } from '../../codemod-helpers';
import { JSCodeShiftOptions } from '../../types';

export const parser = 'tsx';

export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) {
const { alias } = options;
const j = api.jscodeshift;
const source = j(file.source);
const { localName } = getImportInfo(j, file, 'Cell', alias);

if (localName) {
renameProp(j, source, localName, {
expandable: 'chevron',
});
}

return source.toSource();
}
20 changes: 20 additions & 0 deletions packages/codemods/src/transforms/v7/mini-info-cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { API, FileInfo } from 'jscodeshift';
import { getImportInfo, renameProp } from '../../codemod-helpers';
import { JSCodeShiftOptions } from '../../types';

export const parser = 'tsx';

export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) {
const { alias } = options;
const j = api.jscodeshift;
const source = j(file.source);
const { localName } = getImportInfo(j, file, 'MiniInfoCell', alias);

if (localName) {
renameProp(j, source, localName, {
expandable: 'chevron',
});
}

return source.toSource();
}
20 changes: 20 additions & 0 deletions packages/codemods/src/transforms/v7/simple-cell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { API, FileInfo } from 'jscodeshift';
import { getImportInfo, renameProp } from '../../codemod-helpers';
import { JSCodeShiftOptions } from '../../types';

export const parser = 'tsx';

export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) {
const { alias } = options;
const j = api.jscodeshift;
const source = j(file.source);
const { localName } = getImportInfo(j, file, 'SimpleCell', alias);

if (localName) {
renameProp(j, source, localName, {
expandable: 'chevron',
});
}

return source.toSource();
}
20 changes: 20 additions & 0 deletions packages/codemods/src/transforms/v7/subnavigation-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { API, FileInfo } from 'jscodeshift';
import { getImportInfo, renameProp } from '../../codemod-helpers';
import { JSCodeShiftOptions } from '../../types';

export const parser = 'tsx';

export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) {
const { alias } = options;
const j = api.jscodeshift;
const source = j(file.source);
const { localName } = getImportInfo(j, file, 'SubnavigationButton', alias);

if (localName) {
renameProp(j, source, localName, {
expandable: 'chevron',
});
}

return source.toSource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SimpleCell, type SimpleCellProps } from '../SimpleCell/SimpleCell';
import { AccordionContext } from './AccordionContext';
import styles from './Accordion.module.css';

export interface AccordionSummaryProps extends Omit<SimpleCellProps, 'expandable'> {
export interface AccordionSummaryProps extends Omit<SimpleCellProps, 'chevron'> {
/**
* Иконка для раскрытия контента.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Badge/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Example = () => {

<Group header={<Header mode="secondary">В пунктах меню</Header>}>
<Cell
expandable
chevron
before={<Icon28Notifications />}
badgeAfterTitle={<Badge>Есть новые</Badge>}
onClick={noop}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const MiniInfoCellPlayground = (props: ComponentPlaygroundProps) => {
vk.com/team
</Link>,
],
expandable: [true],
chevron: [true],
},
{
before: [<Icon20ArticleOutline key="icon" />],
Expand Down Expand Up @@ -53,7 +53,7 @@ export const MiniInfoCellPlayground = (props: ComponentPlaygroundProps) => {
mode: ['more'],
textWrap: ['short'],
children: ['Подробная информация'],
expandable: [true],
chevron: [true],
},
{
children: ['Ячейка без иконки'],
Expand Down
Loading
Loading