Skip to content

Commit

Permalink
feat(TextContainer): initial impl of a TextContainer cmp (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr authored Mar 15, 2019
1 parent f02ef7e commit 5728d69
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export const Text: FunctionComponent<IProps> = ({
variant = null,
className = '',
children,
}) => {
const cls = cx([styles.root, className], {
[styles.variantMobile]: !!variant && variant === EVariant.Mobile,
[styles.variantDesktop]: !!variant && variant === EVariant.Desktop,
});

return <p className={cls} children={children} />;
};
}) => (
<p
className={cx([styles.root, className], {
[styles.variantMobile]: !!variant && variant === EVariant.Mobile,
[styles.variantDesktop]: !!variant && variant === EVariant.Desktop,
})}
children={children}
/>
);
16 changes: 16 additions & 0 deletions lib/components/TextContainer/TextContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { FunctionComponent, ReactElement } from 'react';
import styles from './style.scss';

export interface IProps {
heading?: ReactElement | null;
}

export const TextContainer: FunctionComponent<IProps> = ({
heading = null,
children,
}) => (
<article className={styles.root}>
{!!heading && <header>{heading}</header>}
{children}
</article>
);
1 change: 1 addition & 0 deletions lib/components/TextContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { TextContainer } from './TextContainer';
61 changes: 61 additions & 0 deletions lib/components/TextContainer/stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { storiesOf } from '@storybook/react';
import React from 'react';
import { Button, EButtonSize, EButtonVariant } from '../Button';
import { Heading } from '../Heading';
import { Text } from '../Text';
import { TextContainer } from './TextContainer';

storiesOf('Components|Type/TextContainer', module)
.addDecorator(story => <div style={{ maxWidth: 512 }}>{story()}</div>)
.add('default', () => (
<TextContainer>
<Heading>Choose a credit pack</Heading>
<Text>
To get started, choose a credit pack that will used for Auto
Top-Up.
</Text>
</TextContainer>
))
.add('with interaction', () => (
<TextContainer
heading={
<>
<Heading>Reviews</Heading>
<Button
variant={EButtonVariant.Secondary}
size={EButtonSize.Small}>
Edit
</Button>
</>
}>
<Text>All of our reviews are from verified customers.</Text>
</TextContainer>
))
.add('with long title', () => (
<TextContainer
heading={
<>
<Heading>Setup your personal settings</Heading>
<Button
variant={EButtonVariant.Secondary}
size={EButtonSize.Small}>
Edit
</Button>
</>
}>
<Text>All of our reviews are from verified customers.</Text>
</TextContainer>
))
.add('with no body text', () => (
<TextContainer>
<Heading>Choose a credit pack</Heading>
</TextContainer>
))
.add('with no title text', () => (
<TextContainer>
<Text>
To get started, choose a credit pack that will used for Auto
Top-Up.
</Text>
</TextContainer>
));
35 changes: 35 additions & 0 deletions lib/components/TextContainer/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.root {
display: block;
margin-bottom: var(--global--space--5);

h1,
h2,
h3,
h4,
h5,
h6,
> header {
display: block;

~ * {
display: block;
padding-top: var(--global--space--2);
}
}

header {
display: flex;
align-items: center;
flex-direction: row;
place-content: center space-between;

> :last-child {
flex-shrink: 0;
margin-left: var(--global--space--4);
}

> * {
display: block;
}
}
}

0 comments on commit 5728d69

Please sign in to comment.