-
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.
[New docs] Global site and docusaurus theme improvements (#8093)
- Loading branch information
Showing
30 changed files
with
359 additions
and
113 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
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/actions_bar/actions_bar.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
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/actions_bar/index.ts
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 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { DemoActionsBar, type DemoActionsBarProps } from './actions_bar'; |
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/code_transformer.ts
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
17 changes: 17 additions & 0 deletions
17
packages/docusaurus-theme/src/components/demo/create_demo.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,17 @@ | ||
/* | ||
* 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 { Demo, DemoProps } from './demo'; | ||
|
||
/** | ||
* Creates a custom <Demo /> component with predefined props. | ||
*/ | ||
export const createDemo = | ||
(defaultProps: Partial<DemoProps>): typeof Demo => | ||
(props: DemoProps) => | ||
<Demo {...defaultProps} {...props} />; |
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
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/editor/index.ts
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 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { DemoEditor } from './editor'; |
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,2 +1,11 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { Demo, type DemoProps } from './demo'; | ||
export { DemoSource } from './source'; | ||
export { createDemo } from './create_demo'; |
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/preview/index.ts
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 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { DemoPreview } from './preview'; |
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
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/source/get_source_from_children.ts
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
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/source/index.ts
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 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { DemoSource, type DemoSourceProps } from './source'; |
8 changes: 8 additions & 0 deletions
8
packages/docusaurus-theme/src/components/demo/source/source.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
96 changes: 96 additions & 0 deletions
96
packages/docusaurus-theme/src/components/guideline/guideline.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,96 @@ | ||
import { PropsWithChildren, ReactNode, useMemo } from 'react'; | ||
import { | ||
EuiFlexItem, | ||
EuiSplitPanel, | ||
EuiPanelProps, | ||
useEuiMemoizedStyles, | ||
UseEuiTheme, | ||
} from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { GuidelineType } from './types'; | ||
import { GuidelineText } from './guideline_text'; | ||
|
||
export interface GuidelineProps extends PropsWithChildren { | ||
type: GuidelineType; | ||
text: string | ReactNode; | ||
panelPadding?: EuiPanelProps['paddingSize']; | ||
panelStyle?: EuiPanelProps['style']; | ||
} | ||
|
||
const getGuidelineStyles = ({ euiTheme }: UseEuiTheme) => ({ | ||
root: css` | ||
margin-block: var(--eui-theme-content-vertical-spacing); | ||
`, | ||
wrapper: css` | ||
border-block-end: 2px solid ${euiTheme.colors.lightShade}; | ||
`, | ||
wrapperDo: css` | ||
border-color: ${euiTheme.colors.success}; | ||
`, | ||
wrapperDont: css` | ||
border-color: ${euiTheme.colors.danger}; | ||
`, | ||
textWrapper: css` | ||
margin-block-start: var(--eui-size-xs); | ||
`, | ||
}); | ||
|
||
export const Guideline = ({ | ||
children, | ||
text, | ||
type = 'default', | ||
panelPadding = 'm', | ||
panelStyle, | ||
}: GuidelineProps) => { | ||
const styles = useEuiMemoizedStyles(getGuidelineStyles); | ||
|
||
const panelColor = useMemo((): EuiPanelProps['color'] => { | ||
if (type === 'do') { | ||
return 'success'; | ||
} | ||
|
||
if (type === 'dont') { | ||
return 'danger'; | ||
} | ||
|
||
return 'subdued'; | ||
}, [type]); | ||
|
||
const textElement = useMemo(() => { | ||
if (typeof text === 'string') { | ||
return <GuidelineText type={type}>{text}</GuidelineText>; | ||
} | ||
|
||
return text; | ||
}, [text]); | ||
|
||
const wrapperStyles = [ | ||
styles.wrapper, | ||
type === 'do' && styles.wrapperDo, | ||
type === 'dont' && styles.wrapperDont, | ||
]; | ||
|
||
return ( | ||
<EuiFlexItem css={styles.root} style={{ flexBasis: 300 }}> | ||
<EuiSplitPanel.Outer | ||
color="transparent" | ||
hasBorder={false} | ||
hasShadow={false} | ||
> | ||
<figure> | ||
<EuiSplitPanel.Inner | ||
css={wrapperStyles} | ||
color={panelColor} | ||
paddingSize={panelPadding} | ||
style={panelStyle} | ||
> | ||
{children} | ||
</EuiSplitPanel.Inner> | ||
<EuiSplitPanel.Inner paddingSize="none" css={styles.textWrapper}> | ||
{textElement} | ||
</EuiSplitPanel.Inner> | ||
</figure> | ||
</EuiSplitPanel.Outer> | ||
</EuiFlexItem> | ||
); | ||
}; |
Oops, something went wrong.