Migrate Emojify to Storybook

This commit is contained in:
Chris Svenningsen 2020-08-21 10:27:37 -07:00 committed by Josh Perez
parent 88dce16b32
commit db1f4d107f
3 changed files with 96 additions and 61 deletions

View file

@ -1,60 +0,0 @@
### All emoji
```jsx
<Emojify text="🔥🔥🔥" />
```
### With skin color modifier
```jsx
<Emojify text="👍🏾" />
```
### With `sizeClass` provided
```jsx
<Emojify text="🔥" sizeClass="jumbo" />
```
```jsx
<Emojify text="🔥" sizeClass="large" />
```
```jsx
<Emojify text="🔥" sizeClass="medium" />
```
```jsx
<Emojify text="🔥" sizeClass="small" />
```
```jsx
<Emojify text="🔥" sizeClass="" />
```
### Starting and ending with emoji
```jsx
<Emojify text="🔥in between🔥" />
```
### With emoji in the middle
```jsx
<Emojify text="Before 🔥🔥 after" />
```
### No emoji
```jsx
<Emojify text="This is the text" />
```
### Providing custom non-link render function
```jsx
const renderNonEmoji = ({ text, key }) => (
<span key={key}>This is my custom content</span>
);
<Emojify text="Before 🔥🔥 after" renderNonEmoji={renderNonEmoji} />;
```

View file

@ -0,0 +1,95 @@
import * as React from 'react';
import { text } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { Emojify, Props } from './Emojify';
const story = storiesOf('Components/Conversation/Emojify', module);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
renderNonEmoji: overrideProps.renderNonEmoji,
sizeClass: overrideProps.sizeClass,
text: text('text', overrideProps.text || ''),
});
story.add('Emoji Only', () => {
const props = createProps({
text: '😹😹😹',
});
return <Emojify {...props} />;
});
story.add('Skin Color Modifier', () => {
const props = createProps({
text: '👍🏾',
});
return <Emojify {...props} />;
});
story.add('Jumbo', () => {
const props = createProps({
text: '😹😹😹',
sizeClass: 'jumbo',
});
return <Emojify {...props} />;
});
story.add('Large', () => {
const props = createProps({
text: '😹😹😹',
sizeClass: 'large',
});
return <Emojify {...props} />;
});
story.add('Medium', () => {
const props = createProps({
text: '😹😹😹',
sizeClass: 'medium',
});
return <Emojify {...props} />;
});
story.add('Small', () => {
const props = createProps({
text: '😹😹😹',
sizeClass: 'small',
});
return <Emojify {...props} />;
});
story.add('Plus Text', () => {
const props = createProps({
text: 'this 😹 cat 😹 is 😹 so 😹 joyful',
});
return <Emojify {...props} />;
});
story.add('All Text, No Emoji', () => {
const props = createProps({
text: 'this cat is so joyful',
});
return <Emojify {...props} />;
});
story.add('Custom Text Render', () => {
const props = createProps({
text: 'this 😹 cat 😹 is 😹 so 😹 joyful',
renderNonEmoji: ({ text: theText, key }) => (
<div key={key} style={{ backgroundColor: 'aquamarine' }}>
{theText}
</div>
),
});
return <Emojify {...props} />;
});

View file

@ -35,7 +35,7 @@ function getImageTag({
);
}
interface Props {
export interface Props {
text: string;
/** A class name to be added to the generated emoji images */
sizeClass?: SizeClassType;