Skip to content
Open
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
55 changes: 32 additions & 23 deletions src/components/Border/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,40 @@

position: relative;
background-color: var(--dui-color-separator);
width: 100%;
height: var(--border-width);
--animation-name: grow-h;

&.top, &.bottom {
height: var(--border-width);
width: 100%;

/* NOTE: this assumes border to be in horizontal direction */
&.extend-to-spacing {
&::before {
position: absolute;
left: calc(-1 * var(--spacing));
background-color: var(--dui-color-separator);
width: var(--spacing);
height: var(--border-width);
content: '';
}

&::after {
position: absolute;
right: calc(-1 * var(--spacing));
background-color: var(--dui-color-separator);
width: var(--spacing);
height: var(--border-width);
content: '';
}
}
}

&.right, &.left {
flex-shrink: 0;
width: var(--border-width);
height: initial;
}

&.absolutely-positioned {
position: absolute;
top: unset;
Expand Down Expand Up @@ -99,27 +129,6 @@
--border-width: var(--dui-width-separator-dense);
}

/* NOTE: this assumes border to be in horizontal direction */
&.extend-to-spacing {
&::before {
position: absolute;
left: calc(-1 * var(--spacing));
background-color: var(--dui-color-separator);
width: var(--spacing);
height: var(--border-width);
content: '';
}

&::after {
position: absolute;
right: calc(-1 * var(--spacing));
background-color: var(--dui-color-separator);
width: var(--spacing);
height: var(--border-width);
content: '';
}
}

&.no-spacing {
--spacing: 0;
}
Expand Down
7 changes: 7 additions & 0 deletions src/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface BaseProps<D, P, K extends OptionKey> {
borderBetweenItem?: boolean;
borderBetweenItemWidth?: BorderProps['width'];
borderBetweenItemClassName?: string;
direction?: 'horizontal' | 'vertical';
spacing?: SpacingTypes;
}

Expand Down Expand Up @@ -64,6 +65,7 @@ function NonGroupedList<D, P, K extends OptionKey>(
borderBetweenItem,
borderBetweenItemClassName,
borderBetweenItemWidth = 'thin',
direction = 'horizontal',
indexOffset = 0,
} = props;

Expand Down Expand Up @@ -93,6 +95,7 @@ function NonGroupedList<D, P, K extends OptionKey>(
spacing={spacing}
className={borderBetweenItemClassName}
width={borderBetweenItemWidth}
position={direction === 'horizontal' ? 'right' : 'bottom'}
/>
)}
</React.Fragment>
Expand All @@ -108,6 +111,7 @@ function NonGroupedList<D, P, K extends OptionKey>(
borderBetweenItem,
borderBetweenItemWidth,
borderBetweenItemClassName,
direction,
]);

return (
Expand Down Expand Up @@ -140,6 +144,7 @@ function GroupedList<D, P, K extends OptionKey, GP extends GroupCommonProps, GK
borderBetweenItem,
borderBetweenItemWidth = 'thin',
borderBetweenItemClassName,
direction = 'horizontal',
} = props;

const data = dataFromProps ?? (emptyList as D[]);
Expand All @@ -166,6 +171,7 @@ function GroupedList<D, P, K extends OptionKey, GP extends GroupCommonProps, GK
spacing={spacing}
className={borderBetweenItemClassName}
width={borderBetweenItemWidth}
position={direction === 'horizontal' ? 'right' : 'bottom'}
/>
)}
</>
Expand All @@ -180,6 +186,7 @@ function GroupedList<D, P, K extends OptionKey, GP extends GroupCommonProps, GK
borderBetweenItemClassName,
borderBetweenItemWidth,
spacing,
direction,
]);

const renderGroup = (
Expand Down
9 changes: 5 additions & 4 deletions src/components/ListView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export type Props<
compactEmptyMessage?: boolean;
compactAndVerticalEmptyMessage?: boolean;
compactPendingMessage?: boolean;
// FIXME: need proper documentation for direction
direction?: 'horizontal' | 'vertical';
messageShown?: boolean;
messageIconShown?: boolean;
style?: React.CSSProperties,
Expand Down Expand Up @@ -75,7 +73,7 @@ function ListView<
compactAndVerticalEmptyMessage,
messageActions,
spacing = 'none',
direction = 'horizontal',
direction = 'vertical',
messageShown = false,
messageIconShown = false,
style,
Expand All @@ -93,7 +91,9 @@ function ListView<
empty && styles.empty,
pending && styles.pending,
spacingToStyleMap[spacing],
direction === 'vertical' && styles.vertical,
direction === 'vertical'
? styles.vertical
: styles.horizontal,
reverse && styles.reverse,
className,
)}
Expand Down Expand Up @@ -123,6 +123,7 @@ function ListView<
<List
data={data}
spacing={spacing}
direction={direction}
{...otherListProps}
/>
)}
Expand Down
10 changes: 10 additions & 0 deletions src/components/ListView/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
}
}

&.horizontal {
display: flex;
flex-direction: row;
gap: var(--spacing);

&.reverse {
flex-direction: row-reverse;
}
}

&.empty {
&.pending {
min-height: calc(2em + var(--dui-spacing-medium) * 2);
Expand Down
35 changes: 31 additions & 4 deletions storybook/stories/ListView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ const Template: Story<ListViewProps<OptionFields, OptionProps, string, any, any>
filtered={filtered}
errored={errored}
onReload={() => { console.warn('reloaded'); }}
direction="vertical"
spacing="comfortable"
messageShown
messageIconShown
// eslint-disable-next-line react/destructuring-assignment
data={empty ? [] : args.data}
/>
Expand All @@ -107,4 +103,35 @@ Default.args = {
renderer: Option,
rendererParams: (_, option) => ({ children: option.label }),
borderBetweenItem: true,
spacing: 'comfortable',
messageShown: true,
messageIconShown: true,
direction: 'vertical',
};

export const Reversed = Template.bind({});
Reversed.args = {
data: options,
keySelector: (d) => d.key,
renderer: Option,
rendererParams: (_, option) => ({ children: option.label }),
borderBetweenItem: true,
reverse: true,
spacing: 'comfortable',
messageShown: true,
messageIconShown: true,
direction: 'vertical',
};

export const Horizontal = Template.bind({});
Horizontal.args = {
data: options,
keySelector: (d) => d.key,
renderer: Option,
rendererParams: (_, option) => ({ children: option.label }),
borderBetweenItem: true,
spacing: 'comfortable',
messageShown: true,
messageIconShown: true,
direction: 'horizontal',
};