-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Use stable context API (#13477)
* [docs] Use stable context API * let's merge * seb review
- Loading branch information
1 parent
f5b38db
commit ac1e742
Showing
8 changed files
with
331 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Button from '@material-ui/core/Button'; | ||
import PageContext from 'docs/src/modules/components/PageContext'; | ||
|
||
function EditPage(props) { | ||
const { markdownLocation, sourceCodeRootUrl } = props; | ||
|
||
return ( | ||
<PageContext.Consumer> | ||
{({ userLanguage }) => { | ||
if (userLanguage === 'zh') { | ||
return ( | ||
<Button component="a" href="https://translate.material-ui.com/project/material-ui-docs"> | ||
{'将此页面翻译成中文'} | ||
</Button> | ||
); | ||
} | ||
|
||
return ( | ||
<Button component="a" href={`${sourceCodeRootUrl}${markdownLocation}`}> | ||
{'Edit this page'} | ||
</Button> | ||
); | ||
}} | ||
</PageContext.Consumer> | ||
); | ||
} | ||
|
||
EditPage.propTypes = { | ||
markdownLocation: PropTypes.string.isRequired, | ||
sourceCodeRootUrl: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default EditPage; |
Oops, something went wrong.