React UI - 07 - Random Image Generator Giphy API
How do I make an react ui - 07 - random image generator giphy api?
What is a react ui - 07 - random image generator giphy api? How do you make a react ui - 07 - random image generator giphy api? This script and codes were developed by Xavier Martínez on 31 October 2022, Monday.
React UI - 07 - Random Image Generator Giphy API - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React UI - 07 - Random Image Generator Giphy API</title> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="card"></div> <script src='https://npmcdn.com/[email protected]/dist/react.min.js'></script>
<script src='https://npmcdn.com/[email protected]/dist/react-dom.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
React UI - 07 - Random Image Generator Giphy API - Script Codes CSS Codes
body { margin: 0; font-family: sans-serif; font-size: 12px; background: #e2e1e0; text-align: center;
}
.btn-loadimg { border: 2px solid #00E676; background-color: #00E676; color: white; padding: 10px; margin: 10px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
.btn-loadimg:hover { cursor: pointer; border: 2px solid #00E676; color: #00E676; background-color: white;
}
h1 { text-align: center; color: #00E676; text-shadow: 1px 1px 1px #00796B; padding: 20px; margin: 0;
}
#card { padding: 20px;
}
.card-item { background-color: #fff; color: #00E676; width: 320px; margin: 0 auto; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.card-item img { display: block;
}
React UI - 07 - Random Image Generator Giphy API - Script Codes JS Codes
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var SEARCH_KEY = 'pug';
var RandomGif = function (_React$Component) { _inherits(RandomGif, _React$Component); function RandomGif(props) { _classCallCheck(this, RandomGif); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { imageSrc: '' }; _this.loadImage = _this.loadImage.bind(_this); return _this; } RandomGif.prototype.componentDidMount = function componentDidMount() { this.loadImage(); }; RandomGif.prototype.loadImage = function loadImage() { var _this2 = this; var url = 'https://api.giphy.com/v1/gifs/random?tag=' + this.props.keyword + '&api_key=' + this.props.apiKey; fetch(url).then(function (response) { return response.json(); }).then(function (res) { return _this2.setState({ imageSrc: res.data.image_url }); }).catch(function (res) { console.log('ERROR: No image from API!'); }); }; RandomGif.prototype.render = function render() { return React.createElement( 'div', { className: 'card-item' }, React.createElement( 'h1', null, 'Random ' + this.props.keyword + ' image' ), React.createElement('img', { src: this.state.imageSrc, style: { width: "100%", maxHeight: "auto" } }), React.createElement( 'button', { onClick: this.loadImage, className: 'btn-loadimg' }, 'MOAR!' ) ); }; return RandomGif;
}(React.Component);
ReactDOM.render(React.createElement(RandomGif, { apiKey: 'afea92ac6eff442ba6fca79368717d0d', keyword: SEARCH_KEY }), document.getElementById('card'));
Developer | Xavier Martínez |
Username | xmjol |
Uploaded | October 31, 2022 |
Rating | 3 |
Size | 4,193 Kb |
Views | 60,720 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Pixel Anim Test | 2,415 Kb |
Flex Side-content-2 | 2,414 Kb |
React UI - 02 - Modal trigger | 4,053 Kb |
Locations-6-Block-Flex | 3,081 Kb |
THRWidgets OldLib | 3,115 Kb |
Bottom Menu- Social | 2,245 Kb |
React UI - 05 - Draggable SVG Path Generator | 6,723 Kb |
Flex Side-content | 2,952 Kb |
ReactJS Simple Component | 2,540 Kb |
Locatifs-Info | 2,592 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Polygon Logo in CSS | Kai | 3,412 Kb |
Minimal Material Design Form Input | Koenigsegg1 | 3,076 Kb |
Simple Responsive Text | Fbrz | 2,282 Kb |
12 DAYS OF XMAS | Proto78 | 2,313 Kb |
Under construction | GhostRider | 1,642 Kb |
CSS Dynamic Width Square Div | Elleestcrimi | 2,861 Kb |
TigerWoods Freecodecamp Page | Baileytj | 2,869 Kb |
Getting Started | Viblast | 1,500 Kb |
HTM5 picture dropzone | Jaysalvat | 2,576 Kb |
Navcube | Wbarlow | 4,775 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!