-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* base message * basic messages added * Image attachments added * attachments are in * all media is in one file * fix compile issue * css properties patch * Image Thumb is in use * tests pass * File Thumb * read receipts are documented
- Loading branch information
Showing
28 changed files
with
830 additions
and
334 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,6 @@ | |
"typescript": "^4.4.4" | ||
}, | ||
"dependencies": { | ||
"html-to-text": "^8.0.0" | ||
"react-grid-system": "^7.3.1" | ||
} | ||
} |
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,11 @@ | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Default as Thing } from './stories'; | ||
|
||
describe('Thing', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing />, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { getFileName } from '../../util/file'; | ||
|
||
import { Props } from './props'; | ||
import { styles } from './styles'; | ||
|
||
export const FileThumb: React.FC<Props> = ({ | ||
attachment, | ||
isLoading = false, | ||
children = 'Loading...', | ||
style = {}, | ||
loadingStyle = {}, | ||
}) => { | ||
const [hovered, setHovered] = useState<boolean>(false); | ||
|
||
const fileStyle = { | ||
...styles.fileView, | ||
...{ | ||
color: hovered ? '#1890ff' : '#434343', | ||
border: hovered ? '1px solid #1890ff' : '1px solid #434343', | ||
}, | ||
}; | ||
|
||
if (isLoading || !attachment) { | ||
return ( | ||
<div style={{ ...styles.loadingContainer, ...loadingStyle }}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ | ||
...fileStyle, | ||
...style, | ||
}} | ||
onMouseEnter={() => setHovered(true)} | ||
onMouseLeave={() => setHovered(false)} | ||
onClick={() => window.open(attachment.file)} | ||
> | ||
{getFileName(attachment.file)} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { Properties } from 'csstype'; | ||
|
||
import { AttachmentProps } from '../../util/interfaces'; | ||
|
||
export interface Props { | ||
attachment?: AttachmentProps; | ||
isLoading?: boolean; | ||
children?: ReactNode; | ||
style?: Properties; | ||
loadingStyle?: Properties; | ||
} |
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,29 @@ | ||
import React from 'react'; | ||
|
||
import { Meta, Story } from '@storybook/react'; | ||
|
||
import { FileThumb } from '.'; | ||
|
||
import { Props } from './props'; | ||
|
||
import { fileAttachment } from '../../util/mocks'; | ||
|
||
const meta: Meta = { | ||
title: 'ChatFeed/FileThumb', | ||
component: FileThumb, | ||
argTypes: {}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: Story<Props> = (props) => <FileThumb {...props}></FileThumb>; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
attachment: fileAttachment, | ||
}; | ||
|
||
export const Loading = Template.bind({}); | ||
Loading.args = { | ||
isLoading: true, | ||
}; |
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,28 @@ | ||
import { Properties } from 'csstype'; | ||
|
||
export const styles = { | ||
fileView: { | ||
fontFamily: 'Avenir', | ||
padding: '12px', | ||
borderRadius: '14px', | ||
display: 'inline-block', | ||
marginBottom: '4px', | ||
marginRight: '2px', | ||
cursor: 'pointer', | ||
transition: 'all .33s ease', | ||
WebkitTransition: 'all .33s ease', | ||
MozTransition: 'all .33s ease', | ||
} as Properties, | ||
loadingContainer: { | ||
fontFamily: 'Avenir', | ||
color: 'white', | ||
padding: '14px', | ||
display: 'inline-block', | ||
borderRadius: '14px', | ||
marginRight: '2px', | ||
width: '136px', | ||
marginBottom: '4px', | ||
marginLeft: '4px', | ||
backgroundColor: '#d9d9d9', | ||
} as Properties, | ||
}; |
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,11 @@ | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Default as Thing } from './stories'; | ||
|
||
describe('Thing', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing />, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { Props } from './props'; | ||
import { styles } from './styles'; | ||
|
||
export const ImageThumb: React.FC<Props> = ({ | ||
attachment, | ||
isLoading = false, | ||
children = 'Loading...', | ||
style = {}, | ||
loadingStyle = {}, | ||
}) => { | ||
const [hovered, setHovered] = useState<boolean>(false); | ||
|
||
const thumbnailStyle = { | ||
...styles.thumbnail, | ||
...{ border: hovered ? '1px solid #1890ff' : '1px solid #fff' }, | ||
}; | ||
|
||
if (isLoading || !attachment) { | ||
return ( | ||
<div style={{ ...styles.loadingContainer, ...loadingStyle }}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<img | ||
onMouseEnter={() => setHovered(true)} | ||
onMouseLeave={() => setHovered(false)} | ||
src={attachment.file} | ||
alt={'thumb-nail'} | ||
style={{ | ||
...thumbnailStyle, | ||
...style, | ||
}} | ||
onClick={() => window.open(attachment.file)} | ||
/> | ||
); | ||
}; |
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,13 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { Properties } from 'csstype'; | ||
|
||
import { AttachmentProps } from '../../util/interfaces'; | ||
|
||
export interface Props { | ||
attachment?: AttachmentProps; | ||
isLoading?: boolean; | ||
children?: ReactNode; | ||
style?: Properties; | ||
loadingStyle?: Properties; | ||
} |
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,29 @@ | ||
import React from 'react'; | ||
|
||
import { Meta, Story } from '@storybook/react'; | ||
|
||
import { ImageThumb } from '.'; | ||
|
||
import { Props } from './props'; | ||
|
||
import { imageAttachment } from '../../util/mocks'; | ||
|
||
const meta: Meta = { | ||
title: 'ChatFeed/ImageThumb', | ||
component: ImageThumb, | ||
argTypes: {}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: Story<Props> = (props) => <ImageThumb {...props}></ImageThumb>; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
attachment: imageAttachment, | ||
}; | ||
|
||
export const Loading = Template.bind({}); | ||
Loading.args = { | ||
isLoading: true, | ||
}; |
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,41 @@ | ||
import { Properties } from 'csstype'; | ||
|
||
export const styles = { | ||
thumbnail: { | ||
cursor: 'pointer', | ||
textAlign: 'right', | ||
display: 'inline', | ||
objectFit: 'cover', | ||
borderRadius: '0.3em', | ||
padding: '2px', | ||
// Size | ||
height: '30vw', | ||
width: '30vw', | ||
maxHeight: '200px', | ||
maxWidth: '200px', | ||
minHeight: '100px', | ||
minWidth: '100px', | ||
transition: 'all .33s ease', | ||
WebkitTransition: 'all .33s ease', | ||
MozTransition: 'all .33s ease', | ||
} as Properties, | ||
loadingContainer: { | ||
fontFamily: 'Avenir', | ||
color: 'white', | ||
cursor: 'pointer', | ||
textAlign: 'right', | ||
display: 'inline-block', | ||
objectFit: 'cover', | ||
borderRadius: '0.3em', | ||
padding: '2px', | ||
marginRight: '2px', | ||
marginBottom: '4px', | ||
height: '30vw', | ||
width: '30vw', | ||
maxHeight: '200px', | ||
maxWidth: '200px', | ||
minHeight: '100px', | ||
minWidth: '100px', | ||
backgroundColor: '#d9d9d9', | ||
} as Properties, | ||
}; |
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,13 @@ | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Default as Thing } from './stories'; | ||
|
||
import { message } from '../../util/mocks'; | ||
|
||
describe('Thing', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing message={message} />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
}); |
Oops, something went wrong.