Skip to content

Commit

Permalink
Fixed spacers between news items
Browse files Browse the repository at this point in the history
  • Loading branch information
cqliu1 committed Sep 17, 2020
1 parent f1cde18 commit 7178374
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ interface Props {
newsfeed$: Observable<FetchResult | null | void>;
}

const addSpacersBetweenElementsReducer = (
acc: JSX.Element[],
element: JSX.Element,
index: number,
elements: JSX.Element[]
) => {
acc.push(element);
if (index < elements.length - 1) {
acc.push(<EuiSpacer key={`homeSolutionsPanel__UseCaseSpacer${index}`} size="m" />);
}
return acc;
};

export const Overview: FC<Props> = ({ newsfeed$ }) => {
const [isNewKibanaInstance, setNewKibanaInstance] = useState(false);
const [newsFetchResult, setNewsFetchResult] = useState<FetchResult | null | void>(null);
Expand Down Expand Up @@ -199,7 +212,6 @@ export const Overview: FC<Props> = ({ newsfeed$ }) => {
<EuiText size="xs">
<p>{description}</p>
</EuiText>
<EuiSpacer size="s" />
</div>
);

Expand Down Expand Up @@ -258,7 +270,12 @@ export const Overview: FC<Props> = ({ newsfeed$ }) => {
/>
</h2>
</EuiTitle>
{newsFetchResult ? newsFetchResult.feedItems.slice(0, 3).map(renderFeedItem) : null}
{newsFetchResult
? newsFetchResult.feedItems
.slice(0, 3)
.map(renderFeedItem)
.reduce(addSpacersBetweenElementsReducer, [])
: null}
</section>
</EuiFlexItem>
<EuiFlexItem grow={3}>
Expand Down

0 comments on commit 7178374

Please sign in to comment.