├── sandbox.config.json ├── src ├── images │ └── logo_elastic.png ├── lib │ ├── loader.ts │ └── theme.ts ├── layouts │ ├── docs.styles.ts │ ├── kibana.styles.ts │ ├── kibana.tsx │ ├── docs.tsx │ └── kibana_collapsible_nav.tsx ├── styles │ ├── getting-started.styles.ts │ └── global.styles.ts ├── components │ ├── starter │ │ ├── header.styles.ts │ │ ├── wrapper.styles.ts │ │ ├── theme_switcher.styles.ts │ │ ├── home_templates.styles.ts │ │ ├── wrapper.tsx │ │ ├── doc_panel.styles.ts │ │ ├── home_hero.styles.ts │ │ ├── gradient_bg.tsx │ │ ├── theme_switcher.tsx │ │ ├── gradient_bg.styles.ts │ │ ├── home_illustration.tsx │ │ ├── doc_panel.tsx │ │ ├── header.tsx │ │ ├── home_hero.tsx │ │ ├── home_illustration.styles.ts │ │ ├── getting_started_steps.tsx │ │ ├── home_why.tsx │ │ └── home_templates.tsx │ ├── chrome │ │ ├── theme_switcher.tsx │ │ └── index.tsx │ ├── next_eui │ │ └── button.tsx │ └── theme.tsx ├── pages │ ├── _error.tsx │ ├── kibana │ │ ├── maps.js │ │ ├── discover.js │ │ ├── index.js │ │ └── dashboards.js │ ├── docs │ │ ├── index.tsx │ │ └── page-2.tsx │ ├── index.tsx │ ├── _app.tsx │ ├── 404.tsx │ ├── getting-started.tsx │ └── _document.tsx └── custom_typings │ └── index.d.ts ├── public └── images │ ├── 404_rainy_cloud_dark.png │ ├── 404_rainy_cloud_light.png │ ├── favicon │ ├── dev │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ └── favicon-96x96.png │ └── prod │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ └── favicon-96x96.png │ ├── logo-eui.svg │ ├── patterns │ └── pattern-1.svg │ └── home │ └── illustration-eui-hero-500-shadow.svg ├── next-env.d.ts ├── .prettierrc ├── .gitignore ├── scripts ├── test-docs.sh └── update-docs.sh ├── tsconfig.json ├── package.json ├── .eslintrc.js ├── README.md ├── next.config.js └── LICENSE /sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "container": { 3 | "node": "16" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/images/logo_elastic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/src/images/logo_elastic.png -------------------------------------------------------------------------------- /public/images/404_rainy_cloud_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/404_rainy_cloud_dark.png -------------------------------------------------------------------------------- /public/images/404_rainy_cloud_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/404_rainy_cloud_light.png -------------------------------------------------------------------------------- /public/images/favicon/dev/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/dev/favicon-16x16.png -------------------------------------------------------------------------------- /public/images/favicon/dev/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/dev/favicon-32x32.png -------------------------------------------------------------------------------- /public/images/favicon/dev/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/dev/favicon-96x96.png -------------------------------------------------------------------------------- /public/images/favicon/prod/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/prod/favicon-16x16.png -------------------------------------------------------------------------------- /public/images/favicon/prod/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/prod/favicon-32x32.png -------------------------------------------------------------------------------- /public/images/favicon/prod/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/next-eui-starter/HEAD/public/images/favicon/prod/favicon-96x96.png -------------------------------------------------------------------------------- /src/lib/loader.ts: -------------------------------------------------------------------------------- 1 | import { ImageLoader } from 'next/image'; 2 | 3 | export const imageLoader: ImageLoader = ({ src, width, quality }) => 4 | `${src}?w=${width}&q=${quality || 75}`; 5 | -------------------------------------------------------------------------------- /src/layouts/docs.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const docsLayout = () => ({ 4 | wrapper: css` 5 | min-height: calc(100vh - 48px); 6 | display: flex; 7 | `, 8 | }); 9 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSameLine": true, 3 | "jsxSingleQuote": false, 4 | "parser": "typescript", 5 | "printWidth": 80, 6 | "semi": true, 7 | "singleQuote": true, 8 | "trailingComma": "es5", 9 | "arrowParens": "avoid" 10 | } 11 | -------------------------------------------------------------------------------- /src/styles/getting-started.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const gettingStartedStyles = euiTheme => ({ 4 | wrapperInner: css` 5 | padding-top: ${euiTheme.size.xxl}; 6 | padding-bottom: ${euiTheme.size.xl}; 7 | `, 8 | }); 9 | -------------------------------------------------------------------------------- /src/styles/global.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const globalStyes = css` 4 | #__next, 5 | .guideBody { 6 | min-height: 100%; 7 | display: flex; 8 | flex-direction: column; 9 | height: 100%; 10 | } 11 | `; 12 | -------------------------------------------------------------------------------- /src/components/starter/header.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const headerStyles = euiTheme => ({ 4 | logo: css` 5 | display: inline-flex; 6 | flex-wrap: wrap; 7 | gap: ${euiTheme.size.m}; 8 | `, 9 | title: css` 10 | line-height: 1.75; // Measured in the browser 11 | `, 12 | }); 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Junk and IDE stuff 2 | *.bak 3 | *.iml 4 | *.orig 5 | *.rej 6 | *.swp 7 | *~ 8 | .DS_Store 9 | .idea 10 | .vim/.netrwhist 11 | yarn-error.log 12 | .eslintcache 13 | 14 | # Files in here are copied by the build 15 | public/themes 16 | 17 | node_modules 18 | .next 19 | 20 | # Default `next export` output directory 21 | out 22 | 23 | # TypeScript cache 24 | tsconfig.tsbuildinfo 25 | -------------------------------------------------------------------------------- /src/components/starter/wrapper.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const wrapperStyles = euiTheme => ({ 4 | content: css` 5 | display: flex; 6 | flex-direction: column; 7 | max-width: 1120px; 8 | margin: 0 auto; 9 | padding-right: ${euiTheme.size.base}; 10 | padding-bottom: ${euiTheme.size.xxl}; 11 | padding-left: ${euiTheme.size.base}; 12 | `, 13 | }); 14 | -------------------------------------------------------------------------------- /src/layouts/kibana.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const kibanaLayoutStyles = () => ({ 4 | mainWrapper: css` 5 | min-height: 100%; 6 | display: flex; 7 | flex-direction: column; 8 | height: 100%; 9 | `, 10 | contentWrapper: css` 11 | display: flex; 12 | flex-flow: column nowrap; 13 | flex-grow: 1; 14 | z-index: 0; 15 | position: relative; 16 | `, 17 | }); 18 | -------------------------------------------------------------------------------- /public/images/logo-eui.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/components/starter/theme_switcher.styles.ts: -------------------------------------------------------------------------------- 1 | import { css, keyframes } from '@emotion/react'; 2 | 3 | const rotate = keyframes` 4 | 0% { 5 | transform: rotate(0); 6 | } 7 | 100% { 8 | transform: rotate(360deg); 9 | } 10 | `; 11 | 12 | export const themeSwitcherStyles = euiTheme => ({ 13 | animation: css` 14 | animation: ${rotate} 0.5s ease; 15 | transition: all ${euiTheme.animation.extraSlow} ${euiTheme.animation.bounce}; 16 | `, 17 | }); 18 | -------------------------------------------------------------------------------- /src/components/starter/home_templates.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const homeTemplates = euiTheme => ({ 4 | circle1: css` 5 | display: flex; 6 | position: absolute; 7 | left: 0; 8 | top: 0; 9 | `, 10 | circle2: css` 11 | display: flex; 12 | position: absolute; 13 | right: 0; 14 | bottom: 0; 15 | `, 16 | panel: css` 17 | position: relative; 18 | `, 19 | panelInner: css` 20 | padding: ${euiTheme.size.xxxxl} 0; 21 | `, 22 | }); 23 | -------------------------------------------------------------------------------- /src/components/starter/wrapper.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import Header from './header'; 3 | import GradientBg from './gradient_bg'; 4 | import { useEuiTheme } from '@elastic/eui'; 5 | import { wrapperStyles } from './wrapper.styles'; 6 | 7 | const Wrapper: FunctionComponent = ({ children }) => { 8 | const { euiTheme } = useEuiTheme(); 9 | const styles = wrapperStyles(euiTheme); 10 | 11 | return ( 12 | <> 13 |
14 | 15 | 16 |
{children}
17 |
18 | 19 | ); 20 | }; 21 | 22 | export default Wrapper; 23 | -------------------------------------------------------------------------------- /scripts/test-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # Generate a fresh temp directory for each build 6 | BUILD_DIR="$(mktemp -d /tmp/next-eui-starter.XXXXXX)" 7 | 8 | # The actual build goes in here 9 | PREFIXED_DIR="$BUILD_DIR/$(node -e 'console.log((require("./package.json")).name.split("/").pop())')" 10 | mkdir "$PREFIXED_DIR" 11 | 12 | # Necessary for GitHub pages - see next.config.js 13 | export PATH_PREFIX="true" 14 | 15 | # Build the site 16 | yarn build 17 | # Now export the static version to the build dir 18 | next export -o "$PREFIXED_DIR" 19 | 20 | # Serve up the site at http://localhost:5000 21 | yarn serve "$BUILD_DIR" 22 | 23 | # Clean up after ourselves 24 | rm -rf "$BUILD_DIR" 25 | 26 | -------------------------------------------------------------------------------- /src/components/starter/doc_panel.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const docPanelStyles = euiTheme => ({ 4 | panel: css` 5 | position: relative; 6 | min-height: 280px; 7 | overflow: hidden; 8 | display: flex; 9 | justify-content: center; 10 | font-size: 20px; 11 | `, 12 | pattern1: css` 13 | display: flex; 14 | position: absolute; 15 | left: 0; 16 | top: 0; 17 | `, 18 | pattern2: css` 19 | display: flex; 20 | position: absolute; 21 | right: 0; 22 | bottom: 0; 23 | `, 24 | content: css` 25 | max-width: 800px; 26 | padding-top: calc(${euiTheme.size.xxl} * 2); 27 | padding-bottom: calc(${euiTheme.size.xxl} * 2); 28 | `, 29 | }); 30 | -------------------------------------------------------------------------------- /src/pages/_error.tsx: -------------------------------------------------------------------------------- 1 | import React, { FunctionComponent } from 'react'; 2 | import Error, { ErrorProps } from 'next/error'; 3 | 4 | /** 5 | * An example of how to render a custom error page. Note that we have a 6 | * dedicated './404.tsx` page. See: 7 | * 8 | * https://nextjs.org/docs/advanced-features/custom-error-page 9 | */ 10 | const ErrorWrapper: FunctionComponent = ({ statusCode }) => { 11 | return ; 12 | }; 13 | 14 | // @ts-ignore getInitialProps doesn't exist on FunctionComponent 15 | ErrorWrapper.getInitialProps = ({ res, err }) => { 16 | const statusCode = res ? res.statusCode : err ? err.statusCode : 404; 17 | return { statusCode }; 18 | }; 19 | 20 | export default ErrorWrapper; 21 | -------------------------------------------------------------------------------- /src/custom_typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-explicit-any */ 2 | 3 | // These type definitions allow us to import image files in JavaScript without 4 | // causing type errors. They tell the TypeScript compiler that such imports 5 | // simply return a value, which they do, thanks to Webpack. 6 | 7 | declare module '*.png' { 8 | const value: any; 9 | export = value; 10 | } 11 | 12 | declare module '*.svg' { 13 | const value: any; 14 | export = value; 15 | } 16 | 17 | // This section works with the `typescript-plugin-css-modules` plugin, and 18 | // allows us to type-check the name in our CSS modules (and get IDE completion!) 19 | declare module '*.module.scss' { 20 | const content: { [className: string]: string }; 21 | export default content; 22 | } 23 | -------------------------------------------------------------------------------- /src/components/starter/home_hero.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const homeHeroStyles = euiTheme => ({ 4 | container: css` 5 | padding-bottom: ${euiTheme.size.base}; 6 | 7 | @media (max-width: ${euiTheme.breakpoint.m}px) { 8 | text-align: center; 9 | 10 | > .euiFlexItem:first-of-type { 11 | order: 2; 12 | } 13 | } 14 | `, 15 | title: css` 16 | @media (min-width: ${euiTheme.breakpoint.m}px) { 17 | padding-top: ${euiTheme.size.base}; 18 | } 19 | `, 20 | subtitle: css` 21 | margin-top: ${euiTheme.size.l}; 22 | padding-bottom: ${euiTheme.size.m}; 23 | `, 24 | description: css` 25 | @media (max-width: ${euiTheme.breakpoint.m}px) { 26 | align-self: center; 27 | } 28 | `, 29 | }); 30 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "plugins": [ 4 | { 5 | "name": "typescript-plugin-css-modules" 6 | } 7 | ], 8 | "target": "es5", 9 | "lib": [ 10 | "dom", 11 | "dom.iterable", 12 | "esnext" 13 | ], 14 | "allowJs": true, 15 | "skipLibCheck": true, 16 | "strict": false, 17 | "forceConsistentCasingInFileNames": true, 18 | "noEmit": true, 19 | "esModuleInterop": true, 20 | "module": "esnext", 21 | "moduleResolution": "node", 22 | "resolveJsonModule": true, 23 | "isolatedModules": true, 24 | "jsx": "preserve", 25 | "jsxImportSource": "@emotion/react", 26 | "incremental": true 27 | }, 28 | "include": [ 29 | "./src/**/*" 30 | ], 31 | "exclude": [ 32 | "node_modules" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/components/chrome/theme_switcher.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { EuiButtonIcon } from '@elastic/eui'; 3 | import { useTheme } from '../theme'; 4 | 5 | /** 6 | * Current theme is set in localStorage 7 | * so that it persists between visits. 8 | */ 9 | const ThemeSwitcher: FunctionComponent = () => { 10 | const { colorMode, setColorMode } = useTheme(); 11 | const isDarkTheme = colorMode === 'dark'; 12 | 13 | const handleChangeTheme = (newTheme: string) => { 14 | setColorMode(newTheme); 15 | }; 16 | 17 | return ( 18 | 23 | handleChangeTheme(isDarkTheme ? 'light' : 'dark') 24 | }> 25 | ); 26 | }; 27 | 28 | export default ThemeSwitcher; 29 | -------------------------------------------------------------------------------- /src/components/next_eui/button.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef } from 'react'; 2 | import { EuiButton } from '@elastic/eui'; 3 | 4 | /** 5 | * Next's `` component passes a ref to its children, which triggers a warning 6 | * on EUI buttons (they expect `buttonRef`). Wrap the button component to pass on the 7 | * ref, and silence the warning. 8 | */ 9 | 10 | type EuiButtonProps = React.ComponentProps; 11 | const NextEuiButton = forwardRef< 12 | HTMLAnchorElement | HTMLButtonElement, 13 | EuiButtonProps 14 | >((props, ref) => { 15 | return ( 16 | // @ts-ignore EuiButton's ref is an HTMLButtonElement or an 17 | // HTMLAnchorElement, depending on whether `href` prop is passed 18 | 19 | {props.children} 20 | 21 | ); 22 | }); 23 | 24 | NextEuiButton.displayName = 'NextEuiButton(EuiButton)'; 25 | 26 | export default NextEuiButton; 27 | -------------------------------------------------------------------------------- /src/pages/kibana/maps.js: -------------------------------------------------------------------------------- 1 | import { EuiText } from '@elastic/eui'; 2 | import KibanaLayout from '../../layouts/kibana'; 3 | 4 | const Maps = () => { 5 | return ( 6 | 10 | 11 |

12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a erat 13 | sed arcu imperdiet eleifend eu vel ante. Nam dapibus lacus id 14 | efficitur luctus. Nunc vitae viverra erat, at euismod metus. Nam nec 15 | nulla ornare, aliquam arcu in, luctus diam. Phasellus convallis lorem 16 | fringilla, dapibus lectus in, pretium dui. Pellentesque massa nulla, 17 | tempus ut elit at, scelerisque commodo eros. Proin interdum libero 18 | aliquam, volutpat justo ut, posuere nulla. 19 |

20 |
21 |
22 | ); 23 | }; 24 | 25 | export default Maps; 26 | -------------------------------------------------------------------------------- /src/pages/docs/index.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { EuiText } from '@elastic/eui'; 3 | import DocsLayout from '../../layouts/docs'; 4 | 5 | const Index: FunctionComponent = () => { 6 | return ( 7 | 11 | 12 |

13 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a erat 14 | sed arcu imperdiet eleifend eu vel ante. Nam dapibus lacus id 15 | efficitur luctus. Nunc vitae viverra erat, at euismod metus. Nam nec 16 | nulla ornare, aliquam arcu in, luctus diam. Phasellus convallis lorem 17 | fringilla, dapibus lectus in, pretium dui. Pellentesque massa nulla, 18 | tempus ut elit at, scelerisque commodo eros. Proin interdum libero 19 | aliquam, volutpat justo ut, posuere nulla. 20 |

21 |
22 |
23 | ); 24 | }; 25 | 26 | export default Index; 27 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import Head from 'next/head'; 3 | import { EuiSpacer } from '@elastic/eui'; 4 | import HomeHero from '../components/starter/home_hero'; 5 | import Wrapper from '../components/starter/wrapper'; 6 | import HomeTemplates from '../components/starter/home_templates'; 7 | import HomeWhy from '../components/starter/home_why'; 8 | 9 | const Index: FunctionComponent = () => { 10 | return ( 11 | <> 12 | 13 | Home 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | ); 35 | }; 36 | 37 | export default Index; 38 | -------------------------------------------------------------------------------- /src/pages/docs/page-2.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { EuiText } from '@elastic/eui'; 3 | import DocsLayout from '../../layouts/docs'; 4 | 5 | const Index: FunctionComponent = () => { 6 | return ( 7 | 11 | 12 |

13 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a erat 14 | sed arcu imperdiet eleifend eu vel ante. Nam dapibus lacus id 15 | efficitur luctus. Nunc vitae viverra erat, at euismod metus. Nam nec 16 | nulla ornare, aliquam arcu in, luctus diam. Phasellus convallis lorem 17 | fringilla, dapibus lectus in, pretium dui. Pellentesque massa nulla, 18 | tempus ut elit at, scelerisque commodo eros. Proin interdum libero 19 | aliquam, volutpat justo ut, posuere nulla. 20 |

21 |
22 |
23 | ); 24 | }; 25 | 26 | export default Index; 27 | -------------------------------------------------------------------------------- /src/layouts/kibana.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import CollapsibleNav from './kibana_collapsible_nav'; 3 | import { kibanaLayoutStyles } from './kibana.styles'; 4 | import { 5 | EuiPageTemplate, 6 | EuiPageTemplateProps, 7 | EuiPageContentHeaderProps, 8 | } from '@elastic/eui'; 9 | 10 | interface KibanaLayoutProps extends EuiPageTemplateProps { 11 | pageHeader: EuiPageContentHeaderProps; 12 | } 13 | 14 | const KibanaLayout: FunctionComponent = ({ 15 | children, 16 | pageHeader, 17 | ...rest 18 | }) => { 19 | const styles = kibanaLayoutStyles(); 20 | return ( 21 |
22 | 23 | 24 |
25 | 30 | 31 | {children} 32 | 33 |
34 |
35 | ); 36 | }; 37 | 38 | export default KibanaLayout; 39 | -------------------------------------------------------------------------------- /src/pages/kibana/discover.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link'; 2 | import { EuiLink, EuiText } from '@elastic/eui'; 3 | import KibanaLayout from '../../layouts/kibana'; 4 | 5 | const Discover = () => { 6 | return ( 7 | 11 | 12 |

13 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a erat 14 | sed arcu imperdiet eleifend eu vel ante. Nam dapibus lacus id 15 | efficitur luctus. Nunc vitae viverra erat, at euismod metus. Nam nec 16 | nulla ornare, aliquam arcu in, luctus diam. Phasellus convallis lorem 17 | fringilla, dapibus lectus in, pretium dui. Pellentesque massa nulla, 18 | tempus ut elit at, scelerisque commodo eros. Proin interdum libero 19 | aliquam, volutpat justo ut, posuere nulla. 20 |

21 | 22 | Go to Kibana home 23 | 24 |
25 |
26 | ); 27 | }; 28 | 29 | export default Discover; 30 | -------------------------------------------------------------------------------- /src/components/starter/gradient_bg.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { useEuiTheme, transparentize } from '@elastic/eui'; 3 | import { useTheme } from '../theme'; 4 | import { gradientBgStyles } from './gradient_bg.styles'; 5 | 6 | const GradientBg: FunctionComponent = ({ children }) => { 7 | const { euiTheme } = useEuiTheme(); 8 | const { colorMode } = useTheme(); 9 | 10 | const alpha = colorMode === 'dark' ? 0.03 : 0.05; 11 | 12 | const backgroundColors = { 13 | topLeft: transparentize(euiTheme.colors.success, alpha), 14 | centerTop: transparentize(euiTheme.colors.accent, alpha), 15 | topRight: transparentize(euiTheme.colors.warning, alpha), 16 | centerMiddleLeft: transparentize(euiTheme.colors.warning, alpha), 17 | centerMiddleRight: transparentize(euiTheme.colors.accent, alpha), 18 | bottomRight: transparentize(euiTheme.colors.primary, alpha), 19 | bottomLeft: transparentize(euiTheme.colors.accent, alpha), 20 | }; 21 | 22 | const styles = gradientBgStyles(backgroundColors); 23 | 24 | return
{children}
; 25 | }; 26 | 27 | export default GradientBg; 28 | -------------------------------------------------------------------------------- /src/components/theme.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | FunctionComponent, 3 | createContext, 4 | useContext, 5 | useState, 6 | useEffect, 7 | } from 'react'; 8 | import { getTheme, enableTheme } from '../lib/theme'; 9 | 10 | /** 11 | * React context for storing theme-related data and callbacks. 12 | * `colorMode` is `light` or `dark` and will be consumed by 13 | * various downstream components, including `EuiProvider`. 14 | */ 15 | export const GlobalProvider = createContext<{ 16 | colorMode?: string; 17 | setColorMode?: (colorMode: string) => void; 18 | }>({}); 19 | 20 | export const Theme: FunctionComponent = ({ children }) => { 21 | const [colorMode, setColorMode] = useState('light'); 22 | 23 | // on initial mount in the browser, use any theme from local storage 24 | useEffect(() => { 25 | setColorMode(getTheme()); 26 | }, []); 27 | 28 | // enable the correct theme when colorMode changes 29 | useEffect(() => enableTheme(colorMode), [colorMode]); 30 | 31 | return ( 32 | 33 | {children} 34 | 35 | ); 36 | }; 37 | 38 | export const useTheme = () => { 39 | return useContext(GlobalProvider); 40 | }; 41 | -------------------------------------------------------------------------------- /src/components/starter/theme_switcher.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { 3 | EuiHeaderSectionItemButton, 4 | EuiIcon, 5 | EuiToolTip, 6 | useEuiTheme, 7 | } from '@elastic/eui'; 8 | import { useTheme } from '../theme'; 9 | import { themeSwitcherStyles } from './theme_switcher.styles'; 10 | 11 | const ThemeSwitcher: FunctionComponent = () => { 12 | const { colorMode, setColorMode } = useTheme(); 13 | const isDarkTheme = colorMode === 'dark'; 14 | 15 | const handleChangeTheme = (newTheme: string) => { 16 | setColorMode(newTheme); 17 | }; 18 | 19 | const lightOrDark = isDarkTheme ? 'light' : 'dark'; 20 | const { euiTheme } = useEuiTheme(); 21 | 22 | const styles = themeSwitcherStyles(euiTheme); 23 | 24 | return ( 25 | 26 | handleChangeTheme(lightOrDark)}> 29 | 35 | 36 | ); 37 | }; 38 | export default ThemeSwitcher; 39 | -------------------------------------------------------------------------------- /src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import 'core-js/stable'; 2 | import 'regenerator-runtime/runtime'; 3 | import { FunctionComponent } from 'react'; 4 | import { AppProps } from 'next/app'; 5 | import Head from 'next/head'; 6 | import { EuiErrorBoundary } from '@elastic/eui'; 7 | import { Global } from '@emotion/react'; 8 | import Chrome from '../components/chrome'; 9 | import { Theme } from '../components/theme'; 10 | import { globalStyes } from '../styles/global.styles'; 11 | 12 | /** 13 | * Next.js uses the App component to initialize pages. You can override it 14 | * and control the page initialization. Here use use it to render the 15 | * `Chrome` component on each page, and apply an error boundary. 16 | * 17 | * @see https://nextjs.org/docs/advanced-features/custom-app 18 | */ 19 | const EuiApp: FunctionComponent = ({ Component, pageProps }) => ( 20 | <> 21 | 22 | {/* You can override this in other pages - see index.tsx for an example */} 23 | Next.js EUI Starter 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | ); 35 | 36 | export default EuiApp; 37 | -------------------------------------------------------------------------------- /src/components/starter/gradient_bg.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const gradientBgStyles = backgroundColors => ({ 4 | gradientBg: css` 5 | position: relative; 6 | padding-top: 48px; // top nav 7 | background: radial-gradient( 8 | circle 600px at top left, 9 | ${backgroundColors.topLeft}, 10 | transparent 11 | ), 12 | radial-gradient( 13 | circle 800px at 600px 200px, 14 | ${backgroundColors.centerTop}, 15 | transparent 16 | ), 17 | radial-gradient( 18 | circle 800px at top right, 19 | ${backgroundColors.topRight}, 20 | transparent 21 | ), 22 | radial-gradient( 23 | circle 800px at left center, 24 | ${backgroundColors.centerMiddleLeft}, 25 | transparent 26 | ), 27 | radial-gradient( 28 | circle 800px at right center, 29 | ${backgroundColors.centerMiddleRight}, 30 | transparent 31 | ), 32 | radial-gradient( 33 | circle 800px at right bottom, 34 | ${backgroundColors.bottomRight}, 35 | transparent 36 | ), 37 | radial-gradient( 38 | circle 800px at left bottom, 39 | ${backgroundColors.bottomLeft}, 40 | transparent 41 | ); 42 | `, 43 | }); 44 | -------------------------------------------------------------------------------- /src/pages/kibana/index.js: -------------------------------------------------------------------------------- 1 | import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui'; 2 | import KibanaLayout from '../../layouts/kibana'; 3 | 4 | const Index = () => { 5 | return ( 6 | 11 | 12 | 13 | } 15 | title="Discover" 16 | description="Example of a card's description. Stick to one or two sentences." 17 | /> 18 | 19 | 20 | } 22 | title="Dashboards" 23 | description="Example of a card's description. Stick to one or two sentences." 24 | /> 25 | 26 | 27 | 28 | } 30 | title="Maps" 31 | description="Example of a card's description. Stick to one or two sentences." 32 | /> 33 | 34 | 35 | 36 | ); 37 | }; 38 | 39 | export default Index; 40 | -------------------------------------------------------------------------------- /src/pages/kibana/dashboards.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link'; 2 | import { EuiLink, EuiText, EuiButton } from '@elastic/eui'; 3 | import KibanaLayout from '../../layouts/kibana'; 4 | 5 | const Discover = () => { 6 | return ( 7 | { 15 | console.log('Create dashboard'); 16 | }} 17 | key="create-dashboard"> 18 | Create dashboard 19 | , 20 | ], 21 | }}> 22 | 23 |

24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a erat 25 | sed arcu imperdiet eleifend eu vel ante. Nam dapibus lacus id 26 | efficitur luctus. Nunc vitae viverra erat, at euismod metus. Nam nec 27 | nulla ornare, aliquam arcu in, luctus diam. Phasellus convallis lorem 28 | fringilla, dapibus lectus in, pretium dui. Pellentesque massa nulla, 29 | tempus ut elit at, scelerisque commodo eros. Proin interdum libero 30 | aliquam, volutpat justo ut, posuere nulla. 31 |

32 | 33 | Go to Kibana home 34 | 35 |
36 |
37 | ); 38 | }; 39 | 40 | export default Discover; 41 | -------------------------------------------------------------------------------- /src/components/chrome/index.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | 3 | import { EuiProvider, EuiThemeColorMode } from '@elastic/eui'; 4 | 5 | import { useTheme } from '../theme'; 6 | 7 | import createCache from '@emotion/cache'; 8 | 9 | /** 10 | * Renders the UI that surrounds the page content. 11 | */ 12 | const Chrome: FunctionComponent = ({ children }) => { 13 | const { colorMode } = useTheme(); 14 | 15 | /** 16 | * This `@emotion/cache` instance is used to insert the global styles 17 | * into the correct location in ``. Otherwise they would be 18 | * inserted after the static CSS files, resulting in style clashes. 19 | * Only necessary until EUI has converted all components to CSS-in-JS: 20 | * https://github.com/elastic/eui/issues/3912 21 | */ 22 | const defaultCache = createCache({ 23 | key: 'eui', 24 | container: 25 | typeof document !== 'undefined' 26 | ? document.querySelector('meta[name="eui-styles"]') 27 | : null, 28 | }); 29 | const utilityCache = createCache({ 30 | key: 'util', 31 | container: 32 | typeof document !== 'undefined' 33 | ? document.querySelector('meta[name="eui-styles-utility"]') 34 | : null, 35 | }); 36 | 37 | return ( 38 | 41 | {children} 42 | 43 | ); 44 | }; 45 | 46 | export default Chrome; 47 | -------------------------------------------------------------------------------- /scripts/update-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -n "$(git status --porcelain)" ]]; then 4 | echo >&2 5 | echo "You have uncommitted changes. Please commit or revert them before proceeding." >&2 6 | echo >&2 7 | exit 1 8 | fi 9 | 10 | set -ex 11 | 12 | # Generate a fresh temp directory for each build 13 | BUILD_DIR="$(mktemp -d /tmp/next-eui-starter.XXXXXX)" 14 | 15 | # Find the current commit. We'll use this in the commit message for 16 | # tracking 17 | HASH="$(git rev-parse --short HEAD)" 18 | 19 | # Necessary for GitHub pages - see next.config.js 20 | export PATH_PREFIX=true 21 | 22 | # Build the site 23 | yarn build 24 | # Now export the static version to the build dir 25 | next export -o "$BUILD_DIR" 26 | 27 | # Switch to the GitHub Pages branch 28 | git checkout gh-pages 29 | 30 | # Remove all tracked files, except .gitignore 31 | git ls-files | grep -v .gitignore | xargs git rm 32 | 33 | # Copy the static site into the branch 34 | tar cf - "$BUILD_DIR" | tar xf - --strip-components 2 35 | # Tell GitHub that this isn't a Jekyll site, and to leave our files alone 36 | touch .nojekyll 37 | 38 | # Commit the changes 39 | git add . 40 | git commit -m "Update gh-pages to $HASH" 41 | 42 | # And go back to the project source 43 | git checkout master 44 | 45 | # Clean up after ourselves 46 | rm -rf "$BUILD_DIR" 47 | 48 | cat >&2 < { 11 | const { colorMode } = useTheme(); 12 | const { euiTheme } = useEuiTheme(); 13 | const styles = homeIllustration(euiTheme); 14 | 15 | const Illustration = 16 | colorMode === 'dark' ? IllustrationDark : IllustrationLight; 17 | 18 | return ( 19 |
20 |
21 |
22 |
23 |
24 |
25 | 26 |
27 | 34 |
35 |
36 |
37 | ); 38 | }; 39 | 40 | export default HomeIllustration; 41 | -------------------------------------------------------------------------------- /src/pages/404.tsx: -------------------------------------------------------------------------------- 1 | import React, { FunctionComponent } from 'react'; 2 | import { 3 | EuiButton, 4 | EuiEmptyPrompt, 5 | EuiPageTemplate, 6 | EuiImage, 7 | } from '@elastic/eui'; 8 | import { useTheme } from '../components/theme'; 9 | import { useRouter } from 'next/router'; 10 | 11 | const NotFoundPage: FunctionComponent = () => { 12 | const { colorMode } = useTheme(); 13 | 14 | const isDarkTheme = colorMode === 'dark'; 15 | 16 | const illustration = isDarkTheme 17 | ? '/images/404_rainy_cloud_dark.png' 18 | : '/images/404_rainy_cloud_light.png'; 19 | 20 | const router = useRouter(); 21 | 22 | const handleClick = e => { 23 | e.preventDefault(); 24 | router.back(); 25 | }; 26 | 27 | return ( 28 | 29 | 30 | 37 | Go back 38 | , 39 | ]} 40 | body={ 41 |

42 | Sorry, we can't find the page you're looking for. It 43 | might have been removed or renamed, or maybe it never existed. 44 |

45 | } 46 | icon={} 47 | layout="vertical" 48 | title={

Page not found

} 49 | titleSize="m" 50 | /> 51 |
52 |
53 | ); 54 | }; 55 | 56 | export default NotFoundPage; 57 | -------------------------------------------------------------------------------- /src/components/starter/doc_panel.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import Head from 'next/head'; 3 | import Image from 'next/image'; 4 | import { EuiPanel, useEuiTheme } from '@elastic/eui'; 5 | import { imageLoader } from '../../lib/loader'; 6 | import { useTheme } from '../theme'; 7 | import { docPanelStyles } from './doc_panel.styles'; 8 | import Pattern1 from '../../../public/images/patterns/pattern-1.svg'; 9 | import Pattern2Light from '../../../public/images/patterns/pattern-2-light.svg'; 10 | import Pattern2Dark from '../../../public/images/patterns/pattern-2-dark.svg'; 11 | 12 | const DocPanel: FunctionComponent = ({ children }) => { 13 | const { euiTheme } = useEuiTheme(); 14 | const { colorMode } = useTheme(); 15 | 16 | const styles = docPanelStyles(euiTheme); 17 | 18 | const Pattern2 = colorMode === 'dark' ? Pattern2Dark : Pattern2Light; 19 | 20 | return ( 21 | <> 22 | 23 | Getting started 24 | 25 | 26 | 27 | 28 | 35 | 36 | 37 | 44 | 45 |
{children}
46 |
47 | 48 | ); 49 | }; 50 | 51 | export default DocPanel; 52 | -------------------------------------------------------------------------------- /src/components/starter/header.tsx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image'; 2 | import Link from 'next/link'; 3 | import { 4 | EuiHeader, 5 | EuiTitle, 6 | EuiHeaderSectionItemButton, 7 | useEuiTheme, 8 | EuiToolTip, 9 | EuiIcon, 10 | } from '@elastic/eui'; 11 | import { imageLoader } from '../../lib/loader'; 12 | import ThemeSwitcher from './theme_switcher'; 13 | import { headerStyles } from './header.styles'; 14 | import Logo from '../../../public/images/logo-eui.svg'; 15 | 16 | const Header = () => { 17 | const { euiTheme } = useEuiTheme(); 18 | const href = 'https://github.com/elastic/next-eui-starter'; 19 | const label = 'EUI GitHub repo'; 20 | const styles = headerStyles(euiTheme); 21 | 22 | return ( 23 | 29 | 30 | 37 | 38 | Next.js EUI Starter 39 | 40 | 41 | , 42 | ], 43 | borders: 'none', 44 | }, 45 | { 46 | items: [ 47 | , 48 | 49 | 50 | 52 | , 53 | ], 54 | borders: 'none', 55 | }, 56 | ]} 57 | /> 58 | ); 59 | }; 60 | 61 | export default Header; 62 | -------------------------------------------------------------------------------- /src/pages/getting-started.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import Head from 'next/head'; 3 | import { useRouter } from 'next/router'; 4 | import { 5 | EuiBreadcrumbs, 6 | EuiSpacer, 7 | useEuiTheme, 8 | EuiTitle, 9 | EuiIcon, 10 | } from '@elastic/eui'; 11 | import GettingStartedSteps from '../components/starter/getting_started_steps'; 12 | import Wrapper from '../components/starter/wrapper'; 13 | import DocPanel from '../components/starter/doc_panel'; 14 | import { gettingStartedStyles } from '../styles/getting-started.styles'; 15 | 16 | const GettingStarted: FunctionComponent = () => { 17 | const { euiTheme } = useEuiTheme(); 18 | const styles = gettingStartedStyles(euiTheme); 19 | const router = useRouter(); 20 | 21 | const handleClick = e => { 22 | e.preventDefault(); 23 | router.back(); 24 | }; 25 | 26 | return ( 27 | <> 28 | 29 | Getting started 30 | 31 | 32 | 33 |
34 | 39 | Go back 40 | 41 | ), 42 | 'aria-current': false, 43 | href: '#', 44 | onClick: handleClick, 45 | //@ts-ignore 46 | color: 'primary', 47 | }, 48 | ]} 49 | truncate={false} 50 | aria-label="An example of EuiBreadcrumbs" 51 | /> 52 | 53 | 54 | 55 | 56 |

Getting started

57 |
58 |
59 | 60 | 61 | 62 | 63 |
64 | 65 | ); 66 | }; 67 | 68 | export default GettingStarted; 69 | -------------------------------------------------------------------------------- /src/layouts/docs.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | EuiHeader, 3 | EuiHeaderLogo, 4 | useGeneratedHtmlId, 5 | EuiPageTemplate, 6 | EuiSideNav, 7 | htmlIdGenerator, 8 | } from '@elastic/eui'; 9 | import ThemeSwitcher from '../components/chrome/theme_switcher'; 10 | import { docsLayout } from './docs.styles'; 11 | 12 | const pathPrefix = process.env.PATH_PREFIX; 13 | 14 | const DocsLayout = ({ pageHeader, children }) => { 15 | const sideNav = [ 16 | { 17 | name: 'Docs', 18 | id: htmlIdGenerator('basicExample')(), 19 | items: [ 20 | { 21 | name: 'Home', 22 | id: htmlIdGenerator('basicExample')(), 23 | href: `${pathPrefix}/docs`, 24 | }, 25 | { 26 | name: 'Page 2', 27 | id: htmlIdGenerator('basicExample')(), 28 | href: `${pathPrefix}/docs/page-2`, 29 | }, 30 | ], 31 | }, 32 | ]; 33 | 34 | const styles = docsLayout(); 35 | 36 | return ( 37 |
38 | 48 | Elastic docs 49 | , 50 | ], 51 | borders: 'none', 52 | }, 53 | { 54 | items: [], 55 | borders: 'none', 56 | }, 57 | ]} 58 | /> 59 | 60 | 61 | 62 | 63 | 64 | {children} 65 | 66 |
67 | ); 68 | }; 69 | 70 | export default DocsLayout; 71 | -------------------------------------------------------------------------------- /src/lib/theme.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The functions here are for tracking and setting the current theme. 3 | * localStorage is used to store the currently preferred them, though 4 | * that doesn't work on the server, where we just use a default. 5 | */ 6 | 7 | const selector = 'link[data-name="eui-theme"]'; 8 | export const defaultTheme = 'light'; 9 | 10 | function getAllThemes(): HTMLLinkElement[] { 11 | // @ts-ignore 12 | return [...document.querySelectorAll(selector)]; 13 | } 14 | 15 | export function enableTheme(newThemeName: string): void { 16 | const oldThemeName = getTheme(); 17 | localStorage.setItem('theme', newThemeName); 18 | 19 | for (const themeLink of getAllThemes()) { 20 | // Disable all theme links, except for the desired theme, which we enable 21 | themeLink.disabled = themeLink.dataset.theme !== newThemeName; 22 | themeLink['aria-disabled'] = themeLink.dataset.theme !== newThemeName; 23 | } 24 | 25 | // Add a class to the `body` element that indicates which theme we're using. 26 | // This allows any custom styling to adapt to the current theme. 27 | if (document.body.classList.contains(`appTheme-${oldThemeName}`)) { 28 | document.body.classList.replace( 29 | `appTheme-${oldThemeName}`, 30 | `appTheme-${newThemeName}` 31 | ); 32 | } else { 33 | document.body.classList.add(`appTheme-${newThemeName}`); 34 | } 35 | } 36 | 37 | export function getTheme(): string { 38 | const storedTheme = localStorage.getItem('theme'); 39 | 40 | return storedTheme || defaultTheme; 41 | } 42 | 43 | export interface Theme { 44 | id: string; 45 | name: string; 46 | publicPath: string; 47 | } 48 | 49 | // This is supplied to the app as JSON by Webpack - see next.config.js 50 | export interface ThemeConfig { 51 | availableThemes: Array; 52 | copyConfig: Array<{ 53 | from: string; 54 | to: string; 55 | }>; 56 | } 57 | 58 | // The config is generated during the build and made available in a JSON string. 59 | export const themeConfig: ThemeConfig = JSON.parse(process.env.THEME_CONFIG!); 60 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elastic/next-eui-starter", 3 | "private": true, 4 | "description": "Start building protoypes quickly with the Next.js EUI Starter", 5 | "version": "1.0.0", 6 | "author": "Rory Hunter ", 7 | "keywords": [ 8 | "next", 9 | "kibana", 10 | "eui", 11 | "elastic", 12 | "typescript" 13 | ], 14 | "engines": { 15 | "node": ">=12.22.0" 16 | }, 17 | "license": "Apache-2.0", 18 | "scripts": { 19 | "analyze": "ANALYZE=true yarn build", 20 | "build": "yarn lint && rm -f public/themes/*.min.css && next build", 21 | "build-docs": "yarn lint && bash scripts/update-docs.sh", 22 | "dev": "next", 23 | "lint": "tsc && next lint", 24 | "start": "next start", 25 | "test-docs": "yarn lint && bash scripts/test-docs.sh" 26 | }, 27 | "repository": { 28 | "type": "git", 29 | "url": "https://github.com/elastic/next-eui-starter" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/elastic/next-eui-starter/issues" 33 | }, 34 | "dependencies": { 35 | "@elastic/eui": "^68.0.0", 36 | "@emotion/cache": "^11.10.3", 37 | "@emotion/react": "^11.10.4", 38 | "core-js": "^3.25.1", 39 | "regenerator-runtime": "^0.13.9" 40 | }, 41 | "devDependencies": { 42 | "@elastic/datemath": "^5.0.3", 43 | "@emotion/babel-plugin": "^11.10.2", 44 | "@next/bundle-analyzer": "^12.3.1", 45 | "@types/node": "^16.11.10", 46 | "@typescript-eslint/eslint-plugin": "^5.5.0", 47 | "copy-webpack-plugin": "^10.0.0", 48 | "eslint": "<8.0.0", 49 | "eslint-config-next": "12.0.4", 50 | "eslint-config-prettier": "^8.3.0", 51 | "eslint-plugin-prettier": "^4.0.0", 52 | "glob": "^7.2.0", 53 | "iniparser": "^1.0.5", 54 | "moment": "^2.29.4", 55 | "next": "^12.3.1", 56 | "null-loader": "^4.0.1", 57 | "prettier": "^2.5.0", 58 | "react": "^17.0.2", 59 | "react-dom": "^17.0.2", 60 | "sass": "^1.43.5", 61 | "serve": "^13.0.2", 62 | "typescript": "^4.5.2", 63 | "typescript-plugin-css-modules": "^3.4.0" 64 | }, 65 | "resolutions": { 66 | "trim": "0.0.3" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/components/starter/home_hero.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { 3 | EuiFlexGroup, 4 | EuiFlexItem, 5 | EuiTitle, 6 | EuiText, 7 | EuiButton, 8 | EuiLink, 9 | } from '@elastic/eui'; 10 | import HomeIllustration from './home_illustration'; 11 | import Link from 'next/link'; 12 | import { homeHeroStyles } from './home_hero.styles'; 13 | import { useEuiTheme } from '@elastic/eui'; 14 | 15 | const HomeHero: FunctionComponent = () => { 16 | const { euiTheme } = useEuiTheme(); 17 | const styles = homeHeroStyles(euiTheme); 18 | 19 | return ( 20 | 21 | 22 | 23 |

Next.js EUI Starter

24 |
25 | 26 |

Welcome to Next.js EUI Starter

27 |
28 | 29 | 30 |

31 | The Next.js Starter uses{' '} 32 | 33 | Next.js 34 | 35 | ,{' '} 36 | 37 | EUI library 38 | 39 | , and{' '} 40 | 43 | Emotion 44 | {' '} 45 | to help you make prototypes. You just need to know a few basic 46 | Next.js concepts and how to use EUI and you're ready to ship 47 | it! 48 |

49 | 50 | 51 | 52 | Getting started 53 | 54 | 55 |
56 |
57 | 58 | 59 | 60 |
61 | ); 62 | }; 63 | 64 | export default HomeHero; 65 | -------------------------------------------------------------------------------- /src/components/starter/home_illustration.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | export const homeIllustration = euiTheme => ({ 4 | homeIllustration: css` 5 | position: relative; 6 | display: flex; 7 | justify-content: center; 8 | 9 | @media (min-width: ${euiTheme.breakpoint.m}px) { 10 | justify-content: flex-end; 11 | } 12 | `, 13 | homeIllustrationEffect: css` 14 | display: block; 15 | position: relative; 16 | 17 | .homeIllustration__EffectSVG { 18 | transform: perspective(1600px); 19 | transform-style: preserve-3d; 20 | transition: all 0.3s ease-in-out; 21 | width: 100%; 22 | height: auto; 23 | 24 | &:before { 25 | content: ''; 26 | display: block; 27 | position: absolute; 28 | left: 0; 29 | top: 0; 30 | width: 100%; 31 | height: 100%; 32 | } 33 | } 34 | 35 | .homeIllustration__TopLeftCorner { 36 | height: 50%; 37 | left: 0; 38 | position: absolute; 39 | top: 0; 40 | width: 50%; 41 | z-index: 300; 42 | 43 | &:hover ~ .homeIllustration__EffectSVG { 44 | transform: perspective(1600px) rotateX(-5deg) rotateY(5deg); 45 | } 46 | } 47 | 48 | .homeIllustration__TopRightCorner { 49 | height: 50%; 50 | position: absolute; 51 | right: 0; 52 | top: 0; 53 | width: 50%; 54 | z-index: 300; 55 | 56 | &:hover ~ .homeIllustration__EffectSVG { 57 | transform: perspective(1600px) rotateX(-5deg) rotateY(-5deg); 58 | } 59 | } 60 | 61 | .homeIllustration__BottomLeftCorner { 62 | bottom: 0; 63 | height: 50%; 64 | left: 0; 65 | position: absolute; 66 | width: 50%; 67 | z-index: 300; 68 | 69 | &:hover ~ .homeIllustration__EffectSVG { 70 | transform: perspective(1600px) rotateX(5deg) rotateY(5deg); 71 | } 72 | } 73 | 74 | .homeIllustration__BottomRightCorner { 75 | bottom: 0; 76 | height: 50%; 77 | position: absolute; 78 | right: 0; 79 | width: 50%; 80 | z-index: 300; 81 | 82 | &:hover ~ .homeIllustration__EffectSVG { 83 | transform: perspective(1600px) rotateX(5deg) rotateY(-5deg); 84 | } 85 | } 86 | `, 87 | }); 88 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'plugin:@typescript-eslint/recommended', 4 | 'prettier', 5 | 'next/core-web-vitals', 6 | ], 7 | plugins: ['prettier'], 8 | rules: { 9 | // In an ideal world, we'd never have to use @ts-ignore, but that's not 10 | // possible right now. 11 | '@typescript-eslint/ban-ts-ignore': 'off', 12 | '@typescript-eslint/ban-ts-comment': 'off', 13 | 14 | // Again, in theory this is a good rule, but it can cause a bit of 15 | // unhelpful noise. 16 | '@typescript-eslint/explicit-function-return-type': 'off', 17 | 18 | // Another theoretically good rule, but sometimes we know better than 19 | // the linter. 20 | '@typescript-eslint/no-non-null-assertion': 'off', 21 | 22 | // Accessibility is important to EUI. Enforce all a11y rules. 23 | 'jsx-a11y/accessible-emoji': 'error', 24 | 'jsx-a11y/alt-text': 'error', 25 | 'jsx-a11y/anchor-has-content': 'error', 26 | 'jsx-a11y/aria-activedescendant-has-tabindex': 'error', 27 | 'jsx-a11y/aria-props': 'error', 28 | 'jsx-a11y/aria-proptypes': 'error', 29 | 'jsx-a11y/aria-role': 'error', 30 | 'jsx-a11y/aria-unsupported-elements': 'error', 31 | 'jsx-a11y/heading-has-content': 'error', 32 | 'jsx-a11y/html-has-lang': 'error', 33 | 'jsx-a11y/iframe-has-title': 'error', 34 | 'jsx-a11y/interactive-supports-focus': 'error', 35 | 'jsx-a11y/media-has-caption': 'error', 36 | 'jsx-a11y/mouse-events-have-key-events': 'error', 37 | 'jsx-a11y/no-access-key': 'error', 38 | 'jsx-a11y/no-distracting-elements': 'error', 39 | 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error', 40 | 'jsx-a11y/no-noninteractive-element-interactions': 'error', 41 | 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error', 42 | 'jsx-a11y/no-redundant-roles': 'error', 43 | 'jsx-a11y/role-has-required-aria-props': 'error', 44 | 'jsx-a11y/role-supports-aria-props': 'error', 45 | 'jsx-a11y/scope': 'error', 46 | 'jsx-a11y/tabindex-no-positive': 'error', 47 | 'jsx-a11y/label-has-associated-control': 'error', 48 | 49 | 'react-hooks/rules-of-hooks': 'error', 50 | 'react-hooks/exhaustive-deps': 'warn', 51 | 52 | 'prefer-object-spread': 'error', 53 | 54 | // Use template strings instead of string concatenation 55 | 'prefer-template': 'error', 56 | 57 | // This is documented as the default, but apparently now needs to be 58 | // set explicitly 59 | 'prettier/prettier': [ 60 | 'error', 61 | {}, 62 | { 63 | usePrettierrc: true, 64 | }, 65 | ], 66 | }, 67 | }; 68 | -------------------------------------------------------------------------------- /src/components/starter/getting_started_steps.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | EuiCode, 3 | EuiSteps, 4 | EuiText, 5 | EuiCodeBlock, 6 | EuiSpacer, 7 | } from '@elastic/eui'; 8 | import Link from 'next/link'; 9 | 10 | const steps = [ 11 | { 12 | title: 'Install yarn', 13 | children: ( 14 | <> 15 | 16 |

17 | This starter expects to use{' '} 18 | yarn to manage 19 | dependencies, so go install it. 20 |

21 |
22 | 23 | 24 | ), 25 | }, 26 | { 27 | title: 'Copy the Next.js starter', 28 | children: ( 29 | 30 |

Clone the repository:

31 | 32 | git clone https://github.com/elastic/next-eui-starter.git 33 | my-eui-starter 34 | 35 |
36 | ), 37 | }, 38 | { 39 | title: 'Start developing', 40 | children: ( 41 | 42 |

Navigate into your new site’s directory and start it up.

43 | 44 | {`cd my-eui-starter/ 45 | 46 | # Install depdendencies. 47 | yarn 48 | 49 | # Optional: start a new git project 50 | rm -rf .git && git init && git add . && git commit -m "Initial commit" 51 | 52 | # Start the dev server 53 | yarn dev`} 54 | 55 |
56 | ), 57 | }, 58 | { 59 | title: 'Open the source code and start editing!', 60 | children: ( 61 | 62 |

63 | Your site is now running at http://localhost:3000. 64 |

65 |

66 | Open the my-eui-starter directory in your code 67 | editor of choice and edit src/pages/index.tsx. Save 68 | your changes and the browser will update in real time! 69 |

70 |

71 | You can also start by using one of available templates:{' '} 72 | kibana or docs. For that just edit{' '} 73 | src/pages/kibana/index.tsx or{' '} 74 | src/pages/docs/index.tsx. These pages are going run 75 | in http://localhost:3000/kibana or{' '} 76 | http://localhost:3000/docs respectively. 77 |

78 |
79 | ), 80 | }, 81 | ]; 82 | 83 | const GettingStartedSteps = () => ( 84 | 85 | ); 86 | 87 | export default GettingStartedSteps; 88 | -------------------------------------------------------------------------------- /src/components/starter/home_why.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { 3 | EuiSpacer, 4 | EuiText, 5 | EuiTitle, 6 | EuiFlexGroup, 7 | EuiFlexItem, 8 | EuiCard, 9 | EuiIcon, 10 | EuiLink, 11 | } from '@elastic/eui'; 12 | 13 | const HomeWhy: FunctionComponent = () => { 14 | return ( 15 | <> 16 | 17 |

Why should you use this starter?

18 |
19 | 20 | 21 | 22 | 23 |

24 | Sometimes you just need to prototype new functionality or test a new 25 | feature. This starter gives you an easy way to start experimenting 26 | with EUI. 27 |

28 |

29 | We always recommend using{' '} 30 | 31 | CodeSandbox 32 | {' '} 33 | for testing small patterns or functionalities. But when it comes to 34 | more complex patterns, this starter can definitely help you out. 35 |

36 |
37 | 38 | 39 | 40 | 41 | 42 | } 44 | display="transparent" 45 | hasBorder 46 | title="Prototype" 47 | description="This starter comes with Next.js, EUI, and Emotion so these give an easy setup to prototype." 48 | /> 49 | 50 | 51 | } 53 | display="transparent" 54 | hasBorder 55 | title="Learn how to code" 56 | description="An easy way to learn how to use EUI and ReactJS, or Emotion." 57 | /> 58 | 59 | 60 | } 62 | display="transparent" 63 | hasBorder 64 | title="Experiment" 65 | description="This starter gives you the perfect environment to experiment 66 | with functionalities, plugins, or anything custom." 67 | /> 68 | 69 | 70 | } 72 | display="transparent" 73 | hasBorder 74 | title="Test functionality" 75 | description="The perfect environment to test a new EUI component or any ReactJS react component. " 76 | /> 77 | 78 | 79 | 80 | ); 81 | }; 82 | 83 | export default HomeWhy; 84 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import React, { ReactElement } from 'react'; 2 | import Document, { Head, Html, Main, NextScript } from 'next/document'; 3 | import { defaultTheme, Theme, themeConfig } from '../lib/theme'; 4 | 5 | const pathPrefix = process.env.PATH_PREFIX; 6 | 7 | function themeLink(theme: Theme): ReactElement { 8 | let disabledProps = {}; 9 | 10 | if (theme.id !== defaultTheme) { 11 | disabledProps = { 12 | disabled: true, 13 | 'aria-disabled': true, 14 | }; 15 | } 16 | 17 | return ( 18 | 27 | ); 28 | } 29 | 30 | /** 31 | * A custom `Document` is commonly used to augment your application's 32 | * `` and `` tags. This is necessary because Next.js pages skip 33 | * the definition of the surrounding document's markup. 34 | * 35 | * In this case, we customize the default `Document` implementation to 36 | * inject the available EUI theme files. Only the `light` theme is 37 | * initially enabled. 38 | * 39 | * @see https://nextjs.org/docs/advanced-features/custom-document 40 | */ 41 | export default class MyDocument extends Document { 42 | render(): ReactElement { 43 | const isLocalDev = process.env.NODE_ENV === 'development'; 44 | 45 | const favicon16Prod = `${pathPrefix}/images/favicon/prod/favicon-16x16.png`; 46 | const favicon32Prod = `${pathPrefix}/images/favicon/prod/favicon-32x32.png`; 47 | const favicon96Prod = `${pathPrefix}/images/favicon/prod/favicon-96x96.png`; 48 | const favicon16Dev = `${pathPrefix}/images/favicon/dev/favicon-16x16.png`; 49 | const favicon32Dev = `${pathPrefix}/images/favicon/dev/favicon-32x32.png`; 50 | const favicon96Dev = `${pathPrefix}/images/favicon/dev/favicon-96x96.png`; 51 | 52 | return ( 53 | 54 | 55 | 59 | 60 | 64 | 68 | 72 | 73 | 74 | 75 | {themeConfig.availableThemes.map(each => themeLink(each))} 76 | 77 | 78 | 79 | 85 | 91 | 97 | 98 | 99 |
100 | 101 | 102 | 103 | ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/components/starter/home_templates.tsx: -------------------------------------------------------------------------------- 1 | import { FunctionComponent } from 'react'; 2 | import { 3 | EuiFlexGroup, 4 | EuiFlexItem, 5 | EuiTitle, 6 | EuiSpacer, 7 | EuiText, 8 | useEuiTheme, 9 | EuiPanel, 10 | EuiButtonEmpty, 11 | } from '@elastic/eui'; 12 | import Image from 'next/image'; 13 | import Link from 'next/link'; 14 | import { imageLoader } from '../../lib/loader'; 15 | import { useTheme } from '../theme'; 16 | import { homeTemplates } from './home_templates.styles'; 17 | import Pattern1 from '../../../public/images/patterns/pattern-1.svg'; 18 | import Pattern2Light from '../../../public/images/patterns/pattern-2-light.svg'; 19 | import Pattern2Dark from '../../../public/images/patterns/pattern-2-dark.svg'; 20 | 21 | const HomeTemplates: FunctionComponent = () => { 22 | const { colorMode } = useTheme(); 23 | const { euiTheme } = useEuiTheme(); 24 | 25 | const Pattern2 = colorMode === 'dark' ? Pattern2Dark : Pattern2Light; 26 | 27 | const styles = homeTemplates(euiTheme); 28 | 29 | const circles = ( 30 | <> 31 | 32 | 39 | 40 | 41 | 48 | 49 | 50 | ); 51 | 52 | return ( 53 | <> 54 | 55 |

Easy start with templates

56 |
57 | 58 | 59 |

60 | To help you get started we provide two templates with some 61 | out-of-the-box patterns. 62 |

63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | {circles} 71 |
72 | 73 |

Kibana template

74 |
75 | 76 | 77 |

78 | This template comes with a collapsible navbar and two stacked 79 | headers just like Kibana is today. On the top header, you can 80 | toggle the dark and light theme. 81 |

82 | 83 | 84 | 85 | Preview Kibana template 86 | 87 | 88 |
89 |
90 |
91 |
92 | 93 | 94 | {circles} 95 |
96 | 97 |

Docs template

98 |
99 | 100 | 101 |

102 | This template comes with a side nav and one header where you 103 | can toggle the dark and light theme. It has a similar layout 104 | as the EUI docs site or Elastic docs. 105 |

106 | 107 | 108 | 109 | Preview Docs template 110 | 111 | 112 |
113 |
114 |
115 |
116 |
117 | 118 | ); 119 | }; 120 | 121 | export default HomeTemplates; 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | EUI Next.js Starter 3 |

4 | 5 | # Elastic's Next.js EUI Starter 6 | > [!IMPORTANT] 7 | > This starter is not constantly maintained and is out of sync with the latest EUI release. The lack of SSR support also currently makes Next.js a challenge with EUI. We plan to enhance our support for Next.js and re-evaulate this project at that time. You can follow along with that initiative with [this issue](https://github.com/elastic/eui/issues/7630) in the EUI repository. 8 | 9 | Jump right in to building prototypes with [EUI](https://github.com/elastic/eui). 10 | 11 | ## 🚀 Super-quick start using CodeSandbox 12 | 13 | 1. Go to 14 | [https://codesandbox.io/s/github/elastic/next-eui-starter](https://codesandbox.io/s/github/elastic/next-eui-starter) 15 | and start editing. CodeSandbox will fork the sandbox when you make 16 | changes! 17 | 18 | ## 🚀 Quick start 19 | 20 | 1. **Install yarn** 21 | 22 | This starter expects to use [yarn](https://yarnpkg.com/) to manage 23 | dependencies, so go install it. 24 | 25 | 1. **Copy the Next.js starter** 26 | 27 | Clone the repository: 28 | 29 | ```sh 30 | git clone https://github.com/elastic/next-eui-starter.git my-eui-starter 31 | ``` 32 | 33 | 1. **Start developing.** 34 | 35 | Navigate into your new site’s directory and start it up. 36 | 37 | ```sh 38 | cd my-eui-starter/ 39 | 40 | # Install depdendencies. 41 | yarn 42 | 43 | # Optional: start a new git project 44 | rm -rf .git && git init && git add . && git commit -m "Initial commit" 45 | 46 | # Start the dev server 47 | yarn dev 48 | ``` 49 | 50 | 1. **Open the source code and start editing!** 51 | 52 | Your site is now running at `http://localhost:3000`! 53 | 54 | Open the `my-eui-starter` directory in your code editor of choice and edit `src/pages/index.tsx`. Save your changes and the browser will update in real time! 55 | 56 | 1. **Deploy your site to GitHub Pages** 57 | 58 | When you're ready to deploy and share your site to GitHub Pages, you can use the provided `yarn build-docs` script to do so. The first time you do this, you need to do some preparation: 59 | 60 | 1. (Optional) If you need to, set the `pathPrefix` option in `next.config.js` to reflect the name of your GitHub repo. The starter kit will try to derive this itself, so you're unlikely to see to do anything here. 61 | 1. (Optional) Commit the above change 62 | 1. Create the GitHub pages branch: `git branch gh-pages` 63 | 64 | Then whenever you want to update your site: 65 | 66 | 1. Commit any pending changes 67 | 1. Run `yarn build-docs` 68 | 1. Publish the `master` and `gh-pages` branches by pushing them to GitHub: `git push origin master gh-pages` 69 | 1. Edit your repository settings to ensure your repository is configured so that the `gh-pages` branch is used for serving the site. (You only need to do this once, but you have to push the branch before you can change this setting) 70 | 1. Access your site at https://your-username.github.io/repo-name. There 71 | can be a slight delay before changes become visible. 72 | 73 | --- 74 | 75 | ## 🧐 What's inside? 76 | 77 | A quick look at the top-level files and directories you'll see in this project. 78 | 79 | . 80 | ├── .eslintrc.js 81 | ├── .gitignore 82 | ├── .next/ 83 | ├── .prettierrc 84 | ├── LICENSE 85 | ├── README.md 86 | ├── next.config.js 87 | ├── node_modules/ 88 | ├── package.json 89 | ├── public/ 90 | ├── src/ 91 | ├── tsconfig.json 92 | └── yarn.lock 93 | 94 | 1. **`.eslintrc.js`**: This file configures [ESLint](https://eslint.org/), which will check the code for potential problems and style issues. It also integrates with Prettier for formatting. 95 | 96 | 2. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. 97 | 98 | 3. **`.next`**: The `next` command line tool uses this for various purposes. You should never need to touch it, but you can delete it without causing any problems. 99 | 100 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. 101 | 102 | 5. **`LICENSE`**: Next.js is licensed under the MIT license. 103 | 104 | 6. **`README.md`**: A text file containing useful reference information about your project. 105 | 106 | 7. **`next.config.js`**: This file customizes the Next.js build process so that it can work with EUI. 107 | 108 | 8. **`node_modules/`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. 109 | 110 | 9. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. 111 | 112 | 10. **`public/`**: Files that will never change can be put here. This starter project automatically puts EUI theme files here during the build 113 | 114 | 11. **`src/`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. 115 | 116 | 12. **`tsconfig.json`**: This file configures the [TypeScript](https://www.typescriptlang.org/) compiler 117 | 118 | 13. **`yarn.lock`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly, but you need to commit any changes to git).** 119 | 120 | ## 🎓 Learning Next.js 121 | 122 | Looking for more guidance? Full documentation for Next.js lives [on the website](https://nextjs.org/). You probably want to being by following the [Getting Started Guide](https://nextjs.org/learn/basics/getting-started). 123 | 124 | ## Other features 125 | 126 | * Bundle analysis - run `yarn analyze` and two windows will open in your browser, showing how big your server and client bundles are, and where that data is coming from. You can use this information to work out where you're sending too much data to the client, and speed up your pages. 127 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-var-requires,@typescript-eslint/no-use-before-define,@typescript-eslint/no-empty-function,prefer-template */ 2 | const crypto = require('crypto'); 3 | const fs = require('fs'); 4 | const glob = require('glob'); 5 | const path = require('path'); 6 | const iniparser = require('iniparser'); 7 | 8 | const withBundleAnalyzer = require('@next/bundle-analyzer'); 9 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 10 | const { IgnorePlugin } = require('webpack'); 11 | 12 | /** 13 | * If you are deploying your site under a directory other than `/` e.g. 14 | * GitHub pages, then you have to tell Next where the files will be served. 15 | * We don't need this during local development, because everything is 16 | * available under `/`. 17 | */ 18 | const usePathPrefix = process.env.PATH_PREFIX === 'true'; 19 | 20 | const pathPrefix = usePathPrefix ? derivePathPrefix() : ''; 21 | 22 | const themeConfig = buildThemeConfig(); 23 | 24 | const nextConfig = { 25 | compiler: { 26 | emotion: true, 27 | }, 28 | /** Disable the `X-Powered-By: Next.js` response header. */ 29 | poweredByHeader: false, 30 | 31 | /** 32 | * When set to something other than '', this field instructs Next to 33 | * expect all paths to have a specific directory prefix. This fact is 34 | * transparent to (almost all of) the rest of the application. 35 | */ 36 | basePath: pathPrefix, 37 | 38 | images: { 39 | loader: 'custom', 40 | }, 41 | 42 | /** 43 | * Set custom `process.env.SOMETHING` values to use in the application. 44 | * You can do this with Webpack's `DefinePlugin`, but this is more concise. 45 | * It's also possible to provide values via `publicRuntimeConfig`, but 46 | * this method is preferred as it can be done statically at build time. 47 | * 48 | * @see https://nextjs.org/docs/api-reference/next.config.js/environment-variables 49 | */ 50 | env: { 51 | PATH_PREFIX: pathPrefix, 52 | THEME_CONFIG: JSON.stringify(themeConfig), 53 | }, 54 | 55 | /** 56 | * Next.js reports TypeScript errors by default. If you don't want to 57 | * leverage this behavior and prefer something else instead, like your 58 | * editor's integration, you may want to disable it. 59 | */ 60 | // typescript: { 61 | // ignoreDevErrors: true, 62 | // }, 63 | 64 | /** Customises the build */ 65 | webpack(config, { isServer }) { 66 | // EUI uses some libraries and features that don't work outside of a 67 | // browser by default. We need to configure the build so that these 68 | // features are either ignored or replaced with stub implementations. 69 | if (isServer) { 70 | config.externals = config.externals.map(eachExternal => { 71 | if (typeof eachExternal !== 'function') { 72 | return eachExternal; 73 | } 74 | 75 | return (context, callback) => { 76 | if (context.request.indexOf('@elastic/eui') > -1) { 77 | return callback(); 78 | } 79 | 80 | return eachExternal(context, callback); 81 | }; 82 | }); 83 | 84 | // Mock HTMLElement on the server-side 85 | const definePluginId = config.plugins.findIndex( 86 | p => p.constructor.name === 'DefinePlugin' 87 | ); 88 | 89 | config.plugins[definePluginId].definitions = { 90 | ...config.plugins[definePluginId].definitions, 91 | HTMLElement: function () {}, 92 | }; 93 | } 94 | 95 | // Copy theme CSS files into `public` 96 | config.plugins.push( 97 | new CopyWebpackPlugin({ patterns: themeConfig.copyConfig }), 98 | 99 | // Moment ships with a large number of locales. Exclude them, leaving 100 | // just the default English locale. If you need other locales, see: 101 | // https://create-react-app.dev/docs/troubleshooting/#momentjs-locales-are-missing 102 | new IgnorePlugin({ 103 | resourceRegExp: /^\.\/locale$/, 104 | contextRegExp: /moment$/, 105 | }) 106 | ); 107 | 108 | config.resolve.mainFields = ['module', 'main']; 109 | 110 | return config; 111 | }, 112 | }; 113 | 114 | /** 115 | * Enhances the Next config with the ability to: 116 | * - Analyze the webpack bundle 117 | * - Load images from JavaScript. 118 | * - Load SCSS files from JavaScript. 119 | */ 120 | module.exports = withBundleAnalyzer({ 121 | enabled: process.env.ANALYZE === 'true', 122 | })(nextConfig); 123 | 124 | /** 125 | * Find all EUI themes and construct a theme configuration object. 126 | * 127 | * The `copyConfig` key is used to configure CopyWebpackPlugin, which 128 | * copies the default EUI themes into the `public` directory, injecting a 129 | * hash into the filename so that when EUI is updated, new copies of the 130 | * themes will be fetched. 131 | * 132 | * The `availableThemes` key is used in the app to includes the themes in 133 | * the app's `` element, and for theme switching. 134 | * 135 | * @return {ThemeConfig} 136 | */ 137 | function buildThemeConfig() { 138 | const themeFiles = glob.sync( 139 | path.join( 140 | __dirname, 141 | 'node_modules', 142 | '@elastic', 143 | 'eui', 144 | 'dist', 145 | 'eui_theme_*.min.css' 146 | ) 147 | ); 148 | 149 | const themeConfig = { 150 | availableThemes: [], 151 | copyConfig: [], 152 | }; 153 | 154 | for (const each of themeFiles) { 155 | const basename = path.basename(each, '.min.css'); 156 | 157 | const themeId = basename.replace(/^eui_theme_/, ''); 158 | 159 | const themeName = 160 | themeId[0].toUpperCase() + themeId.slice(1).replace(/_/g, ' '); 161 | 162 | const publicPath = `themes/${basename}.${hashFile(each)}.min.css`; 163 | const toPath = path.join( 164 | __dirname, 165 | `public`, 166 | `themes`, 167 | `${basename}.${hashFile(each)}.min.css` 168 | ); 169 | 170 | themeConfig.availableThemes.push({ 171 | id: themeId, 172 | name: themeName, 173 | publicPath, 174 | }); 175 | 176 | themeConfig.copyConfig.push({ 177 | from: each, 178 | to: toPath, 179 | }); 180 | } 181 | 182 | return themeConfig; 183 | } 184 | 185 | /** 186 | * Given a file, calculate a hash and return the first portion. The number 187 | * of characters is truncated to match how Webpack generates hashes. 188 | * 189 | * @param {string} filePath the absolute path to the file to hash. 190 | * @return string 191 | */ 192 | function hashFile(filePath) { 193 | const hash = crypto.createHash(`sha256`); 194 | const fileData = fs.readFileSync(filePath); 195 | hash.update(fileData); 196 | const fullHash = hash.digest(`hex`); 197 | 198 | // Use a hash length that matches what Webpack does 199 | return fullHash.substr(0, 20); 200 | } 201 | 202 | /** 203 | * This starter assumes that if `usePathPrefix` is true, then you're serving the site 204 | * on GitHub pages. If that isn't the case, then you can simply replace the call to 205 | * this function with whatever is the correct path prefix. 206 | * 207 | * The implementation attempts to derive a path prefix for serving up a static site by 208 | * looking at the following in order. 209 | * 210 | * 1. The git config for "origin" 211 | * 2. The `name` field in `package.json` 212 | * 213 | * Really, the first should be sufficient and correct for a GitHub Pages site, because the 214 | * repository name is what will be used to serve the site. 215 | */ 216 | function derivePathPrefix() { 217 | const gitConfigPath = path.join(__dirname, '.git', 'config'); 218 | 219 | if (fs.existsSync(gitConfigPath)) { 220 | const gitConfig = iniparser.parseSync(gitConfigPath); 221 | 222 | if (gitConfig['remote "origin"'] != null) { 223 | const originUrl = gitConfig['remote "origin"'].url; 224 | 225 | // eslint-disable-next-line prettier/prettier 226 | return '/' + originUrl.split('/').pop().replace(/\.git$/, ''); 227 | } 228 | } 229 | 230 | const packageJsonPath = path.join(__dirname, 'package.json'); 231 | 232 | if (fs.existsSync(packageJsonPath)) { 233 | const { name: packageName } = require(packageJsonPath); 234 | // Strip out any username / namespace part. This works even if there is 235 | // no username in the package name. 236 | return '/' + packageName.split('/').pop(); 237 | } 238 | 239 | throw new Error( 240 | "Can't derive path prefix, as neither .git/config nor package.json exists" 241 | ); 242 | } 243 | -------------------------------------------------------------------------------- /src/layouts/kibana_collapsible_nav.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { 3 | EuiCollapsibleNav, 4 | EuiCollapsibleNavGroup, 5 | EuiHeaderSectionItemButton, 6 | EuiHeaderLogo, 7 | EuiHeader, 8 | EuiIcon, 9 | EuiPinnableListGroup, 10 | EuiPinnableListGroupItemProps, 11 | EuiFlexItem, 12 | EuiHorizontalRule, 13 | EuiListGroup, 14 | useGeneratedHtmlId, 15 | EuiAvatar, 16 | EuiThemeProvider, 17 | } from '@elastic/eui'; 18 | import find from 'lodash/find'; 19 | import findIndex from 'lodash/findIndex'; 20 | import { css } from '@emotion/react'; 21 | import ThemeSwitcher from '../components/chrome/theme_switcher'; 22 | 23 | const pathPrefix = process.env.PATH_PREFIX; 24 | 25 | const TopLinks: EuiPinnableListGroupItemProps[] = [ 26 | { 27 | label: 'Home', 28 | iconType: 'home', 29 | isActive: true, 30 | 'aria-current': true, 31 | href: `${pathPrefix}/kibana`, 32 | pinnable: false, 33 | }, 34 | ]; 35 | 36 | const KibanaLinks: EuiPinnableListGroupItemProps[] = [ 37 | { label: 'Discover', href: `${pathPrefix}/kibana/discover` }, 38 | { label: 'Dashboard', href: `${pathPrefix}/kibana/dashboards` }, 39 | { label: 'Maps', href: `${pathPrefix}/kibana/maps` }, 40 | ]; 41 | 42 | const CollapsibleNav = () => { 43 | const [navIsOpen, setNavIsOpen] = useState(false); 44 | 45 | const breadcrumbs = [ 46 | { 47 | text: 'Home', 48 | }, 49 | ]; 50 | 51 | /** 52 | * Accordion toggling 53 | */ 54 | const [openGroups, setOpenGroups] = useState(['Kibana']); 55 | 56 | // Save which groups are open and which are not with state and local store 57 | const toggleAccordion = (isOpen: boolean, title?: string) => { 58 | if (!title) return; 59 | const itExists = openGroups.includes(title); 60 | if (isOpen) { 61 | if (itExists) return; 62 | openGroups.push(title); 63 | } else { 64 | const index = openGroups.indexOf(title); 65 | if (index > -1) { 66 | openGroups.splice(index, 1); 67 | } 68 | } 69 | setOpenGroups([...openGroups]); 70 | localStorage.setItem('openNavGroups', JSON.stringify(openGroups)); 71 | }; 72 | 73 | /** 74 | * Pinning 75 | */ 76 | const [pinnedItems, setPinnedItems] = useState< 77 | EuiPinnableListGroupItemProps[] 78 | >([]); 79 | 80 | const addPin = (item: EuiPinnableListGroupItemProps) => { 81 | if (!item || find(pinnedItems, { label: item.label })) { 82 | return; 83 | } 84 | item.pinned = true; 85 | const newPinnedItems = pinnedItems ? pinnedItems.concat(item) : [item]; 86 | setPinnedItems(newPinnedItems); 87 | localStorage.setItem('pinnedItems', JSON.stringify(newPinnedItems)); 88 | }; 89 | 90 | const removePin = (item: EuiPinnableListGroupItemProps) => { 91 | const pinIndex = findIndex(pinnedItems, { label: item.label }); 92 | if (pinIndex > -1) { 93 | item.pinned = false; 94 | const newPinnedItems = pinnedItems; 95 | newPinnedItems.splice(pinIndex, 1); 96 | setPinnedItems([...newPinnedItems]); 97 | localStorage.setItem('pinnedItems', JSON.stringify(newPinnedItems)); 98 | } 99 | }; 100 | 101 | function alterLinksWithCurrentState( 102 | links: EuiPinnableListGroupItemProps[], 103 | showPinned = false 104 | ): EuiPinnableListGroupItemProps[] { 105 | return links.map(link => { 106 | const { pinned, ...rest } = link; 107 | return { 108 | pinned: showPinned ? pinned : false, 109 | ...rest, 110 | }; 111 | }); 112 | } 113 | 114 | function addLinkNameToPinTitle(listItem: EuiPinnableListGroupItemProps) { 115 | return `Pin ${listItem.label} to top`; 116 | } 117 | 118 | function addLinkNameToUnpinTitle(listItem: EuiPinnableListGroupItemProps) { 119 | return `Unpin ${listItem.label}`; 120 | } 121 | 122 | const collapsibleNavId = useGeneratedHtmlId({ prefix: 'collapsibleNav' }); 123 | 124 | const collapsibleNav = ( 125 | setNavIsOpen(!navIsOpen)}> 139 | 212 | ); 213 | 214 | const leftSectionItems = [collapsibleNav]; 215 | 216 | return ( 217 | <> 218 | 228 | Elastic 229 | , 230 | ], 231 | borders: 'none', 232 | }, 233 | { 234 | items: [ 235 | , 236 | 239 | 240 | , 241 | ], 242 | borders: 'none', 243 | }, 244 | ]} 245 | /> 246 | 247 | 259 | 260 | , 261 | ], 262 | breadcrumbs: breadcrumbs, 263 | borders: 'right', 264 | }, 265 | ]} 266 | /> 267 | 268 | ); 269 | }; 270 | 271 | export default CollapsibleNav; 272 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2019 Elasticsearch BV 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /public/images/patterns/pattern-1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /public/images/home/illustration-eui-hero-500-shadow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | --------------------------------------------------------------------------------