-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Flag examples #357
Add Flag examples #357
Conversation
Oops I missed ESLint, |
Current coverage is 92.60% (diff: 100%)
|
@fodurrr thanks much for your contribution. Also, great job with your research. I've been doing this a while and I think you've selected the best stack. I'm traveling at the moment. So, I'll give this a review tomorrow. Cheers! |
"name": "western.sahara", | ||
"country_Code": "eh", | ||
"alias": "" | ||
name: 'western.sahara', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace dots in names with spaces 👍
I'll later make PR that fixes this in <Flag>
.
Not actual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has been merged. Thanks @layershifter.
I propose use function that will generate data from const countries = [];
for (let i = 0; i < names.length;) {
const country = names.slice(i, i + 3);
const hasAlias = country.length === 3 && country[2].length !== 2;
countries.push({
code: country[0],
name: country[1],
alias: hasAlias ? country[2] : ''
})
i += hasAlias ? 3 : 2
} Code is quite ugly, but it seems be better solution than hadrcoded object. |
It would be better to generate the list, however, it will be very difficult to account for the correct capitalization and punctuation of the country names. A few I noticed were
const countries = [
{ name: 'Afghanistan', countryCode: 'af' },
{ name: 'Aland Islands', countryCode: 'ax' },
{ name: 'Albania', countryCode: 'al' },
{ name: 'Algeria', countryCode: 'dz' },
{ name: 'American Samoa', countryCode: 'as' },
{ name: 'Andorra', countryCode: 'ad' },
{ name: 'Angola', countryCode: 'ao' },
{ name: 'Anguilla', countryCode: 'ai' },
{ name: 'Antigua', countryCode: 'ag' },
{ name: 'Argentina', countryCode: 'ar' },
{ name: 'Armenia', countryCode: 'am' },
{ name: 'Aruba', countryCode: 'aw' },
{ name: 'Australia', countryCode: 'au' },
{ name: 'Austria', countryCode: 'at' },
{ name: 'Azerbaijan', countryCode: 'az' },
{ name: 'Bahamas', countryCode: 'bs' },
{ name: 'Bahrain', countryCode: 'bh' },
{ name: 'Bangladesh', countryCode: 'bd' },
{ name: 'Barbados', countryCode: 'bb' },
{ name: 'Belarus', countryCode: 'by' },
{ name: 'Belgium', countryCode: 'be' },
{ name: 'Belize', countryCode: 'bz' },
{ name: 'Benin', countryCode: 'bj' },
{ name: 'Bermuda', countryCode: 'bm' },
{ name: 'Bhutan', countryCode: 'bt' },
{ name: 'Bolivia', countryCode: 'bo' },
{ name: 'Bosnia', countryCode: 'ba' },
{ name: 'Botswana', countryCode: 'bw' },
{ name: 'Bouvet Island', countryCode: 'bv' },
{ name: 'Brazil', countryCode: 'br' },
{ name: 'British Virgin Islands', countryCode: 'vg' },
{ name: 'Brunei', countryCode: 'bn' },
{ name: 'Bulgaria', countryCode: 'bg' },
{ name: 'Burkina Faso', countryCode: 'bf' },
{ name: 'Burma', countryCode: 'mm', alias: 'Myanmar' },
{ name: 'Burundi', countryCode: 'bi' },
{ name: 'Caicos Islands', countryCode: 'tc' },
{ name: 'Cambodia', countryCode: 'kh' },
{ name: 'Cameroon', countryCode: 'cm' },
{ name: 'Canada', countryCode: 'ca' },
{ name: 'Cape Verde', countryCode: 'cv' },
{ name: 'Cayman Islands', countryCode: 'ky' },
{ name: 'Central African Republic', countryCode: 'cf' },
{ name: 'Chad', countryCode: 'td' },
{ name: 'Chile', countryCode: 'cl' },
{ name: 'China', countryCode: 'cn' },
{ name: 'Christmas Island', countryCode: 'cx' },
{ name: 'Cocos Islands', countryCode: 'cc' },
{ name: 'Colombia', countryCode: 'co' },
{ name: 'Comoros', countryCode: 'km' },
{ name: 'Congo', countryCode: 'cd' },
{ name: 'Congo Brazzaville', countryCode: 'cg' },
{ name: 'Cook Islands', countryCode: 'ck' },
{ name: 'Costa Rica', countryCode: 'cr' },
{ name: 'Cote Divoire', countryCode: 'ci' },
{ name: 'Croatia', countryCode: 'hr' },
{ name: 'Cuba', countryCode: 'cu' },
{ name: 'Cyprus', countryCode: 'cy' },
{ name: 'Czech Republic', countryCode: 'cz' },
{ name: 'Denmark', countryCode: 'dk' },
{ name: 'Djibouti', countryCode: 'dj' },
{ name: 'Dominica', countryCode: 'dm' },
{ name: 'Dominican Republic', countryCode: 'do' },
{ name: 'Ecuador', countryCode: 'ec' },
{ name: 'Egypt', countryCode: 'eg' },
{ name: 'El Salvador', countryCode: 'sv' },
{ name: 'Equatorial Guinea', countryCode: 'gq' },
{ name: 'Eritrea', countryCode: 'er' },
{ name: 'Estonia', countryCode: 'ee' },
{ name: 'Ethiopia', countryCode: 'et' },
{ name: 'Europeanunion', countryCode: 'eu' },
{ name: 'Falkland Islands', countryCode: 'fk' },
{ name: 'Faroe Islands', countryCode: 'fo' },
{ name: 'Fiji', countryCode: 'fj' },
{ name: 'Finland', countryCode: 'fi' },
{ name: 'France', countryCode: 'fr' },
{ name: 'French Guiana', countryCode: 'gf' },
{ name: 'French Polynesia', countryCode: 'pf' },
{ name: 'French Territories', countryCode: 'tf' },
{ name: 'Gabon', countryCode: 'ga' },
{ name: 'Gambia', countryCode: 'gm' },
{ name: 'Georgia', countryCode: 'ge' },
{ name: 'Germany', countryCode: 'de' },
{ name: 'Ghana', countryCode: 'gh' },
{ name: 'Gibraltar', countryCode: 'gi' },
{ name: 'Greece', countryCode: 'gr' },
{ name: 'Greenland', countryCode: 'gl' },
{ name: 'Grenada', countryCode: 'gd' },
{ name: 'Guadeloupe', countryCode: 'gp' },
{ name: 'Guam', countryCode: 'gu' },
{ name: 'Guatemala', countryCode: 'gt' },
{ name: 'Guinea', countryCode: 'gn' },
{ name: 'Guinea-Bissau', countryCode: 'gw' },
{ name: 'Guyana', countryCode: 'gy' },
{ name: 'Haiti', countryCode: 'ht' },
{ name: 'Heard Island', countryCode: 'hm' },
{ name: 'Honduras', countryCode: 'hn' },
{ name: 'Hong Kong', countryCode: 'hk' },
{ name: 'Hungary', countryCode: 'hu' },
{ name: 'Iceland', countryCode: 'is' },
{ name: 'India', countryCode: 'in' },
{ name: 'Indian Ocean Territory', countryCode: 'io' },
{ name: 'Indonesia', countryCode: 'id' },
{ name: 'Iran', countryCode: 'ir' },
{ name: 'Iraq', countryCode: 'iq' },
{ name: 'Ireland', countryCode: 'ie' },
{ name: 'Israel', countryCode: 'il' },
{ name: 'Italy', countryCode: 'it' },
{ name: 'Jamaica', countryCode: 'jm' },
{ name: 'Jan Mayen', countryCode: 'sj', alias: 'Svalbard' },
{ name: 'Japan', countryCode: 'jp' },
{ name: 'Jordan', countryCode: 'jo' },
{ name: 'Kazakhstan', countryCode: 'kz' },
{ name: 'Kenya', countryCode: 'ke' },
{ name: 'Kiribati', countryCode: 'ki' },
{ name: 'Kuwait', countryCode: 'kw' },
{ name: 'Kyrgyzstan', countryCode: 'kg' },
{ name: 'Laos', countryCode: 'la' },
{ name: 'Latvia', countryCode: 'lv' },
{ name: 'Lebanon', countryCode: 'lb' },
{ name: 'Lesotho', countryCode: 'ls' },
{ name: 'Liberia', countryCode: 'lr' },
{ name: 'Libya', countryCode: 'ly' },
{ name: 'Liechtenstein', countryCode: 'li' },
{ name: 'Lithuania', countryCode: 'lt' },
{ name: 'Luxembourg', countryCode: 'lu' },
{ name: 'Macau', countryCode: 'mo' },
{ name: 'Macedonia', countryCode: 'mk' },
{ name: 'Madagascar', countryCode: 'mg' },
{ name: 'Malawi', countryCode: 'mw' },
{ name: 'Malaysia', countryCode: 'my' },
{ name: 'Maldives', countryCode: 'mv' },
{ name: 'Mali', countryCode: 'ml' },
{ name: 'Malta', countryCode: 'mt' },
{ name: 'Marshall Islands', countryCode: 'mh' },
{ name: 'Martinique', countryCode: 'mq' },
{ name: 'Mauritania', countryCode: 'mr' },
{ name: 'Mauritius', countryCode: 'mu' },
{ name: 'Mayotte', countryCode: 'yt' },
{ name: 'Mexico', countryCode: 'mx' },
{ name: 'Micronesia', countryCode: 'fm' },
{ name: 'Moldova', countryCode: 'md' },
{ name: 'Monaco', countryCode: 'mc' },
{ name: 'Mongolia', countryCode: 'mn' },
{ name: 'Montenegro', countryCode: 'me' },
{ name: 'Montserrat', countryCode: 'ms' },
{ name: 'Morocco', countryCode: 'ma' },
{ name: 'Mozambique', countryCode: 'mz' },
{ name: 'Namibia', countryCode: 'na' },
{ name: 'Nauru', countryCode: 'nr' },
{ name: 'Nepal', countryCode: 'np' },
{ name: 'Netherlands', countryCode: 'nl' },
{ name: 'Netherlandsantilles', countryCode: 'an' },
{ name: 'New Caledonia', countryCode: 'nc' },
{ name: 'New Guinea', countryCode: 'pg' },
{ name: 'New Zealand', countryCode: 'nz' },
{ name: 'Nicaragua', countryCode: 'ni' },
{ name: 'Niger', countryCode: 'ne' },
{ name: 'Nigeria', countryCode: 'ng' },
{ name: 'Niue', countryCode: 'nu' },
{ name: 'Norfolk Island', countryCode: 'nf' },
{ name: 'North Korea', countryCode: 'kp' },
{ name: 'Northern Mariana Islands', countryCode: 'mp' },
{ name: 'Norway', countryCode: 'no' },
{ name: 'Oman', countryCode: 'om' },
{ name: 'Pakistan', countryCode: 'pk' },
{ name: 'Palau', countryCode: 'pw' },
{ name: 'Palestine', countryCode: 'ps' },
{ name: 'Panama', countryCode: 'pa' },
{ name: 'Paraguay', countryCode: 'py' },
{ name: 'Peru', countryCode: 'pe' },
{ name: 'Philippines', countryCode: 'ph' },
{ name: 'Pitcairn Islands', countryCode: 'pn' },
{ name: 'Poland', countryCode: 'pl' },
{ name: 'Portugal', countryCode: 'pt' },
{ name: 'Puerto Rico', countryCode: 'pr' },
{ name: 'Qatar', countryCode: 'qa' },
{ name: 'Reunion', countryCode: 're' },
{ name: 'Romania', countryCode: 'ro' },
{ name: 'Russia', countryCode: 'ru' },
{ name: 'Rwanda', countryCode: 'rw' },
{ name: 'Saint Helena', countryCode: 'sh' },
{ name: 'Saint Kitts and Nevis', countryCode: 'kn' },
{ name: 'Saint Lucia', countryCode: 'lc' },
{ name: 'Saint Pierre', countryCode: 'pm' },
{ name: 'Saint Vincent', countryCode: 'vc' },
{ name: 'Samoa', countryCode: 'ws' },
{ name: 'San Marino', countryCode: 'sm' },
{ name: 'Sandwich Islands', countryCode: 'gs' },
{ name: 'Sao Tome', countryCode: 'st' },
{ name: 'Saudi Arabia', countryCode: 'sa' },
{ name: 'Scotland', countryCode: 'gb sct' },
{ name: 'Senegal', countryCode: 'sn' },
{ name: 'Serbia', countryCode: 'cs' },
{ name: 'Serbia', countryCode: 'rs' },
{ name: 'Seychelles', countryCode: 'sc' },
{ name: 'Sierra Leone', countryCode: 'sl' },
{ name: 'Singapore', countryCode: 'sg' },
{ name: 'Slovakia', countryCode: 'sk' },
{ name: 'Slovenia', countryCode: 'si' },
{ name: 'Solomon Islands', countryCode: 'sb' },
{ name: 'Somalia', countryCode: 'so' },
{ name: 'South Africa', countryCode: 'za' },
{ name: 'South Korea', countryCode: 'kr' },
{ name: 'Spain', countryCode: 'es' },
{ name: 'Sri Lanka', countryCode: 'lk' },
{ name: 'Sudan', countryCode: 'sd' },
{ name: 'Suriname', countryCode: 'sr' },
{ name: 'Swaziland', countryCode: 'sz' },
{ name: 'Sweden', countryCode: 'se' },
{ name: 'Switzerland', countryCode: 'ch' },
{ name: 'Syria', countryCode: 'sy' },
{ name: 'Taiwan', countryCode: 'tw' },
{ name: 'Tajikistan', countryCode: 'tj' },
{ name: 'Tanzania', countryCode: 'tz' },
{ name: 'Thailand', countryCode: 'th' },
{ name: 'Timorleste', countryCode: 'tl' },
{ name: 'Togo', countryCode: 'tg' },
{ name: 'Tokelau', countryCode: 'tk' },
{ name: 'Tonga', countryCode: 'to' },
{ name: 'Trinidad', countryCode: 'tt' },
{ name: 'Tunisia', countryCode: 'tn' },
{ name: 'Turkey', countryCode: 'tr' },
{ name: 'Turkmenistan', countryCode: 'tm' },
{ name: 'Tuvalu', countryCode: 'tv' },
{ name: 'U.A.E.', countryCode: 'ae', alias: 'United Arab Emirates' },
{ name: 'Uganda', countryCode: 'ug' },
{ name: 'Ukraine', countryCode: 'ua' },
{ name: 'United Kingdom', countryCode: 'gb' },
{ name: 'United States', countryCode: 'us', alias: 'America' },
{ name: 'Uruguay', countryCode: 'uy' },
{ name: 'US Minor Islands', countryCode: 'um' },
{ name: 'US Virgin Islands', countryCode: 'vi' },
{ name: 'Uzbekistan', countryCode: 'uz' },
{ name: 'Vanuatu', countryCode: 'vu' },
{ name: 'Vatican City', countryCode: 'va' },
{ name: 'Venezuela', countryCode: 've' },
{ name: 'Vietnam', countryCode: 'vn' },
{ name: 'Wales', countryCode: 'gb wls' },
{ name: 'Wallis and Futuna', countryCode: 'wf' },
{ name: 'Western Sahara', countryCode: 'eh' },
{ name: 'Yemen', countryCode: 'ye' },
{ name: 'Zambia', countryCode: 'zm' },
{ name: 'Zimbabwe', countryCode: 'zw' },
] |
<Table.Column dataKey='name' /> | ||
<Table.Column dataKey='country_code' /> | ||
<Table.Column dataKey='alias' /> | ||
</Table> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a first column that renders the flags themselves:
const flagRenderer = (item) => <Flag name={item.countryCode}/>
<Table data={countries}>
<Table.Column dataKey='Flag' cellRenderer={flagRenderer} />
<Table.Column dataKey='name' />
<Table.Column dataKey='countryCode' />
<Table.Column dataKey='alias' />
</Table>
Note, I used the updated camelCased key names.
Sorry guys, it seems something went wrong for me with Git, I did the update based on your comments but somehow I could not push my commits.... |
Guessing since you merged master into this branch on GitHub, you need to first As long as you committed your changes locally, you can certainly get back to them. Feel free to post any errors and I'll see if I can help find your changes. |
@levithomason Thanks for the quick reply. Pheeew, Thanks for you patience. One of my boss used to say: First walk, then run, then learn to fly. |
Looks good, I'll merge this. Thanks for the improvement! |
Hi,
I am quite a newbie on Github and in general, but after 6 months research, reading hundreds of articles and watching hundreds of videos I settled down in General with React, Redux, etc.
Then I started to look for my stack a good component UI library, I must say that was really a hard part with almost every library I found different issues which I did not like, except this one.
I love your work, love the idea that you eliminate JQuery, etc.
I am super convinced that this library will be the defacto standard for React very soon :))
I am really amazed, keep up the good work.
As I mentioned I am newbie but I would like to contribute and I thought a good place to start is the documentation since anyway I am learning.
I would like to contribute to the examples part in the documentation.
Please feedback, I hope I got my first small open source contribution right :)
Thanks,
Peter