Skip to content

Commit

Permalink
fix(Cell): fix offset when no before (#7327)
Browse files Browse the repository at this point in the history
* fix(Cell): fix offset when no before

* fix(Cell): add draggable and selectable variant + update screenshots

* fix: revert Readme.md changes

* chore: update screenshots
  • Loading branch information
BlackySoul authored Aug 7, 2024
1 parent f834700 commit 08647eb
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 42 deletions.
4 changes: 4 additions & 0 deletions packages/vkui/src/components/Cell/Cell.e2e-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const CellPlayground = (props: ComponentPlaygroundProps) => {
children: ['Мария Саломея Склодовская-Кюри', 'Артур Стамбульцян'],
multiline: [true, false],
},
{
mode: ['selectable'],
children: ['Мария Саломея Склодовская-Кюри'],
},
]}
>
{(props: CellProps) => <Cell {...props} />}
Expand Down
10 changes: 10 additions & 0 deletions packages/vkui/src/components/Cell/Cell.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
margin-inline-end: var(--vkui--spacing_size_2xl);
}

.Cell__control--noBefore {
/* Когда в before нет ничего, кроме dragger или checkbox, нужно добавлять компенсированный отступ */
margin-inline-end: calc(var(--vkui--spacing_size_2xl) - var(--vkui--spacing_size_xl));
}

.Cell__content {
max-inline-size: 100%;
min-inline-size: 0;
Expand Down Expand Up @@ -52,6 +57,11 @@
margin-inline-end: var(--vkui--spacing_size_xl);
}

.Cell--ios .Cell__control--noBefore {
/* Когда в before нет ничего, кроме dragger или checkbox, оставляем только отступ у before в SimpleCell */
margin-inline-end: 0;
}

.Cell--ios.Cell--removable .Cell__content {
/* размер removable icon + icon margins*/
padding-inline: 48px var(--vkui--size_base_padding_horizontal--regular);
Expand Down
15 changes: 13 additions & 2 deletions packages/vkui/src/components/Cell/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export const Cell: React.FC<CellProps> & {
const dragger = draggable ? (
<CellDragger
elRef={rootElRef}
className={styles['Cell__dragger']}
className={classNames(
styles['Cell__dragger'],
!before && !selectable && styles['Cell__control--noBefore'],
)}
disabled={disabled}
onDragStateChange={setDragging}
onDragFinish={onDragFinish}
Expand All @@ -104,7 +107,15 @@ export const Cell: React.FC<CellProps> & {
disabled,
onChange,
};
checkbox = <CellCheckbox className={styles['Cell__checkbox']} {...checkboxProps} />;
checkbox = (
<CellCheckbox
className={classNames(
styles['Cell__checkbox'],
!before && styles['Cell__control--noBefore'],
)}
{...checkboxProps}
/>
);
}

const simpleCellDisabled =
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.
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 08647eb

Please sign in to comment.