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'));
![React UI - 07 - Random Image Generator Giphy API - Script Codes](http://shots.codepen.io/xmjol/pen/awRqWy-512.jpg)
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 |
Flex Side-content | 2,952 Kb |
React UI - 07 - Random Image Generator Giphy API | 4,193 Kb |
THRWidgets OldLib | 3,115 Kb |
React UI - 05 - Draggable SVG Path Generator | 6,723 Kb |
Bottom Menu- Social | 2,245 Kb |
ReactJS Simple Component | 2,540 Kb |
ReactJS Tutorial Testing | 3,236 Kb |
Locatifs-Info | 2,592 Kb |
ResaFav Customizer | 3,669 Kb |
Open Card Animation | 4,603 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 |
We Simplify animation | Meodai | 48,169 Kb |
Confirm Close Of Foundation Reveal Modal | Winghouchan | 1,818 Kb |
Week7 replicate | Hwcasis | 1,620 Kb |
Test | Dviate | 2,668 Kb |
A Pen by Stan Williams | Stanssongs | 6,706 Kb |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
SVG Playground | Roygwells | 1,834 Kb |
Slide out Menu | Rbiggs | 4,936 Kb |
Simple Login Form Template | Banunn | 3,571 Kb |
Nested flexbox layout for library catalog | Boycetrus | 3,271 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!