Hiding content that requires JS when JS is disabled

This commit is contained in:
Jeff Avallone 2019-01-16 06:50:55 -05:00
parent c7ea0659f4
commit f0233ee030
6 changed files with 29 additions and 4 deletions

View File

@ -3,6 +3,7 @@
exports[`Form rendering 1`] = ` exports[`Form rendering 1`] = `
<div <div
className="form" className="form"
data-requires-js={true}
> >
<form <form
onSubmit={[Function]} onSubmit={[Function]}

View File

@ -53,7 +53,7 @@ class Form extends React.PureComponent {
} = this.props; } = this.props;
const { expr, syntax } = this.state; const { expr, syntax } = this.state;
return <div className={ style.form }> return <div className={ style.form } data-requires-js>
<form onSubmit={ this.handleSubmit }> <form onSubmit={ this.handleSubmit }>
<textarea <textarea
name="expr" name="expr"

View File

@ -39,7 +39,9 @@ exports[`Header rendering 1`] = `
</WithMergedOptions(TransComponent)> </WithMergedOptions(TransComponent)>
</mockConstructor> </mockConstructor>
</li> </li>
<li> <li
data-requires-js={true}
>
<LoadNamespace(LocaleSwitcher) /> <LoadNamespace(LocaleSwitcher) />
</li> </li>
</ul> </ul>
@ -85,7 +87,9 @@ exports[`Header rendering with no banner 1`] = `
</WithMergedOptions(TransComponent)> </WithMergedOptions(TransComponent)>
</mockConstructor> </mockConstructor>
</li> </li>
<li> <li
data-requires-js={true}
>
<LoadNamespace(LocaleSwitcher) /> <LoadNamespace(LocaleSwitcher) />
</li> </li>
</ul> </ul>

View File

@ -31,7 +31,7 @@ export const Header = ({ banner }) => (
<Trans>Privacy Policy</Trans> <Trans>Privacy Policy</Trans>
</Link> </Link>
</li> </li>
<li> <li data-requires-js>
<LocaleSwitcher /> <LocaleSwitcher />
</li> </li>
</ul> </ul>

View File

@ -2,6 +2,17 @@
exports[`Layout rendering 1`] = ` exports[`Layout rendering 1`] = `
<SentryBoundary> <SentryBoundary>
<noscript>
<style
type="text/css"
>
[data-requires-js] {
display: none !important;
}
</style>
</noscript>
<LoadNamespace(Header) <LoadNamespace(Header)
banner="Test Banner" banner="Test Banner"
/> />

View File

@ -17,7 +17,16 @@ const query = graphql`
} }
`; `;
const noscriptStyle = `
[data-requires-js] {
display: none !important;
}
`;
export const Layout = ({ banner, buildId, children }) => <SentryBoundary> export const Layout = ({ banner, buildId, children }) => <SentryBoundary>
<noscript>
<style type="text/css">{ noscriptStyle }</style>
</noscript>
<Header banner={ banner } /> <Header banner={ banner } />
<SentryBoundary> <SentryBoundary>
{ children } { children }