Skip to content

Commit

Permalink
fix: cleanup mobile auth ui
Browse files Browse the repository at this point in the history
  • Loading branch information
vhpoet committed Jun 23, 2017
1 parent 8ebd335 commit 26276ac
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/components/ChangePasswordForm/ChangePasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class ChangePasswordForm extends Component {
label='Repeat Password'
size='lg' />
</div>
<div className='row'>
<div>
<button type='submit' className='btn btn-success' disabled={pristine || (invalid && !submitFailed) || submitting}>
{submitting ? ' Submitting...' : ' Submit'}
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ForgotPasswordForm/ForgotPasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class ForgotPasswordForm extends Component {
focus
autoCapitalize='off' />
</div>
<div className='row'>
<div>
<button type='submit' className='btn btn-success btn-lg' disabled={pristine || (invalid && !submitFailed) || submitting}>
{submitting ? ' Submitting...' : ' Submit'}
</button>
Expand Down
20 changes: 19 additions & 1 deletion src/containers/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ export default class App extends Component {
this.props.verify(params.username, params.verifyCode)
}
}

// Disable scaling
document.addEventListener('touchmove', function(event) {
event = event.originalEvent || event
if (event.scale !== 1) {
event.preventDefault()
}
}, false)

this.fixAppHeight()
}

componentWillReceiveProps (nextProps) {
Expand All @@ -110,6 +120,14 @@ export default class App extends Component {
}
}

fixAppHeight = () => {
// Viewport height
const height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
document.getElementsByClassName(cx('App'))[0].style['min-height'] = height + 'px'

window.addEventListener('resize', this.fixAppHeight, false)
}

connect = (props = this.props) => {
if (!props.user || !props.user.username) return

Expand Down Expand Up @@ -149,7 +167,7 @@ export default class App extends Component {
const { user, config = {}, advancedMode, verified, verificationEmailSent } = this.props

return (
<div className={cx('App', !user && 'darkBg')}>
<div className={cx('App', !user && 'guest')}>
<Helmet defaultTitle={config.title} titleTemplate={config.title && '%s - ' + config.title}>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<meta property='og:type' content='website' />
Expand Down
8 changes: 5 additions & 3 deletions src/containers/App/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
@import 'mixins';

.App {
min-height: 100%;
padding-bottom: 30px;

&.darkBg {
background: #333333;
@include mobile {
padding-bottom: 50px;
}

&.guest {
padding-bottom: 0;
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/containers/Auth/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ export default class Home extends Component {
this.setCurrentView()
}

componentDidMount () {
document.getElementsByTagName('body')[0].className = 'guest'
}

componentWillReceiveProps (nextProps) {
this.setCurrentView(nextProps)
}

componentWillUnmount () {
document.getElementsByTagName('body')[0].className = ''
}

setCurrentView (props) {
const prps = props || this.props
const fullPath = prps.route.path
Expand All @@ -74,7 +82,7 @@ export default class Home extends Component {
const appConfig = this.props.config || {}

return (
<div className={cx('Auth', 'container')}>
<div className={cx('Auth')}>
<div>
<div className={cx('header')}>
<h1 className={cx('title')}>{appConfig.title}</h1>
Expand Down
9 changes: 5 additions & 4 deletions src/containers/Auth/Auth.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
align-items: center;
justify-content: center;

// just to bring the .window a bit higher
padding-bottom: 3%;

min-height: 100vh;
min-height: 80vh;
}
.header {
margin: 0 0 20px;
Expand All @@ -24,6 +21,10 @@
background: #fff;
border-radius: 3px;
padding: 25px;

@include mobile {
width: 90vw;
}
}
.oauthBox {
color: #d9d9d9;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Html extends Component {
{helmet.script.toComponent()}

<link rel='shortcut icon' href='/favicon.png' />
<meta name='viewport' content='width=device-width, initial-scale=1' />
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
{/* styles (will be present only in production with webpack extract text plugin) */}
<link href={assets.styles.main} media='screen, projection' rel='stylesheet' type='text/css' charSet='UTF-8' />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' />
Expand Down
9 changes: 4 additions & 5 deletions src/theme/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ html,
body {
height: 100%;
background: #fff;

&.guest {
background: #333333;
}
}

#content {
display: table;
width: 100%;
height: inherit;

@include mobile {
padding-bottom: 50px;
}
}
#app {
display: table-cell;
}

a {
cursor: pointer;
}
Expand Down

0 comments on commit 26276ac

Please sign in to comment.