diff --git a/LICENSE b/LICENSE index 896ba66..5e2d7c3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Kris Borchers +Copyright (c) 2015 Kris Borchers, Rafael Xavier de Souza @rxaviers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/examples/README.md b/examples/README.md index 4a72102..93587ba 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,5 +6,14 @@ Install These instructions assume you have node and npm installed. For help, see the [npm docs](https://docs.npmjs.com/getting-started/installing-node) 1. Run `npm install` -2. Run `npm run-script build` to generate the built JS file -3. Open browser and navigate to `react-globalize/examples/index.html` + +Development +----------- + +1. Run `npm run start` to start a server with live reload support. + +Production +---------- + +1. Run `npm run build` to generate the distribution JS file +1. Open browser and navigate to `react-globalize/examples/dist/index.html` diff --git a/examples/components/currency.jsx b/examples/components/currency.jsx new file mode 100644 index 0000000..c01b3d5 --- /dev/null +++ b/examples/components/currency.jsx @@ -0,0 +1,201 @@ +var React = require("react"); +var ReactGlobalize = require("react-globalize"); +var FormatCurrency = ReactGlobalize.FormatCurrency; +var FormatMessage = ReactGlobalize.FormatMessage; + +var LocalizedCurrencies = React.createClass({ + getInitialState: function() { + return { + valueA: 150, + valueB: 1, + valueC: -1000, + valueD: 1.491 + } + }, + handleSubmit: function(event) { + event.preventDefault(); + }, + handleValueA: function(event) { + this.setState({ + valueA: event.target.value + }); + }, + handleValueB: function(event) { + this.setState({ + valueB: event.target.value + }); + }, + handleValueC: function(event) { + this.setState({ + valueC: event.target.value + }); + }, + handleValueD: function(event) { + this.setState({ + valueD: event.target.value + }); + }, + render: function() { + console.log("render"); + return ( +
+ Formatting currencies using symbols, the default + |
+
+ {"{}"} + |
+ + + | +
+ USD + |
+
+ |
+
+ EUR + |
+
+ |
+ |||
+ CNY + |
+
+ |
+ |||
+ Formatting currencies in their full names + |
+
+ {"{style: \"name\"}"} + |
+ + + | +
+ USD + |
+
+ |
+
+ EUR + |
+
+ |
+ |||
+ CNY + |
+
+ |
+ |||
+ Formatting currencies in the accounting form + |
+
+ {"{style: \"accounting\"}"} + |
+ + + | +
+ USD + |
+
+ |
+
+ EUR + |
+
+ |
+ |||
+ CNY + |
+
+ |
+ |||
+ Formatting currencies specifying the rounding method + |
+
+ {"{round: \"ceil\"}"} + |
+ + + | +
+ USD + |
+
+ |
+
+ EUR + |
+
+ |
+ |||
+ CNY + |
+
+ |
+
+ Formatting dates using the default options + |
+
+ {"{}"} + |
+
+ |
+
+ Formatting dates using presets + |
+
+ {"{date: \"medium\"}"} + |
+
+ |
+
+ {"{time: \"medium\"}"} + |
+
+ |
+ |
+ {"{datetime: \"medium\"}"} + |
+
+ |
+ |
+ Formatting dates selecting the fields individually + |
+
+ {"{skeleton: \"GyMMMdhms\"}"} + |
+
+ |
+
{getRawLocalizedMessage("Hello, {name}")}
{"{name: \"" + this.state.nameA + "\"}"}+ +
{getRawLocalizedMessage( + "{hostGender, select,\n" + + " female {{host} invites {guest} to her party}\n" + + " male {{host} invites {guest} to his party}\n" + + " other {{host} invites {guest} to their party}\n" + + "}" + )}
{ + "{\n" + + " host: \"" + this.state.host + "\",\n" + + " hostGender: \"" + this.state.hostGender + "\",\n" + + " guest: \"" + this.state.guest + "\",\n" + + " guestGender: \"" + this.state.guestGender + "\"\n" + + "}" + }+ +
{getRawLocalizedMessage( + "You have {count, plural,\n" + + " =0 {no tasks}\n" + + " one {one task}\n" + + " other {{formattedCount} tasks}\n" + + "} remaining" + )}
{ + "{\n" + + " count: " + (+this.state.count) + ",\n" + + " formattedCount: \"" + Globalize.formatNumber(+this.state.count) + "\"\n" + + "}" + }+ +
+ Formatting numbers using the default options + |
+
+ {"{}"} + |
+ + + | +
+ |
+
+ Formatting numbers specifying the rounding method + |
+
+ {"{round: \"floor\"}"} + |
+
+ |
+ |
+ Formatting numbers specifying the maximum fraction digits + |
+
+ {"{maximumFractionDigits: 2}"} + |
+
+ |
+ |
+ Formatting numbers specifying significant digits + |
+
+
+ {"{"} minimumSignificantDigits: 2,
+ {"}"}
+
+ maximumSignificantDigits: 4 |
+
+ |
+ |
+ Formatting numbers using the default options (again) + |
+
+ {"{}"} + |
+
+ + + | +
+ |
+
+ Formatting numbers specifying the maximum fraction digits + |
+
+ {"{minimumFractionDigits: 2}"} + |
+
+ |
+ |
+ Formatting percentages + |
+
+ {"{style: \"percent\"}"} + |
+ + + | +
+ |
+
+ Formatting relative times in seconds + |
+
+ second + |
+
+ {"{}"} + |
+
+ |
+
+ Formatting relative times in seconds using the short form + |
+
+ second + |
+
+ {"{form: \"short\"}"} + |
+
+ |
+
+ Formatting relative times in minutes + |
+
+ minute + |
+
+ {"{}"} + |
+
+ |
+
+ Formatting relative times in minutes using the narrow form + |
+
+ minute + |
+
+ {"{form: \"narrow\"}"} + |
+
+ |
+