-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Add ExpansionPanels TypeScript Demo #15162
Merged
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c7efe77
docs: Add breadcrumbs Typescript Demo
Adherentman fa9aacf
docs: yarn prettier breadcrumbs demo
Adherentman 86ba604
docs: format ts demo
Adherentman 7704ab5
docs: format code
Adherentman 851676d
docs: fix eslint
Adherentman 926b451
Merge branch 'next' of github.com:mui-org/material-ui into next
Adherentman 611b951
docs: format js
Adherentman fea3313
docs: update ts file
Adherentman 248dd19
docs: fix js file
Adherentman fc727d2
fix ts import order
Adherentman 169bfd3
docs: fix ts demo
Adherentman 755f00e
docs: yarn docs:typescript:formatted
Adherentman a9ec856
docs: fix lint
Adherentman 30faf84
docs: fix lint
Adherentman 5795fd7
fix lint
Adherentman 97bb2ac
fix link error
Adherentman ae018fe
docs: fix eslint and ts type error
Adherentman b750901
Merge branch 'next' of github.com:mui-org/material-ui into next
Adherentman 2a6602f
docs: fix ts and js
Adherentman c406f0d
docs: Add ExpansionPanels TypeScript Demo
Adherentman a3559c0
docs: prettier tsx
Adherentman 7465dc6
docs: fix routerBreadcrumbs propTypes and list component
Adherentman 63eb35b
docs: yarn docs:typescript:formatted
Adherentman b250068
docs: fix ControlledExpansionPanels useState types
Adherentman 94050f4
Update docs/src/pages/demos/expansion-panels/ControlledExpansionPanel…
eps1lon 29f3ca4
docs: pull and yarn docs:typescript:formatted
Adherentman df45611
docs: Add ExpansionPanels TypeScript Demo
Adherentman 0e579a2
docs: prettier tsx
Adherentman 01c0dc6
docs: fix ControlledExpansionPanels useState types
Adherentman 4328f5e
Update docs/src/pages/demos/expansion-panels/ControlledExpansionPanel…
eps1lon 908c876
docs: pull and yarn docs:typescript:formatted
Adherentman b254a2c
Merge branch 'expansion-panels-ts' of github.com:Adherentman/material…
Adherentman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,57 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, Theme, createStyles, WithStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/core/Breadcrumbs'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Link from '@material-ui/core/Link'; | ||
|
||
interface CollapsedBreadcrumbsProps extends WithStyles<typeof styles> {} | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
justifyContent: 'center', | ||
flexWrap: 'wrap', | ||
}, | ||
paper: { | ||
padding: theme.spacing(1, 2), | ||
}, | ||
}); | ||
|
||
function handleClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CollapsedBreadcrumbs(props: CollapsedBreadcrumbsProps) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<Paper elevation={0} className={classes.paper}> | ||
<Breadcrumbs maxItems={2} aria-label="Breadcrumb"> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Home | ||
</Link> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Catalog | ||
</Link> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Accessories | ||
</Link> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
New Collection | ||
</Link> | ||
<Typography color="textPrimary">Belts</Typography> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
CollapsedBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
export default withStyles(styles)(CollapsedBreadcrumbs); |
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,76 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, Theme, createStyles, WithStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/core/Breadcrumbs'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Link from '@material-ui/core/Link'; | ||
import NavigateNextIcon from '@material-ui/icons/NavigateNext'; | ||
|
||
interface CustomSeparatorProps extends WithStyles<typeof styles> {} | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
justifyContent: 'center', | ||
flexWrap: 'wrap', | ||
}, | ||
paper: { | ||
padding: theme.spacing(1, 2), | ||
}, | ||
}); | ||
|
||
function handleClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CustomSeparator(props: CustomSeparatorProps) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Paper elevation={0} className={classes.paper}> | ||
<Breadcrumbs separator="›" aria-label="Breadcrumb"> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
<Link color="inherit" href="/getting-started/installation/" onClick={handleClick}> | ||
Core | ||
</Link> | ||
<Typography color="textPrimary">Breadcrumb</Typography> | ||
</Breadcrumbs> | ||
</Paper> | ||
<br /> | ||
<Paper elevation={0} className={classes.paper}> | ||
<Breadcrumbs separator="-" aria-label="Breadcrumb"> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
<Link color="inherit" href="/getting-started/installation/" onClick={handleClick}> | ||
Core | ||
</Link> | ||
<Typography color="textPrimary">Breadcrumb</Typography> | ||
</Breadcrumbs> | ||
</Paper> | ||
<br /> | ||
<Paper elevation={0} className={classes.paper}> | ||
<Breadcrumbs separator={<NavigateNextIcon fontSize="small" />} aria-label="Breadcrumb"> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
<Link color="inherit" href="/getting-started/installation/" onClick={handleClick}> | ||
Core | ||
</Link> | ||
<Typography color="textPrimary">Breadcrumb</Typography> | ||
</Breadcrumbs> | ||
</Paper> | ||
</div> | ||
); | ||
} | ||
|
||
CustomSeparator.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
export default withStyles(styles)(CustomSeparator); |
89 changes: 89 additions & 0 deletions
89
docs/src/pages/demos/breadcrumbs/CustomizedBreadcrumbs.tsx
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,89 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, Theme, createStyles, WithStyles } from '@material-ui/core/styles'; | ||
import { emphasize } from '@material-ui/core/styles/colorManipulator'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/core/Breadcrumbs'; | ||
import Chip from '@material-ui/core/Chip'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import HomeIcon from '@material-ui/icons/Home'; | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; | ||
|
||
interface CustomBreadcrumbProps extends WithStyles<typeof styles> {} | ||
|
||
interface CustomizedBreadcrumbsProps extends WithStyles<typeof styles> {} | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
padding: theme.spacing(1), | ||
}, | ||
chip: { | ||
backgroundColor: theme.palette.grey[100], | ||
height: 24, | ||
color: theme.palette.grey[800], | ||
fontWeight: theme.typography.fontWeightRegular, | ||
'&:hover, &:focus': { | ||
backgroundColor: theme.palette.grey[300], | ||
}, | ||
'&:active': { | ||
boxShadow: theme.shadows[1], | ||
backgroundColor: emphasize(theme.palette.grey[300], 0.12), | ||
}, | ||
}, | ||
avatar: { | ||
background: 'none', | ||
marginRight: -theme.spacing(1.5), | ||
}, | ||
}); | ||
|
||
function handleClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CustomBreadcrumb(props: CustomBreadcrumbProps) { | ||
const { classes, ...rest } = props; | ||
return <Chip className={classes.chip} {...rest} />; | ||
} | ||
|
||
CustomBreadcrumb.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
const StyledBreadcrumb = withStyles(styles)(CustomBreadcrumb); | ||
|
||
function CustomizedBreadcrumbs(props: CustomizedBreadcrumbsProps) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<Paper elevation={0} className={classes.root}> | ||
<Breadcrumbs aria-label="Breadcrumb"> | ||
<StyledBreadcrumb | ||
component="a" | ||
href="#" | ||
label="Home" | ||
avatar={ | ||
<Avatar className={classes.avatar}> | ||
<HomeIcon /> | ||
</Avatar> | ||
} | ||
onClick={handleClick} | ||
/> | ||
<StyledBreadcrumb component="a" href="#" label="Catalog" onClick={handleClick} /> | ||
<StyledBreadcrumb | ||
label="Accessories" | ||
deleteIcon={<ExpandMoreIcon />} | ||
onClick={handleClick} | ||
onDelete={handleClick} | ||
/> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
CustomizedBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
export default withStyles(styles)(CustomizedBreadcrumbs); |
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,65 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, Theme, createStyles, WithStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Breadcrumbs from '@material-ui/core/Breadcrumbs'; | ||
import Link from '@material-ui/core/Link'; | ||
import HomeIcon from '@material-ui/icons/Home'; | ||
import WhatshotIcon from '@material-ui/icons/Whatshot'; | ||
import GrainIcon from '@material-ui/icons/Grain'; | ||
|
||
interface IconBreadcrumbsProps extends WithStyles<typeof styles> {} | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
padding: theme.spacing(1, 2), | ||
}, | ||
link: { | ||
display: 'flex', | ||
}, | ||
icon: { | ||
marginRight: theme.spacing(0.5), | ||
width: 20, | ||
height: 20, | ||
}, | ||
}); | ||
|
||
function handleClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function IconBreadcrumbs(props: IconBreadcrumbsProps) { | ||
const { classes } = props; | ||
return ( | ||
<Paper elevation={0} className={classes.root}> | ||
<Breadcrumbs aria-label="Breadcrumb"> | ||
<Link color="inherit" href="/" onClick={handleClick} className={classes.link}> | ||
<HomeIcon className={classes.icon} /> | ||
Material-UI | ||
</Link> | ||
<Link | ||
color="inherit" | ||
href="/getting-started/installation/" | ||
onClick={handleClick} | ||
className={classes.link} | ||
> | ||
<WhatshotIcon className={classes.icon} /> | ||
Core | ||
</Link> | ||
<Typography color="textPrimary" className={classes.link}> | ||
<GrainIcon className={classes.icon} /> | ||
Breadcrumb | ||
</Typography> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
IconBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
export default withStyles(styles)(IconBreadcrumbs); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something we could improve in the TypeScript to JavaScript logic generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to change the js file directly, but I can't pass this ci. what should i do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a topic for a different pull request. I was only raising the potential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's fine with prettier it's fine with me