an Ellie and Nele: From she to he - and back to she again By www.bbc.co.uk Published On :: Tue, 10 Mar 2020 00:43:56 GMT When two trans men fell in love they began to have second thoughts about their gender. Full Article
an Life and struggle after YouTube fame By www.bbc.co.uk Published On :: Wed, 11 Mar 2020 00:43:14 GMT Dax was one of YouTube's first stars, but 13 years later, few people remember his name. Can a vlogging legend seize glory again? Full Article
an 'How do I convince the Home Office I'm a lesbian?' By www.bbc.co.uk Published On :: Wed, 26 Feb 2020 00:32:26 GMT More than 1,500 people claim asylum in the UK each year, claiming that they are persecuted for being gay. But it's not an easy thing to prove. Full Article
an Blasian love: The day we introduced our black and Asian families By www.bbc.co.uk Published On :: Wed, 11 Mar 2020 00:20:43 GMT Blasian - black and Asian - couples now exist in South Africa... but they don't always have an easy time. Full Article
an Coronavirus: The month everything changed By www.bbc.co.uk Published On :: Sat, 28 Mar 2020 00:03:25 GMT In the space of a month, the United Kingdom has transformed beyond recognition. Full Article
an Coronavirus: Here's how you can stop bad information from going viral By www.bbc.co.uk Published On :: Mon, 20 Apr 2020 10:39:28 GMT Experts are calling on the public to practise ‘information hygiene’ to help stop the spread of falsehoods online. Full Article
an Coronavirus: ‘It’s just anxiety, anxiety, anxiety’ By www.bbc.co.uk Published On :: Wed, 01 Apr 2020 00:28:54 GMT The coronavirus crisis is having a huge impact on young people with existing mental health conditions. Full Article
an Birth in a pandemic: 'You are stronger than you think' By www.bbc.co.uk Published On :: Tue, 31 Mar 2020 23:09:29 GMT Coronavirus is throwing many birth plans up in the air and leading some health trusts to increase home births. Full Article
an Coronavirus: Where has all the hand sanitiser gone? By www.bbc.co.uk Published On :: Thu, 02 Apr 2020 06:48:18 GMT Shelves all over the world are empty - it turns out more alcohol is needed, to ramp up production. Full Article
an Coronavirus: The grandad who became a TikTok star without realising it By www.bbc.co.uk Published On :: Sun, 12 Apr 2020 23:42:47 GMT Joe Allington was persuaded to dance on TikTok for the first time in January. Now he's got 1.5 million followers. Full Article
an Stop and search: the controversial police power By www.bbc.co.uk Published On :: Sat, 07 Dec 2019 09:04:42 GMT Reporter Aaron Roach Bridgeman speaks to suspects, police and campaigners. Full Article
an Why being gay in Russia is about "love and passion" By www.bbc.co.uk Published On :: Sat, 15 Feb 2020 00:19:02 GMT The secret moment between two gay Russian lovers that defied haters. Full Article
an Rob Lawrie, the ex-squaddie, and the girl taken By www.bbc.co.uk Published On :: Mon, 30 Mar 2020 00:13:01 GMT Rob thought he was helping a refugee girl and her father as they struggled to get to the UK. But he found out it was all a lie. Full Article
an The man who grew his own Amazon rainforest By www.bbc.co.uk Published On :: Wed, 01 Apr 2020 23:07:59 GMT Fighting back against destruction in the Amazon: how one man grew a rainforest of his own. Full Article
an Coronavirus: Love and dating in lockdown By www.bbc.co.uk Published On :: Thu, 09 Apr 2020 16:33:03 GMT How dating and love continue for three couples during the coronavirus lockdown. Full Article
an Coronavirus: what we can learn from the war generation By www.bbc.co.uk Published On :: Thu, 09 Apr 2020 16:52:35 GMT What can younger people learn from the generations that lived through World War Two? Full Article
an Coronavirus: DIY hair shaving and beauty treatments By www.bbc.co.uk Published On :: Fri, 17 Apr 2020 07:15:21 GMT As hair dye and clippers become the next thing on the stockpile list - we look at how people are managing their hair and beauty. Full Article
an From patient to healer: How this woman is saving lives By www.bbc.co.uk Published On :: Wed, 08 Apr 2020 23:17:58 GMT Women who have overcome depression are running therapy sessions to help others Full Article
an Ex porn-star and activist explores men's rights issues By www.bbc.co.uk Published On :: Tue, 21 Apr 2020 06:16:04 GMT Philipp travels to a conference on men’s issues in Chicago, shedding light on the controversial movement. Full Article
an Sex, Disability, and Sex and Disability By www.bbc.co.uk Published On :: Thu, 23 Apr 2020 01:12:00 GMT Disability and sex is a topic around which there are a lot of misconceptions, but what do disabled people think when people get awkward talking about sex with them? Full Article
an Ultra-Orthodox and trans: 'I prayed to God to make me a girl' By www.bbc.co.uk Published On :: Sat, 25 Apr 2020 23:28:57 GMT Growing up as a Hasidic Jew, Abby Stein had no idea trans people existed - she just felt sure she was a girl. Full Article
an Ramadan and Coronavirus: Breaking my fast on Zoom By www.bbc.co.uk Published On :: Thu, 30 Apr 2020 23:57:07 GMT How fasting in lockdown and isolation has changed Ramadan for young Muslims this year. Full Article
an Coronavirus: A toast to my cancelled wedding By www.bbc.co.uk Published On :: Sat, 02 May 2020 00:13:03 GMT Today was going to be my big day until Covid-19 intervened. But that won't stop me delivering my speech. Full Article
an The shop where you can still buy huge bags of pasta By www.bbc.co.uk Published On :: Mon, 06 Apr 2020 23:08:08 GMT Wholesalers are opening their doors to members of the public keen to buy supplies in bulk. Full Article
an Coronavirus tests and masks sold by fraudsters online By www.bbc.co.uk Published On :: Fri, 10 Apr 2020 04:54:22 GMT A BBC investigation has found online scams selling fake protective equipment and coronavirus tests. Full Article
an Coronavirus: 'My parents' campervan has become my office' By www.bbc.co.uk Published On :: Fri, 10 Apr 2020 21:26:57 GMT A marketing manager explains why she turned a campervan into her office during coronavirus. Full Article
an Coronavirus will have "significant impact" on economy By www.bbc.co.uk Published On :: Tue, 14 Apr 2020 12:44:47 GMT Chancellor Rishi Sunak has told reporters that Covid-19 will cause "hardship ahead". Full Article
an Coronavirus: ‘Buying a round’ to thank NHS workers By www.bbc.co.uk Published On :: Sat, 18 Apr 2020 23:05:01 GMT Social enterprise Brewgooder is helping people buy beers for those on the coronavirus front line. Full Article
an Coronavirus: UK chancellor on new microloan scheme for small businesses By www.bbc.co.uk Published On :: Mon, 27 Apr 2020 16:30:38 GMT Firms will be able to borrow up to £50,000, which will be interest free for the first year. Full Article
an Coronavirus: Pint delivery service to challenge Belfast ban By www.bbc.co.uk Published On :: Sun, 26 Apr 2020 23:11:06 GMT A pub delivering Guinness to people's homes during lockdown says it was operating within the law. Full Article
an Coronavirus: Should maternity and paternity leave be extended? By www.bbc.co.uk Published On :: Sun, 26 Apr 2020 23:22:29 GMT A petition calling for maternity leave to be extended due to coronavirus has attracted many signatures. Full Article
an Chancellor: 'Tough times' as coronavirus affects UK economy By www.bbc.co.uk Published On :: Mon, 27 Apr 2020 15:48:21 GMT The chancellor says there have already been "tough times" as the coronavirus outbreak has an impact on the UK and warns "there will be more to come". Full Article
an Coronavirus: Aer Lingus flight had 'no social distancing' says passenger By www.bbc.co.uk Published On :: Tue, 05 May 2020 14:54:07 GMT Sean Mallon's photos of an Aer Lingus Belfast-Heathrow flight showed passengers sitting close together. Full Article
an Coronavirus: Bread and cake tips from a self-isolating baker By www.bbc.co.uk Published On :: Fri, 08 May 2020 23:02:33 GMT Ray normally runs his family bakery, Rinkoffs, but is currently staying at home with his wife. Full Article
an Staging a 'socially distanced' boxing match By www.bbc.co.uk Published On :: Wed, 29 Apr 2020 23:31:52 GMT Inside the Nicaraguan boxing event that caught the world's attention during the pandemic. Full Article
an Playing With React and D3 By reactjsnews.com Published On :: Thu, 21 Apr 2016 17:00:00 +0000 D3 is great at data visualizations, but it manipulates the DOM directly to display that data. Rendering DOM elements is where React shines. It uses a virtual representation of the DOM (virtual DOM) and a super performant diffing algorithm in order to determine the fastest way to update the DOM. We want to leverage React’s highly efficient, declarative, and reusable components with D3’s data utility functions. At this point, we can safely say that React is the preferred JavaScript library for building user interfaces. It is used practically everywhere and is almost as pervasive as jQuery. It has an API that is simple, powerful, and easy to learn. Its performance metrics are really impressive thanks to the Virtual DOM and its clever diff algorithm between state changes. Nothing, however, is perfect, and React too has its limitations. One of React’s greatest strengths is the ease with which it integrate third-party libraries, but some libraries, especially opinionated ones, are more difficult to integrate than others. An extremely popular library that can be tricky to integrate with React is D3.js. D3 is an excellent data visualization library with a rich and powerful API. It is the gold standard of data visualizations. However, Because this library is opinionated about data, it is no trivial endeavour to get it to work with React. A few simple strategies permit these two libraries to work together in very powerful ways. Editor’s Note: Check out our upcoming workshop, React and D3, a crash course in learning how to create data visualizations with these two in demand libraries. Reserve your spot now on Eventbrite and get 20% off admission. Learn more at the Eventbrite page What is React? React is an open-source JavaScript library for creating user interfaces that addresses the challenges of building large applications with data that changes over time. Originally developed at Facebook, it is now seen in many of the most commonly used web applications including Instagram, Netflix, Airbnb, and HelloSign. Why is React so popular? React helps developers build applications by helping manage the application state. It’s simple, declarative, and composable. React is not a traditional MVC framework because React is really only interested in building user interfaces. Some have called it the “V(iew)” in MVC, but that’s a little misleading. React’s viewpoint is different. As application logic has reoriented toward the client, developers have applied more structure to their front-end JavaScript. We applied a paradigm that we already understood from the server (MVC) to the browser. Of course, the browser environment is very different from the server. React acknowledges that client-side applications are really a collection of UI components that should react to events like user interaction. React encourages the building applications out of self-contained, reusable components that only care about a small piece of the UI. Other frameworks such as Angular also attempt to do this, but React stands out because it enforces a unidirectional data flow from parent component to child component. This makes debugging much easier. Debugging is the hardest part of application development, so while React is more verbose that other libraries or frameworks, in the end it saves a lot of time. In a framework like Angular’s, it can be hard to figure out where a bug is coming from: The view? The model? The controller? The directive? The directive controller? Data in Angular flows in many different directions, and this makes it hard to reason about that state of your application. In React, when there is a bug (and there will be!), you can quickly determine where the bug originated from because data only moves in one direction. Locating a bug is as simple as connecting the numbered dots until you find the culprit. What is D3? D3 (Data-Driven Documents) is a JavaScript library for producing dynamic, interactive data-visualizations. It’s fairly low level, and the developer has a lot of control over the end result. It takes a bit of work to get D3 to do what you want, so if you’re looking for a more prepackaged solution, you’re probably better off with highcharts.js. That said, it is fairly simple to pick up once you get the hang of it. D3 does four main things: LOADS: D3 has convenient methods for importing data from CSV documents. BINDS: D3 binds data elements to the DOM via JavaScript and SVG. TRANSFORMS: data can be adjusted to fit your visual requirements TRANSITIONS: D3 can respond to user input and animate elements based on that input Why Would We Want To Use React with D3? D3 is great at data visualizations, but it manipulates the DOM directly to display that data. Rendering DOM elements is where React shines. It uses a virtual representation of the DOM (virtual DOM) and a super performant diffing algorithm in order to determine the fastest way to update the DOM. We want to leverage React’s highly efficient, declarative, and reusable components with D3’s data utility functions. Also, once we create a chart component, we can want to be able to reuse that chart with different data anywhere in our app. How to use React and D3? D3, like React, is declarative.D3 uses data binding, whereas React uses a unidirectional data flow paradigm. Getting these two libraries to work together takes a bit of work, but the strategy is fairly simple: since SVG lives in the DOM, let React handle displaying SVG representations of the data and lett D3 handle all the math to render the data. Of course, we’ll have to make compromises. React is unopinionated and flexible, thereby allowing you to accomplish whatever needs to be done. Some tasks, like creating axes, are tedious. We can let D3 directly access the DOM and create. It handles axes well, and since we only need to create very few, this tactic won’t affect performance. Let’s go through a simple example. I created a repository you can use to follow along here: playing-with-react-and-d3. You can follow in the unfinished directory and if you get stuck you can take a look at the finished directory. Let’s generate a random list of X-Y coordinates and display them on a ScatterPlot chart. If you’re following the tutorial, a finished example is provided for you under the “finished” directory, but you can also follow along under “unfinished.” I’ve gone through the trouble of doing all the setup for you. The build will automatically be created from “unfinished/src/index.jsx” Let’s start by creating a simple “Hello World!” React component. Create a file under “components” named “chart.jsx” // unfinished/src/components/chart.jsx import React from 'react'; export default (props) => { return <h1>Hello, World!</h1>; } This example is simple, but let’s go over the explanation anyway. Since we’re rendering a simple H1 with no state, we can just export a function that returns the HTML we expect. If you’re familiar with Angular or Ember, it might look weird to insert HTML directly into our JS code. On the one hand, this goes against everything we’ve learned about unobtrusive JavaScript. But on the other hand, it actually makes sense: we’re not putting JavaScript in our HTML, we’re putting our HTML into our JavaScript. React sees HTML and client-side JavaScript as fundamentally bonded together. They’re both concerned about one thing – rendering UI components to the user. They simply cannot be separated without losing the ability to see what your component is going at a glance. The great benefits of this approach is that you can describe exactly what your component will look like when it’s rendered. Also, keep in mind that this is only possible with JSX, which translates HTML elements into React functions that will render the HTML to the page. Now, let’s move on and mount our component to the DOM. Open up “index.jsx” // unfinished/src/index.jsx import './main.css'; import React from 'react'; import ReactDOM from 'react-dom'; import Chart from './components/chart.jsx'; const mountingPoint = document.createElement('div'); mountingPoint.className = 'react-app'; document.body.appendChild(mountingPoint); ReactDOM.render(<Chart/>, mountingPoint); You probably noticed a few things. You might be wondering why we’re requiring a CSS file. We’re using Webpack, which allows us to require CSS files. This is very useful when we modularize both our stylesheets and our JavaScript. We’re also creating a div in which we want to mount our React app. This is just a good practice in case you want to do other things on the page then render a React component. Lastly, we’re calling render on ReactDOM with 2 arguments, the name of the component and the DOM element we want to mount it on. Now, let’s install all the dependencies by navigating to the unfinished directory and running npm i. Then, fire up the server with npm run start and go to localhost:8080 Awesome! We have rendered our first React component! Let’s do something a little less trivial now. Let’s compose some functions that will create an array of random data points and then render a scatter plot. While we’re at it, we’ll add a button to randomize the dataset and trigger a re-render of our app. Let’s open up our Chart component and add the following: // unfinished/src/components/chart.jsx import React from 'react'; import ScatterPlot from './scatter-plot'; const styles = { width : 500, height : 300, padding : 30, }; // The number of data points for the chart. const numDataPoints = 50; // A function that returns a random number from 0 to 1000 const randomNum = () => Math.floor(Math.random() * 1000); // A function that creates an array of 50 elements of (x, y) coordinates. const randomDataSet = () => { return Array.apply(null, {length: numDataPoints}).map(() => [randomNum(), randomNum()]); } export default class Chart extends React.Component{ constructor(props) { super(props); this.state = { data: randomDataSet() }; } randomizeData() { this.setState({ data: randomDataSet() }); } render() { return <div> <h1>Playing With React and D3</h1> <ScatterPlot {...this.state} {...styles} /> <div className="controls"> <button className="btn randomize" onClick={() => this.randomizeData()}> Randomize Data </button> </div> </div> } } Since we want our component to manage it’s own state, we need to add a bit more code than was necessary for our previous “Hello World” stateless functional component. Instead of just a function, we’re going to extend React.Component and describe our component in the render() method. render() is the heart of any React component. It describes what our component is supposed to looks like. React will call render() on initial mount and on every state change. Inside of render(), we are both rendering a scatter plot component as if it were an HTML element and setting some properties or “props”. The ... syntax is a convenient JSX and ES2015 spread operator that spreads the attributes of an array or object instead of doing all of that explicitly. For more information check out: JSX Spread Attributes. We’re going to use render() to pass our data and a style object that will be used by some of our child components. In addition, we’re also rendering a button with an onClick event handler. We’re going to wrap this.randomizeData() with an arrow function and bind the value of this to our Chart component. When the button is clicked, randomizeData() will call this.setState() and pass in some new data. Let’s talk about this.setState(). If render() is the heart of a React component, setState() is the brains of a component. setState explicitly tells React that we’re changing the state, thereby triggering a re-render of the component and its children. This essentially turns UI components into state machines. Inside of setState(), we’re passing an object with data set to the randomDataSet(). This means that if we want to retrieve the state of our application, we need only call this.state.whateverStateWereLookingFor. In this case, we can retrieve the randomData by calling this.state.data. A little side note on how React works: React offers great performance for rendering UI components by implementing a diff algorithm and comparing a virtual DOM in memory with the actual DOM. When you think about it, the DOM is really a large tree structure. If there’s one thing we have learned from decades of computer science research, it’s how to compare and manipulate trees. React takes advantage of clever tree diffing algorithms, but in order to work, each component can only render one parent element (i.e., you cannot render sibling elements). That’s why In the render function we’re wrapping all our elements in one parent div. Let’s get started with the scatter plot component. Create a file unfinished/src/components/scatter-plot.jsx : // unfinished/src/components/scatter-plot.jsx import React from 'react'; import d3 from 'd3'; import DataCircles from './data-circles'; // Returns the largest X coordinate from the data set const xMax = (data) => d3.max(data, (d) => d[0]); // Returns the highest Y coordinate from the data set const yMax = (data) => d3.max(data, (d) => d[1]); // Returns a function that "scales" X coordinates from the data to fit the chart const xScale = (props) => { return d3.scale.linear() .domain([0, xMax(props.data)]) .range([props.padding, props.width - props.padding * 2]); }; // Returns a function that "scales" Y coordinates from the data to fit the chart const yScale = (props) => { return d3.scale.linear() .domain([0, yMax(props.data)]) .range([props.height - props.padding, props.padding]); }; export default (props) => { const scales = { xScale: xScale(props), yScale: yScale(props) }; return <svg width={props.width} height={props.height}> <DataCircles {...props} {...scales} /> </svg> } There’s a lot going on here, so let’s start with the stateless functional component that we’re exporting. D3 uses SVG to render data visualizations. D3 has special methods for creating SVG elements and binding data to those elements – but we’re going to let React handle that. We’re creating an SVG element with the properties passed in by the Chart component and which can be accessed via this.props. Then we’re creating a DataCircles component (more on that below) which will render the points for the scatter plot. Let’s talk about D3 scales. This is where D3 shines. Scales takes care of the messy math involved in converting your data into a format that can be displayed on a chart. If you have a data point value 189281, but your chart is only 200 pixels wide, then D3 scales converts that value to a number you can use. d3.scale.linear() returns a linear scale. D3 also supports other types of scales (ordinal, logarithmic, square root, etc.), but we won’t be talking about those here. domain is short for an “input domain”, i.e., the range of possible input values. It takes an array of the smallest input value possible and the maximum input value. range on its own is the range of possible output values. So in domain, we’re setting the range of possible data values from our random data, and in range we’re telling D3 the range of our chart. d3.max is a D3 method for determining the maximum value of a dataset. It can take a function which D3 will use to give the max values of the X and Y coordinates. We use the scales to render the data circles and our axes. Let’s create the DataCircles component under unfinished/src/components/data-circles.jsx // unfinished/src/components/data-circles.jsx import React from 'react'; const renderCircles = (props) => { return (coords, index) => { const circleProps = { cx: props.xScale(coords[0]), cy: props.yScale(coords[1]), r: 2, key: index }; return <circle {...circleProps} />; }; }; export default (props) => { return <g>{ props.data.map(renderCircles(props)) }</g> } In this component, we’re rendering a g element, the SVG equivalent to a div. Since we want to render a point for every set of X-Y coordinates, were must render multiple sibling elements which we wrap together in a g element for React to work. Inside of g, we’re mapping over the data and rendering a circle for each one using renderCircles. renderCircles creates an SVG circle element with a number of properties. Here’s where we’re setting the x and y coordinates (cx and cy respectively) with the D3 scales passed in from the scatter plot component. r is the radius of our circle, and key is something React requires us to do. Since we’re rendering identical sibling components, React’s diffing algorithm needs a way to keep track of them as it updates the DOM over and over. You can use any key you like, as long as it’s unique to the list. Here we’re just going to use the index of each element. Now, when we look at our browser, we see this: We can see our random data and randomize that data via user input. Awesome! But we’re missing a way to read this data. What we need are axes. Let’s create them now. Let’s open up ScatterPlot.jsx and add an XYAxis component // unfinished/src/components/scatter-plot.jsx // ... import XYAxis from './x-y-axis'; // ... export default (props) => { const scales = { xScale: xScale(props), yScale: yScale(props) }; return <svg width={props.width} height={props.height}> <DataCircles {...props} {...scales} /> <XYAxis {...props} {...scales} /> </svg> } Now, let’s create the XYAxis component; // unfinished/src/components/x-y-axis.jsx import React from 'react'; import Axis from './axis'; export default (props) => { const xSettings = { translate: `translate(0, ${props.height - props.padding})`, scale: props.xScale, orient: 'bottom' }; const ySettings = { translate: `translate(${props.padding}, 0)`, scale: props.yScale, orient: 'left' }; return <g className="xy-axis"> <Axis {...xSettings}/> <Axis {...ySettings}/> </g> } For simplicity’s sake, we’re creating two objects which will hold the props for each of our X-Y axes. Let’s create an axis component to explain what these props do. Go ahead and create axis.jsx // unfinished/src/components/x-y-axis.jsx import React from 'react'; import d3 from 'd3'; export default class Axis extends React.Component { componentDidMount() { this.renderAxis(); } componentDidUpdate() { this.renderAxis(); } renderAxis() { var node = this.refs.axis; var axis = d3.svg.axis().orient(this.props.orient).ticks(5).scale(this.props.scale); d3.select(node).call(axis); } render() { return <g className="axis" ref="axis" transform={this.props.translate}></g> } } Our strategy up to this point has been to let React exclusively handle the DOM. This is a good general rule, but we should leave room for nuance. In this case, the math and work necessary in order to render an axis is quite complicated and D3 has abstracted that pretty nicely. We’re going to let D3 have access to the DOM in this case. And since we’re only going to render a ma Full Article
an Leveraging React for Easy Image Management By reactjsnews.com Published On :: Tue, 17 Jan 2017 17:00:00 +0000 React is a good tool when it comes to building flexible and reusable UI components. However, it’s “one of those libraries” that cannot handle all the tasks involved in building a full fleshed UI project. Other supporting tools - such as a recently announced React SDK from Cloudinary - are available to provide solutions that the React core cannot. In such cases where media (images and videos) becomes a heavy task to handle, Cloudinary simplifies the process with the new React SDK. Let’s build and image library with Cloudinary and React using the Cloudinary’s React SDK. Prerequisites The only requirements for using Cloudinary in your existing React project are to install the React SDK and the upload widget. If you do not have an existing React project and want to try these examples, take the following steps: 1. Install Dependencies We need a minimal amount of dependencies so we can focus on building a media library and not structuring a React app: { "name": "img-library", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "watch": "webpack -d --watch", "build": "webpack", "serve": "serve ./public" }, "author": "", "license": "MIT", "devDependencies": { "babel-core": "^6.18.2", "babel-loader": "^6.2.9", "babel-preset-es2015": "^6.18.0", "babel-preset-react": "^6.16.0", "serve": "^1.4.0", "webpack": "^1.14.0" }, "dependencies": { "axios": "^0.15.3", "cloudinary-react": "^1.0.1", "react": "^15.4.1", "react-dom": "^15.4.1" } } React (and React DOM) must be used since we are making a React app. The cloudinary-react dependency is Cloudinary’s React SDK, which we will soon see how it works. axios is a tool for making HTTP requests and, in our case, we will use it request images from the Cloudinary server. # Install dependencies npm install 2. Setup Webpack Webpack is our build tool. Only minimal settings are required to have a build running and our React app compiling: // ./webpack.config.js var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname, 'public'); var APP_DIR = path.resolve(__dirname, 'src'); var config = { entry: APP_DIR + '/index.jsx', output: { path: BUILD_DIR, filename: 'bundle.js' }, module : { loaders : [ { test : /.jsx?/, include : APP_DIR, loader : 'babel' } ] } }; module.exports = config; Basic configuration - an entry, output and loaders to handle the React .jsx files. 3. Entry Points We need to create an entry point, as we specified in the Webpack configuration, and another entry point for the browser, which is an index.html file: // ./src/index.jsx import React, { Component } from 'react'; import { render } from 'react-dom'; class Main extends Component { render() { return ( <div className="main"> <h1>Scotchage</h1> </div> ); } } render(<Main />, document.getElementById('container')); <!-- ./public/index.html --> <html> <head> <!--Stylesheet--> <link rel="stylesheet" href="style.css"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <!--Container for React rendering--> <div id="container"></div> <!--Bundled file--> <script src="bundle.js"></script> </body> </html> 4. Create Cloudinary Account You need a Cloudinary account to continue with these examples. Sign up for free and store your credentials safely as shown on the dashboard: Uploading Images Before using the React SDK to deliver images from the Cloudinary servers, let’s use the awesome Cloudinary upload widget to upload images. First, we need to add this widget to our index.html: <!-- ./public/index.html --> <html> <head> . . . </head> <body> . . . <!-- UPLOAD WIDGET --> <script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script> <script src="bundle.js"></script> </body> </html> Next, we create a button, attach an event to it and upload an image once the button is clicked: import React, { Component } from 'react'; import { render } from 'react-dom'; class Main extends Component { uploadWidget() { cloudinary.openUploadWidget({ cloud_name: 'CLOUD_NAME', upload_preset: 'PRESET', tags:['xmas']}, function(error, result) { console.log(result); }); } render(){ return ( <div className="main"> <h1>Galleria</h1> <div className="upload"> <button onClick={this.uploadWidget.bind(this)} className="upload-button"> Add Image </button> </div> </div> ); } } render(<Main />, document.getElementById('container')); The uploadWidget member method is the handler invoked by the click event to handle our image upload by calling cloudinary.openUploadWidget. openUploadWidget takes a config object and the upload callback handler. The config object must have at least cloud_name and upload_preset properties with valid values. You can read more about Cloud Names and Upload Presets. Delivering Images with SDK The Cloudinary React SDK has three major components, Image, CloudinaryContext and Transformation: Image: This component is responsible for the actual delivery of images. It takes the image ID and asks the server for this image. When the image is provided, it is also responsible for painting the image on the browser. Transformation: This component is used to apply transformations to images delivered with Image. CloudinaryContext: You can specify Cloudinary configuration for each image on the Image component. This can be tedious when you are dealing with multiple images. CloudinaryContext allows you to apply configuration to a group of Images. Most times you would end up with a structure like this: <CloudinaryContext> <Image> <Transformation /> <Transformation /> </Image> <Image> <Transformation /> </Image> </CloudinaryContext> Back to our demo app, we can request an image from the Cloudinary server and display it with the following components: import React, { Component } from 'react'; import axios from 'axios'; import { CloudinaryContext, Transformation, Image } from 'cloudinary-react'; import { render } from 'react-dom'; class Main extends Component { constructor(props) { super(props); this.state = { gallery: [] } } componentDidMount() { // Request for images tagged xmas axios.get('http://res.cloudinary.com/christekh/image/list/xmas.json') .then(res => { console.log(res.data.resources); this.setState({gallery: res.data.resources}); }); } uploadWidget() { // . . . } render(){ return ( <div className="main"> <h1>Galleria</h1> <div className="gallery"> <CloudinaryContext cloudName="CLOUDNAME"> { this.state.gallery.map(data => { return ( <div className="responsive" key={data.public_id}> <div className="img"> <a target="_blank" href={`http://res.cloudinary.com/christekh/image/upload/${data.public_id}.jpg`}> <Image publicId={data.public_id}> <Transformation crop="scale" width="300" height="200" dpr="auto" responsive_placeholder="blank" /> </Image> </a> <div className="desc">Created at {data.created_at}</div> </div> </div> ) }) } </CloudinaryContext> <div className="clearfix"></div> </div> </div> ); } } render(<Main />, document.getElementById('container')); Take one more look at the upload code: cloudinary.openUploadWidget({ cloud_name: 'christekh', upload_preset: 'idcidr0h', tags:['xmas']}, function(error, result) { . . . Each image is tagged with xmas, which serves as a way to request images with this tag as a collection. This is exactly what we are using the axios library to do when the component mounts: axios.get('http://res.cloudinary.com/CLOUDNAME/image/list/xmas.json') .then(res => { console.log(res.data.resources); this.setState({gallery: res.data.resources}); }); axios uses promises, so whenever the promise resolves in our case, we have a payload of images. We take advantage of React state to update our UI with the fetched resources. Down to rendering, we configure the CloudinaryContext with our cloud_name, iterate over the gallery state that stores the images and displays them using the Image component. We also apply few transformations using the Transformation component. For security reasons, Cloudinary will not allow you to make such request from the client unless you tell it to. The best way to go is to use the admin API via a backend SDK and then send the resource list to the client. Updating State with New Uploads We are able to upload images and request for images to be displayed on the user’s browsers. Here is how we update the displayed images instantly when the user uploads a new image: uploadWidget() { let _this = this; cloudinary.openUploadWidget({ cloud_name: 'CLOUDNAME', upload_preset: 'PRESET', tags:['xmas']}, function(error, result) { // Update gallery state with newly uploaded image _this.setState({gallery: _this.state.gallery.concat(result)}) }); } Rather than logging the uploaded image information to the console, we update the gallery state, which bears the list of requested images, by concatenating the uploaded result to the gallery. Image Management Simplified Image uploads, transformation and delivery has never been easier. These tasks have been a serious challenge for developers. Cloudinary has created a way to abstract all this hard work, enabling you to simply plug and play. Full Article
an 2000 FIFA Club World Championship: Corinthians 0-0 Vasco da Gama (4-3 PSO) By www.fifa.com Published On :: Sun, 02 Dec 2012 23:18:00 GMT Corinthians-Vasco da Gama, FIFA Club World Cup Brazil 2000 Final: The all-Brazilian final had a plethora of familiar names - including legend Romario, Edmundo, Gilberto Melo, Ricardinho and Dida - and ended in a dramatic penalty shootout. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Championship Brazil 2000
an 2007 Club World Cup Final: Boca Juniors 2-4 AC Milan By www.fifa.com Published On :: Sat, 08 Dec 2012 02:03:00 GMT In the final of the FIFA Club World Cup Japan 2007, Italian giants AC Milan got two goals from 'Pippo' Inzaghi and one each from Kaka and Alessandro Nesta to become the world's top team. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup Japan 2007
an 2008 Club World Cup Final: LDU Quito 0-1 Manchester United By www.fifa.com Published On :: Mon, 10 Dec 2012 02:58:00 GMT Liga de Quito-Manchester United, FIFA Club World Cup Japan 2008 Final: Both teams showed impressive attacking flair, but it was Wayne Rooney's angled shot that made the difference. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup Japan 2008
an 2009 Club World Cup: Estudiantes 1-2 Barcelona (AET) By www.fifa.com Published On :: Tue, 11 Dec 2012 03:06:00 GMT A:Estudiantes-Barcelona, FIFA Club World Cup UAE 2009 final: Barcelona won their sixth trophy of the year following a last-gasp equaliser and a headed winner in extra time against a dogged Argentine opponent. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup UAE 2009
an 2011 Club World Cup Final: Santos 0-4 Barcelona By www.fifa.com Published On :: Fri, 14 Dec 2012 02:18:00 GMT Hopes were high in the final of the FIFA Club World Cup Japan 2011 that Brazilian team Santos could match Barcelona's firepower, but Lionel Messi, Cesc Fabregas, Xavi and crew had other ideas. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup Japan 2011
an 2012 Club World Cup Final: Corinthians 1-0 Chelsea By www.fifa.com Published On :: Mon, 17 Dec 2012 02:43:00 GMT Corinthians and Chelsea met in the FIFA Club World Cup Cup Japan 2012 final. Watch highlights from the match when the South American champions defeated their European counterparts. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup Japan 2012
an 2013 Club World Cup Final: Bayern Munich 2-0 Raja Casablanca By www.fifa.com Published On :: Sun, 22 Dec 2013 03:51:00 GMT Bayern Munich - Raja Casablanca, FIFA Club World Cup Morocco 2013: The European champions got goals from Dante and Thiago as the host Moroccan club came close but fell in the end in this well-played final. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup Morocco 2013
an Kashima Antlers 3-2 CD Guadalajara (UAE 2018) By www.fifa.com Published On :: Sat, 15 Dec 2018 16:36:00 GMT Losing finalists at the 2016 edition of the FIFA Club World Cup, Kashima Antlers defeated Mexico's CD Guadalajara to set up a semi-final against the team that beat them in that 2016 final, Real Madrid. Full Article Area=Tournament Section=Competition Kind=Match HL Tournament=FIFA Club World Cup UAE 2018
an Esperance 1-1 (6-5 pens) CD Guadalajara (UAE 2018) By www.fifa.com Published On :: Tue, 18 Dec 2018 16:42:00 GMT Nine-man Esperance ended their FIFA Club World Cup UAE 2018 campaign on a high after a tense 6-5 penalty shoot-out win against Chivas in the match for fifth place. Full Article Area=Tournament Section=Competition Kind=Match HL Tournament=FIFA Club World Cup UAE 2018
an Kashima Antlers 0-4 River Plate (UAE 2018) By www.fifa.com Published On :: Sat, 22 Dec 2018 15:58:00 GMT River Plate ended their FIFA Club World Cup UAE 2018 campaign with an emphatic 4-0 victory over AFC Champions League holders Kashima Antlers. Full Article Area=Tournament Section=Competition Kind=Video Tournament=FIFA Club World Cup UAE 2018
an Javier Ceppi, Praful Patel, and Jaime Yarza speak to the media during a press conference By www.fifa.com Published On :: Thu, 26 Oct 2017 14:03:00 GMT KOLKATA, INDIA - OCTOBER 26: L-R: Javier Ceppi, Tournament Director at LOC FIFA U-17 World Cup India 2017, Patel Praful and Head of FIFA Tournaments, Jaime Yarza speak to the media during a press conference ahead of the FIFA U-17 World Cup India 2017 tournament at Vivekananda Yuba Bharati Krirangan on October 26, 2017 in Kolkata, India. (Photo by Tom Dulat - FIFA/FIFA via Getty Images) Full Article Area=Tournament Section=Competition Kind=Photo Tournament=FIFA U-17 World Cup India 2017
an Javier Ceppi, Praful Patel and Jaime Yarza speak during a India 2017 press conference By www.fifa.com Published On :: Thu, 26 Oct 2017 14:07:00 GMT KOLKATA, INDIA - OCTOBER 26: L-R: Javier Ceppi, Tournament Director at LOC FIFA U-17 World Cup India 2017, Patel Praful and Head of FIFA Tournaments, Jaime Yarza speak to the media during a press conference ahead of the FIFA U-17 World Cup India 2017 tournament at Vivekananda Yuba Bharati Krirangan on October 26, 2017 in Kolkata, India. (Photo by Tom Dulat - FIFA/FIFA via Getty Images) Full Article Area=Tournament Section=Competition Kind=Photo Tournament=FIFA U-17 World Cup India 2017
an Praful Patel and Jaime Yarza speak to the media during an India 2017 press conference By www.fifa.com Published On :: Thu, 26 Oct 2017 14:11:00 GMT KOLKATA, INDIA - OCTOBER 26: Patel Praful and Head of FIFA Tournaments, Jaime Yarza speak to the media during a press conference ahead of the FIFA U-17 World Cup India 2017 tournament at Vivekananda Yuba Bharati Krirangan on October 26, 2017 in Kolkata, India. (Photo by Tom Dulat - FIFA/FIFA via Getty Images) Full Article Area=Tournament Section=Competition Kind=Photo Tournament=FIFA U-17 World Cup India 2017