Skip to content
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 SkipNav #15409

Merged
merged 9 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/src/modules/components/AppContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const styles = theme => ({
maxWidth: 'calc(100% - 175px)',
},
[theme.breakpoints.up('lg')]: {
paddingLeft: theme.spacing(1),
paddingRight: theme.spacing(5),
maxWidth: 'calc(100% - 240px - 175px)',
},
Expand All @@ -34,13 +33,16 @@ function AppContent(props) {
const { className, classes, children, disableToc } = props;

return (
<main
<Container
component="main"
id="main-content"
tabIndex="-1"
className={clsx(classes.root, className, {
[classes.disableToc]: disableToc,
})}
>
<Container>{children}</Container>
</main>
{children}
</Container>
);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function AppDrawer(props) {
);

return (
<nav className={className}>
<nav className={className} role="navigation" aria-label="Main navigation">
<Hidden lgUp={!disablePermanent} implementation="js">
<SwipeableDrawer
classes={{
Expand Down
2 changes: 2 additions & 0 deletions docs/src/modules/components/AppDrawerNavItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class AppDrawerNavItem extends React.Component {
const activeElement = document.querySelector(`.${this.props.classes.active}`);
if (activeElement && activeElement.scrollIntoView) {
activeElement.scrollIntoView({});
// Fix a Chrome issue, reset the tabbable ring back to the top of the document.
document.body.scrollIntoView({});
}
}

Expand Down
28 changes: 28 additions & 0 deletions docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import MenuIcon from '@material-ui/icons/Menu';
import LanguageIcon from '@material-ui/icons/Language';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import MuiLink from '@material-ui/core/Link';
import ColorsIcon from '@material-ui/icons/InvertColors';
import LightbulbOutlineIcon from '@material-ui/docs/svgIcons/LightbulbOutline';
import LightbulbFullIcon from '@material-ui/docs/svgIcons/LightbulbFull';
Expand Down Expand Up @@ -98,6 +99,25 @@ const styles = theme => ({
marginLeft: theme.spacing(2),
flex: '0 1 auto',
},
skipNav: {
position: 'fixed',
padding: theme.spacing(1),
backgroundColor: theme.palette.background.paper,
transition: theme.transitions.create('top', {
easing: theme.transitions.easing.easeIn,
duration: theme.transitions.duration.leavingScreen,
}),
left: theme.spacing(2),
top: theme.spacing(-6),
zIndex: theme.zIndex.tooltip + 1,
'&:focus': {
top: theme.spacing(2),
transition: theme.transitions.create('top', {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
},
},
appBar: {
transition: theme.transitions.create('width'),
'@media print': {
Expand All @@ -123,6 +143,11 @@ const styles = theme => ({
display: 'none',
},
},
'@global': {
'#main-content': {
outline: 'none',
},
},
});

class AppFrame extends React.Component {
Expand Down Expand Up @@ -197,6 +222,9 @@ class AppFrame extends React.Component {
<div className={classes.root}>
<NProgressBar />
<CssBaseline />
<MuiLink color="secondary" className={classes.skipNav} href="#main-content">
Skip to content
</MuiLink>
<Notifications />
<MarkdownLinks />
<AppBar className={appBarClassName}>
Expand Down
108 changes: 55 additions & 53 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const GettingStartedLink = React.forwardRef((props, ref) => {

class HomePage extends React.Component {
componentDidMount() {
if (window.location.hash !== '') {
if (window.location.hash !== '' && window.location.hash !== '#main=content') {
window.location.replace(`https://v0.material-ui.com/${window.location.hash}`);
}

Expand All @@ -120,58 +120,60 @@ class HomePage extends React.Component {
<AppFrame classes={{ drawer: classes.drawer }}>
<div className={classes.root}>
<Head />
<div className={classes.hero}>
<Container maxWidth="md" className={classes.content}>
<img
src="/static/images/material-ui-logo.svg"
alt="Material-UI Logo"
className={classes.logo}
/>
<div>
<Typography
variant="h3"
component="h1"
color="inherit"
gutterBottom
className={classes.title}
>
{'MATERIAL-UI'}
</Typography>
<Typography variant="h5" component="h2" color="inherit">
{t('strapline')}
</Typography>
<Button
component={GettingStartedLink}
className={classes.button}
variant="outlined"
color="primary"
>
{t('getStarted')}
</Button>
</div>
</Container>
</div>
<div className={classes.social}>
<a
className="github-button"
href="https://github.com/mui-org/material-ui"
data-icon="octicon-star"
data-show-count="true"
>
Star
</a>
<a
className="twitter-follow-button"
href="https://twitter.com/@materialui"
data-show-screen-name="false"
>
Follow
</a>
</div>
<HomeQuickWord />
<HomeSteps />
<HomeBackers />
<HomeUsers />
<main id="main-content" tabIndex="-1">
<div className={classes.hero}>
<Container maxWidth="md" className={classes.content}>
<img
src="/static/images/material-ui-logo.svg"
alt="Material-UI Logo"
className={classes.logo}
/>
<div>
<Typography
variant="h3"
component="h1"
color="inherit"
gutterBottom
className={classes.title}
>
{'MATERIAL-UI'}
</Typography>
<Typography variant="h5" component="h2" color="inherit">
{t('strapline')}
</Typography>
<Button
component={GettingStartedLink}
className={classes.button}
variant="outlined"
color="primary"
>
{t('getStarted')}
</Button>
</div>
</Container>
</div>
<div className={classes.social}>
<a
className="github-button"
href="https://github.com/mui-org/material-ui"
data-icon="octicon-star"
data-show-count="true"
>
Star
</a>
<a
className="twitter-follow-button"
href="https://twitter.com/@materialui"
data-show-screen-name="false"
>
Follow
</a>
</div>
<HomeQuickWord />
<HomeSteps />
<HomeBackers />
<HomeUsers />
</main>
<HomeFooter />
</div>
<script
Expand Down