Skip to content

Commit

Permalink
feat(Item): alignment of the Item component
Browse files Browse the repository at this point in the history
  • Loading branch information
Utzel-Butzel committed Feb 3, 2021
1 parent cb25eb1 commit 6cbb4b6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
27 changes: 23 additions & 4 deletions src/components/Item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const { prefix } = settings;

/** The item component can be used whenever a section should indicate that there is no content available. This can be the case for a item list table or search results. */
export const Item = ({
additional,
button,
children,
className,
href,
subText,
icon,
hint,
title,
kind = 'large',
...other
Expand All @@ -27,11 +29,28 @@ export const Item = ({
<div className={classNames} {...other}>
<div className={`${prefix}--item__icon`}>{icon}</div>
<div className={`${prefix}--item__content`}>
{title && <h2 className={`${prefix}--item__title`}>{title}</h2>}
{children && <div className={`${prefix}--item__text`}>{children}</div>}
{subText && <div className={`${prefix}--item__subtext`}>{subText}</div>}
{title && (
<h2 className={`${prefix}--item__title`}>
{title}
{additional && (
<div className={`${prefix}--item__additional`}>{additional}</div>
)}
</h2>
)}
<div className={`${prefix}--item__textwrapper`}>
<div>
{children && (
<div className={`${prefix}--item__text`}>{children}</div>
)}
{subText && (
<div className={`${prefix}--item__subtext`}>{subText}</div>
)}
</div>
<div className={`${prefix}--item__right`}>
{hint && <div className={`${prefix}--item__hint`}>{hint}</div>}
</div>
</div>
</div>
<div className={`${prefix}--item__button`}>{button}</div>
</div>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/components/Item/Item.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import markdown from './README.mdx';
import Item from '.';
import Button from '../Button';
import Tag from '../Tag';

export default {
title: 'Components/UI Elements/Item',
Expand Down Expand Up @@ -31,15 +32,16 @@ Regular.args = {
export const Horizontal = (args) => <Item {...args} />;

Horizontal.args = {
title: 'No entries found',
children: `You haven't yet created an entry`,
subText: `You haven't yet created an entry`,
title: 'A title is shown',
children: `nonumy eirmod tempor invidunt`,
subText: `This is the subText. Lorem ipsum dolor sit amet, consetetur sadipscing elitr`,
kind: 'horizontal',
icon: (
<img
alt="Moving van"
src="https://www.wfp.org/sites/default/files/images/27DA6743-41A0-4970-A9BA-B4B1415CDD2E_0.jpeg"
/>
),
button: <Button kind="accent">New entry</Button>,
additional: 'Yesterday',
hint: <Tag kind="wfp">Hint</Tag>,
};
13 changes: 13 additions & 0 deletions src/components/Item/_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
h2 {
margin-bottom: $spacing-2xs;
font-size: 1em;
display: flex;
justify-content: space-between;
}

p {
Expand All @@ -101,6 +103,17 @@
.#{$prefix}--item__content {
flex: 1;
}
.#{$prefix}--item__right {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
text-align: right;
}
.#{$prefix}--item__textwrapper {
display: flex;
justify-content: space-between;
}
.#{$prefix}--item__text {
flex: 1;
font-size: 0.9em;
Expand Down

0 comments on commit 6cbb4b6

Please sign in to comment.