-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into add-window-provider…
…-update
- Loading branch information
Showing
107 changed files
with
2,573 additions
and
1,099 deletions.
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
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
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
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,94 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import useBrokenLinks from '@docusaurus/useBrokenLinks'; | ||
import { Props as HeadingProps } from '@theme/Heading'; | ||
import { | ||
EuiTitle, | ||
EuiButtonIcon, | ||
UseEuiTheme, | ||
EuiTitleProps, | ||
useEuiMemoizedStyles, | ||
} from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
|
||
const TAG_TO_TITLE_SIZE_MAP: Record<string, EuiTitleProps['size']> = { | ||
h6: 'xxxs', | ||
h5: 'xxs', | ||
h4: 'xs', | ||
h3: 's', | ||
h2: 'm', | ||
h1: 'l', | ||
}; | ||
|
||
const getHeadingStyles = ({ euiTheme }: UseEuiTheme) => ({ | ||
heading: css` | ||
margin-block-start: calc(var(--eui-theme-content-vertical-spacing) * 2.5); | ||
margin-block-end: var(--eui-theme-content-vertical-spacing); | ||
scroll-margin-block-start: calc(var(--ifm-navbar-height) + 1rem); | ||
&:first-child { | ||
margin-block-start: var(--eui-theme-content-vertical-spacing); | ||
} | ||
`, | ||
|
||
anchor: css` | ||
margin-inline-start: ${euiTheme.size.s}; | ||
opacity: 0; | ||
&:focus, | ||
.heading:hover & { | ||
opacity: 1; | ||
} | ||
`, | ||
}); | ||
|
||
const Heading = ({ | ||
as: Component, | ||
children, | ||
id, | ||
...restProps | ||
}: HeadingProps) => { | ||
const brokenLinks = useBrokenLinks(); | ||
const styles = useEuiMemoizedStyles(getHeadingStyles); | ||
|
||
brokenLinks.collectAnchor(id); | ||
|
||
const anchorTitle = `Direct link to ${ | ||
typeof children === 'string' ? children : id | ||
}`; | ||
|
||
// We don't want to show section links on document title headings | ||
const shouldShowSectionLink = Component !== 'h1'; | ||
|
||
return ( | ||
<EuiTitle size={TAG_TO_TITLE_SIZE_MAP[Component]}> | ||
<Component | ||
{...restProps} | ||
className="heading anchor" | ||
css={styles.heading} | ||
id={id} | ||
> | ||
{children} | ||
{shouldShowSectionLink && ( | ||
<EuiButtonIcon | ||
css={styles.anchor} | ||
href={`#${id}`} | ||
aria-label={anchorTitle} | ||
title={anchorTitle} | ||
iconType="link" | ||
color="text" | ||
size="xs" | ||
/> | ||
)} | ||
</Component> | ||
</EuiTitle> | ||
); | ||
}; | ||
|
||
export default Heading; |
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
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
38 changes: 12 additions & 26 deletions
38
packages/docusaurus-theme/src/theme/MDXComponents/Heading.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 |
---|---|---|
@@ -1,29 +1,15 @@ | ||
import OriginalHeading from '@theme-init/MDXComponents/Heading'; | ||
import type HeadingType from '@theme-init/MDXComponents/Heading'; | ||
import type { WrapperProps } from '@docusaurus/types'; | ||
import { EuiTitle, EuiTitleSize } from '@elastic/eui'; | ||
import { FunctionComponent } from 'react'; | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
type Props = WrapperProps<typeof HeadingType>; | ||
import Heading, { Props as HeadingProps } from '@theme/Heading'; | ||
|
||
const SIZE_TO_LEVEL_MAP: Record<string, EuiTitleSize> = { | ||
h6: 'xxxs', | ||
h5: 'xxs', | ||
h4: 'xs', | ||
h3: 's', | ||
h2: 'm', | ||
h1: 'l', | ||
}; | ||
const MDXHeading = (props: HeadingProps): JSX.Element => ( | ||
<Heading {...props} /> | ||
); | ||
|
||
const Heading: FunctionComponent<Omit<Props, 'as'> & { as: string }> = ({ | ||
as, | ||
...rest | ||
}): JSX.Element => { | ||
return ( | ||
<EuiTitle size={SIZE_TO_LEVEL_MAP[as]}> | ||
<OriginalHeading as={as} {...rest} /> | ||
</EuiTitle> | ||
); | ||
}; | ||
|
||
export default Heading; | ||
export default MDXHeading; |
20 changes: 20 additions & 0 deletions
20
packages/docusaurus-theme/src/theme/MDXComponents/ListItem.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,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { HTMLAttributes } from 'react'; | ||
import { EuiText } from '@elastic/eui'; | ||
|
||
export const ListItem = ({ children, ...props }: HTMLAttributes<HTMLLIElement>) => { | ||
return ( | ||
<li> | ||
<EuiText size="m"> | ||
{children} | ||
</EuiText> | ||
</li> | ||
); | ||
}; |
Oops, something went wrong.