-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Kat Hagan <[email protected]> Co-authored-by: Dennis Snell <[email protected]> Co-authored-by: Jonathan Belcher <[email protected]>
- Loading branch information
1 parent
625cb2a
commit dea5307
Showing
19 changed files
with
453 additions
and
153 deletions.
There are no files selected for viewing
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,103 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import classNames from 'classnames'; | ||
import Modal from 'react-modal'; | ||
import { connect } from 'react-redux'; | ||
|
||
import CrossIcon from '../icons/cross'; | ||
import WarningIcon from '../icons/warning'; | ||
|
||
import actions from '../state/actions'; | ||
|
||
import * as selectors from '../state/selectors'; | ||
import * as S from '../state'; | ||
|
||
type StateProps = { | ||
alternateLoginEmail: string | null; | ||
email: string | null; | ||
theme: 'light' | 'dark'; | ||
}; | ||
|
||
type DispatchProps = { | ||
logout: () => any; | ||
dismiss: () => any; | ||
}; | ||
|
||
type Props = StateProps & DispatchProps; | ||
|
||
const AlternateLoginPrompt: FunctionComponent<Props> = ({ | ||
alternateLoginEmail, | ||
dismiss, | ||
email, | ||
logout, | ||
theme, | ||
}) => { | ||
const displayClose = ( | ||
<div className="alternate-login__dismiss"> | ||
<button | ||
className="icon-button" | ||
aria-label="Close dialog" | ||
onClick={dismiss} | ||
> | ||
<CrossIcon /> | ||
</button> | ||
</div> | ||
); | ||
|
||
const displayAlternateLoginPrompt = ( | ||
<> | ||
{displayClose} | ||
<span className="theme-color-fg-dim"> | ||
<WarningIcon /> | ||
</span> | ||
<h2>Logout?</h2> | ||
<p>You are already logged in as:</p> | ||
<p className="alternate-login__email"> | ||
<strong>{email}</strong> | ||
</p> | ||
<p>You tried logging in with:</p> | ||
<p className="alternate-login__email"> | ||
<strong>{alternateLoginEmail}</strong> | ||
</p> | ||
<p>Would you like to log out?</p> | ||
|
||
<div className="alternate-login__button-row button-borderless"> | ||
<a target="_blank" rel="noreferrer" onClick={dismiss}> | ||
<button className="button button-borderless">Cancel</button> | ||
</a> | ||
<a target="_blank" rel="noreferrer" onClick={logout}> | ||
<button className="button button-primary">Logout</button> | ||
</a> | ||
</div> | ||
</> | ||
); | ||
|
||
return ( | ||
<Modal | ||
key="alternate-login" | ||
className="alternate-login__modal theme-color-fg theme-color-bg" | ||
isOpen | ||
onRequestClose={dismiss} | ||
contentLabel="Log out?" | ||
overlayClassName="alternate-login__overlay" | ||
portalClassName={classNames('alternate-login__portal', 'theme-' + theme)} | ||
> | ||
{displayAlternateLoginPrompt} | ||
</Modal> | ||
); | ||
}; | ||
|
||
const mapDispatchToProps: S.MapDispatch<DispatchProps> = { | ||
dismiss: () => actions.ui.showAlternateLoginPrompt(false), | ||
logout: actions.ui.logout, | ||
}; | ||
|
||
const mapStateToProps: S.MapState<StateProps> = (state) => ({ | ||
alternateLoginEmail: state.ui.alternateLoginEmail, | ||
email: state.settings.accountName, | ||
theme: selectors.getTheme(state), | ||
}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(AlternateLoginPrompt); |
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,81 @@ | ||
.alternate-login__overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background: rgba($studio-gray-20, 0.75); | ||
} | ||
|
||
.alternate-login__dismiss { | ||
display: flex; | ||
height: 60px; | ||
justify-content: flex-end; | ||
align-items: center; | ||
margin: 0 16px; | ||
width: 100%; | ||
|
||
svg { | ||
height: 16px; | ||
width: 16px; | ||
margin: auto 0; | ||
} | ||
} | ||
|
||
.alternate-login__email { | ||
word-break: break-all; | ||
} | ||
|
||
.alternate-login__modal { | ||
align-items: center; | ||
border-radius: 8px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
margin: 20%; | ||
max-width: 420px; | ||
padding: 0 24px 16px; | ||
font-size: 16px; | ||
|
||
p { | ||
margin: 0 26px; | ||
margin-block-start: 0; | ||
} | ||
|
||
p:not(:last-of-type) { | ||
padding-bottom: 20px; | ||
} | ||
|
||
.alternate-login__button-row { | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
|
||
a { | ||
padding-right: 12px; | ||
} | ||
.button-borderless { | ||
color: $studio-simplenote-blue-50; | ||
} | ||
} | ||
|
||
&:focus { | ||
outline: 0; | ||
} | ||
} | ||
|
||
.theme-dark { | ||
.alternate-login__overlay { | ||
background: rgba($studio-gray-100, 0.75); | ||
} | ||
.alternate-login__button-row .button-borderless { | ||
color: $studio-simplenote-blue-30; | ||
} | ||
} |
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
Oops, something went wrong.