This repository has been archived by the owner on Oct 1, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 'Import your contacts' bio action
Improve the layout of bio actions
- Loading branch information
1 parent
70a0d41
commit 26ba70f
Showing
9 changed files
with
206 additions
and
12 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
This file is a part of libertysoil.org website | ||
Copyright (C) 2017 Loki Education (Social Enterprise) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import React, { PropTypes } from 'react'; | ||
import isEqual from 'lodash/isEqual'; | ||
import Switch from 'react-toggle-switch'; | ||
import Link from 'react-router/lib/Link'; | ||
|
||
import { addError } from '../../../actions/messages'; | ||
import Button from '../../button'; | ||
import Modal from '../../sidebar-modal'; | ||
import Card from '../card'; | ||
|
||
const icon = { icon: 'image', pack: 'fa' }; | ||
|
||
const SERVICES = [ | ||
{ name: 'gmail', title: 'Gmail', img: '/images/services/gmail.png' }, | ||
{ name: 'yahoo', title: 'Yahoo!', img: '/images/services/yahoo.png' } | ||
]; | ||
|
||
export default class ImportContactsAction extends React.Component { | ||
static displayName = 'ImportContactsAction'; | ||
|
||
static propTypes = { | ||
dispatch: PropTypes.func, | ||
// eslint-disable-next-line react/no-unused-prop-types | ||
triggers: PropTypes.shape({ | ||
uploadPicture: PropTypes.func, | ||
updateUserInfo: PropTypes.func | ||
}) | ||
}; | ||
|
||
static defaultProps = { | ||
dispatch: () => {} | ||
}; | ||
|
||
constructor(...args) { | ||
super(...args); | ||
this.state = { | ||
isActive: false, | ||
isChecked: false | ||
}; | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return nextProps !== this.props || !isEqual(nextState, this.state); | ||
} | ||
|
||
handleCardClick = () => { | ||
this.setState({ isActive: true }); | ||
}; | ||
|
||
handleModalClose = () => { | ||
this.setState({ isActive: false }); | ||
}; | ||
|
||
handleSwitch = () => { | ||
this.setState((state) => ({ isChecked: !state.isChecked })); | ||
}; | ||
|
||
handleSubmit = async () => { | ||
try { | ||
this.handleModalClose(); | ||
} catch (e) { | ||
this.props.dispatch(addError(e.message)); | ||
} | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Card | ||
className="bio__card--bg_1" | ||
icon={icon} | ||
title="Import your contacts" | ||
onClick={this.handleCardClick} | ||
> | ||
<Modal.Overlay isVisible={this.state.isActive}> | ||
<Modal isVisible={this.state.isActive} onHide={this.handleModalClose}> | ||
<Modal.Header onClose={this.handleModalClose}> | ||
Import your contacts | ||
</Modal.Header> | ||
<Modal.Body> | ||
Importing your contacts does not send out any invitations. | ||
<div className="sidebar-modal__actions layout layout-align_vertical"> | ||
{SERVICES.map(s => | ||
<div className="service-card" key={s.name}> | ||
<img alt={s.title} className="service-card__icon" src={s.img} /> | ||
<div className="service-card__title">{s.title}</div> | ||
</div> | ||
)} | ||
</div> | ||
<div className="sidebar-modal__actions layout layout-align_vertical"> | ||
<Switch on={this.state.isChecked} onClick={this.handleSwitch} /> | ||
<span className="margin--all_left--h font--size_small"> | ||
Email each and everyone I know about us. | ||
<Link className="font--underlined" to="/settings">Learn more</Link> | ||
</span> | ||
</div> | ||
<div className="layout sidebar-modal__actions"> | ||
<Button | ||
className="sidebar-modal__button sidebar-modal__button--type_submit" | ||
title="Import" | ||
onClick={this.handleSubmit} | ||
/> | ||
<Button | ||
className="sidebar-modal__button sidebar-modal__button--type_cancel" | ||
title="No." | ||
onClick={this.handleModalClose} | ||
/> | ||
</div> | ||
</Modal.Body> | ||
</Modal> | ||
</Modal.Overlay> | ||
</Card> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.service-card { | ||
padding: 0 9px; | ||
cursor: pointer; | ||
|
||
&__icon { | ||
display: block; | ||
padding: 8px; | ||
width: 60px; | ||
height: 60px; | ||
background-color: #fff; | ||
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
&__title { | ||
margin-top: 6px; | ||
font-size: 12px; | ||
color: rgba(0, 0, 0, 0.7); | ||
text-align: center; | ||
} | ||
|
||
&:hover { | ||
.service-card__title { | ||
text-decoration: underline; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,3 +142,4 @@ | |
@import 'blocks/bio'; | ||
@import 'blocks/sidebar-modal'; | ||
@import 'blocks/switch'; | ||
@import 'blocks/service-card'; |