-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add Web Share Target support
- Loading branch information
Showing
5 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react' | ||
import { RouteComponentProps } from 'react-router-dom' | ||
|
||
import Page from '../common/Page' | ||
import { URLRegExp } from '../common/helpers' | ||
import ButtonIcon from '../common/ButtonIcon' | ||
import AddArticleForm from './components/AddArticleForm' | ||
|
||
type AllProps = RouteComponentProps | ||
|
||
export default ({ location, history }: AllProps) => { | ||
const params = new URLSearchParams(location.search) | ||
|
||
let value = "" | ||
if (params.has('url')) { | ||
value = params.get('url')! | ||
} else if (params.has('text') || params.has('title')) { | ||
const text = params.get('text') || params.get('title')! | ||
if (URLRegExp.test(text)) { | ||
value = text | ||
} else { | ||
const matches = text.match(/\bhttps?:\/\/\S+/gi) | ||
if (matches && URLRegExp.test(matches[0])) { | ||
value = matches[0] | ||
} | ||
} | ||
} | ||
|
||
const redirect = () => history.replace("/unread") | ||
|
||
return ( | ||
<Page title="Add new article" | ||
actions={ | ||
<ButtonIcon | ||
to="/unread" | ||
icon="arrow_back" | ||
title="back to the list" | ||
/> | ||
}> | ||
<AddArticleForm value={value} onCancel={redirect} onSuccess={redirect} /> | ||
</Page> | ||
) | ||
} |
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,17 +1,19 @@ | ||
import React from 'react' | ||
import { RouteComponentProps, Route, Switch } from 'react-router-dom' | ||
|
||
import { ConnectedReduxProps } from '../store' | ||
|
||
import ArticlesPage from './ArticlesPage' | ||
import ArticlePage from './ArticlePage' | ||
|
||
import { ConnectedReduxProps } from '../store' | ||
import AddArticlePage from './AddArticlePage' | ||
|
||
// Combine both state + dispatch props - as well as any props we want to pass - in a union type. | ||
type AllProps = RouteComponentProps<{}> & ConnectedReduxProps | ||
|
||
export default ({match}: AllProps) => ( | ||
<Switch> | ||
<Route exact path={match.path + '/'} component={ArticlesPage} /> | ||
<Route exact path={match.path + '/add'} component={AddArticlePage} /> | ||
<Route path={match.path + '/:id'} component={ArticlePage} /> | ||
</Switch> | ||
) |
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