Skip to content

Commit

Permalink
fix(UsersStack): make counter width adaptive (#8066)
Browse files Browse the repository at this point in the history
* fix(UsersStack): make counter width adaptive

* fix: add screenshots

* test: update screenshots

* fix: remove unused selectors
  • Loading branch information
EldarMuhamethanov authored Dec 13, 2024
1 parent 6f6e984 commit de9fc46
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const UsersStackPlayground = (props: ComponentPlaygroundProps) => {
[base64Image, base64Image, base64Image, base64Image],
],
},
{
children: [undefined],
size: ['m', 'l'],
photos: [[base64Image, base64Image, base64Image]],
count: [99],
},
]}
>
{(props: UsersStackProps) => <UsersStack {...props} />}
Expand Down
44 changes: 27 additions & 17 deletions packages/vkui/src/components/UsersStack/UsersStack.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
display: flex;
align-items: center;
color: var(--vkui--color_text_secondary);

--vkui_internal--UsersStack_item_size: 16px;
}

.sizeS {
--vkui_internal--UsersStack_item_size: 16px;
}

.sizeM {
--vkui_internal--UsersStack_item_size: 24px;
}

.sizeL {
--vkui_internal--UsersStack_item_size: 32px;
}

.avatarsPositionInlineEnd {
Expand All @@ -21,28 +35,24 @@
fill: var(--vkui--color_image_placeholder_alpha);
}

.photoOthers {
.item {
block-size: var(--vkui_internal--UsersStack_item_size);
min-inline-size: var(--vkui_internal--UsersStack_item_size);
}

.photo {
max-inline-size: var(--vkui_internal--UsersStack_item_size);
}

.counter {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding-inline: var(--vkui--spacing_size_xs);
color: var(--vkui--color_text_contrast_themed);
background: var(--vkui--color_icon_secondary);
border-radius: 50%;
}

.sizeS .photo {
inline-size: 16px;
block-size: 16px;
}

.sizeM .photo {
inline-size: 24px;
block-size: 24px;
}

.sizeL .photo {
inline-size: 32px;
block-size: 32px;
border-radius: calc(var(--vkui_internal--UsersStack_item_size) / 2);
}

.photoWrapper {
Expand Down
9 changes: 7 additions & 2 deletions packages/vkui/src/components/UsersStack/UsersStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ export const UsersStack = ({
const photoSrc = isPhotoType ? photo.src : photo;

let photoElement = (
<svg xmlns="http://www.w3.org/2000/svg" className={styles.photo} aria-hidden display="block">
<svg
xmlns="http://www.w3.org/2000/svg"
className={classNames(styles.photo, styles.item)}
aria-hidden
display="block"
>
<defs>
<PathElement id={id} direction={direction} photoSize={photoSize} />
</defs>
Expand Down Expand Up @@ -198,7 +203,7 @@ export const UsersStack = ({

const othersElement = canShowOthers ? (
<div className={styles.photoWrapper}>
<CounterTypography caps weight="1" className={classNames(styles.photo, styles.photoOthers)}>
<CounterTypography caps weight="1" className={classNames(styles.item, styles.counter)}>
+{count}
</CounterTypography>
</div>
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 de9fc46

Please sign in to comment.