mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-19 09:37:43 +02:00
refactor(theme-classic): avoid using clsx class dict with CSS modules (#6891)
This commit is contained in:
parent
2648ec090e
commit
e08777c9c5
10 changed files with 45 additions and 44 deletions
|
@ -132,9 +132,7 @@ export default function BackToTopButton(): JSX.Element {
|
||||||
'clean-btn',
|
'clean-btn',
|
||||||
ThemeClassNames.common.backToTopButton,
|
ThemeClassNames.common.backToTopButton,
|
||||||
styles.backToTopButton,
|
styles.backToTopButton,
|
||||||
{
|
show && styles.backToTopButtonShow,
|
||||||
[styles.backToTopButtonShow!]: show,
|
|
||||||
},
|
|
||||||
)}
|
)}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => smoothScrollTop()}
|
onClick={() => smoothScrollTop()}
|
||||||
|
|
|
@ -112,9 +112,10 @@ export default function BlogPostItem(props: Props): JSX.Element {
|
||||||
|
|
||||||
{(tagsExists || truncated) && (
|
{(tagsExists || truncated) && (
|
||||||
<footer
|
<footer
|
||||||
className={clsx('row docusaurus-mt-lg', {
|
className={clsx(
|
||||||
[styles.blogPostDetailsFull!]: isBlogPostPage,
|
'row docusaurus-mt-lg',
|
||||||
})}>
|
isBlogPostPage && styles.blogPostDetailsFull,
|
||||||
|
)}>
|
||||||
{tagsExists && (
|
{tagsExists && (
|
||||||
<div className={clsx('col', {'col--9': truncatedPost})}>
|
<div className={clsx('col', {'col--9': truncatedPost})}>
|
||||||
<TagsListInline tags={tags} />
|
<TagsListInline tags={tags} />
|
||||||
|
|
|
@ -31,11 +31,13 @@ function ColorModeToggle({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(styles.toggle, className, {
|
className={clsx(
|
||||||
[styles.toggleChecked!]: checked,
|
styles.toggle,
|
||||||
[styles.toggleFocused!]: focused,
|
className,
|
||||||
[styles.toggleDisabled!]: !isBrowser,
|
checked && styles.toggleChecked,
|
||||||
})}>
|
focused && styles.toggleFocused,
|
||||||
|
!isBrowser && styles.toggleDisabled,
|
||||||
|
)}>
|
||||||
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
|
||||||
<div
|
<div
|
||||||
className={styles.toggleButton}
|
className={styles.toggleButton}
|
||||||
|
|
|
@ -53,10 +53,7 @@ export default function DocItem(props: Props): JSX.Element {
|
||||||
<Seo {...{title, description, keywords, image}} />
|
<Seo {...{title, description, keywords, image}} />
|
||||||
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div
|
<div className={clsx('col', !hideTableOfContents && styles.docItemCol)}>
|
||||||
className={clsx('col', {
|
|
||||||
[styles.docItemCol!]: !hideTableOfContents,
|
|
||||||
})}>
|
|
||||||
<DocVersionBanner />
|
<DocVersionBanner />
|
||||||
<div className={styles.docItemContainer}>
|
<div className={styles.docItemContainer}>
|
||||||
<article>
|
<article>
|
||||||
|
|
|
@ -70,9 +70,7 @@ function DocPageContent({
|
||||||
className={clsx(
|
className={clsx(
|
||||||
ThemeClassNames.docs.docSidebarContainer,
|
ThemeClassNames.docs.docSidebarContainer,
|
||||||
styles.docSidebarContainer,
|
styles.docSidebarContainer,
|
||||||
{
|
hiddenSidebarContainer && styles.docSidebarContainerHidden,
|
||||||
[styles.docSidebarContainerHidden!]: hiddenSidebarContainer,
|
|
||||||
},
|
|
||||||
)}
|
)}
|
||||||
onTransitionEnd={(e) => {
|
onTransitionEnd={(e) => {
|
||||||
if (
|
if (
|
||||||
|
@ -122,17 +120,16 @@ function DocPageContent({
|
||||||
</aside>
|
</aside>
|
||||||
)}
|
)}
|
||||||
<main
|
<main
|
||||||
className={clsx(styles.docMainContainer, {
|
className={clsx(
|
||||||
[styles.docMainContainerEnhanced!]:
|
styles.docMainContainer,
|
||||||
hiddenSidebarContainer || !sidebar,
|
(hiddenSidebarContainer || !sidebar) &&
|
||||||
})}>
|
styles.docMainContainerEnhanced,
|
||||||
|
)}>
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'container padding-top--md padding-bottom--lg',
|
'container padding-top--md padding-bottom--lg',
|
||||||
styles.docItemWrapper,
|
styles.docItemWrapper,
|
||||||
{
|
hiddenSidebarContainer && styles.docItemWrapperEnhanced,
|
||||||
[styles.docItemWrapperEnhanced!]: hiddenSidebarContainer,
|
|
||||||
},
|
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,10 +25,12 @@ function AnchorHeading({as: As, id, ...props}: Props) {
|
||||||
return (
|
return (
|
||||||
<As
|
<As
|
||||||
{...props}
|
{...props}
|
||||||
className={clsx('anchor', {
|
className={clsx(
|
||||||
[styles.anchorWithHideOnScrollNavbar!]: hideOnScroll,
|
'anchor',
|
||||||
[styles.anchorWithStickyNavbar!]: !hideOnScroll,
|
hideOnScroll
|
||||||
})}
|
? styles.anchorWithHideOnScrollNavbar
|
||||||
|
: styles.anchorWithStickyNavbar,
|
||||||
|
)}
|
||||||
id={id}>
|
id={id}>
|
||||||
{props.children}
|
{props.children}
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -237,13 +237,19 @@ export default function Navbar(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
ref={navbarRef}
|
ref={navbarRef}
|
||||||
className={clsx('navbar', 'navbar--fixed-top', {
|
className={clsx(
|
||||||
'navbar--dark': style === 'dark',
|
'navbar',
|
||||||
'navbar--primary': style === 'primary',
|
'navbar--fixed-top',
|
||||||
'navbar-sidebar--show': mobileSidebar.shown,
|
hideOnScroll && [
|
||||||
[styles.navbarHideable!]: hideOnScroll,
|
styles.navbarHideable,
|
||||||
[styles.navbarHidden!]: hideOnScroll && !isNavbarVisible,
|
!isNavbarVisible && styles.navbarHidden,
|
||||||
})}>
|
],
|
||||||
|
{
|
||||||
|
'navbar--dark': style === 'dark',
|
||||||
|
'navbar--primary': style === 'primary',
|
||||||
|
'navbar-sidebar--show': mobileSidebar.shown,
|
||||||
|
},
|
||||||
|
)}>
|
||||||
<div className="navbar__inner">
|
<div className="navbar__inner">
|
||||||
<div className="navbar__items">
|
<div className="navbar__items">
|
||||||
{(items?.length > 0 || activeDocPlugin) && (
|
{(items?.length > 0 || activeDocPlugin) && (
|
||||||
|
|
|
@ -27,9 +27,7 @@ export default function TOCCollapsible({
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
styles.tocCollapsible,
|
styles.tocCollapsible,
|
||||||
{
|
!collapsed && styles.tocCollapsibleExpanded,
|
||||||
[styles.tocCollapsibleExpanded!]: !collapsed,
|
|
||||||
},
|
|
||||||
className,
|
className,
|
||||||
)}>
|
)}>
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -18,10 +18,10 @@ export default function Tag(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
href={permalink}
|
href={permalink}
|
||||||
className={clsx(styles.tag, {
|
className={clsx(
|
||||||
[styles.tagRegular!]: !count,
|
styles.tag,
|
||||||
[styles.tagWithCount!]: count,
|
count ? styles.tagWithCount : styles.tagRegular,
|
||||||
})}>
|
)}>
|
||||||
{name}
|
{name}
|
||||||
{count && <span>{count}</span>}
|
{count && <span>{count}</span>}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default function Details({
|
||||||
data-collapsed={collapsed}
|
data-collapsed={collapsed}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
styles.details,
|
styles.details,
|
||||||
{[styles.isBrowser!]: isBrowser},
|
isBrowser && styles.isBrowser,
|
||||||
props.className,
|
props.className,
|
||||||
)}
|
)}
|
||||||
onMouseDown={(e) => {
|
onMouseDown={(e) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue