-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into storybook-upgrade
- Loading branch information
Showing
155 changed files
with
3,137 additions
and
3,002 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { upperFirst } from 'lodash'; | ||
import React from 'react'; | ||
import styled, { ThemeProvider } from 'styled-components'; | ||
import theme, { prop } from '../client/theme'; | ||
|
||
const PreviewArea = styled.div` | ||
background: ${prop('backgroundColor')}; | ||
flex-grow: 1; | ||
padding: 2rem; | ||
& > h4 { | ||
margin-top: 0; | ||
color: ${prop('primaryTextColor')}; | ||
} | ||
`; | ||
|
||
const themeKeys = Object.keys(theme); | ||
|
||
export const withThemeProvider = (Story, context) => { | ||
const setting = context.globals.theme; | ||
if (setting === 'all') { | ||
return ( | ||
<div style={{ display: 'flex', flexWrap: 'wrap' }}> | ||
{Object.keys(theme).map((themeName) => ( | ||
<ThemeProvider theme={theme[themeName]} key={themeName}> | ||
<PreviewArea className={themeName}> | ||
<h4>{upperFirst(themeName)}</h4> | ||
<Story /> | ||
</PreviewArea> | ||
</ThemeProvider> | ||
))} | ||
</div> | ||
); | ||
} else { | ||
const themeName = setting; | ||
return ( | ||
<ThemeProvider theme={theme[themeName]}> | ||
<PreviewArea className={themeName}> | ||
<Story /> | ||
</PreviewArea> | ||
</ThemeProvider> | ||
); | ||
} | ||
}; | ||
|
||
export const themeToolbarItem = { | ||
description: 'Global theme for components', | ||
defaultValue: 'all', | ||
toolbar: { | ||
title: 'Theme', | ||
icon: 'mirror', | ||
items: [...themeKeys, 'all'] | ||
} | ||
}; |
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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import React, { useState } from 'react'; | ||
import classNames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const SkipLink = ({ targetId, text }) => { | ||
const [focus, setFocus] = useState(false); | ||
const { t } = useTranslation(); | ||
const handleFocus = () => { | ||
setFocus(true); | ||
}; | ||
|
||
const handleBlur = () => { | ||
setFocus(false); | ||
}; | ||
const linkClasses = classNames('skip_link', { focus }); | ||
|
||
return ( | ||
<a | ||
href={`#${targetId}`} | ||
className={linkClasses} | ||
onFocus={handleFocus} | ||
onBlur={handleBlur} | ||
> | ||
{t(`SkipLink.${text}`)} | ||
</a> | ||
); | ||
}; | ||
|
||
SkipLink.propTypes = { | ||
targetId: PropTypes.string.isRequired, | ||
text: PropTypes.string.isRequired | ||
}; | ||
|
||
export default SkipLink; |
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 |
---|---|---|
@@ -1,29 +1,24 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import browserHistory from '../browserHistory'; | ||
import { useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useHistory } from 'react-router-dom'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const RedirectToUser = ({ username, url = '/:username/sketches' }) => { | ||
React.useEffect(() => { | ||
if (username == null) { | ||
return; | ||
const RedirectToUser = ({ url = '/:username/sketches' }) => { | ||
const history = useHistory(); | ||
const username = useSelector((state) => | ||
state.user ? state.user.username : null | ||
); | ||
useEffect(() => { | ||
if (username) { | ||
history.replace(url.replace(':username', username)); | ||
} | ||
|
||
browserHistory.replace(url.replace(':username', username)); | ||
}, [username]); | ||
}, [history, url, username]); | ||
|
||
return null; | ||
}; | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
username: state.user ? state.user.username : null | ||
}; | ||
} | ||
|
||
const ConnectedRedirectToUser = connect(mapStateToProps)(RedirectToUser); | ||
|
||
const createRedirectWithUsername = (url) => (props) => ( | ||
<ConnectedRedirectToUser {...props} url={url} /> | ||
); | ||
RedirectToUser.propTypes = { | ||
url: PropTypes.string.isRequired | ||
}; | ||
|
||
export default createRedirectWithUsername; | ||
export default RedirectToUser; |
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.