diff --git a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js index a3380004f8142fa5c4498b6a82ee3c1468075db2..19a4bda77c1d338841d03d25b35d84f653accf27 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js @@ -7,18 +7,12 @@ import { reduxForm } from 'redux-form' import { compose, withProps } from 'recompose' import { selectCurrentUser } from 'xpub-selectors' +import countries from './countries' import { Spinner } from '../UIComponents/' import classes from './AuthorList.local.scss' import { getAuthorFetching } from '../../redux/authors' import { MenuItem, ValidatedTextField } from './FormItems' -const countries = [ - { label: 'Romania', value: 'ro' }, - { label: 'United Kingdom', value: 'uk' }, - { label: 'Germany', value: 'de' }, - { label: 'France', value: 'fr' }, -] - const emailRegex = new RegExp(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/) const emailValidator = value => diff --git a/packages/components-faraday/src/components/AuthorList/AuthorEditor.js b/packages/components-faraday/src/components/AuthorList/AuthorEditor.js index 10f4f5a81c2915fc8ff19986f2b87a21f1d3e88b..72ea87fc3315b0bf4035f4603368727b68b51a1d 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorEditor.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorEditor.js @@ -5,19 +5,13 @@ import { Button } from '@pubsweet/ui' import { connect } from 'react-redux' import { reduxForm } from 'redux-form' +import countries from './countries' import { Spinner } from '../UIComponents' import { getAuthorFetching } from '../../redux/authors' import { ValidatedTextField, MenuItem } from './FormItems' import classes from './AuthorList.local.scss' -const countries = [ - { label: 'Romania', value: 'ro' }, - { label: 'United Kingdom', value: 'uk' }, - { label: 'Germany', value: 'de' }, - { label: 'France', value: 'fr' }, -] - const emailRegex = new RegExp(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/) const emailValidator = value => diff --git a/packages/components-faraday/src/components/AuthorList/AuthorList.js b/packages/components-faraday/src/components/AuthorList/AuthorList.js index a41601af5d2a1aa09bb278657c4cd69dda37da09..382931818f802c5cc66b6d90e4f256f2e1d5a13e 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorList.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorList.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' +import { get } from 'lodash' import { withRouter } from 'react-router-dom' import { compose, @@ -15,18 +16,12 @@ import { SortableList } from 'pubsweet-components-faraday/src/components' import { addAuthor } from '../../redux/authors' import Author from './Author' +import countries from './countries' import StaticList from './StaticList' import AuthorAdder from './AuthorAdder' import AuthorEditor from './AuthorEditor' import { DragHandle } from './FormItems' -const countries = [ - { label: 'Romania', value: 'ro' }, - { label: 'United Kingdom', value: 'uk' }, - { label: 'Germany', value: 'de' }, - { label: 'France', value: 'fr' }, -] - const Authors = ({ authors, moveAuthor, @@ -111,7 +106,7 @@ export default compose( setFormAuthors(authors) }, countryParser: () => countryCode => - countries.find(c => c.value === countryCode).label, + get(countries.find(c => c.value === countryCode), 'label'), parseAuthorType: () => (isSubmitting, isCorresponding, index) => { if (isSubmitting) return `#${index + 1} Submitting author` if (isCorresponding) return `#${index + 1} Corresponding author` diff --git a/packages/components-faraday/src/components/AuthorList/FormItems.js b/packages/components-faraday/src/components/AuthorList/FormItems.js index a51969f622641759fe00a81fc21479e52a47be81..96b8a93c4cb4ff0f6b68e0e6ddc19df02d26500b 100644 --- a/packages/components-faraday/src/components/AuthorList/FormItems.js +++ b/packages/components-faraday/src/components/AuthorList/FormItems.js @@ -21,7 +21,7 @@ export const ValidatedTextField = ({ } export const MenuItem = ({ label, name, options }) => ( - <div className={classnames(classes['validated-text'])}> + <div className={classnames(classes['validated-text'], classes['fix-height'])}> <span className={classnames(classes.label)}>{label}</span> <ValidatedField component={input => <Menu {...input} options={options} />} diff --git a/packages/components-faraday/src/components/AuthorList/FormItems.local.scss b/packages/components-faraday/src/components/AuthorList/FormItems.local.scss index 2ffbe88971b4e4a576693d4187701f548244254c..1a2e5c0fece6c01f212a10b11d0039241e8f6a08 100644 --- a/packages/components-faraday/src/components/AuthorList/FormItems.local.scss +++ b/packages/components-faraday/src/components/AuthorList/FormItems.local.scss @@ -21,6 +21,13 @@ } } +.fix-height { + div[class^='Menu-local_options-'] { + height: 250px; + overflow-y: scroll; + } +} + .drag-handle { align-items: center; border-right: 1px solid #444; diff --git a/packages/components-faraday/src/components/AuthorList/countries.js b/packages/components-faraday/src/components/AuthorList/countries.js new file mode 100644 index 0000000000000000000000000000000000000000..b746f4355554d22abea3ffa439d17881c8863d3e --- /dev/null +++ b/packages/components-faraday/src/components/AuthorList/countries.js @@ -0,0 +1,245 @@ +export default [ + { label: 'Afghanistan', value: 'AF' }, + { label: 'Ã…land Islands', value: 'AX' }, + { label: 'Albania', value: 'AL' }, + { label: 'Algeria', value: 'DZ' }, + { label: 'American Samoa', value: 'AS' }, + { label: 'Andorra', value: 'AD' }, + { label: 'Angola', value: 'AO' }, + { label: 'Anguilla', value: 'AI' }, + { label: 'Antarctica', value: 'AQ' }, + { label: 'Antigua and Barbuda', value: 'AG' }, + { label: 'Argentina', value: 'AR' }, + { label: 'Armenia', value: 'AM' }, + { label: 'Aruba', value: 'AW' }, + { label: 'Australia', value: 'AU' }, + { label: 'Austria', value: 'AT' }, + { label: 'Azerbaijan', value: 'AZ' }, + { label: 'Bahamas', value: 'BS' }, + { label: 'Bahrain', value: 'BH' }, + { label: 'Bangladesh', value: 'BD' }, + { label: 'Barbados', value: 'BB' }, + { label: 'Belarus', value: 'BY' }, + { label: 'Belgium', value: 'BE' }, + { label: 'Belize', value: 'BZ' }, + { label: 'Benin', value: 'BJ' }, + { label: 'Bermuda', value: 'BM' }, + { label: 'Bhutan', value: 'BT' }, + { label: 'Bolivia', value: 'BO' }, + { label: 'Bosnia and Herzegovina', value: 'BA' }, + { label: 'Botswana', value: 'BW' }, + { label: 'Bouvet Island', value: 'BV' }, + { label: 'Brazil', value: 'BR' }, + { label: 'British Indian Ocean Territory', value: 'IO' }, + { label: 'Brunei Darussalam', value: 'BN' }, + { label: 'Bulgaria', value: 'BG' }, + { label: 'Burkina Faso', value: 'BF' }, + { label: 'Burundi', value: 'BI' }, + { label: 'Cambodia', value: 'KH' }, + { label: 'Cameroon', value: 'CM' }, + { label: 'Canada', value: 'CA' }, + { label: 'Cape Verde', value: 'CV' }, + { label: 'Cayman Islands', value: 'KY' }, + { label: 'Central African Republic', value: 'CF' }, + { label: 'Chad', value: 'TD' }, + { label: 'Chile', value: 'CL' }, + { label: 'China', value: 'CN' }, + { label: 'Christmas Island', value: 'CX' }, + { label: 'Cocos (Keeling) Islands', value: 'CC' }, + { label: 'Colombia', value: 'CO' }, + { label: 'Comoros', value: 'KM' }, + { label: 'Congo', value: 'CG' }, + { label: 'Congo, The Democratic Republic of the', value: 'CD' }, + { label: 'Cook Islands', value: 'CK' }, + { label: 'Costa Rica', value: 'CR' }, + { label: "Cote D'Ivoire", value: 'CI' }, + { label: 'Croatia', value: 'HR' }, + { label: 'Cuba', value: 'CU' }, + { label: 'Cyprus', value: 'CY' }, + { label: 'Czech Republic', value: 'CZ' }, + { label: 'Denmark', value: 'DK' }, + { label: 'Djibouti', value: 'DJ' }, + { label: 'Dominica', value: 'DM' }, + { label: 'Dominican Republic', value: 'DO' }, + { label: 'Ecuador', value: 'EC' }, + { label: 'Egypt', value: 'EG' }, + { label: 'El Salvador', value: 'SV' }, + { label: 'Equatorial Guinea', value: 'GQ' }, + { label: 'Eritrea', value: 'ER' }, + { label: 'Estonia', value: 'EE' }, + { label: 'Ethiopia', value: 'ET' }, + { label: 'Falkland Islands (Malvinas)', value: 'FK' }, + { label: 'Faroe Islands', value: 'FO' }, + { label: 'Fiji', value: 'FJ' }, + { label: 'Finland', value: 'FI' }, + { label: 'France', value: 'FR' }, + { label: 'French Guiana', value: 'GF' }, + { label: 'French Polynesia', value: 'PF' }, + { label: 'French Southern Territories', value: 'TF' }, + { label: 'Gabon', value: 'GA' }, + { label: 'Gambia', value: 'GM' }, + { label: 'Georgia', value: 'GE' }, + { label: 'Germany', value: 'DE' }, + { label: 'Ghana', value: 'GH' }, + { label: 'Gibraltar', value: 'GI' }, + { label: 'Greece', value: 'GR' }, + { label: 'Greenland', value: 'GL' }, + { label: 'Grenada', value: 'GD' }, + { label: 'Guadeloupe', value: 'GP' }, + { label: 'Guam', value: 'GU' }, + { label: 'Guatemala', value: 'GT' }, + { label: 'Guernsey', value: 'GG' }, + { label: 'Guinea', value: 'GN' }, + { label: 'Guinea-Bissau', value: 'GW' }, + { label: 'Guyana', value: 'GY' }, + { label: 'Haiti', value: 'HT' }, + { label: 'Heard Island and Mcdonald Islands', value: 'HM' }, + { label: 'Holy See (Vatican City State)', value: 'VA' }, + { label: 'Honduras', value: 'HN' }, + { label: 'Hong Kong', value: 'HK' }, + { label: 'Hungary', value: 'HU' }, + { label: 'Iceland', value: 'IS' }, + { label: 'India', value: 'IN' }, + { label: 'Indonesia', value: 'ID' }, + { label: 'Iran, Islamic Republic Of', value: 'IR' }, + { label: 'Iraq', value: 'IQ' }, + { label: 'Ireland', value: 'IE' }, + { label: 'Isle of Man', value: 'IM' }, + { label: 'Israel', value: 'IL' }, + { label: 'Italy', value: 'IT' }, + { label: 'Jamaica', value: 'JM' }, + { label: 'Japan', value: 'JP' }, + { label: 'Jersey', value: 'JE' }, + { label: 'Jordan', value: 'JO' }, + { label: 'Kazakhstan', value: 'KZ' }, + { label: 'Kenya', value: 'KE' }, + { label: 'Kiribati', value: 'KI' }, + { label: "Korea, Democratic People's Republic of", value: 'KP' }, + { label: 'Korea, Republic of', value: 'KR' }, + { label: 'Kuwait', value: 'KW' }, + { label: 'Kyrgyzstan', value: 'KG' }, + { label: "Lao People'S Democratic Republic", value: 'LA' }, + { label: 'Latvia', value: 'LV' }, + { label: 'Lebanon', value: 'LB' }, + { label: 'Lesotho', value: 'LS' }, + { label: 'Liberia', value: 'LR' }, + { label: 'Libyan Arab Jamahiriya', value: 'LY' }, + { label: 'Liechtenstein', value: 'LI' }, + { label: 'Lithuania', value: 'LT' }, + { label: 'Luxembourg', value: 'LU' }, + { label: 'Macao', value: 'MO' }, + { label: 'Macedonia, The Former Yugoslav Republic of', value: 'MK' }, + { label: 'Madagascar', value: 'MG' }, + { label: 'Malawi', value: 'MW' }, + { label: 'Malaysia', value: 'MY' }, + { label: 'Maldives', value: 'MV' }, + { label: 'Mali', value: 'ML' }, + { label: 'Malta', value: 'MT' }, + { label: 'Marshall Islands', value: 'MH' }, + { label: 'Martinique', value: 'MQ' }, + { label: 'Mauritania', value: 'MR' }, + { label: 'Mauritius', value: 'MU' }, + { label: 'Mayotte', value: 'YT' }, + { label: 'Mexico', value: 'MX' }, + { label: 'Micronesia, Federated States of', value: 'FM' }, + { label: 'Moldova, Republic of', value: 'MD' }, + { label: 'Monaco', value: 'MC' }, + { label: 'Mongolia', value: 'MN' }, + { label: 'Montserrat', value: 'MS' }, + { label: 'Morocco', value: 'MA' }, + { label: 'Mozambique', value: 'MZ' }, + { label: 'Myanmar', value: 'MM' }, + { label: 'Namibia', value: 'NA' }, + { label: 'Nauru', value: 'NR' }, + { label: 'Nepal', value: 'NP' }, + { label: 'Netherlands', value: 'NL' }, + { label: 'Netherlands Antilles', value: 'AN' }, + { label: 'New Caledonia', value: 'NC' }, + { label: 'New Zealand', value: 'NZ' }, + { label: 'Nicaragua', value: 'NI' }, + { label: 'Niger', value: 'NE' }, + { label: 'Nigeria', value: 'NG' }, + { label: 'Niue', value: 'NU' }, + { label: 'Norfolk Island', value: 'NF' }, + { label: 'Northern Mariana Islands', value: 'MP' }, + { label: 'Norway', value: 'NO' }, + { label: 'Oman', value: 'OM' }, + { label: 'Pakistan', value: 'PK' }, + { label: 'Palau', value: 'PW' }, + { label: 'Palestinian Territory, Occupied', value: 'PS' }, + { label: 'Panama', value: 'PA' }, + { label: 'Papua New Guinea', value: 'PG' }, + { label: 'Paraguay', value: 'PY' }, + { label: 'Peru', value: 'PE' }, + { label: 'Philippines', value: 'PH' }, + { label: 'Pitcairn', value: 'PN' }, + { label: 'Poland', value: 'PL' }, + { label: 'Portugal', value: 'PT' }, + { label: 'Puerto Rico', value: 'PR' }, + { label: 'Qatar', value: 'QA' }, + { label: 'Reunion', value: 'RE' }, + { label: 'Romania', value: 'RO' }, + { label: 'Russian Federation', value: 'RU' }, + { label: 'RWANDA', value: 'RW' }, + { label: 'Saint Helena', value: 'SH' }, + { label: 'Saint Kitts and Nevis', value: 'KN' }, + { label: 'Saint Lucia', value: 'LC' }, + { label: 'Saint Pierre and Miquelon', value: 'PM' }, + { label: 'Saint Vincent and the Grenadines', value: 'VC' }, + { label: 'Samoa', value: 'WS' }, + { label: 'San Marino', value: 'SM' }, + { label: 'Sao Tome and Principe', value: 'ST' }, + { label: 'Saudi Arabia', value: 'SA' }, + { label: 'Senegal', value: 'SN' }, + { label: 'Serbia and Montenegro', value: 'CS' }, + { label: 'Seychelles', value: 'SC' }, + { label: 'Sierra Leone', value: 'SL' }, + { label: 'Singapore', value: 'SG' }, + { label: 'Slovakia', value: 'SK' }, + { label: 'Slovenia', value: 'SI' }, + { label: 'Solomon Islands', value: 'SB' }, + { label: 'Somalia', value: 'SO' }, + { label: 'South Africa', value: 'ZA' }, + { label: 'South Georgia and the South Sandwich Islands', value: 'GS' }, + { label: 'Spain', value: 'ES' }, + { label: 'Sri Lanka', value: 'LK' }, + { label: 'Sudan', value: 'SD' }, + { label: 'Suriname', value: 'SR' }, + { label: 'Svalbard and Jan Mayen', value: 'SJ' }, + { label: 'Swaziland', value: 'SZ' }, + { label: 'Sweden', value: 'SE' }, + { label: 'Switzerland', value: 'CH' }, + { label: 'Syrian Arab Republic', value: 'SY' }, + { label: 'Taiwan, Province of China', value: 'TW' }, + { label: 'Tajikistan', value: 'TJ' }, + { label: 'Tanzania, United Republic of', value: 'TZ' }, + { label: 'Thailand', value: 'TH' }, + { label: 'Timor-Leste', value: 'TL' }, + { label: 'Togo', value: 'TG' }, + { label: 'Tokelau', value: 'TK' }, + { label: 'Tonga', value: 'TO' }, + { label: 'Trinidad and Tobago', value: 'TT' }, + { label: 'Tunisia', value: 'TN' }, + { label: 'Turkey', value: 'TR' }, + { label: 'Turkmenistan', value: 'TM' }, + { label: 'Turks and Caicos Islands', value: 'TC' }, + { label: 'Tuvalu', value: 'TV' }, + { label: 'Uganda', value: 'UG' }, + { label: 'Ukraine', value: 'UA' }, + { label: 'United Arab Emirates', value: 'AE' }, + { label: 'United Kingdom', value: 'GB' }, + { label: 'United States', value: 'US' }, + { label: 'United States Minor Outlying Islands', value: 'UM' }, + { label: 'Uruguay', value: 'UY' }, + { label: 'Uzbekistan', value: 'UZ' }, + { label: 'Vanuatu', value: 'VU' }, + { label: 'Venezuela', value: 'VE' }, + { label: 'Vietnam', value: 'VN' }, + { label: 'Virgin Islands, British', value: 'VG' }, + { label: 'Virgin Islands, U.S.', value: 'VI' }, + { label: 'Wallis and Futuna', value: 'WF' }, + { label: 'Western Sahara', value: 'EH' }, + { label: 'Yemen', value: 'YE' }, + { label: 'Zambia', value: 'ZM' }, + { label: 'Zimbabwe', value: 'ZW' }, +] diff --git a/packages/components-faraday/src/components/Dashboard/DashboardFilters.js b/packages/components-faraday/src/components/Dashboard/DashboardFilters.js index 898778b14ed4066ef604323bb89754cf08e493eb..78241263936811ee2b9ce54aa7faddf3607314e3 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardFilters.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardFilters.js @@ -6,18 +6,6 @@ import { compose, withHandlers } from 'recompose' import classes from './Dashboard.local.scss' import { changeFilter, changeSort } from './redux/filters' -const statusFilterOptions = [ - { label: 'All', value: 'all' }, - { label: 'Submitted', value: 'submitted' }, - { label: 'Draft', value: 'draft' }, -] - -const ownerFilterOptions = [ - { label: 'Everyone', value: 'all' }, - { label: 'My work', value: 'me' }, - { label: `Other's work`, value: 'other' }, -] - const sortOptions = [ { label: 'Newest first', value: 'newest' }, { label: 'Oldest first', value: 'oldest' }, diff --git a/packages/components-faraday/src/components/UIComponents/Spinner.js b/packages/components-faraday/src/components/UIComponents/Spinner.js index 020eebbd4f16c40cf543b1efceb921df6683dc65..7a39370c7688493d1cdbe7f19a5579fa7fd4b1d8 100644 --- a/packages/components-faraday/src/components/UIComponents/Spinner.js +++ b/packages/components-faraday/src/components/UIComponents/Spinner.js @@ -1,15 +1,38 @@ import React from 'react' -import classnames from 'classnames' import { Icon } from '@pubsweet/ui' - -import classes from './Spinner.local.scss' +import styled, { keyframes } from 'styled-components' const Spinner = ({ icon = 'loader', size = 16, color = '#444' }) => ( - <div className={classnames(classes.rotate, classes.icon)}> + <Root> <Icon color={color} size={size}> {icon} </Icon> - </div> + </Root> ) +const rotating = keyframes` + from { + -o-transform: rotate(0deg); + -ms-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + to { + -o-transform: rotate(360deg); + -ms-transform: rotate(360deg); + -moz-transform: rotate(360deg); + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +` + +const Root = styled.div` + align-items: center; + display: flex; + justify-content: center; + animation: ${rotating} 1.5s linear infinite; +` + export default Spinner diff --git a/packages/components-faraday/src/components/UIComponents/Spinner.local.scss b/packages/components-faraday/src/components/UIComponents/Spinner.local.scss deleted file mode 100644 index b82f01d0e4f0d7113d1e63f67845f40120027477..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/UIComponents/Spinner.local.scss +++ /dev/null @@ -1,44 +0,0 @@ -@keyframes rotating { - from { - -o-transform: rotate(0deg); - -ms-transform: rotate(0deg); - -moz-transform: rotate(0deg); - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - - to { - -o-transform: rotate(360deg); - -ms-transform: rotate(360deg); - -moz-transform: rotate(360deg); - -webkit-transform: rotate(360deg); - transform: rotate(360deg); - } -} - -@-webkit-keyframes rotating { - from { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - - to { - -webkit-transform: rotate(360deg); - transform: rotate(360deg); - } -} - -.rotate { - -webkit-animation: rotating 1.8s linear infinite; - -moz-animation: rotating 1.8s linear infinite; - -ms-animation: rotating 1.8s linear infinite; - -o-animation: rotating 1.8s linear infinite; - animation: rotating 1.8s linear infinite; -} - -.icon { - align-items: center; - display: flex; - justify-content: center; - margin: 0 5px 0 0; -} diff --git a/packages/components-faraday/src/components/UIComponents/Spinner.md b/packages/components-faraday/src/components/UIComponents/Spinner.md index 613387829983e4756f9364e36e8c60eafacd21df..bfcff7255f991f51dbbaa65acea0e9e07a00d41d 100644 --- a/packages/components-faraday/src/components/UIComponents/Spinner.md +++ b/packages/components-faraday/src/components/UIComponents/Spinner.md @@ -13,8 +13,9 @@ Spinning icon used when loading or waiting for API calls to finish. ## Examples ```js -import { Spinner } from 'pubsweet-components-faraday/src/components' - -<Spinner /> // renders the default spinner -<Spinner color="pink" size={40} icon="compass" /> // renders a huge pink spinning compass +<Spinner /> ``` + +```js +<Spinner color="pink" size={40} icon="compass" /> +``` \ No newline at end of file