forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Interoperability with react-jss (mui#8735)
- Loading branch information
1 parent
def1e0a
commit 023dcdb
Showing
7 changed files
with
90 additions
and
10 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,62 @@ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import injectSheet from 'react-jss/lib/injectSheet'; | ||
import Typography from 'material-ui/Typography'; | ||
|
||
// 1. We define the styles. | ||
const styles = theme => ({ | ||
root: { | ||
color: 'inherit', | ||
textDecoration: 'inherit', | ||
'&:hover': { | ||
textDecoration: 'underline', | ||
}, | ||
}, | ||
primary: { | ||
color: theme.palette.primary[500], | ||
}, | ||
}); | ||
|
||
function MyLink(props) { | ||
const { children, classes, className, variant, ...other } = props; | ||
|
||
return ( | ||
<a | ||
className={classNames( | ||
classes.root, | ||
{ | ||
[classes.primary]: variant === 'primary', | ||
}, | ||
className, | ||
)} | ||
{...other} | ||
> | ||
{children} | ||
</a> | ||
); | ||
} | ||
|
||
MyLink.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
classes: PropTypes.object.isRequired, | ||
className: PropTypes.string, | ||
variant: PropTypes.oneOf(['primary']), | ||
}; | ||
|
||
// 2. We inject the styles. | ||
const MyLinkStyled = injectSheet(styles)(MyLink); | ||
|
||
export default function CssInJs() { | ||
return ( | ||
<Typography type="subheading"> | ||
<MyLinkStyled href="#">MyLink</MyLinkStyled> | ||
{' - '} | ||
<MyLinkStyled href="#" variant="primary"> | ||
{'primary'} | ||
</MyLinkStyled> | ||
</Typography> | ||
); | ||
} |
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 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