-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* File Thumb mdx file * tests pass * Image Thumb MDX * attachment required + test patch
- Loading branch information
Showing
11 changed files
with
226 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Default as Thing } from './stories'; | ||
|
||
import { FileThumb as Thing } from '.'; | ||
|
||
import { fileAttachment } from '../../util/mocks'; | ||
|
||
describe('Thing', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing />, div); | ||
ReactDOM.render(<Thing attachment={fileAttachment} />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { ArgsTable, Meta, Story, Canvas } from '@storybook/addon-docs'; | ||
|
||
import { FileOutlined } from '@ant-design/icons'; | ||
|
||
import { FileThumb } from '.'; | ||
import { Props } from './props'; | ||
|
||
import { fileAttachment } from '../../util/mocks'; | ||
|
||
<Meta title="ChatFeed/FileThumb" component={FileThumb} /> | ||
|
||
export const Template = ({ | ||
children, | ||
isLoading, | ||
attachment, | ||
style, | ||
loadingStyle, | ||
}) => ( | ||
<FileThumb | ||
attachment={attachment} | ||
isLoading={isLoading} | ||
style={style} | ||
loadingStyle={loadingStyle} | ||
> | ||
{children} | ||
</FileThumb> | ||
); | ||
|
||
# File Thumb | ||
|
||
File Thumbs are used to display a file, which isn't an image, and was sent by a user. | ||
|
||
A File Thumb will display the file's name, and will open the file in another tab once clicked. | ||
|
||
The component requires an `attachment` prop to display the correct file info. | ||
|
||
The component takes optional `isLoading`, `children`, `style`, and `loadingStyle` props. | ||
|
||
## Default | ||
|
||
<Story name="Default" args={{ attachment: fileAttachment }}> | ||
{Template.bind({})} | ||
</Story> | ||
|
||
<ArgsTable story="Default" /> | ||
|
||
## Is Loading | ||
|
||
You can set the `isLoading` prop to `true` and the message will appear to be loading/processing the file. | ||
|
||
This is used when a message is sending and has not delivered yet. | ||
|
||
<Canvas> | ||
<Story | ||
name="Is Loading" | ||
args={{ attachment: fileAttachment, isLoading: true }} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Children | ||
|
||
You can put child props within the `<FileThumb>` component. This lets you customize what is in a file thumb's body. | ||
|
||
<Canvas> | ||
<Story | ||
name="Children" | ||
args={{ | ||
attachment: fileAttachment, | ||
children: ( | ||
<div> | ||
<FileOutlined /> Custom Text and Icon | ||
</div> | ||
), | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Custom Style | ||
|
||
You can customize the CSS style of a file component too. | ||
|
||
<Canvas> | ||
<Story | ||
name="Custom Style" | ||
args={{ | ||
attachment: fileAttachment, | ||
style: { | ||
backgroundColor: 'rgb(74, 81, 98)', | ||
border: 'none', | ||
color: 'white', | ||
}, | ||
loadingStyle: { | ||
backgroundColor: 'rgb(74, 81, 98)', | ||
border: 'none', | ||
color: 'white', | ||
}, | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Default as Thing } from './stories'; | ||
import { ImageThumb as Thing } from '.'; | ||
import { imageAttachment } from '../../util/mocks'; | ||
|
||
describe('Thing', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing />, div); | ||
ReactDOM.render(<Thing attachment={imageAttachment} />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { ArgsTable, Meta, Story, Canvas } from '@storybook/addon-docs'; | ||
|
||
import { FileOutlined } from '@ant-design/icons'; | ||
|
||
import { ImageThumb } from '.'; | ||
import { Props } from './props'; | ||
|
||
import { imageAttachment } from '../../util/mocks'; | ||
|
||
<Meta title="ChatFeed/ImageThumb" component={ImageThumb} /> | ||
|
||
export const Template = ({ | ||
children, | ||
isLoading, | ||
attachment, | ||
style, | ||
loadingStyle, | ||
}) => ( | ||
<ImageThumb | ||
attachment={attachment} | ||
isLoading={isLoading} | ||
style={style} | ||
loadingStyle={loadingStyle} | ||
> | ||
{children} | ||
</ImageThumb> | ||
); | ||
|
||
# File Thumb | ||
|
||
Image Thumbs are used to display an Image, and was sent by a user. | ||
|
||
An Image Thumb will display a cropped version of the image, and will expand in another tab once clicked. | ||
|
||
The component requires an `attachment` prop to display the correct image / info. | ||
|
||
The component takes optional `isLoading`, `children`, `style`, and `loadingStyle` props. | ||
|
||
## Default | ||
|
||
<Story name="Default" args={{ attachment: imageAttachment }}> | ||
{Template.bind({})} | ||
</Story> | ||
|
||
<ArgsTable story="Default" /> | ||
|
||
## Is Loading | ||
|
||
You can set the `isLoading` prop to `true` and the message will appear to be loading/processing the file. | ||
|
||
This is used when a message is sending and has not delivered yet. | ||
|
||
<Canvas> | ||
<Story | ||
name="Is Loading" | ||
args={{ attachment: imageAttachment, isLoading: true }} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Children | ||
|
||
You can put child props within the `<ImageThumb>` component. This lets you customize what is in an image thumb's body. | ||
|
||
<Canvas> | ||
<Story | ||
name="Children" | ||
args={{ | ||
attachment: imageAttachment, | ||
isLoading: true, | ||
children: ( | ||
<div style={{ color: 'black', padding: '12px' }}> | ||
<FileOutlined /> Custom Text | ||
</div> | ||
), | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Custom Style | ||
|
||
You can customize the CSS style of an image thumb component too. | ||
|
||
<Canvas> | ||
<Story | ||
name="Custom Style" | ||
args={{ | ||
attachment: imageAttachment, | ||
style: { | ||
backgroundColor: 'rgb(74, 81, 98)', | ||
border: 'none', | ||
}, | ||
loadingStyle: { | ||
backgroundColor: 'rgb(74, 81, 98)', | ||
border: 'none', | ||
color: 'white', | ||
}, | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> |
This file was deleted.
Oops, something went wrong.