From 771543fb3925b9893d633d0554f3a18edc0814e2 Mon Sep 17 00:00:00 2001 From: Amanda Date: Thu, 9 Aug 2018 00:55:16 -0700 Subject: [PATCH] Add demo login button and functionality --- .../stylesheets/components/_session_form.scss | 19 ++++++++++------ frontend/components/session/session_form.jsx | 22 +++++++++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/components/_session_form.scss b/app/assets/stylesheets/components/_session_form.scss index 0e36093..0f29619 100644 --- a/app/assets/stylesheets/components/_session_form.scss +++ b/app/assets/stylesheets/components/_session_form.scss @@ -12,6 +12,11 @@ $button-green: #108851; border-bottom: 1px solid #ddd; } +.errors { + // text-align: center; + color: red; +} + .session-form { display: flex; flex-direction: column; @@ -36,11 +41,7 @@ $button-green: #108851; font-weight: bold; } -.errors { - color: red; -} - -.auth-credentials, .session-submit { +.auth-credentials, .session-submit, .demo-button { margin: 10px; padding: 5px 20px; min-width: 300px; @@ -54,15 +55,19 @@ $button-green: #108851; text-align: left; } -.session-submit { +.session-submit, .demo-button { background-color: #0c7c4e; color: white; } -.session-submit:active { +.session-submit:active, .demo-button:active { background-color: #ddd; } +.demo-button { + margin-top: 0px; +} + .alt-auth-link { color: $button-link-blue; } diff --git a/frontend/components/session/session_form.jsx b/frontend/components/session/session_form.jsx index 593b528..902d856 100644 --- a/frontend/components/session/session_form.jsx +++ b/frontend/components/session/session_form.jsx @@ -13,6 +13,11 @@ class SessionForm extends React.Component { this.handleSumbit = this.handleSumbit.bind(this); } + componentDidMount() { + this.usernameInput.focus(); //Rails way to autofocus: have cursor automatically in input + this.props.eraseErrors(); + } + update(field) { return e => ( this.setState({[field]: e.target.value}) @@ -24,6 +29,7 @@ class SessionForm extends React.Component { this.props.processForm(this.state); } + alternateAuth() { if(this.props.formType === 'Sign Up') { return ( @@ -52,9 +58,16 @@ class SessionForm extends React.Component { ); } - componentDidMount() { - this.usernameInput.focus(); //Rails way to autofocus: have cursor automatically in input - this.props.eraseErrors(); + demoButton() { + if(this.props.formType === 'Log In') { + return ( + this.setState({username: 'harry_potter', password: '123456'}) } /> + ); + } } render() { @@ -66,7 +79,7 @@ class SessionForm extends React.Component {

{this.props.formHeader}

{this.renderErrors()} - +

Enter your username and password.

+ {this.demoButton()}
{this.alternateAuth()}