-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5381 from Sayegh7/feature/markdown_giphy
ADD giphy support in notes addon
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 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
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,34 @@ | ||
import React from 'react' | ||
import * as PropTypes from 'prop-types'; | ||
|
||
interface Props{ | ||
gif: String | ||
} | ||
interface GiphyState { | ||
src?: string; | ||
} | ||
export default class Giphy extends React.Component<Props, GiphyState> { | ||
static propTypes = { | ||
gif: PropTypes.string.isRequired, | ||
} | ||
constructor(props: any){ | ||
super(props) | ||
this.state = { | ||
src: null | ||
} | ||
fetch(`http://api.giphy.com/v1/gifs/search?limit=1&api_key=dc6zaTOxFJmzC&q=${props.gif}`) | ||
.then(response => { | ||
if(response.ok){ | ||
return response.json() | ||
} | ||
}) | ||
.then(data => { | ||
this.setState({ src: data.data[0].images.original.url}) | ||
}) | ||
} | ||
render() { | ||
return ( | ||
<img src={this.state.src} /> | ||
) | ||
} | ||
} |
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