Skip to content

Commit

Permalink
feat(HorizontalCell): rename prop header to title
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarMuhamethanov committed Oct 2, 2024
1 parent ccb6246 commit 7c42b48
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ export const HorizontalCellPlayground = (props: ComponentPlaygroundProps) => {
{...props}
propSets={[
{
header: ['Header'],
title: ['Title'],
subtitle: ['Just subtitle'],
extraSubtitle: ['Some extra subtitle'],
},
{
header: ['Very long title example'],
title: ['Very long title example'],
},
]}
>
{({ header, subtitle, extraSubtitle, ...restProps }: HorizontalCellProps) => (
{({ title, subtitle, extraSubtitle, ...restProps }: HorizontalCellProps) => (
<div style={containerStyle}>
<HorizontalCell {...restProps} header={header} size="s">
<HorizontalCell {...restProps} title={title} size="s">
<Avatar size={56} />
</HorizontalCell>
<HorizontalCell
{...restProps}
header={header}
title={title}
subtitle={subtitle}
extraSubtitle={extraSubtitle}
size="m"
Expand All @@ -45,7 +45,7 @@ export const HorizontalCellPlayground = (props: ComponentPlaygroundProps) => {
</HorizontalCell>
<HorizontalCell
{...restProps}
header={header}
title={title}
subtitle={subtitle}
extraSubtitle={extraSubtitle}
size="l"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Playground: Story = {
<>
{values.map((value) => {
return (
<HorizontalCell key={value.id} header={value.title} {...args}>
<HorizontalCell key={value.id} title={value.title} {...args}>
<Image size={platform === 'ios' ? 64 : 56} borderRadius="l" src={value.icon} />
</HorizontalCell>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('HorizontalCell', () => {
expect(document.querySelector(`.${styles.content}`)).toBeNull();

rerender(
<HorizontalCell size="s" header="Author name">
<HorizontalCell size="s" title="Author name">
<div>Children data</div>
</HorizontalCell>,
);
Expand Down
10 changes: 5 additions & 5 deletions packages/vkui/src/components/HorizontalCell/HorizontalCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const CellTypography = ({ size, children, ...restProps }: CellTypographyProps) =
};

export interface HorizontalCellProps
extends Omit<TappableProps, 'size' | 'getRootRef'>,
extends Omit<TappableProps, 'size' | 'getRootRef' | 'title'>,
HasRootRef<HTMLDivElement>,
HasRef<HTMLDivElement> {
size?: 's' | 'm' | 'l';
/**
* Заголовок
*/
header?: React.ReactNode;
title?: React.ReactNode;
/**
* Дополнительная строка текста под `children`.
*/
Expand All @@ -50,7 +50,7 @@ export interface HorizontalCellProps
*/
export const HorizontalCell = ({
className,
header,
title,
style,
subtitle,
size = 's',
Expand All @@ -68,9 +68,9 @@ export const HorizontalCell = ({
>
<Tappable className={styles.body} getRootRef={getRef} {...restProps}>
{hasReactNode(children) && <div className={styles.image}>{children}</div>}
{(header || subtitle || extraSubtitle) && (
{(title || subtitle || extraSubtitle) && (
<div className={styles.content}>
{hasReactNode(header) && <CellTypography size={size}>{header}</CellTypography>}
{hasReactNode(title) && <CellTypography size={size}>{title}</CellTypography>}
{hasReactNode(subtitle) && <Footnote className={styles.subtitle}>{subtitle}</Footnote>}
{hasReactNode(extraSubtitle) && (
<Footnote className={styles.subtitle}>{extraSubtitle}</Footnote>
Expand Down
10 changes: 5 additions & 5 deletions packages/vkui/src/components/HorizontalCell/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const largeImageStyles = {

const UserItems = () => {
return getRandomUsers(15).map((user) => (
<HorizontalCell onClick={() => {}} key={user.id} size="s" header={user.first_name}>
<HorizontalCell onClick={() => {}} key={user.id} size="s" title={user.first_name}>
<Avatar size={56} src={user.photo_100} />
</HorizontalCell>
));
Expand Down Expand Up @@ -47,7 +47,7 @@ const miniApps = [

const MiniAppItems = () => {
return miniApps.map(({ id, title, icon_139 }) => (
<HorizontalCell onClick={() => {}} key={id} size="s" header={title}>
<HorizontalCell onClick={() => {}} key={id} size="s" title={title}>
<Image size={56} borderRadius="m" src={icon_139} />
</HorizontalCell>
));
Expand All @@ -73,7 +73,7 @@ const gamesItems = [

const GamesItems = () => {
return gamesItems.map(({ id, title, icon_139 }) => (
<HorizontalCell onClick={() => {}} key={id} size="m" header={title}>
<HorizontalCell onClick={() => {}} key={id} size="m" title={title}>
<Image size={88} borderRadius="l" src={icon_139} />
</HorizontalCell>
));
Expand Down Expand Up @@ -102,7 +102,7 @@ const playlistItems = [

const PlaylistItems = () => {
return playlistItems.map(({ id, title, description, photo_300 }) => (
<HorizontalCell onClick={() => {}} key={id} size="l" header={title} subtitle={description}>
<HorizontalCell onClick={() => {}} key={id} size="l" title={title} subtitle={description}>
<Image size={128} src={photo_300} />
</HorizontalCell>
));
Expand Down Expand Up @@ -135,7 +135,7 @@ const AlbumItems = () => {
onClick={() => {}}
key={id}
size="l"
header={title}
title={title}
subtitle={`${size} фотографии`}
>
<img style={largeImageStyles} src={thumb_src} />
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.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function AlbumItems({ height = 124 }: { height?: number }) {
return (
<>
{albumItems.map(({ id, title, size }) => (
<HorizontalCell key={id} size="l" header={title} subtitle={`${size} фотографии`}>
<HorizontalCell key={id} size="l" title={title} subtitle={`${size} фотографии`}>
<Avatar size={height} />
</HorizontalCell>
))}
Expand All @@ -57,7 +57,7 @@ function AlbumItems({ height = 124 }: { height?: number }) {
}

const smallCells = new Array(3).fill(0).map((_, i) => (
<HorizontalCell key={i} header={`item ${i + 1}`}>
<HorizontalCell key={i} title={`item ${i + 1}`}>
<Avatar size={56} />
</HorizontalCell>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const Playground: Story = {
<Group>
<HorizontalScroll>
{CELL_ITEMS.map((element) => (
<HorizontalCell key={element.id} size={args.size} header={element.title}>
<HorizontalCell key={element.id} size={args.size} title={element.title}>
<Avatar size={cellImageSize} src={element.icon} alt={`avatar: ${element.title}`} />
</HorizontalCell>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HorizontalCell } from '../HorizontalCell/HorizontalCell';
import { HorizontalScroll, type HorizontalScrollProps } from './HorizontalScroll';

const items = new Array(20).fill(0).map((_, i) => (
<HorizontalCell key={i} header={`item ${i}`} onClick={noop}>
<HorizontalCell key={i} title={`item ${i}`} onClick={noop}>
<Avatar size={56} />
</HorizontalCell>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Playground: Story = {
<React.Fragment>
{commonFriends.map((item) => {
return (
<HorizontalCell key={item.id} header={item.first_name}>
<HorizontalCell key={item.id} title={item.first_name}>
<Avatar size={56} src={item.photo_200} />
</HorizontalCell>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/View/View.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ProfilePanelContent = ({
>
<HorizontalScroll>
{getRandomUsers(15).map((user) => (
<HorizontalCell key={user.id} size="s" header={user.first_name}>
<HorizontalCell key={user.id} size="s" title={user.first_name}>
<Avatar size={56} src={user.photo_100} />
</HorizontalCell>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/View/View.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe(View, () => {
<HorizontalCell
key={user.id}
size="s"
header={user.first_name}
title={user.first_name}
data-testid={`horizontal-cell-${index}`}
>
<Avatar size={56} src={user.photo_100} />
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/View/ViewInfinite.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ describe(ViewInfinite, () => {
<HorizontalCell
key={user.id}
size="s"
header={user.first_name}
title={user.first_name}
data-testid={`horizontal-cell-${index}`}
>
<Avatar size={56} src={user.photo_100} />
Expand Down

0 comments on commit 7c42b48

Please sign in to comment.