Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoginModal #3

Merged
merged 2 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@
"hideKeyboard": "Hide Keyboard",
"showKeyboard": "Show Keyboard"
}
},
"LoginModal": {
"buttonCancel": "Cancel",
"buttonLogin": "Login",
"email": "Email",
"header": "Login",
"loginErrorContent": "The username and/or password you entered is invalid. Please double check and try again.",
"loginErrorHeader": "Invalid Credentials",
"password": "Password"
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export { default as KeyboardField } from './semantic-ui/KeyboardField';
export { default as LinkButton } from './semantic-ui/LinkButton';
export { default as LinkLabel } from './semantic-ui/LinkLabel';
export { default as ListTable } from './semantic-ui/ListTable';
export { default as LoginModal } from './semantic-ui/LoginModal';
export { default as PhotoViewer } from './semantic-ui/PhotoViewer';
export { default as Selectize } from './semantic-ui/Selectize';
7 changes: 7 additions & 0 deletions src/semantic-ui/LoginModal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.row {
margin: 15px 150px 0px 150px;
}

.ui.input.form-field {
display: block;
}
99 changes: 99 additions & 0 deletions src/semantic-ui/LoginModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// @flow

import React, { Component } from 'react';
import {
Button,
Form,
Grid,
Header,
Icon,
Input,
Message,
Modal
} from 'semantic-ui-react';
import { withTranslation } from 'react-i18next';
import './LoginModal.css';

type Props = {
disabled: boolean,
loginFailed: boolean,
onClose: () => void,
onLogin: () => void,
onPasswordChange: () => void,
onUsernameChange: () => void,
open: boolean,
t: () => string,
trigger: () => Component
};

const LoginModal = (props: Props) => (
<Modal
as={Form}
error={props.loginFailed}
open={props.open}
size='small'
trigger={props.trigger}
>
<Header
icon='user circle'
content={props.t('LoginModal.header')}
/>
<Message
error
header={props.t('LoginModal.loginErrorHeader')}
content={props.t('LoginModal.loginErrorContent')}
/>
<Grid
padded='vertically'
textAlign='center'
>
<Grid.Column>
<Grid.Row
className='row'
>
<Input
autoFocus
className='form-field'
icon={<Icon name='at' />}
onChange={props.onUsernameChange.bind(this)}
placeholder={props.t('LoginModal.email')}
size='huge'
/>
</Grid.Row>
<Grid.Row
className='row'
>
<Input
className='form-field'
icon={<Icon name='lock' />}
onChange={props.onPasswordChange.bind(this)}
placeholder={props.t('LoginModal.password')}
size='huge'
type='password'
/>
</Grid.Row>
</Grid.Column>
</Grid>
<Modal.Actions>
<Button
disabled={props.disabled}
onClick={props.onLogin.bind(this)}
primary
size='large'
type='submit'
>
{ props.t('LoginModal.buttonLogin') }
</Button>
<Button
inverted
onClick={props.onClose.bind(this)}
primary
size='large'
>
{ props.t('LoginModal.buttonCancel') }
</Button>
</Modal.Actions>
</Modal>
);

export default withTranslation()(LoginModal);
22 changes: 22 additions & 0 deletions stories/components/semantic-ui/LoginModal.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { withA11y } from '@storybook/addon-a11y';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean } from '@storybook/addon-knobs';
import LoginModal from '../../../src/semantic-ui/LoginModal';

export default {
title: 'Components/Semantic UI/LoginModal',
decorators: [withA11y, withKnobs]
};

export const Default = () => (
<LoginModal
disabled={boolean('Disabled', false)}
loginFailed={boolean('Login failed', false)}
onClose={action('close')}
onLogin={action('login')}
onPasswordChange={action('password-change')}
onUsernameChange={action('username-change')}
open={boolean('Open', true)}
/>
);