Skip to content

Commit fa390ac

Browse files
authored
Merge pull request #436 from performant-software/RB-accordion-list-horiz
Adds optional horizontal setting for accordion sections
2 parents 52a42a5 + 3ac227c commit fa390ac

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

packages/core-data/src/components/AccordionItemsList.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ const AccordionItemsList = (props: Props) => (
6868
</Accordion.Trigger>
6969
</h2>
7070
</Accordion.Header>
71-
<Accordion.Content
72-
className='accordion-list-content text-[13px] font-semibold leading-[120%]'
73-
>
74-
<ul>
71+
<Accordion.Content className='accordion-list-content text-[13px] font-semibold leading-[120%]'>
72+
<ul className={clsx(
73+
{ flex: relation.horizontal },
74+
{ 'flex-row': relation.horizontal },
75+
{ 'flex-wrap': relation.horizontal },
76+
{ 'gap-6': relation.horizontal },
77+
{ 'py-6': relation.horizontal }
78+
)}
79+
>
7580
{
7681
_.map(relation.items, (item, idxx) => (
7782
<>

packages/core-data/src/types/RelatedRecordsList.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import type { RelatedRecord } from './RelatedRecord';
44

55
export type RelatedRecordsList = {
6+
/**
7+
* When set to true, items will be displayed in a row rather than a column
8+
*/
9+
horizontal?: boolean,
10+
611
/**
712
* Icon to use in front of each list item. Defaults to none. Note this is overridden if a renderItem prop is provided
813
*/

packages/storybook/src/core-data/AccordionItemsList.stories.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@ const sampleDataWithIcon = [
5454
}
5555
];
5656

57+
const sampleDataWithImages = [
58+
{
59+
title: 'Related Images',
60+
horizontal: true,
61+
renderItem: (item) => (
62+
<img src={item.data.src} className='max-h-[90px]' alt={item.name} />
63+
),
64+
items: [
65+
{
66+
name: 'Kazuya Miyuki',
67+
data: {
68+
src: 'https://static.wikia.nocookie.net/all-worlds-alliance/images/1/15/MiyukiKazuya-Render.png'
69+
}
70+
},
71+
{
72+
name: 'Eijun Sawamura',
73+
data: {
74+
src: 'https://static.wikia.nocookie.net/all-worlds-alliance/images/2/22/369779ccc7619f63a468c6e8fd3be2f4.png'
75+
}
76+
}
77+
],
78+
icon: 'person'
79+
},
80+
{
81+
title: 'Related Organizations',
82+
items: [
83+
{
84+
name: 'Seido High School Baseball Club'
85+
}
86+
],
87+
icon: 'occupation'
88+
}
89+
];
90+
5791
const sampleDataWithClickEvent = [
5892
{
5993
title: 'Related People',
@@ -103,3 +137,9 @@ export const WithClickEvent = () => (
103137
items={sampleDataWithClickEvent}
104138
/>
105139
);
140+
141+
export const WithImagesInRow = () => (
142+
<AccordionItemsList
143+
items={sampleDataWithImages}
144+
/>
145+
);

0 commit comments

Comments
 (0)