@elastic/eui-docusaurus-theme 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,16 @@ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
8
8
  */
9
9
  import { useEffect, useState } from 'react';
10
10
  import { css } from '@emotion/react';
11
- import { FixedSizeList } from 'react-window';
12
- import { EuiButtonEmpty, euiFocusRing, EuiListGroupItem, EuiPopover, useEuiMemoizedStyles, } from '@elastic/eui';
11
+ import { EuiButtonEmpty, euiFocusRing, EuiListGroup, EuiListGroupItem, EuiPopover, useEuiMemoizedStyles, useEuiYScroll, } from '@elastic/eui';
13
12
  const getStyles = (euiThemeContext) => {
14
13
  const { euiTheme } = euiThemeContext;
15
14
  return {
16
15
  button: css `
17
16
  font-weight: ${euiTheme.font.weight.bold};
18
17
  color: ${euiTheme.colors.primary};
18
+ `,
19
+ list: css `
20
+ max-block-size: 200px;
19
21
  `,
20
22
  listItem: css `
21
23
  .euiListGroupItem__button:focus-visible {
@@ -67,13 +69,12 @@ export const VersionSwitcher = ({ ariaLabel, currentVersion, extraAction, previo
67
69
  return null;
68
70
  const latestVersion = allVersions[0];
69
71
  const button = (_jsxs(EuiButtonEmpty, { size: "s", color: "text", iconType: "chevronSingleDown", iconSide: "right", css: styles.button, onClick: () => setPopoverOpen((isOpen) => !isOpen), "aria-label": `${pronounceVersion(currentVersion)}. Click to switch versions`, children: ["v", currentVersion] }));
70
- return (_jsx(EuiPopover, { isOpen: isPopoverOpen, closePopover: () => setPopoverOpen(false), button: button, repositionOnScroll: true, panelPaddingSize: "xs", "aria-label": ariaLabel, children: _jsx(FixedSizeList, { className: "eui-yScroll", itemCount: allVersions.length, itemSize: 24, height: 200, width: 120, innerElementType: "ul", children: ({ index, style }) => {
71
- const version = allVersions[index];
72
+ return (_jsx(EuiPopover, { isOpen: isPopoverOpen, closePopover: () => setPopoverOpen(false), button: button, repositionOnScroll: true, panelPaddingSize: "xs", "aria-label": ariaLabel, children: _jsx(EuiListGroup, { css: [styles.list, useEuiYScroll()], children: allVersions.map((version) => {
72
73
  const isCurrentVersion = version === currentVersion;
73
74
  const screenReaderVersion = pronounceVersion(version);
74
75
  const url = version === latestVersion
75
76
  ? `${previousVersionUrl}/`
76
77
  : `${previousVersionUrl}/v${version}/`;
77
- return (_jsx(EuiListGroupItem, { css: styles.listItem, style: style, label: `v${version}`, "aria-label": screenReaderVersion, href: url, isActive: isCurrentVersion, color: isCurrentVersion ? 'primary' : 'text', extraAction: extraAction?.(version) }));
78
- } }) }));
78
+ return (_jsx(EuiListGroupItem, { css: styles.listItem, label: `v${version}`, "aria-label": screenReaderVersion, href: url, isActive: isCurrentVersion, color: isCurrentVersion ? 'primary' : 'text', extraAction: extraAction?.(version) }, version));
79
+ }) }) }));
79
80
  };
@@ -1,3 +1,3 @@
1
- import { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import type { Props } from '@theme-original/Logo';
3
3
  export default function Logo(props: Props): JSX.Element;
@@ -11,14 +11,16 @@ import { css } from '@emotion/react';
11
11
  import Link from '@docusaurus/Link';
12
12
  import useBaseUrl from '@docusaurus/useBaseUrl';
13
13
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
14
- import { useThemeConfig, } from '@docusaurus/theme-common';
15
- import { EuiImage, euiTextTruncate, useEuiMemoizedStyles, } from '@elastic/eui';
14
+ import { useThemeConfig } from '@docusaurus/theme-common';
15
+ import { EuiImage, euiCanAnimate, euiTextTruncate, useEuiMemoizedStyles, } from '@elastic/eui';
16
16
  import { AppThemeContext } from '../../components/theme_context';
17
+ const EUI_LOGO = 'eui_logo.svg';
18
+ const LOGO_DISTANCE = '5px';
17
19
  const getStyles = ({ euiTheme }) => ({
18
20
  wrapper: css `
19
- ${euiTextTruncate()}
20
21
  // create space to prevent focus outline from being cut off
21
22
  padding: ${euiTheme.size.xs};
23
+ min-inline-size: 0;
22
24
 
23
25
  @media (min-width: 997px) {
24
26
  border-right: ${euiTheme.border.thin};
@@ -27,7 +29,6 @@ const getStyles = ({ euiTheme }) => ({
27
29
  .navbar__brand {
28
30
  display: flex;
29
31
  align-items: center;
30
-
31
32
  margin-inline-end: ${euiTheme.size.m};
32
33
 
33
34
  @media (min-width: 997px) {
@@ -36,27 +37,80 @@ const getStyles = ({ euiTheme }) => ({
36
37
  }
37
38
 
38
39
  .navbar__logo {
39
- height: 100%;
40
+ overflow: visible;
41
+ height: auto;
42
+ }
43
+
44
+ .navbar__title {
45
+ ${euiTextTruncate()}
40
46
  }
41
47
  `,
42
48
  imageWrapper: css `
49
+ overflow: visible;
43
50
  margin-inline-end: ${euiTheme.size.m};
44
51
  `,
45
52
  image: css `
46
53
  position: relative;
54
+ display: block;
55
+ block-size: ${euiTheme.size.l};
56
+ inline-size: ${euiTheme.size.l};
57
+ margin: 0;
58
+ `,
59
+ logo: css `
60
+ display: block;
61
+ overflow: visible;
47
62
  block-size: ${euiTheme.size.l};
48
63
  inline-size: ${euiTheme.size.l};
49
64
  margin: 0;
65
+ // Firefox clips transformed SVG descendants to the viewport even
66
+ // with overflow: visible. Expand the clip so pieces can travel 5px.
67
+ @supports (-moz-appearance: none) {
68
+ clip-path: inset(-8px);
69
+ }
70
+
71
+ .euiNavbarLogo__piece {
72
+ transform: translate(0, 0);
73
+
74
+ ${euiCanAnimate} {
75
+ transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
76
+ }
77
+ }
78
+
79
+ ${euiCanAnimate} {
80
+ &:hover {
81
+ .euiNavbarLogo__pink {
82
+ transform: translate(-${LOGO_DISTANCE}, -${LOGO_DISTANCE});
83
+ }
84
+
85
+ .euiNavbarLogo__yellow {
86
+ transform: translate(${LOGO_DISTANCE}, ${LOGO_DISTANCE});
87
+ }
88
+
89
+ .euiNavbarLogo__teal {
90
+ transform: translate(${LOGO_DISTANCE}, -${LOGO_DISTANCE});
91
+ }
92
+
93
+ .euiNavbarLogo__blue {
94
+ transform: translate(-${LOGO_DISTANCE}, ${LOGO_DISTANCE});
95
+ }
96
+ }
97
+ }
50
98
  `,
51
99
  });
100
+ function EuiNavbarLogo({ alt, className, style, }) {
101
+ const styles = useEuiMemoizedStyles(getStyles);
102
+ const isDecorative = alt === '';
103
+ return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", fill: "none", overflow: "visible", className: className, style: style, css: styles.logo, "aria-hidden": isDecorative ? true : undefined, role: isDecorative ? undefined : 'img', "aria-label": isDecorative ? undefined : alt, children: [_jsx("path", { fill: "#FF957D", d: "M18 25c-.5-5.5-5.5-10.5-11-11l7-7c.5 5.5 5.5 10.5 11 11l-7 7z" }), _jsx("circle", { className: "euiNavbarLogo__piece euiNavbarLogo__pink", cx: "7", cy: "7", r: "7", fill: "#F04E98" }), _jsx("circle", { className: "euiNavbarLogo__piece euiNavbarLogo__yellow", cx: "25", cy: "25", r: "7", fill: "#FEC514" }), _jsx("path", { className: "euiNavbarLogo__piece euiNavbarLogo__teal", fill: "#00BFB3", d: "M31 14c-7.18 0-13-5.82-13-13h13v13z" }), _jsx("path", { className: "euiNavbarLogo__piece euiNavbarLogo__blue", fill: "#1BA9F5", d: "M1 18c7.18 0 13 5.82 13 13H1V18z" })] }));
104
+ }
52
105
  function LogoThemedImage({ logo, alt, imageClassName, }) {
53
106
  const { colorMode } = useContext(AppThemeContext);
54
107
  const isDarkMode = colorMode === 'dark';
55
108
  const styles = useEuiMemoizedStyles(getStyles);
109
+ const isEuiLogo = logo.src.includes(EUI_LOGO);
56
110
  const src = isDarkMode
57
111
  ? useBaseUrl(logo.srcDark || logo.src)
58
112
  : useBaseUrl(logo.src);
59
- const themedImage = (_jsx(EuiImage, { src: src, size: "fullWidth", alt: alt, className: logo.className, wrapperProps: {
113
+ const themedImage = isEuiLogo ? (_jsx(EuiNavbarLogo, { alt: alt, className: logo.className, style: logo.style })) : (_jsx(EuiImage, { src: src, size: "fullWidth", alt: alt, className: logo.className, wrapperProps: {
60
114
  style: logo.style,
61
115
  css: styles.image,
62
116
  } }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eui-docusaurus-theme",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "EUI theme for Docusaurus",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "scripts": {
@@ -40,19 +40,17 @@
40
40
  "@docusaurus/theme-common": "^3.7.0",
41
41
  "@docusaurus/utils-validation": "^3.7.0",
42
42
  "@elastic/datemath": "^5.0.3",
43
- "@elastic/eui": "^118.0.0",
43
+ "@elastic/eui": "^119.1.0",
44
44
  "@elastic/eui-theme-borealis": "^8.0.0",
45
45
  "@emotion/css": "^11.11.2",
46
46
  "@emotion/react": "^11.11.4",
47
- "@types/react-window": "^1.8.8",
48
47
  "clsx": "^2.1.1",
49
48
  "dedent": "^1.5.3",
50
49
  "lz-string": "^1.5.0",
51
50
  "moment": "^2.30.1",
52
51
  "prism-react-renderer": "^2.3.1",
53
52
  "react-is": "^18.3.1",
54
- "react-live": "patch:react-live@npm%3A4.1.7#~/.yarn/patches/react-live-npm-4.1.7-7b41625faa.patch",
55
- "react-window": "^1.8.10"
53
+ "react-live": "patch:react-live@npm%3A4.1.7#~/.yarn/patches/react-live-npm-4.1.7-7b41625faa.patch"
56
54
  },
57
55
  "peerDependencies": {
58
56
  "react": "^18.0.0",
@@ -8,13 +8,14 @@
8
8
 
9
9
  import { ComponentProps, useEffect, useState } from 'react';
10
10
  import { css } from '@emotion/react';
11
- import { FixedSizeList } from 'react-window';
12
11
  import {
13
12
  EuiButtonEmpty,
14
13
  euiFocusRing,
14
+ EuiListGroup,
15
15
  EuiListGroupItem,
16
16
  EuiPopover,
17
17
  useEuiMemoizedStyles,
18
+ useEuiYScroll,
18
19
  UseEuiTheme,
19
20
  } from '@elastic/eui';
20
21
 
@@ -26,6 +27,9 @@ const getStyles = (euiThemeContext: UseEuiTheme) => {
26
27
  font-weight: ${euiTheme.font.weight.bold};
27
28
  color: ${euiTheme.colors.primary};
28
29
  `,
30
+ list: css`
31
+ max-block-size: 200px;
32
+ `,
29
33
  listItem: css`
30
34
  .euiListGroupItem__button:focus-visible {
31
35
  // overriding the global "outset" style to ensure the focus style is not cut off
@@ -144,18 +148,10 @@ export const VersionSwitcher = ({
144
148
  panelPaddingSize="xs"
145
149
  aria-label={ariaLabel}
146
150
  >
147
- <FixedSizeList
148
- className="eui-yScroll"
149
- itemCount={allVersions.length}
150
- itemSize={24}
151
- height={200}
152
- width={120}
153
- innerElementType="ul"
154
- >
155
- {({ index, style }) => {
156
- const version = allVersions[index];
151
+ <EuiListGroup css={[styles.list, useEuiYScroll()]}>
152
+ {allVersions.map((version) => {
157
153
  const isCurrentVersion = version === currentVersion;
158
- const screenReaderVersion = pronounceVersion(version!);
154
+ const screenReaderVersion = pronounceVersion(version);
159
155
 
160
156
  const url =
161
157
  version === latestVersion
@@ -164,8 +160,8 @@ export const VersionSwitcher = ({
164
160
 
165
161
  return (
166
162
  <EuiListGroupItem
163
+ key={version}
167
164
  css={styles.listItem}
168
- style={style}
169
165
  label={`v${version}`}
170
166
  aria-label={screenReaderVersion}
171
167
  href={url}
@@ -174,8 +170,8 @@ export const VersionSwitcher = ({
174
170
  extraAction={extraAction?.(version)}
175
171
  />
176
172
  );
177
- }}
178
- </FixedSizeList>
173
+ })}
174
+ </EuiListGroup>
179
175
  </EuiPopover>
180
176
  );
181
177
  };
@@ -6,19 +6,16 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
 
9
- import { useContext, JSX } from 'react';
9
+ import { useContext, type CSSProperties, type JSX } from 'react';
10
10
  import { css } from '@emotion/react';
11
11
  import Link from '@docusaurus/Link';
12
12
  import useBaseUrl from '@docusaurus/useBaseUrl';
13
13
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
14
- import {
15
- useColorMode,
16
- useThemeConfig,
17
- type NavbarLogo,
18
- } from '@docusaurus/theme-common';
14
+ import { useThemeConfig, type NavbarLogo } from '@docusaurus/theme-common';
19
15
  import type { Props } from '@theme-original/Logo';
20
16
  import {
21
17
  EuiImage,
18
+ euiCanAnimate,
22
19
  euiTextTruncate,
23
20
  useEuiMemoizedStyles,
24
21
  UseEuiTheme,
@@ -26,11 +23,14 @@ import {
26
23
 
27
24
  import { AppThemeContext } from '../../components/theme_context';
28
25
 
26
+ const EUI_LOGO = 'eui_logo.svg';
27
+ const LOGO_DISTANCE = '5px';
28
+
29
29
  const getStyles = ({ euiTheme }: UseEuiTheme) => ({
30
30
  wrapper: css`
31
- ${euiTextTruncate()}
32
31
  // create space to prevent focus outline from being cut off
33
32
  padding: ${euiTheme.size.xs};
33
+ min-inline-size: 0;
34
34
 
35
35
  @media (min-width: 997px) {
36
36
  border-right: ${euiTheme.border.thin};
@@ -39,7 +39,6 @@ const getStyles = ({ euiTheme }: UseEuiTheme) => ({
39
39
  .navbar__brand {
40
40
  display: flex;
41
41
  align-items: center;
42
-
43
42
  margin-inline-end: ${euiTheme.size.m};
44
43
 
45
44
  @media (min-width: 997px) {
@@ -48,20 +47,124 @@ const getStyles = ({ euiTheme }: UseEuiTheme) => ({
48
47
  }
49
48
 
50
49
  .navbar__logo {
51
- height: 100%;
50
+ overflow: visible;
51
+ height: auto;
52
+ }
53
+
54
+ .navbar__title {
55
+ ${euiTextTruncate()}
52
56
  }
53
57
  `,
54
58
  imageWrapper: css`
59
+ overflow: visible;
55
60
  margin-inline-end: ${euiTheme.size.m};
56
61
  `,
57
62
  image: css`
58
63
  position: relative;
64
+ display: block;
59
65
  block-size: ${euiTheme.size.l};
60
66
  inline-size: ${euiTheme.size.l};
61
67
  margin: 0;
62
68
  `,
69
+ logo: css`
70
+ display: block;
71
+ overflow: visible;
72
+ block-size: ${euiTheme.size.l};
73
+ inline-size: ${euiTheme.size.l};
74
+ margin: 0;
75
+ // Firefox clips transformed SVG descendants to the viewport even
76
+ // with overflow: visible. Expand the clip so pieces can travel 5px.
77
+ @supports (-moz-appearance: none) {
78
+ clip-path: inset(-8px);
79
+ }
80
+
81
+ .euiNavbarLogo__piece {
82
+ transform: translate(0, 0);
83
+
84
+ ${euiCanAnimate} {
85
+ transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
86
+ }
87
+ }
88
+
89
+ ${euiCanAnimate} {
90
+ &:hover {
91
+ .euiNavbarLogo__pink {
92
+ transform: translate(-${LOGO_DISTANCE}, -${LOGO_DISTANCE});
93
+ }
94
+
95
+ .euiNavbarLogo__yellow {
96
+ transform: translate(${LOGO_DISTANCE}, ${LOGO_DISTANCE});
97
+ }
98
+
99
+ .euiNavbarLogo__teal {
100
+ transform: translate(${LOGO_DISTANCE}, -${LOGO_DISTANCE});
101
+ }
102
+
103
+ .euiNavbarLogo__blue {
104
+ transform: translate(-${LOGO_DISTANCE}, ${LOGO_DISTANCE});
105
+ }
106
+ }
107
+ }
108
+ `,
63
109
  });
64
110
 
111
+ function EuiNavbarLogo({
112
+ alt,
113
+ className,
114
+ style,
115
+ }: {
116
+ alt: string;
117
+ className?: string;
118
+ style?: CSSProperties;
119
+ }) {
120
+ const styles = useEuiMemoizedStyles(getStyles);
121
+ const isDecorative = alt === '';
122
+
123
+ return (
124
+ <svg
125
+ xmlns="http://www.w3.org/2000/svg"
126
+ viewBox="0 0 32 32"
127
+ fill="none"
128
+ overflow="visible"
129
+ className={className}
130
+ style={style}
131
+ css={styles.logo}
132
+ aria-hidden={isDecorative ? true : undefined}
133
+ role={isDecorative ? undefined : 'img'}
134
+ aria-label={isDecorative ? undefined : alt}
135
+ >
136
+ <path
137
+ fill="#FF957D"
138
+ d="M18 25c-.5-5.5-5.5-10.5-11-11l7-7c.5 5.5 5.5 10.5 11 11l-7 7z"
139
+ />
140
+ <circle
141
+ className="euiNavbarLogo__piece euiNavbarLogo__pink"
142
+ cx="7"
143
+ cy="7"
144
+ r="7"
145
+ fill="#F04E98"
146
+ />
147
+ <circle
148
+ className="euiNavbarLogo__piece euiNavbarLogo__yellow"
149
+ cx="25"
150
+ cy="25"
151
+ r="7"
152
+ fill="#FEC514"
153
+ />
154
+ <path
155
+ className="euiNavbarLogo__piece euiNavbarLogo__teal"
156
+ fill="#00BFB3"
157
+ d="M31 14c-7.18 0-13-5.82-13-13h13v13z"
158
+ />
159
+ <path
160
+ className="euiNavbarLogo__piece euiNavbarLogo__blue"
161
+ fill="#1BA9F5"
162
+ d="M1 18c7.18 0 13 5.82 13 13H1V18z"
163
+ />
164
+ </svg>
165
+ );
166
+ }
167
+
65
168
  function LogoThemedImage({
66
169
  logo,
67
170
  alt,
@@ -75,12 +178,15 @@ function LogoThemedImage({
75
178
  const isDarkMode = colorMode === 'dark';
76
179
 
77
180
  const styles = useEuiMemoizedStyles(getStyles);
181
+ const isEuiLogo = logo.src.includes(EUI_LOGO);
78
182
 
79
183
  const src = isDarkMode
80
184
  ? useBaseUrl(logo.srcDark || logo.src)
81
185
  : useBaseUrl(logo.src);
82
186
 
83
- const themedImage = (
187
+ const themedImage = isEuiLogo ? (
188
+ <EuiNavbarLogo alt={alt} className={logo.className} style={logo.style} />
189
+ ) : (
84
190
  <EuiImage
85
191
  src={src}
86
192
  size="fullWidth"