From 599cbfc649dbc3a8d33f59a96040aa5ec6f1e4f9 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Fri, 5 Apr 2019 13:07:44 -0400 Subject: [PATCH] refactor: use raw html form elements (#123) * refactor: use raw html for form elements * test: update snapshot to reflect minor changes in html output * refactor: replace all reactstrap with paragon or html * test: update snapshot * fix: add a noop to the button in async button if needed This is a flaw in the Button component in Paragon. It calls props.onClick even if it doesn't exist. * refactor: use classnames for toggling class names * fix: remove unneeded ids. fix some form markup * fix: update snapshot to reflect removed labels --- .eslintrc | 7 + package-lock.json | 40 ---- package.json | 3 +- src/components/ErrorPage.jsx | 42 ++-- src/components/NotFoundPage.jsx | 8 +- src/components/ProfilePage.jsx | 49 ++--- src/components/ProfilePage/AgeMessage.jsx | 51 +++-- src/components/ProfilePage/Bio.jsx | 23 +-- src/components/ProfilePage/Certificates.jsx | 33 +-- src/components/ProfilePage/Country.jsx | 23 +-- src/components/ProfilePage/Education.jsx | 24 +-- src/components/ProfilePage/Name.jsx | 30 ++- src/components/ProfilePage/PageLoading.jsx | 3 +- .../ProfilePage/PreferredLanguage.jsx | 24 +-- src/components/ProfilePage/ProfileAvatar.jsx | 97 ++++----- src/components/ProfilePage/SocialLinks.jsx | 15 +- .../elements/AsyncActionButton.jsx | 35 ++-- .../ProfilePage/elements/FormControls.jsx | 22 +- .../ProfilePage/elements/Visibility.jsx | 5 +- .../__snapshots__/ProfilePage.test.jsx.snap | 188 +++++++++++------- src/index.scss | 12 ++ 21 files changed, 372 insertions(+), 362 deletions(-) diff --git a/.eslintrc b/.eslintrc index a0125d9..ba8734a 100755 --- a/.eslintrc +++ b/.eslintrc @@ -16,6 +16,13 @@ "jsx-a11y/anchor-is-valid": [ "error", { "components": [ "Link" ], "specialLink": [ "to" ] + }], + "jsx-a11y/label-has-for": [ 2, { + "components": [ "label" ], + "required": { + "some": [ "nesting", "id" ] + }, + "allowChildren": false }] }, "env": { diff --git a/package-lock.json b/package-lock.json index 89ada31..2243c3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13933,16 +13933,6 @@ "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", "dev": true }, - "lodash.isfunction": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz", - "integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==" - }, - "lodash.isobject": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz", - "integrity": "sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0=" - }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -14009,11 +13999,6 @@ "integrity": "sha1-0jM6NtnncXyK0vfKyv7HwytERmQ=", "dev": true }, - "lodash.tonumber": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/lodash.tonumber/-/lodash.tonumber-4.0.3.tgz", - "integrity": "sha1-C5azGzVnJ5Prf1pj7nkfG56QJdk=" - }, "lodash.uniq": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", @@ -18792,15 +18777,6 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, - "react-popper": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-0.10.4.tgz", - "integrity": "sha1-rypBXqIike3VBGeNev2opu4ylao=", - "requires": { - "popper.js": "^1.14.1", - "prop-types": "^15.6.1" - } - }, "react-proptype-conditional-require": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/react-proptype-conditional-require/-/react-proptype-conditional-require-1.0.4.tgz", @@ -18912,22 +18888,6 @@ "integrity": "sha512-HH2N/b5tRxh7ypIgCRsiBl/CTxRkTEPf9DhIstaM6hne4WiwM5/bBbWuvVlRZc/i3FdqZED3pZ//6n4mtxma4w==", "dev": true }, - "reactstrap": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-7.1.0.tgz", - "integrity": "sha512-wtc4RkgnGn1TsZ0AxOZ2OqT+b8YmCWZj/tErPujWLepxzlEEhveZGC+uDerdaHVSAzJUP2DTk605iper7hutQQ==", - "requires": { - "@babel/runtime": "^7.2.0", - "classnames": "^2.2.3", - "lodash.isfunction": "^3.0.9", - "lodash.isobject": "^3.0.2", - "lodash.tonumber": "^4.0.3", - "prop-types": "^15.5.8", - "react-lifecycles-compat": "^3.0.4", - "react-popper": "^0.10.4", - "react-transition-group": "^2.3.1" - } - }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", diff --git a/package.json b/package.json index 063ecda..481ef4c 100755 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@fortawesome/react-fontawesome": "^0.1.4", "babel-polyfill": "^6.26.0", "bootstrap": "^4.2.1", - "classnames": "^2.2.5", + "classnames": "^2.2.6", "connected-react-router": "^5.0.1", "email-prop-type": "^1.1.5", "font-awesome": "^4.7.0", @@ -59,7 +59,6 @@ "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "react-transition-group": "^2.5.3", - "reactstrap": "^7.1.0", "redux": "^4.0.1", "redux-devtools-extension": "^2.13.2", "redux-logger": "^3.0.6", diff --git a/src/components/ErrorPage.jsx b/src/components/ErrorPage.jsx index a24a75b..7fc2e77 100644 --- a/src/components/ErrorPage.jsx +++ b/src/components/ErrorPage.jsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Button, Col, Container, Row } from 'reactstrap'; +import { Button } from '@edx/paragon'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; @@ -12,12 +12,9 @@ export default class ErrorPage extends Component { const { username } = apiClient.getAuthenticationState().authentication; return ( - - - +
+
+

- - - - +
+
+
+
- +
+
+
); } } diff --git a/src/components/NotFoundPage.jsx b/src/components/NotFoundPage.jsx index 9e0077c..0a4807f 100644 --- a/src/components/NotFoundPage.jsx +++ b/src/components/NotFoundPage.jsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import { Container } from 'reactstrap'; import { FormattedMessage } from 'react-intl'; export default class NotFoundPage extends Component { @@ -7,10 +6,7 @@ export default class NotFoundPage extends Component { render() { return ( - +

- +
); } } diff --git a/src/components/ProfilePage.jsx b/src/components/ProfilePage.jsx index 2bee9a4..c099cce 100644 --- a/src/components/ProfilePage.jsx +++ b/src/components/ProfilePage.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Container, Row, Col, Alert, Button } from 'reactstrap'; +import { StatusAlert, Hyperlink } from '@edx/paragon'; import { connect } from 'react-redux'; import { injectIntl, intlShape } from 'react-intl'; @@ -89,9 +89,12 @@ export class ProfilePage extends React.Component { } return ( - + ); } @@ -116,11 +119,11 @@ export class ProfilePage extends React.Component { } return ( - - - {photoUploadError.userMessage} - - +
+
+ +
+
); } @@ -160,9 +163,9 @@ export class ProfilePage extends React.Component { return (
- - - +
+
+
- - +
+
{this.renderHeadingLockup()}
{this.renderViewMyRecordsButton()}
- - +
+
{this.renderPhotoUploadErrorMessage()} - - +
+
{this.renderHeadingLockup()}
@@ -224,8 +227,8 @@ export class ProfilePage extends React.Component { formId="socialLinks" {...commonFormProps} /> - - +
+
{shouldShowAgeMessage ? : null} - - - +
+
+
); } diff --git a/src/components/ProfilePage/AgeMessage.jsx b/src/components/ProfilePage/AgeMessage.jsx index d7da685..c0ff14c 100644 --- a/src/components/ProfilePage/AgeMessage.jsx +++ b/src/components/ProfilePage/AgeMessage.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Alert } from 'reactstrap'; +import { StatusAlert } from '@edx/paragon'; import { FormattedMessage } from 'react-intl'; import { configuration } from '../../config/environment'; @@ -8,27 +8,34 @@ const { ACCOUNT_SETTINGS_URL } = configuration; function AgeMessage() { return ( - - - - - - - + + + + + + + + } + dismissible={false} + open + /> ); } diff --git a/src/components/ProfilePage/Bio.jsx b/src/components/ProfilePage/Bio.jsx index e3cc5e0..e64fbdc 100644 --- a/src/components/ProfilePage/Bio.jsx +++ b/src/components/ProfilePage/Bio.jsx @@ -1,8 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Form, FormFeedback, FormGroup, Input, Label } from 'reactstrap'; import { connect } from 'react-redux'; import { injectIntl, intlShape, FormattedMessage } from 'react-intl'; +import classNames from 'classnames'; import messages from './Bio.messages'; @@ -55,22 +55,21 @@ class Bio extends React.Component { cases={{ editing: (
-
- -