Skip to content

adding sementic #1

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

Merged
merged 2 commits into from
Dec 11, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ yarn-error.log*

.firebase
.firebaserc
.idea
78 changes: 77 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "react-semantic-ui-firebase-authentication",
"name": "react-firebase-authentication",
"version": "0.2.0",
"private": true,
"dependencies": {
"date-fns": "^1.30.1",
"firebase": "^5.6.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
"recompose": "^0.30.0"
"recompose": "^0.30.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.83.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
175 changes: 108 additions & 67 deletions src/components/Account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { withFirebase } from '../Firebase';
import { PasswordForgetForm } from '../PasswordForget';
import PasswordChangeForm from '../PasswordChange';

import {Grid, Card, Header, Message, Form, Button } from 'semantic-ui-react'

const SIGN_IN_METHODS = [
{
id: 'password',
Expand All @@ -33,9 +35,29 @@ const AccountPage = () => (
<AuthUserContext.Consumer>
{authUser => (
<div>
<h1>Account: {authUser.email}</h1>
<PasswordForgetForm />
<PasswordChangeForm />
<Header as='h2'>Account: {authUser.email}</Header>
<Grid columns={2}>
<Grid.Column>
<Card fluid={true}>
<Card.Content>
<Card.Header>Reset Password</Card.Header>
<Card.Description>
<PasswordForgetForm />
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
<Grid.Column>
<Card fluid={true}>
<Card.Content>
<Card.Header>New Password</Card.Header>
<Card.Description>
<PasswordChangeForm />
</Card.Description>
</Card.Content>
</Card>
</Grid.Column>
</Grid>
<LoginManagement authUser={authUser} />
</div>
)}
Expand Down Expand Up @@ -95,40 +117,51 @@ class LoginManagementBase extends Component {
const { activeSignInMethods, error } = this.state;

return (
<div>
Sign In Methods:
<ul>
{SIGN_IN_METHODS.map(signInMethod => {
const onlyOneLeft = activeSignInMethods.length === 1;
const isEnabled = activeSignInMethods.includes(
signInMethod.id,
);

return (
<li key={signInMethod.id}>
{signInMethod.id === 'password' ? (
<DefaultLoginToggle
onlyOneLeft={onlyOneLeft}
isEnabled={isEnabled}
signInMethod={signInMethod}
onLink={this.onDefaultLoginLink}
onUnlink={this.onUnlink}
/>
) : (
<SocialLoginToggle
onlyOneLeft={onlyOneLeft}
isEnabled={isEnabled}
signInMethod={signInMethod}
onLink={this.onSocialLoginLink}
onUnlink={this.onUnlink}
/>
)}
</li>
);
})}
</ul>
{error && error.message}
</div>
<Card fluid={true}>
<Card.Content>
<Card.Header>Sign In Methods</Card.Header>
<Card.Description>
{error && <Message negative>
<p>{error.message}</p>
</Message>}
<div>
{SIGN_IN_METHODS.map(signInMethod => {
const onlyOneLeft = activeSignInMethods.length === 1;
const isEnabled = activeSignInMethods.includes(
signInMethod.id,
);

return (
<span key={signInMethod.id}>
{signInMethod.id === 'password' ? (
<Grid columns={1}>
<Grid.Column>
<DefaultLoginToggle
onlyOneLeft={onlyOneLeft}
isEnabled={isEnabled}
signInMethod={signInMethod}
onLink={this.onDefaultLoginLink}
onUnlink={this.onUnlink}
/>
<br />
</Grid.Column>
</Grid>
) : (
<SocialLoginToggle
onlyOneLeft={onlyOneLeft}
isEnabled={isEnabled}
signInMethod={signInMethod}
onLink={this.onSocialLoginLink}
onUnlink={this.onUnlink}
/>
)}
</span>
);
})}
</div>
</Card.Description>
</Card.Content>
</Card>
);
}
}
Expand All @@ -141,20 +174,22 @@ const SocialLoginToggle = ({
onUnlink,
}) =>
isEnabled ? (
<button
<Button
color={signInMethod.id === 'google.com' ? 'google plus' : signInMethod.id === 'facebook.com' ? 'facebook' : signInMethod.id === 'twitter.com' ? 'twitter' : ''}
type="button"
onClick={() => onUnlink(signInMethod.id)}
disabled={onlyOneLeft}
>
Deactivate {signInMethod.id}
</button>
</Button>
) : (
<button
<Button
color={signInMethod.id === 'google.com' ? 'google plus' : signInMethod.id === 'facebook.com' ? 'facebook' : signInMethod.id === 'twitter.com' ? 'twitter' : ''}
type="button"
onClick={() => onLink(signInMethod.provider)}
>
Link {signInMethod.id}
</button>
</Button>
);

class DefaultLoginToggle extends Component {
Expand Down Expand Up @@ -189,34 +224,40 @@ class DefaultLoginToggle extends Component {
passwordOne !== passwordTwo || passwordOne === '';

return isEnabled ? (
<button
type="button"
onClick={() => onUnlink(signInMethod.id)}
disabled={onlyOneLeft}
>
Deactivate {signInMethod.id}
</button>
<span>
<Button type="button" onClick={() => onUnlink(signInMethod.id)} disabled={onlyOneLeft}>
Deactivate {signInMethod.id}
</Button>
<br />
</span>
) : (
<form onSubmit={this.onSubmit}>
<input
name="passwordOne"
value={passwordOne}
onChange={this.onChange}
type="password"
placeholder="New Password"
/>
<input
name="passwordTwo"
value={passwordTwo}
onChange={this.onChange}
type="password"
placeholder="Confirm New Password"
/>

<button disabled={isInvalid} type="submit">
<Form onSubmit={this.onSubmit}>
<Form.Group widths='equal'>
<Form.Field>
<label>New Password</label>
<input
name="passwordOne"
value={passwordOne}
onChange={this.onChange}
type="password"
placeholder="New Password"
/>
</Form.Field>
<Form.Field>
<label>Confirm Password</label>
<input
name="passwordTwo"
value={passwordTwo}
onChange={this.onChange}
type="password"
placeholder="Confirm New Password"
/>
</Form.Field>
</Form.Group>
<Button primary disabled={isInvalid} type="submit">
Link {signInMethod.id}
</button>
</form>
</Button>
</Form>
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { UserList, UserItem } from '../Users';
import * as ROLES from '../../constants/roles';
import * as ROUTES from '../../constants/routes';

import { Header } from 'semantic-ui-react';

const AdminPage = () => (
<div>
<h1>Admin</h1>
<Header as='h2'>Admin</Header>
<p>The Admin Page is accessible by every signed in admin user.</p>

<Switch>
Expand Down
Loading