mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-29 17:07:08 +02:00
refactor(theme-classic): fix a few margin inconsistencies (#7129)
* refactor(theme-classic): minor fixes and improvements * Fixes after review * Reset spacing for all children inside browser window
This commit is contained in:
parent
7941a46be3
commit
d5cfa5b7cf
13 changed files with 46 additions and 13 deletions
|
@ -176,6 +176,7 @@ declare module '@theme/DocCardList' {
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
readonly items: PropSidebarItem[];
|
readonly items: PropSidebarItem[];
|
||||||
|
readonly className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DocCardList(props: Props): JSX.Element;
|
export default function DocCardList(props: Props): JSX.Element;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
.sidebarItemLink {
|
.sidebarItemLink {
|
||||||
color: var(--ifm-font-color-base);
|
color: var(--ifm-font-color-base);
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebarItemLink:hover {
|
.sidebarItemLink:hover {
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
import DocCard from '@theme/DocCard';
|
import DocCard from '@theme/DocCard';
|
||||||
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
||||||
import {findFirstCategoryLink} from '@docusaurus/theme-common';
|
import {findFirstCategoryLink} from '@docusaurus/theme-common';
|
||||||
|
import type {Props} from '@theme/DocCardList';
|
||||||
|
|
||||||
// Filter categories that don't have a link.
|
// Filter categories that don't have a link.
|
||||||
function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
|
function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
|
||||||
|
@ -21,13 +23,9 @@ function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DocCardList({
|
export default function DocCardList({items, className}: Props): JSX.Element {
|
||||||
items,
|
|
||||||
}: {
|
|
||||||
items: PropSidebarItem[];
|
|
||||||
}): JSX.Element {
|
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className={clsx('row', className)}>
|
||||||
{filterItems(items).map((item, index) => (
|
{filterItems(items).map((item, index) => (
|
||||||
<article key={index} className="col col--6 margin-bottom--lg">
|
<article key={index} className="col col--6 margin-bottom--lg">
|
||||||
<DocCard key={index} item={item} />
|
<DocCard key={index} item={item} />
|
||||||
|
|
|
@ -61,7 +61,7 @@ function DocCategoryGeneratedIndexPageContent({
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
<main className="margin-top--lg">
|
<main className="margin-top--lg">
|
||||||
<DocCardList items={category.items} />
|
<DocCardList items={category.items} className={styles.list} />
|
||||||
</main>
|
</main>
|
||||||
<footer className="margin-top--lg">
|
<footer className="margin-top--lg">
|
||||||
<DocPaginator
|
<DocPaginator
|
||||||
|
|
|
@ -16,3 +16,7 @@
|
||||||
--ifm-h1-font-size: 3rem;
|
--ifm-h1-font-size: 3rem;
|
||||||
margin-bottom: calc(1.25 * var(--ifm-leading));
|
margin-bottom: calc(1.25 * var(--ifm-leading));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list article:nth-last-child(-n + 2) {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
|
@ -20,3 +20,9 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.tocMobile {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default function LocaleDropdownNavbarItem({
|
||||||
label={
|
label={
|
||||||
<span>
|
<span>
|
||||||
<IconLanguage className={styles.iconLanguage} />
|
<IconLanguage className={styles.iconLanguage} />
|
||||||
<span>{dropdownLabel}</span>
|
{dropdownLabel}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
items={items}
|
items={items}
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type {Props} from '@theme/TabItem';
|
import type {Props} from '@theme/TabItem';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
export default function TabItem({
|
export default function TabItem({
|
||||||
children,
|
children,
|
||||||
|
@ -14,7 +17,10 @@ export default function TabItem({
|
||||||
className,
|
className,
|
||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div role="tabpanel" {...{hidden, className}}>
|
<div
|
||||||
|
role="tabpanel"
|
||||||
|
className={clsx(styles.tabItem, className)}
|
||||||
|
{...{hidden}}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.tabItem > *:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
|
@ -141,7 +141,7 @@ function TabsComponent(props: Props): JSX.Element {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="tabs-container">
|
<div className={clsx('tabs-container', styles.tabList)}>
|
||||||
<ul
|
<ul
|
||||||
role="tablist"
|
role="tablist"
|
||||||
aria-orientation="horizontal"
|
aria-orientation="horizontal"
|
||||||
|
@ -181,10 +181,10 @@ function TabsComponent(props: Props): JSX.Element {
|
||||||
children.filter(
|
children.filter(
|
||||||
(tabItem) => tabItem.props.value === selectedValue,
|
(tabItem) => tabItem.props.value === selectedValue,
|
||||||
)[0]!,
|
)[0]!,
|
||||||
{className: 'margin-vert--md'},
|
{className: 'margin-top--md'},
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<div className="margin-vert--md">
|
<div className="margin-top--md">
|
||||||
{children.map((tabItem, i) =>
|
{children.map((tabItem, i) =>
|
||||||
cloneElement(tabItem, {
|
cloneElement(tabItem, {
|
||||||
key: i,
|
key: i,
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
.tabList {
|
||||||
|
margin-bottom: var(--ifm-leading);
|
||||||
|
}
|
||||||
|
|
||||||
.tabItem {
|
.tabItem {
|
||||||
margin-top: 0 !important;
|
margin-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,3 +56,7 @@ CSS variables, meant to be overridden by final theme
|
||||||
border-top: 1px solid var(--docusaurus-details-decoration-color);
|
border-top: 1px solid var(--docusaurus-details-decoration-color);
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.collapsibleContent > *:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
|
@ -115,7 +115,6 @@ It is also possible to provide `values` and `defaultValue` props to `Tabs`:
|
||||||
<TabItem value="banana" label="Banana 2" default>This is a banana 🍌</TabItem>
|
<TabItem value="banana" label="Banana 2" default>This is a banana 🍌</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</BrowserWindow>
|
</BrowserWindow>
|
||||||
<br/>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue