diff --git a/app/soapbox/components/showable_password.js b/app/soapbox/components/showable_password.js new file mode 100644 index 000000000..a6dbdad24 --- /dev/null +++ b/app/soapbox/components/showable_password.js @@ -0,0 +1,64 @@ +import React from 'react'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import { defineMessages, injectIntl } from 'react-intl'; +import PropTypes from 'prop-types'; +import classNames from 'classnames'; +import IconButton from 'soapbox/components/icon_button'; +import { FormPropTypes, InputContainer, LabelInputContainer } from 'soapbox/features/forms'; + +const messages = defineMessages({ + showPassword: { id: 'forms.show_password', defaultMessage: 'Show password' }, + hidePassword: { id: 'forms.hide_password', defaultMessage: 'Hide password' }, +}); + +export default @injectIntl +class ShowablePassword extends ImmutablePureComponent { + + static propTypes = { + intl: PropTypes.object.isRequired, + label: FormPropTypes.label, + className: PropTypes.string, + hint: PropTypes.node, + error: PropTypes.bool, + } + + state = { + revealed: false, + } + + toggleReveal = () => { + if (this.props.onToggleVisibility) { + this.props.onToggleVisibility(); + } else { + this.setState({ revealed: !this.state.revealed }); + } + } + + render() { + const { intl, hint, error, label, className, ...props } = this.props; + const { revealed } = this.state; + + const revealButton = ( + + ); + + return ( + + {label ? ( + + + {revealButton} + + ) : (<> + + {revealButton} + )} + + ); + } + +} \ No newline at end of file diff --git a/app/soapbox/features/auth_login/components/__tests__/__snapshots__/login_form-test.js.snap b/app/soapbox/features/auth_login/components/__tests__/__snapshots__/login_form-test.js.snap index ad357af03..0588d8a02 100644 --- a/app/soapbox/features/auth_login/components/__tests__/__snapshots__/login_form-test.js.snap +++ b/app/soapbox/features/auth_login/components/__tests__/__snapshots__/login_form-test.js.snap @@ -25,19 +25,48 @@ exports[` renders for Mastodon 1`] = ` />
+

renders for Pleroma 1`] = ` />

+

renders correctly on load 1`] = ` />

+

-

+ + {/*
-
+
*/}

{hasResetPasswordAPI ? ( diff --git a/app/soapbox/features/auth_login/components/registration_form.js b/app/soapbox/features/auth_login/components/registration_form.js index a4c52ef62..f0d27c297 100644 --- a/app/soapbox/features/auth_login/components/registration_form.js +++ b/app/soapbox/features/auth_login/components/registration_form.js @@ -5,6 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { injectIntl, FormattedMessage, defineMessages } from 'react-intl'; import { Link } from 'react-router-dom'; +import ShowablePassword from 'soapbox/components/showable_password'; import { SimpleForm, SimpleInput, @@ -231,10 +232,9 @@ class RegistrationForm extends ImmutablePureComponent { )} - - - {intl.formatMessage(messages.passwordHeader)}

- - -
-
- @@ -313,8 +312,7 @@ class OtpConfirmForm extends ImmutablePureComponent { />
- diff --git a/app/soapbox/locales/pl.json b/app/soapbox/locales/pl.json index 0fb0bf97f..a907d1219 100644 --- a/app/soapbox/locales/pl.json +++ b/app/soapbox/locales/pl.json @@ -424,6 +424,8 @@ "follow_request.authorize": "Autoryzuj", "follow_request.reject": "Odrzuć", "forms.copy": "Kopiuj", + "forms.hide_password": "Ukryj hasło", + "forms.show_password": "Pokaż hasło", "getting_started.open_source_notice": "{code_name} jest oprogramowaniem o otwartym źródle. Możesz pomóc w rozwoju lub zgłaszać błędy na GitLabie tutaj: {code_link} (v{code_version}).", "group.detail.archived_group": "Zarchiwizowana grupa", "group.members.empty": "Ta grupa nie ma żadnych członków.", diff --git a/app/styles/about.scss b/app/styles/about.scss index b4c4034e0..af281ff00 100644 --- a/app/styles/about.scss +++ b/app/styles/about.scss @@ -97,6 +97,7 @@ $fluid-breakpoint: $maximum-width + 20px; } .input { + flex: 1; margin-bottom: 0; margin-right: 10px; diff --git a/app/styles/forms.scss b/app/styles/forms.scss index b28676a32..67ca9ce34 100644 --- a/app/styles/forms.scss +++ b/app/styles/forms.scss @@ -608,6 +608,31 @@ code { margin-bottom: 14px; font-weight: bold; } + + .showable-password { + position: relative; + + input { + padding-right: 36px; + } + + .icon-button { + position: absolute; + top: 0; + right: 0; + height: 41px; + width: 36px; + padding: 0; + margin: 0; + background: transparent; + color: var(--primary-text-color); + + .svg-icon { + height: 20px; + width: 20px; + } + } + } } .block-icon {