Skip to content

Commit 930dc3a

Browse files
committed
fix(user-block): fix fields wrapping in horizontal mode
1 parent 90649e5 commit 930dc3a

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- `UserBlock`: fix fields wrapping in horizontal mode.
13+
1014
## [3.14.1][] - 2025-06-02
1115

1216
### Fixed

packages/lumx-core/src/scss/components/user-block/_index.scss

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,10 @@
7373
display: none;
7474
}
7575

76-
#{$self}--size-m & {
77-
display: flex;
78-
}
79-
80-
#{$self}--size-l & {
76+
#{$self}--size-l &,
77+
#{$self}--orientation-vertical & {
8178
display: flex;
8279
flex-direction: column;
83-
}
84-
85-
#{$self}--orientation-vertical & {
8680
align-items: center;
8781
}
8882
}

packages/lumx-react/src/components/user-block/UserBlock.stories.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
/* eslint-disable jsx-a11y/anchor-is-valid */
12
import React from 'react';
23

34
import { mdiMenuDown, mdiStar } from '@lumx/icons';
4-
import { Badge, ColorPalette, Icon, IconButton, Orientation, Size, Text } from '@lumx/react';
5+
import { Badge, ColorPalette, Icon, IconButton, Link, Orientation, Size, Text } from '@lumx/react';
56
import { CustomLink } from '@lumx/react/stories/utils/CustomLink';
67

78
import { AVATAR_IMAGES } from '@lumx/react/stories/controls/image';
89
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
910
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
11+
import { withResizableBox } from '@lumx/react/stories/decorators/withResizableBox';
1012
import { UserBlock } from './UserBlock';
1113

1214
const sizes = [Size.xs, Size.s, Size.m, Size.l];
@@ -19,6 +21,7 @@ export default {
1921
size: getSelectArgType(sizes),
2022
orientation: getSelectArgType(Orientation),
2123
},
24+
decorators: [withResizableBox({ width: 'auto', minWidth: 'min-content', height: 'auto' })],
2225
};
2326

2427
/** Only an avatar */
@@ -33,19 +36,28 @@ export const AvatarAndName = {
3336

3437
/** Avatar and children */
3538
export const AvatarAndCustomName = {
36-
args: { ...AvatarOnly.args, name: <Text as="span">Emmitt O. Lum</Text> },
39+
args: {
40+
...AvatarOnly.args,
41+
name: (
42+
<Text as="span" color="green">
43+
Emmitt O. Lum
44+
</Text>
45+
),
46+
},
3747
};
3848

3949
/** Avatar, name and secondary fields */
4050
export const AvatarAndNameAndSecondaryFields = {
41-
args: { ...AvatarAndName.args, fields: ['Creative developer', 'Denpasar'] },
51+
args: {
52+
...AvatarAndName.args,
53+
fields: ['Creative developer', 'Denpasar'],
54+
},
4255
};
4356

4457
/** With Right component */
4558
export const WithAfter = {
4659
args: {
47-
...AvatarAndName.args,
48-
fields: ['Creative developer', 'Denpasar'],
60+
...AvatarAndNameAndSecondaryFields.args,
4961
after: <IconButton label="View" icon={mdiMenuDown} emphasis="low" />,
5062
},
5163
};
@@ -54,18 +66,27 @@ export const WithAfter = {
5466
export const WithAdditionalFields = {
5567
args: {
5668
...AvatarAndName.args,
57-
fields: ['Creative developer', 'Denpasar'],
69+
fields: [
70+
<Text key={0} as="span" color="dark">
71+
Published a post in <Link href="#">Space</Link>
72+
</Text>,
73+
<time key={1}>May 13, 2025</time>,
74+
],
5875
additionalFields: (
5976
<Text as="span" typography="body1">
6077
Works at the Toronto office
6178
</Text>
6279
),
6380
},
81+
parameters: {
82+
// Testing constrained space
83+
wrapperProps: { style: { width: 245 } },
84+
},
6485
};
6586

6687
/** Size variants */
6788
export const SizesAndOrientations = {
68-
...AvatarAndNameAndSecondaryFields,
89+
args: AvatarAndNameAndSecondaryFields.args,
6990
decorators: [
7091
withCombinations({
7192
combinations: {
@@ -78,7 +99,7 @@ export const SizesAndOrientations = {
7899

79100
/** Setting `onClick` to use it as a button */
80101
export const AsButton = {
81-
...AvatarAndNameAndSecondaryFields,
102+
args: AvatarAndNameAndSecondaryFields.args,
82103
argTypes: { onClick: { action: true } },
83104
};
84105

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
import type { CSSProperties } from 'react';
12
import { withWrapper } from './withWrapper';
23

34
/** Storybook decorator wrapping story in a resizable box */
4-
export const withResizableBox = ({ width = 150, height = 50 } = {}) =>
5-
withWrapper({
5+
export const withResizableBox = ({
6+
width = 150,
7+
height = 50,
8+
...style
9+
}: Pick<CSSProperties, 'height' | 'minWidth' | 'width'> = {}) => {
10+
return withWrapper({
611
style: {
712
display: 'flex',
813
width,
914
height,
1015
border: '1px solid red',
1116
resize: 'both',
1217
overflow: 'hidden',
18+
...style,
1319
},
1420
});
21+
};

packages/lumx-react/src/stories/decorators/withWrapper.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ export const withWrapper = <E extends React.ElementType = 'div'>(
88
as?: E,
99
) => {
1010
// eslint-disable-next-line react/display-name
11-
return (Story: any) => {
11+
return (Story: any, ctx: any) => {
1212
const Wrapper = as || 'div';
13+
const { wrapperProps } = ctx.parameters;
14+
const overriddenProps = { ...props, ...wrapperProps, style: { ...props?.style, ...wrapperProps?.style } };
1315
return (
14-
<Wrapper {...props}>
16+
<Wrapper {...overriddenProps}>
1517
<Story />
1618
</Wrapper>
1719
);

0 commit comments

Comments
 (0)