Skip to content

Commit f9527ea

Browse files
alunnyrxaviers
authored andcommitted
Fix example
- fix generator script - fix currency and messages - fix dates, numbers, new defaults in index.js - fix example/README Fixes #25
1 parent 1609c23 commit f9527ea

File tree

9 files changed

+37
-27
lines changed

9 files changed

+37
-27
lines changed

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ The date object to be formatted. Required.
8787

8888
#### Props
8989

90-
- **value** - required
91-
- The date object to be formatted
9290
- **options**
9391
- An optional set of options which defines how to format the date. See the [dateFormatter][] docs in Globalize for more info on supported patterns
9492
- **locale** - optional
@@ -214,8 +212,6 @@ The number to be formatted. Required.
214212

215213
#### Props
216214

217-
- **value** - required
218-
- The number to be formatted
219215
- **options**
220216
- An optional set of options to further format the value. See the [numberFormatter][] docs in Globalize for more info on specific options
221217
- **locale** - optional

examples/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
app.js
2+
react-globalize

examples/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Install
55
-------
66
These instructions assume you have node and npm installed. For help, see the [npm docs](https://docs.npmjs.com/getting-started/installing-node)
77

8-
1. Run `npm install`
9-
2. Run `npm run-script build` to generate the built JS file
10-
3. Open browser and navigate to `react-globalize/examples/index.html`
8+
1. Build react-globalize (`cd .. && grunt`)
9+
2. Run `npm install` in this directory
10+
3. Run `npm run-script build` to generate the built JS file
11+
4. Open browser and navigate to `react-globalize/examples/index.html`

examples/components/currency.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ module.exports = React.createClass({
2323
</select>
2424
</div>
2525
<br/>
26-
USD, 150, locale default - <FormatCurrency locale={this.state.locale} currency="USD" value={150} />
26+
USD, 150, locale default - <FormatCurrency locale={this.state.locale} currency="USD">{150}</FormatCurrency>
2727
<br/>
28-
USD, -150, style: "accounting" - <FormatCurrency locale={this.state.locale} currency="USD" value={-150} options={{ style: "accounting" }} />
28+
USD, -150, style: "accounting" - <FormatCurrency locale={this.state.locale} currency="USD" options={{ style: "accounting" }}>{-150}</FormatCurrency>
2929
<br/>
30-
USD, 150, style: "name" - <FormatCurrency locale={this.state.locale} currency="USD" value={150} options={{ style: "name" }} />
30+
USD, 150, style: "name" - <FormatCurrency locale={this.state.locale} currency="USD" options={{ style: "name" }}>{150}</FormatCurrency>
3131
<br/>
32-
USD, 150, style: "code" - <FormatCurrency locale={this.state.locale} currency="USD" value={150} options={{ style: "code" }} />
32+
USD, 150, style: "code" - <FormatCurrency locale={this.state.locale} currency="USD" options={{ style: "code" }}>{150}</FormatCurrency>
3333
<br/>
34-
USD, 1.491, round: "ceil" - <FormatCurrency locale={this.state.locale} currency="USD" value={1.491} options={{ round: "ceil" }} />
34+
USD, 1.491, round: "ceil" - <FormatCurrency locale={this.state.locale} currency="USD" options={{ round: "ceil" }}>{1.491}</FormatCurrency>
3535
<br/>
36-
EUR, 150, locale default - <FormatCurrency locale={this.state.locale} currency="EUR" value={150} />
36+
EUR, 150, locale default - <FormatCurrency locale={this.state.locale} currency="EUR">{150}</FormatCurrency>
3737
<br/>
38-
EUR, -150, style: "accounting" - <FormatCurrency locale={this.state.locale} currency="EUR" value={-150} options={{ style: "accounting" }} />
38+
EUR, -150, style: "accounting" - <FormatCurrency locale={this.state.locale} currency="EUR" options={{ style: "accounting" }}>{-150}</FormatCurrency>
3939
<br/>
40-
EUR, 150, style: "name" - <FormatCurrency locale={this.state.locale} currency="EUR" value={150} options={{ style: "name" }} />
40+
EUR, 150, style: "name" - <FormatCurrency locale={this.state.locale} currency="EUR" options={{ style: "name" }}>{150}</FormatCurrency>
4141
<br/>
42-
EUR, 150, style: "code" - <FormatCurrency locale={this.state.locale} currency="EUR" value={150} options={{ style: "code" }} />
42+
EUR, 150, style: "code" - <FormatCurrency locale={this.state.locale} currency="EUR" options={{ style: "code" }}>{150}</FormatCurrency>
4343
<br/>
44-
EUR, 1.491, round: "ceil" - <FormatCurrency locale={this.state.locale} currency="EUR" value={1.491} options={{ round: "ceil" }} />
44+
EUR, 1.491, round: "ceil" - <FormatCurrency locale={this.state.locale} currency="EUR" options={{ round: "ceil" }}>{1.491}</FormatCurrency>
4545
</div>
4646
);
4747
}

examples/components/dates.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ module.exports = React.createClass({
2323
</select>
2424
</div>
2525
<br/>
26-
"GyMMMd" - <FormatDate locale={this.state.locale} value={new Date()} pattern="GyMMMd" />
26+
"GyMMMd" - <FormatDate locale={this.state.locale} pattern="GyMMMd">{new Date()}</FormatDate>
2727
<br/>
28-
date: "medium" - <FormatDate locale={this.state.locale} value={new Date()} pattern={{ date: "medium" }} />
28+
date: "medium" - <FormatDate locale={this.state.locale} pattern={{ date: "medium" }}>{new Date()}</FormatDate>
2929
<br/>
30-
time: "medium" - <FormatDate locale={this.state.locale} value={new Date()} pattern={{ time: "medium" }} />
30+
time: "medium" - <FormatDate locale={this.state.locale} pattern={{ time: "medium" }}>{new Date()}</FormatDate>
3131
<br/>
32-
datetime: "medium" - <FormatDate locale={this.state.locale} value={new Date()} pattern={{ datetime: 'medium' }} />
32+
datetime: "medium" - <FormatDate locale={this.state.locale} pattern={{ datetime: 'medium' }}>{new Date()}</FormatDate>
3333
</div>
3434
);
3535
}

examples/components/messages.js

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ module.exports = React.createClass({
2727
hi - <FormatMessage locale={this.state.locale} path="salutations/hi" />
2828
<br/>
2929
bye - <FormatMessage locale={this.state.locale} path="salutations/bye" />
30+
<h3>Simple default message</h3>
31+
<FormatMessage locale={this.state.locale}>Hi</FormatMessage>
32+
<br/>
33+
<FormatMessage locale={this.state.locale}>Bye</FormatMessage>
34+
<br/>
35+
<FormatMessage locale={this.state.locale}>Hi/Bye</FormatMessage>
3036
<h3>Variable Replacement</h3>
3137
["Wolfgang", "Amadeus", "Mozart"] - <FormatMessage locale={this.state.locale} path="variables/hello" variables={["Wolfgang", "Amadeus", "Mozart"]} />
3238
<br/>

examples/components/numbers.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ module.exports = React.createClass({
2323
</select>
2424
</div>
2525
<br/>
26-
pi, no options - <FormatNumber locale={this.state.locale} value={Math.PI} />
26+
pi, no options - <FormatNumber locale={this.state.locale}>{Math.PI}</FormatNumber>
2727
<br/>
28-
pi, maximumFractionDigits: 5 - <FormatNumber locale={this.state.locale} value={Math.PI} options={{ maximumFractionDigits: 5 }} />
28+
pi, maximumFractionDigits: 5 - <FormatNumber locale={this.state.locale} options={{ maximumFractionDigits: 5 }}>{Math.PI}</FormatNumber>
2929
<br/>
30-
pi, round: 'floor' - <FormatNumber locale={this.state.locale} value={Math.PI} options={{ round: 'floor' }} />
30+
pi, round: 'floor' - <FormatNumber locale={this.state.locale} options={{ round: 'floor' }}>{Math.PI}</FormatNumber>
3131
<br/>
32-
10000, minimumFractionDigits: 2 - <FormatNumber locale={this.state.locale} value={10000} options={{ minimumFractionDigits: 2 }} />
32+
10000, minimumFractionDigits: 2 - <FormatNumber locale={this.state.locale} options={{ minimumFractionDigits: 2 }}>{10000}</FormatNumber>
33+
<br/>
34+
0.5, style: 'percent' - <FormatNumber locale={this.state.locale} options={{ style: 'percent' }}>{0.5}</FormatNumber>
3335
<br/>
34-
0.5, style: 'percent' - <FormatNumber locale={this.state.locale} value={0.5} options={{ style: 'percent' }} />
3536
</div>
3637
);
3738
}

examples/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ var messages = {
3939
]
4040
},
4141
"pt-BR": {
42+
// default message examples
43+
"Hi": "Oi",
44+
"Bye": "Tchau",
45+
"Hi|Bye": "Oi/Tchau",
4246
salutations: {
4347
hi: "Oi",
4448
bye: "Tchau"

examples/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"globalize": "~1.0.0-alpha.18"
1414
},
1515
"scripts": {
16-
"build": "cp -f ../index.js react-globalize.js && browserify --debug --transform reactify index.js > app.js"
16+
"build": "mkdir -p react-globalize && cp ../dist/*.js react-globalize/ && browserify --debug --transform reactify index.js > app.js"
1717
}
1818
}

0 commit comments

Comments
 (0)