diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e2ae3afd1..67d3880ca84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # [`master`](https://github.com/elastic/eui/tree/master) +- Added `EuiInMemoryTable`, which encapsulates sorting, searching, selection, and pagination state +and logic ([#390](https://github.com/elastic/eui/pull/390)) +- Added stack trace information to `EuiErrorBoundary` ([#428](https://github.com/elastic/eui/pull/428)) + **Bug fixes** - Fixed `EuiContextMenu` bug when using the keyboard to navigate up, which was caused by unnecessarily re-rendering the items, thus losing references to them ([#431](https://github.com/elastic/eui/pull/431)) @@ -9,7 +13,7 @@ - Added `EuiDelayHide` component. ([#412](https://github.com/elastic/eui/pull/412)) - Decreased overall size of checkbox, radio, and switches as well as better styles for the different states. ([#407](https://github.com/elastic/eui/pull/407)) - Added `EuiFilePicker` component for `input type="file"` needs. ([#402](https://github.com/elastic/eui/pedull/402)) -- Add `isLoading` prop to `EuiButton` ([#427](https://github.com/elastic/eui/pull/427)) +- Added `isLoading` prop to `EuiButton` ([#427](https://github.com/elastic/eui/pull/427)) - Added icons: `eye`, `eyeClosed`, `grab`, `heatmap`, `vector` ([#427](https://github.com/elastic/eui/pull/427)) - Added `hasNoInitialSelection` option to `EuiSelect`. ([#422](https://github.com/elastic/eui/pull/422)) @@ -19,7 +23,7 @@ - Fixed disabled vs enabled appearance of checked checkeboxes and radios ([#407](https://github.com/elastic/eui/pull/407)) - Fixed disabled & checked state of switches ([#407](https://github.com/elastic/eui/pull/407)) - Fixed `EuiCard` content alignment when content is short. ([#415](https://github.com/elastic/eui/pull/415)) -- Only apply the `$euiCodeBlockSelectedBackgroundColor` variable if it is a color ([#427](https://github.com/elastic/eui/pull/427)) +- Only apply the `$euiCodeBlockSelectedBackgroundColor` variable if it is a color ([#427](https://github.com/elastic/eui/pull/427)) - No margins for `
` ([#427](https://github.com/elastic/eui/pull/427)) - Fixed `EuiButton` truncation ([#427](https://github.com/elastic/eui/pull/427)) @@ -36,17 +40,17 @@ - Added horizontal steps component ([#375](https://github.com/elastic/eui/pull/375)) - Changed look and feel of pagination. Added `compressed` prop for smaller footprint pagination. ([#380](https://github.com/elastic/eui/pull/380)) - Added `EuiBasicTable` as an opinionated, high level component for constructing tables. Its addition deprecates `EuiTableOfRecords` which is still avaiable, but now marked for removal. ([#377](https://github.com/elastic/eui/pull/377)) -- Add styles for `readOnly` states of form controls. ([#391](https://github.com/elastic/eui/pull/391)) +- Added styles for `readOnly` states of form controls. ([#391](https://github.com/elastic/eui/pull/391)) - Added importAction and exportAction icons ([#394](https://github.com/elastic/eui/pull/394)) - Added `EuiCard` for UI patterns that need an icon/image, title and description with some sort of action. ([#380](https://github.com/elastic/eui/pull/380)) -- Add TypeScript definitions for the `EuiHealth` component. ([#403](https://github.com/elastic/eui/pull/403)) +- Added TypeScript definitions for the `EuiHealth` component. ([#403](https://github.com/elastic/eui/pull/403)) - Added `SearchBar` component - introduces a simple yet rich query language to search for objects + search box and filter controls to construct/manipulate it. ([#379](https://github.com/elastic/eui/pull/379)) **Bug fixes** - Tables now default to `table-layout: fixed` to avoid some collapsing cell problems. [#398](https://github.com/elastic/eui/pull/398) - Wrap long lines of text within the body of `EuiToast` instead of letting text overflow ([#392](https://github.com/elastic/eui/pull/392)) -- Fix dark theme coloring of Substeps ([#396](https://github.com/elastic/eui/pull/396)) +- Fixed dark theme coloring of Substeps ([#396](https://github.com/elastic/eui/pull/396)) - Reorder selectors to fix fixed progress bar in Firefox ([#404](https://github.com/elastic/eui/pull/404)) # [`0.0.20`](https://github.com/elastic/eui/tree/v0.0.20) @@ -184,8 +188,8 @@ **Bug fixes** -- Fix bug in `Pager` service which occurred when there were no items. [(#237)[https://github.com/elastic/eui/pull/237]] -- Add `isPageable` method to `Pager` service and set first and last page index to -1 when there are no pages. [(#242)[https://github.com/elastic/eui/pull/242]] +- Fixed bug in `Pager` service which occurred when there were no items. [(#237)[https://github.com/elastic/eui/pull/237]] +- Added `isPageable` method to `Pager` service and set first and last page index to -1 when there are no pages. [(#242)[https://github.com/elastic/eui/pull/242]] # [`0.0.9`](https://github.com/elastic/eui/tree/v0.0.9) @@ -219,13 +223,13 @@ # [`0.0.6`](https://github.com/elastic/eui/tree/v0.0.6) - `justify` prop of `EuiFlexGroup` now accepts `spaceEvenly` [(#205)](https://github.com/elastic/eui/pull/205) -- Increase size of `` so that it's distinguishable as a title [(#204)](https://github.com/elastic/eui/pull/204) +- Increased size of `` so that it's distinguishable as a title [(#204)](https://github.com/elastic/eui/pull/204) # [`0.0.5`](https://github.com/elastic/eui/tree/v0.0.5) **Bug fixes** -- Fixed import paths for `EuiTable`, `EuiHealth`, and `EuiPopover` which prevented dependents of EUI from being able to compile when importing components from the `lib` directory [(#203)](https://github.com/elastic/eui/pull/203) +- Fixed import paths for `EuiTable`, `EuiHealth`, and `EuiPopover` which prevented dependents of EUI from being able to compile when importing components from the `lib` directory [(#203)](https://github.com/elastic/eui/pull/203) # [`0.0.4`](https://github.com/elastic/eui/tree/v0.0.4) @@ -236,18 +240,17 @@ - Table spacing is now smaller [(#158)](https://github.com/elastic/eui/pull/158) - Dark theme forms now have better contrast with their borders [(#158)](https://github.com/elastic/eui/pull/158) - Added icons to match Kibana's app directory [(#162)](https://github.com/elastic/eui/pull/162) -- Convert icons from SVG to React component during the build and stop using - sprites [(#160)](https://github.com/elastic/eui/pull/160) -- Add `isReadOnly`, `setOptions`, and `cursorStart` props to `EuiCodeEditor` ([#169](https://github.com/elastic/eui/pull/169)) -- Add `wrap` prop to `EuiFlexGroup` ([#170](https://github.com/elastic/eui/pull/170)) -- Add `scope` prop to `EuiTableHeaderCell` and `EuiTableHeaderCellCheckbox` ([#171](https://github.com/elastic/eui/pull/171)) -- Add `disabled` prop to `EuiContextMenuItem` ([#172](https://github.com/elastic/eui/pull/172)) -- Add `EuiTablePagination` component and `Pager` service ([#178](https://github.com/elastic/eui/pull/178)) -- Add `EuiTooltip` component ([#174](https://github.com/elastic/eui/pull/174), [#193](https://github.com/elastic/eui/pull/193)) -- Add a bold weight of 700 and apply it to `` elements by default ([#193](https://github.com/elastic/eui/pull/193)) +- Converted icons from SVG to React component during the build and stop using sprites [(#160)](https://github.com/elastic/eui/pull/160) +- Added `isReadOnly`, `setOptions`, and `cursorStart` props to `EuiCodeEditor` ([#169](https://github.com/elastic/eui/pull/169)) +- Added `wrap` prop to `EuiFlexGroup` ([#170](https://github.com/elastic/eui/pull/170)) +- Added `scope` prop to `EuiTableHeaderCell` and `EuiTableHeaderCellCheckbox` ([#171](https://github.com/elastic/eui/pull/171)) +- Added `disabled` prop to `EuiContextMenuItem` ([#172](https://github.com/elastic/eui/pull/172)) +- Added `EuiTablePagination` component and `Pager` service ([#178](https://github.com/elastic/eui/pull/178)) +- Added `EuiTooltip` component ([#174](https://github.com/elastic/eui/pull/174), [#193](https://github.com/elastic/eui/pull/193)) +- Added a bold weight of 700 and apply it to `` elements by default ([#193](https://github.com/elastic/eui/pull/193)) - Icon size prop now accepts `s`. Adjusted coloring of sidenav arrows ([#178](https://github.com/elastic/eui/pull/197)) -- Add `EuiErrorBoundary` ([#198](https://github.com/elastic/eui/pull/198)) -- Export `test` module, which includes `findTestSubject`, `startThrowingReactWarnings`, `stopThrowingReactWarnings`, `requiredProps`, and `takeMountedSnapshot` helpers ([#198](https://github.com/elastic/eui/pull/198)) +- Added `EuiErrorBoundary` ([#198](https://github.com/elastic/eui/pull/198)) +- Exported `test` module, which includes `findTestSubject`, `startThrowingReactWarnings`, `stopThrowingReactWarnings`, `requiredProps`, and `takeMountedSnapshot` helpers ([#198](https://github.com/elastic/eui/pull/198)) - Added a more systematic way to add themes; includes a new K6 theme for Kibana. [(#191)](https://github.com/elastic/eui/pull/191) **Bug fixes** @@ -265,7 +268,7 @@ - `EuiFlexItem` now accepts integers between 1 and 10 for the `grow` prop. [(#144)](https://github.com/elastic/eui/pull/144) - `EuiFlexItem` and `EuiFlexGrow` now accept a `component` prop which you can set to `span` or `div` (default). [(#141)](https://github.com/elastic/eui/pull/141) -- Add `isLoading` prop to form inputs to allow for a loading state [(#150)](https://github.com/elastic/eui/pull/150) +- Added `isLoading` prop to form inputs to allow for a loading state [(#150)](https://github.com/elastic/eui/pull/150) **Breaking changes** diff --git a/src-docs/src/components/guide_components.scss b/src-docs/src/components/guide_components.scss index 1b5a4a069c3..06b4cbe24f4 100644 --- a/src-docs/src/components/guide_components.scss +++ b/src-docs/src/components/guide_components.scss @@ -115,6 +115,5 @@ $guideZLevelHighest: $euiZLevel9 + 1000; } } -@import "guide_sandbox/index"; @import "guide_section/index"; @import "guide_rule/index"; diff --git a/src-docs/src/components/guide_page/guide_page_chrome.js b/src-docs/src/components/guide_page/guide_page_chrome.js index 08b9d2d010d..78fa2b683f6 100644 --- a/src-docs/src/components/guide_page/guide_page_chrome.js +++ b/src-docs/src/components/guide_page/guide_page_chrome.js @@ -91,172 +91,47 @@ export class GuidePageChrome extends Component { })); } - renderGuidelineNavItems() { - const matchingItems = this.props.guidelines.filter(item => ( - item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 - )); - - const items = matchingItems.map(item => { - const { - name, - path, - sections, - } = item; - - return { - id: `guideline-${path}`, - name, - href: `#/${path}`, - items: this.renderSubSections(sections), - isSelected: name === this.props.currentRouteName, - }; - }); - - if (!items.length) { - return; - } - - return { - name: 'Guidelines', - id: 'guidelines', - items, - }; - } - - renderServiceNavItems() { - const matchingItems = this.props.services.filter(item => ( - item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 - )); - - const items = matchingItems.map(item => { - const { - name, - path, - sections, - } = item; - - return { - id: `service-${path}`, - name, - href: `#/${path}`, - items: this.renderSubSections(sections), - isSelected: name === this.props.currentRouteName, - }; - }); - - if (!items.length) { - return; - } - - return { - name: 'Services', - id: 'services', - items, - }; - } - - renderComponentNavItems() { - const matchingItems = this.props.components.filter(item => ( - item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 - )); - - const items = matchingItems.map(item => { - const { - name, - path, - sections, - } = item; - - return { - id: `component-${path}`, - name, - href: `#/${path}`, - items: this.renderSubSections(sections), - isSelected: name === this.props.currentRouteName, - }; - }); - - if (!items.length) { - return; - } - - return { - name: 'Components', - id: 'components', - items, - }; - } - - rendePatternNavItems() { - const matchingItems = this.props.patterns.filter(item => ( - item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 - )); - - const items = matchingItems.map(item => { - const { - name, - path, - sections, - } = item; - - return { - id: `pattern-${path}`, - name, - href: `#/${path}`, - items: this.renderSubSections(sections), - isSelected: name === this.props.currentRouteName, - }; - }); - - if (!items.length) { - return; - } - - return { - name: 'Patterns', - id: 'patterns', - items, - }; - } - - renderSandboxNavItems() { - const matchingItems = this.props.sandboxes.filter(item => ( - item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 - )); - - const items = matchingItems.map(item => { - const { - name, - path, - } = item; - - return { - id: `sandbox-${path}`, - name, - href: `#/${path}`, - isSelected: name === this.props.currentRouteName, - }; + renderSideNav = sideNav => { + // TODO: Add contents pages + const sideNavSections = []; + + sideNav.forEach(section => { + const matchingItems = section.items.filter(item => ( + item.name.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 + )); + + const items = matchingItems.map(item => { + const { + name, + path, + sections, + } = item; + + return { + id: `${section.type}-${path}`, + name, + href: `#/${path}`, + items: this.renderSubSections(sections), + isSelected: name === this.props.currentRouteName, + }; + }); + + if (!items.length) { + return; + } + + sideNavSections.push({ + name: section.name, + id: section.type, + items, + }); }); - if (!items.length) { - return; - } - - return { - name: 'Sandboxes', - id: 'sandboxes', - items, - }; - } + return sideNavSections; + }; render() { - const sideNav = [ - this.renderGuidelineNavItems(), - this.renderServiceNavItems(), - this.renderComponentNavItems(), - this.rendePatternNavItems(), - this.renderSandboxNavItems(), - ].filter(section => section); + const sideNav = this.renderSideNav(this.props.navigation); let sideNavContent; @@ -301,9 +176,5 @@ GuidePageChrome.propTypes = { currentRouteName: PropTypes.string.isRequired, onToggleTheme: PropTypes.func.isRequired, selectedTheme: PropTypes.string.isRequired, - guidelines: PropTypes.array.isRequired, - services: PropTypes.array.isRequired, - components: PropTypes.array.isRequired, - patterns: PropTypes.array.isRequired, - sandboxes: PropTypes.array.isRequired, + navigation: PropTypes.array.isRequired, }; diff --git a/src-docs/src/components/guide_sandbox/_guide_sandbox_chrome.scss b/src-docs/src/components/guide_sandbox/_guide_sandbox_chrome.scss deleted file mode 100644 index 0aaf81f5f14..00000000000 --- a/src-docs/src/components/guide_sandbox/_guide_sandbox_chrome.scss +++ /dev/null @@ -1,30 +0,0 @@ -.guideSandboxChrome { - background: #222; - color: #FFF !important; - height: $euiSizeXXL; - border-bottom: $euiBorderThin; - line-height: $euiSizeXXL; - padding-left: $euiSizeS; -} - -.guideSandboxChrome__link { - color: #FFF; -} - -.guideSandboxChrome__appListIcon { - fill: #FFF !important; -} - -.guideSandboxChromeToggle { - position: fixed; - z-index: $guideZLevelHighest; - right: 0; - bottom: $euiSizeXXL; - padding: $euiSizeS; - background-color: $euiColorPrimary; - color: $euiColorEmptyShade; - - svg { - fill: $euiColorEmptyShade; - } -} diff --git a/src-docs/src/components/guide_sandbox/_index.scss b/src-docs/src/components/guide_sandbox/_index.scss deleted file mode 100644 index 81a7b53ec26..00000000000 --- a/src-docs/src/components/guide_sandbox/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import "./guide_sandbox_chrome"; diff --git a/src-docs/src/components/guide_sandbox/guide_sandbox_chrome.js b/src-docs/src/components/guide_sandbox/guide_sandbox_chrome.js deleted file mode 100644 index 496b5485d97..00000000000 --- a/src-docs/src/components/guide_sandbox/guide_sandbox_chrome.js +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { - Link, -} from 'react-router'; - -import { - EuiIcon, - EuiFlexGroup, - EuiFlexItem, -} from '../../../../src/components'; - -import { - GuideThemeSelector, -} from '../guide_theme_selector'; - -import { - GuideSandboxChromeToggle, -} from './guide_sandbox_chrome_toggle'; - -export const GuideSandboxChrome = ({ - isVisible, - onToggleTheme, - onToggleSandboxChrome, - selectedTheme, -}) => { - const toggle = ; - - if (!isVisible) { - return toggle; - } - - return ( -
- - - - - - - - - - - - - {toggle} -
- ); -}; - -GuideSandboxChrome.propTypes = { - routes: PropTypes.array.isRequired, - onToggleTheme: PropTypes.func.isRequired, - onToggleSandboxChrome: PropTypes.func.isRequired, - selectedTheme: PropTypes.string.isRequired, - isVisible: PropTypes.bool, -}; diff --git a/src-docs/src/components/guide_sandbox/guide_sandbox_chrome_toggle.js b/src-docs/src/components/guide_sandbox/guide_sandbox_chrome_toggle.js deleted file mode 100644 index 79a0fd43da3..00000000000 --- a/src-docs/src/components/guide_sandbox/guide_sandbox_chrome_toggle.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { - EuiIcon, -} from '../../../../src/components'; - -export const GuideSandboxChromeToggle = ({ - onClick, -}) => ( - -); - -GuideSandboxChromeToggle.propTypes = { - onClick: PropTypes.func.isRequired, -}; diff --git a/src-docs/src/components/guide_sandbox/index.js b/src-docs/src/components/guide_sandbox/index.js deleted file mode 100644 index 6cc2ac18890..00000000000 --- a/src-docs/src/components/guide_sandbox/index.js +++ /dev/null @@ -1 +0,0 @@ -export { GuideSandboxChrome } from './guide_sandbox_chrome'; diff --git a/src-docs/src/components/guide_section/_guide_section.scss b/src-docs/src/components/guide_section/_guide_section.scss index 3dc7b0e880f..2e46edff3da 100644 --- a/src-docs/src/components/guide_section/_guide_section.scss +++ b/src-docs/src/components/guide_section/_guide_section.scss @@ -8,17 +8,6 @@ height: $euiSizeL; } -.guideSandbox { - .guideSection__text { - margin-top: $euiSizeXL; - padding: 0 $euiSizeL; - } - - .guideSection__space { - height: 0; - } -} - .guideSectionPropsTable { width: auto; min-width: 50%; diff --git a/src-docs/src/components/guide_section/guide_section.js b/src-docs/src/components/guide_section/guide_section.js index ea3fffd69cd..ac094b7f0ca 100644 --- a/src-docs/src/components/guide_section/guide_section.js +++ b/src-docs/src/components/guide_section/guide_section.js @@ -2,10 +2,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { flatten } from 'lodash'; -import { - GuideSandboxChrome, -} from '../guide_sandbox'; - import { EuiCode, EuiCodeBlock, @@ -110,9 +106,6 @@ export class GuideSection extends Component { this.state = { selectedTab: this.tabs[0], - sandbox: { - isChromeVisible: props.isSandbox ? false : undefined, - }, }; } @@ -122,14 +115,6 @@ export class GuideSection extends Component { }); } - onToggleSandboxChrome = () => { - this.setState({ - sandbox: { - isChromeVisible: !this.state.sandbox.isChromeVisible, - }, - }); - } - renderTabs() { return this.tabs.map(tab => ( - ); - } - - if (this.props.isSandbox && !this.state.sandbox.isChromeVisible) { - return header; - } - return (
- {header}

{this.props.title}

@@ -396,7 +362,6 @@ GuideSection.propTypes = { id: PropTypes.string, source: PropTypes.array, children: PropTypes.any, - isSandbox: PropTypes.bool, toggleTheme: PropTypes.func.isRequired, theme: PropTypes.string.isRequired, routes: PropTypes.object.isRequired, diff --git a/src-docs/src/components/guide_section/guide_section_container.js b/src-docs/src/components/guide_section/guide_section_container.js index 94dfd3a04de..75d322fd63d 100644 --- a/src-docs/src/components/guide_section/guide_section_container.js +++ b/src-docs/src/components/guide_section/guide_section_container.js @@ -3,7 +3,6 @@ import { connect } from 'react-redux'; import { GuideSection } from './guide_section'; import { - getIsSandbox, getTheme, getRoutes, } from '../../store'; @@ -14,7 +13,6 @@ import { function mapStateToProps(state) { return { - isSandbox: getIsSandbox(state), theme: getTheme(state), routes: getRoutes(state), }; diff --git a/src-docs/src/components/index.js b/src-docs/src/components/index.js index 1157bb59568..460237c5c56 100644 --- a/src-docs/src/components/index.js +++ b/src-docs/src/components/index.js @@ -10,10 +10,6 @@ export { GuidePageChrome, } from './guide_page'; -export { - GuideSandboxChrome, -} from './guide_sandbox'; - export { GuideSection, GuideSectionTypes, diff --git a/src-docs/src/routes.js b/src-docs/src/routes.js index 464aed5812b..c37a4170d96 100644 --- a/src-docs/src/routes.js +++ b/src-docs/src/routes.js @@ -14,13 +14,14 @@ import { EuiErrorBoundary, } from '../../src/components'; -import { Slugify } from './services'; - // Guidelines import WritingGuidelines from './views/guidelines/writing'; +import TextScales + from './views/text_scaling/text_scaling_sandbox'; + // Services import { IsColorDarkExample } @@ -169,27 +170,22 @@ import { ToastExample } import { TooltipExample } from './views/tooltip/tooltip_example'; -// Patterns - -// Sandboxes - -import AdvancedSettingsSandbox - from './views/kibana/advanced_settings_sandbox'; - -import WatchesSandbox - from './views/kibana/watches_sandbox'; - -import TextScalingSandbox - from './views/text_scaling/text_scaling_sandbox'; - -const guidelines = [{ - name: 'Writing', - component: WritingGuidelines, -}]; +/** + * Lowercases input and replaces spaces with hyphens: + * e.g. 'GridView Example' -> 'gridview-example' + */ +const slugify = str => { + const parts = str + .toLowerCase() + .replace(/[-]+/g, ' ') + .replace(/[^\w^\s]+/g, '') + .replace(/ +/g, ' ').split(' '); + return parts.join('-'); +}; const createExample = ({ title, intro, sections }) => { sections.forEach(section => { - section.id = Slugify.one(section.title); + section.id = slugify(section.title); }); const renderedSections = sections.map(section => createElement(GuideSection, { @@ -213,93 +209,102 @@ const createExample = ({ title, intro, sections }) => { }; }; -// Component route names should match the component name exactly. -const services = [ - IsColorDarkExample, -].map(example => createExample(example)); - -// Component route names should match the component name exactly. -const components = [ - AccessibilityExample, - AccordionExample, - AvatarExample, - BadgeExample, - BottomBarExample, - ButtonExample, - CardExample, - CallOutExample, - CodeEditorExample, - CodeExample, - ColorPickerExample, - ContextMenuExample, - DelayHideExample, - DescriptionListExample, - ErrorBoundaryExample, - ExpressionExample, - FilterGroupExample, - FilePickerExample, - FlexExample, - FlyoutExample, - FormExample, - HeaderExample, - HealthExample, - HorizontalRuleExample, - IconExample, - ImageExample, - KeyPadMenuExample, - LinkExample, - LoadingExample, - ModalExample, - OutsideClickDetectorExample, - PageExample, - PaginationExample, - PanelExample, - PopoverExample, - ProgressExample, - SearchBarExample, - SideNavExample, - SpacerExample, - StepsExample, - TableExample, - TableOfRecordsExample, - TabsExample, - TextExample, - TitleExample, - ToastExample, - TooltipExample, -].map(example => createExample(example)); - -const patterns = [ -].map(example => createExample(example)); - -const sandboxes = [{ - name: 'Advanced Settings', - component: AdvancedSettingsSandbox, +const navigation = [{ + name: 'Guidelines', + items: [{ + name: 'Writing', + component: WritingGuidelines, + }, { + name: 'Text scales', + component: TextScales, + }], }, { - name: 'Watches', - component: WatchesSandbox, + name: 'Layout', + items: [ + AccordionExample, + BottomBarExample, + FlexExample, + FlyoutExample, + HeaderExample, + HorizontalRuleExample, + ModalExample, + PageExample, + PanelExample, + PopoverExample, + SpacerExample, + ].map(example => createExample(example)), }, { - name: 'Text scales', - component: TextScalingSandbox, -}]; - -sandboxes.forEach(sandbox => { sandbox.isSandbox = true; }); - -const allRoutes = [ - ...guidelines, - ...services, - ...components, - ...sandboxes, - ...patterns, -]; + name: 'Navigation', + items: [ + ButtonExample, + ContextMenuExample, + KeyPadMenuExample, + LinkExample, + PaginationExample, + SideNavExample, + StepsExample, + TabsExample, + ].map(example => createExample(example)), +}, { + name: 'Display', + items: [ + AvatarExample, + BadgeExample, + CallOutExample, + CardExample, + CodeExample, + DescriptionListExample, + HealthExample, + IconExample, + ImageExample, + LoadingExample, + ProgressExample, + TableExample, + TableOfRecordsExample, + TextExample, + TitleExample, + ToastExample, + TooltipExample, + ].map(example => createExample(example)), +}, { + name: 'Forms', + items: [ + CodeEditorExample, + ColorPickerExample, + ExpressionExample, + FilePickerExample, + FilterGroupExample, + FormExample, + SearchBarExample, + ].map(example => createExample(example)), +}, { + name: 'Utilities', + items: [ + AccessibilityExample, + DelayHideExample, + ErrorBoundaryExample, + IsColorDarkExample, + OutsideClickDetectorExample, + ].map(example => createExample(example)), +}].map(({ name, items, ...rest }) => ({ + name, + type: slugify(name), + items: items.map(({ name: itemName, ...rest }) => ({ + name: itemName, + path: `${slugify(name)}/${slugify(itemName)}`, + ...rest, + })), + ...rest +})); + +const allRoutes = navigation.reduce((accummulatedRoutes, section) => { + accummulatedRoutes.push(...section.items); + return accummulatedRoutes; +}, []); export default { history: useRouterHistory(createHashHistory)(), - guidelines: Slugify.each(guidelines, 'name', 'path'), - services: Slugify.each(services, 'name', 'path'), - components: Slugify.each(components, 'name', 'path'), - patterns: Slugify.each(patterns, 'name', 'path'), - sandboxes: Slugify.each(sandboxes, 'name', 'path'), + navigation, getRouteForPath: path => { // React-router kinda sucks. Sometimes the path contains a leading slash, sometimes it doesn't. diff --git a/src-docs/src/services/index.js b/src-docs/src/services/index.js index 5b06f5123a9..c7a3a967ba4 100644 --- a/src-docs/src/services/index.js +++ b/src-docs/src/services/index.js @@ -4,5 +4,3 @@ export { registerTheme, applyTheme, } from './theme/theme'; - -export { default as Slugify } from './string/slugify'; diff --git a/src-docs/src/services/string/slugify.js b/src-docs/src/services/string/slugify.js deleted file mode 100644 index 5447929d4bb..00000000000 --- a/src-docs/src/services/string/slugify.js +++ /dev/null @@ -1,27 +0,0 @@ - - -/** - * Lowercases input and replaces spaces with hyphens: - * e.g. 'GridView Example' -> 'gridview-example' - */ -function one(str) { - const parts = str - .toLowerCase() - .replace(/[-]+/g, ' ') - .replace(/[^\w^\s]+/g, '') - .replace(/ +/g, ' ').split(' '); - return parts.join('-'); -} - -function each(items, src, dest) { - return items.map(item => { - const _item = item; - _item[dest] = one(_item[src]); - return _item; - }); -} - -export default { - one, - each, -}; diff --git a/src-docs/src/store/index.js b/src-docs/src/store/index.js index f617797047b..a9df2b1f466 100644 --- a/src-docs/src/store/index.js +++ b/src-docs/src/store/index.js @@ -1,7 +1,3 @@ -export function getIsSandbox(state) { - return state.sandbox.isSandbox; -} - export function getTheme(state) { return state.theme.theme; } diff --git a/src-docs/src/views/app_container.js b/src-docs/src/views/app_container.js index ca826e9988b..5276db0615c 100644 --- a/src-docs/src/views/app_container.js +++ b/src-docs/src/views/app_container.js @@ -3,7 +3,6 @@ import { connect } from 'react-redux'; import { AppView } from './app_view'; import { - getIsSandbox, getTheme, getRoutes, } from '../store'; @@ -16,7 +15,6 @@ function mapStateToProps(state, ownProps) { return { routes: ownProps.routes, currentRoute: ownProps.routes[1], - isSandbox: getIsSandbox(state), theme: getTheme(state), routes: getRoutes(state), }; diff --git a/src-docs/src/views/app_view.js b/src-docs/src/views/app_view.js index edca0251b1a..1d4d9bf4c17 100644 --- a/src-docs/src/views/app_view.js +++ b/src-docs/src/views/app_view.js @@ -77,13 +77,7 @@ export class AppView extends Component {
); } else { - const { - guidelines, - services, - components, - patterns, - sandboxes, - } = routes; + const { navigation } = routes; return ( @@ -94,11 +88,7 @@ export class AppView extends Component { currentRouteName={currentRoute.name} onToggleTheme={toggleTheme} selectedTheme={theme} - guidelines={guidelines} - services={services} - components={components} - patterns={patterns} - sandboxes={sandboxes} + navigation={navigation} /> diff --git a/src-docs/src/views/bottom_bar/bottom_bar_example.js b/src-docs/src/views/bottom_bar/bottom_bar_example.js index 1fce3aaf84f..fe282484b88 100644 --- a/src-docs/src/views/bottom_bar/bottom_bar_example.js +++ b/src-docs/src/views/bottom_bar/bottom_bar_example.js @@ -16,7 +16,7 @@ const bottomBarSource = require('!!raw-loader!./bottom_bar'); const bottomBarHtml = renderToHtml(BottomBar); export const BottomBarExample = { - title: 'BottomBar', + title: 'Bottom Bar', sections: [{ title: 'BottomBar', source: [{ diff --git a/src-docs/src/views/call_out/call_out_example.js b/src-docs/src/views/call_out/call_out_example.js index f2fee249f89..a53b66fb935 100644 --- a/src-docs/src/views/call_out/call_out_example.js +++ b/src-docs/src/views/call_out/call_out_example.js @@ -28,7 +28,7 @@ const dangerSource = require('!!raw-loader!./danger'); const dangerHtml = renderToHtml(Danger); export const CallOutExample = { - title: 'CallOut', + title: 'Call Out', sections: [{ title: 'Info', source: [{ diff --git a/src-docs/src/views/context_menu/context_menu_example.js b/src-docs/src/views/context_menu/context_menu_example.js index cb9f4ee7084..9908dc75c6c 100644 --- a/src-docs/src/views/context_menu/context_menu_example.js +++ b/src-docs/src/views/context_menu/context_menu_example.js @@ -20,7 +20,7 @@ const singlePanelSource = require('!!raw-loader!./single_panel'); const singlePanelHtml = renderToHtml(SinglePanel); export const ContextMenuExample = { - title: 'ContextMenu', + title: 'Context Menu', sections: [{ title: 'ContextMenu', source: [{ diff --git a/src-docs/src/views/delay_hide/delay_hide_example.js b/src-docs/src/views/delay_hide/delay_hide_example.js index 32ffe87c8e4..a7b3cd03736 100644 --- a/src-docs/src/views/delay_hide/delay_hide_example.js +++ b/src-docs/src/views/delay_hide/delay_hide_example.js @@ -8,7 +8,7 @@ const delayHideSource = require('!!raw-loader!./delay_hide'); const delayHideHtml = renderToHtml(DelayHide); export const DelayHideExample = { - title: 'DelayHide', + title: 'Delay Hide', sections: [ { title: 'DelayHide', diff --git a/src-docs/src/views/description_list/description_list_example.js b/src-docs/src/views/description_list/description_list_example.js index 0e12975d853..aa423f54a80 100644 --- a/src-docs/src/views/description_list/description_list_example.js +++ b/src-docs/src/views/description_list/description_list_example.js @@ -28,7 +28,7 @@ const descriptionListInlineSource = require('!!raw-loader!./description_list_inl const descriptionListInlineHtml = renderToHtml(DescriptionListInline); export const DescriptionListExample = { - title: 'DescriptionList', + title: 'Description List', sections: [{ title: 'DescriptionList', source: [{ diff --git a/src-docs/src/views/error_boundary/error_boundary.js b/src-docs/src/views/error_boundary/error_boundary.js index b501a5889ed..8e43a9012ff 100644 --- a/src-docs/src/views/error_boundary/error_boundary.js +++ b/src-docs/src/views/error_boundary/error_boundary.js @@ -5,7 +5,7 @@ import { } from '../../../../src/components'; const BadComponent = () => { - throw new Error('I\'m here to kick butt and chew bubblegum.\n\n\And I\'m all out of gum.'); + throw new Error('I\'m here to kick butt and chew bubblegum. And I\'m all out of gum.'); }; export default () => ( diff --git a/src-docs/src/views/error_boundary/error_boundary_example.js b/src-docs/src/views/error_boundary/error_boundary_example.js index 5c1a617d13b..0873f1d4a04 100644 --- a/src-docs/src/views/error_boundary/error_boundary_example.js +++ b/src-docs/src/views/error_boundary/error_boundary_example.js @@ -16,7 +16,7 @@ const errorBoundarySource = require('!!raw-loader!./error_boundary'); const errorBoundaryHtml = renderToHtml(ErrorBoundary); export const ErrorBoundaryExample = { - title: 'ErrorBoundary', + title: 'Error Boundary', sections: [{ title: 'ErrorBoundary', source: [{ diff --git a/src-docs/src/views/file_picker/file_picker_example.js b/src-docs/src/views/file_picker/file_picker_example.js index 4d1b153f0e8..ef2da198557 100644 --- a/src-docs/src/views/file_picker/file_picker_example.js +++ b/src-docs/src/views/file_picker/file_picker_example.js @@ -17,7 +17,7 @@ const filePickerSource = require('!!raw-loader!./file_picker'); const filePickerHtml = renderToHtml(FilePicker); export const FilePickerExample = { - title: 'FilePicker', + title: 'File Picker', sections: [{ title: 'FilePicker', source: [{ diff --git a/src-docs/src/views/filter_group/filter_group_example.js b/src-docs/src/views/filter_group/filter_group_example.js index 0afe0b244e7..ee9f759d8ca 100644 --- a/src-docs/src/views/filter_group/filter_group_example.js +++ b/src-docs/src/views/filter_group/filter_group_example.js @@ -20,7 +20,7 @@ const filterGroupSource = require('!!raw-loader!./filter_group'); const filterGroupHtml = renderToHtml(FilterGroup); export const FilterGroupExample = { - title: 'FilterGroup', + title: 'Filter Group', intro: (
- - Options for the lucene query string parser. - - Reset - -
- } - > - - - - - - - - - - - - - - - - - - - - - - - - ); - } - - renderPage() { - return ( - - - - -

Management

-
-
-
- - - - - - - - - - -

Advanced settings » General

-
-
-
- - - -

- Tweaks you make here can break Kibana if you do not know what you are doing. -

-
- - - - {this.renderForm()} -
-
-
-
- ); - } - - - render() { - let bottomBar; - if (this.state.showBar) { - bottomBar = ( - - - - -

- - You have unsaved changes in your form. - -

-
-
- - - - - Save - - - - Discard - - - -
-
- ); - } - - return ( - - {this.renderPage()} - {bottomBar} - - ); - } -} diff --git a/src-docs/src/views/kibana/advanced_settings_sandbox.js b/src-docs/src/views/kibana/advanced_settings_sandbox.js deleted file mode 100644 index 110025bdfbb..00000000000 --- a/src-docs/src/views/kibana/advanced_settings_sandbox.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; - -import { renderToHtml } from '../../services'; - -import { - GuidePage, - GuideSection, - GuideSectionTypes, -} from '../../components'; - -import AdvancedSettings from './advanced_settings'; -const advancedSettingsSource = require('!!raw-loader!./advanced_settings'); -const advancedSettingsHtml = renderToHtml(AdvancedSettings); - -export default props => ( - - - This is a pretty dirty example of how to handle a menu system with - nesting within it. Right now it includes a lot of the same code - from the Kibana demo, but we should abstract this stuff into more - portable wrappers. -

- } - demo={} - /> -
-); diff --git a/src-docs/src/views/kibana/kibana_chrome.js b/src-docs/src/views/kibana/kibana_chrome.js deleted file mode 100644 index cd61496829f..00000000000 --- a/src-docs/src/views/kibana/kibana_chrome.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; - -import KibanaHeader from '../header/header'; - -export default ({ - children, - ...rest -}) => ( -
- - {children} -
-); diff --git a/src-docs/src/views/kibana/watches.js b/src-docs/src/views/kibana/watches.js deleted file mode 100644 index 70d39df2b96..00000000000 --- a/src-docs/src/views/kibana/watches.js +++ /dev/null @@ -1,178 +0,0 @@ -import React, { - Component, -} from 'react'; - -import { - EuiButton, - EuiContextMenuItem, - EuiContextMenuPanel, - EuiFlexGroup, - EuiFlexItem, - EuiPage, - EuiPageBody, - EuiPageContent, - EuiPageHeader, - EuiPageHeaderSection, - EuiPageContentBody, - EuiPageContentHeader, - EuiPageContentHeaderSection, - EuiPageSideBar, - EuiPopover, - EuiSpacer, - EuiText, - EuiTitle, -} from '../../../../src/components'; - -import { - KibanaChrome, - ManagementSideNav, - Table, -} from '../partials'; - -export default class extends Component { - constructor(props) { - super(props); - - this.state = { - isPopoverOpen: false, - }; - } - - onButtonClick = () => { - this.setState(prevState => ({ - isPopoverOpen: !prevState.isPopoverOpen, - })); - }; - - closePopover = () => { - this.setState({ - isPopoverOpen: false, - }); - }; - - renderAddWatchPopover() { - const button = ( - - Create Watch - - ); - - const items = [ - ( - - - Threshold alert - - - Send out an alert on a specific condition. - - - ), ( - - - Change-based alert - - - Send out an alert on a specific change. - - - ), ( - - - Advanced watch - - - Set up a custom watch in raw JSON. - - - ), - ]; - - return ( - - - - ); - } - - renderPage() { - return ( - - - - -

Management

-
-
-
- - - - - - - - - -

Watches

-

- Far out in the uncharted backwaters of the unfashionable end of - the western spiral arm of the Galaxy lies a small unregarded - yellow sun. -

-
-
- - - - - {this.renderAddWatchPopover()} - - - -
- - - - - - - - - - ); - } - - render() { - return ( - - {this.renderPage()} - - ); - } -} diff --git a/src-docs/src/views/kibana/watches_sandbox.js b/src-docs/src/views/kibana/watches_sandbox.js deleted file mode 100644 index 0c4917d9f99..00000000000 --- a/src-docs/src/views/kibana/watches_sandbox.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; - -import { renderToHtml } from '../../services'; - -import { - GuidePage, - GuideSection, - GuideSectionTypes, -} from '../../components'; - -import Watches from './watches'; -const watchesSource = require('!!raw-loader!./watches'); -const watchesHtml = renderToHtml(Watches); - -export default props => ( - - - } - /> - -); diff --git a/src-docs/src/views/outside_click_detector/outside_click_detector_example.js b/src-docs/src/views/outside_click_detector/outside_click_detector_example.js index 701719d27ed..9a24a71bf44 100644 --- a/src-docs/src/views/outside_click_detector/outside_click_detector_example.js +++ b/src-docs/src/views/outside_click_detector/outside_click_detector_example.js @@ -16,7 +16,7 @@ const outsideClickDetectorSource = require('!!raw-loader!./outside_click_detecto const outsideClickDetectorHtml = renderToHtml(OutsideClickDetector); export const OutsideClickDetectorExample = { - title: 'OutsideClickDetector', + title: 'Outside Click Detector', sections: [{ title: 'OutsideClickDetector', source: [{ diff --git a/src-docs/src/views/partials.js b/src-docs/src/views/partials.js deleted file mode 100644 index f1b713f40a0..00000000000 --- a/src-docs/src/views/partials.js +++ /dev/null @@ -1,9 +0,0 @@ -export { default as KibanaChrome } from './kibana/kibana_chrome'; -export { default as KibanaHeader } from './header/header'; -export { default as ManagementSideNav } from './side_nav/side_nav_complex'; -export { default as Table } from './tables/custom/custom'; -export { - default as ToastList, - addToast, - removeAllToasts, -} from './toast/toast_list'; diff --git a/src-docs/src/views/search_bar/search_bar_example.js b/src-docs/src/views/search_bar/search_bar_example.js index cc529711bdd..93d2d2a0ef9 100644 --- a/src-docs/src/views/search_bar/search_bar_example.js +++ b/src-docs/src/views/search_bar/search_bar_example.js @@ -17,7 +17,7 @@ const searchBarSource = require('!!raw-loader!./search_bar'); const searchBarHtml = renderToHtml(SearchBar); export const SearchBarExample = { - title: 'SearchBar', + title: 'Search Bar', sections: [ { title: 'SearchBar', diff --git a/src-docs/src/views/side_nav/side_nav_example.js b/src-docs/src/views/side_nav/side_nav_example.js index c51dd4a7df4..6065768197d 100644 --- a/src-docs/src/views/side_nav/side_nav_example.js +++ b/src-docs/src/views/side_nav/side_nav_example.js @@ -20,7 +20,7 @@ const sideNavComplexSource = require('!!raw-loader!./side_nav_complex'); const sideNavComplexHtml = renderToHtml(SideNavComplex); export const SideNavExample = { - title: 'SideNav', + title: 'Side Nav', sections: [{ title: 'SideNav', source: [{ diff --git a/src-docs/src/views/table_of_records/table_of_records_example.js b/src-docs/src/views/table_of_records/table_of_records_example.js index 40d9d6efefe..0bda5b83cf0 100644 --- a/src-docs/src/views/table_of_records/table_of_records_example.js +++ b/src-docs/src/views/table_of_records/table_of_records_example.js @@ -25,7 +25,7 @@ const columnRenderersSource = require('!!raw-loader!./column_data_types'); const columnRenderersHtml = renderToHtml(ColumnDataTypes); export const TableOfRecordsExample = { - title: 'TableOfRecords', + title: 'Table Of Records', intro: ( diff --git a/src/components/error_boundary/__snapshots__/error_boundary.test.js.snap b/src/components/error_boundary/__snapshots__/error_boundary.test.js.snap index 5124b9ba82a..1989fb10443 100644 --- a/src/components/error_boundary/__snapshots__/error_boundary.test.js.snap +++ b/src/components/error_boundary/__snapshots__/error_boundary.test.js.snap @@ -1,32 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiErrorBoundary is rendered with an error 1`] = ` -
-
-
-

- Error -

-
-        

- Error: I'm here to kick butt and chew bubblegum. - -And I'm all out of gum. -

-
-
-
-
-`; - exports[`EuiErrorBoundary is rendered without an error 1`] = `
No error diff --git a/src/components/error_boundary/_error_boundary.scss b/src/components/error_boundary/_error_boundary.scss index 17fb958d5d3..f0bc10fcd7b 100644 --- a/src/components/error_boundary/_error_boundary.scss +++ b/src/components/error_boundary/_error_boundary.scss @@ -17,3 +17,7 @@ background-color: $euiColorEmptyShade; padding: $euiSizeS; } + + .euiErrorBoundary__stack { + white-space: pre-wrap; + } diff --git a/src/components/error_boundary/error_boundary.js b/src/components/error_boundary/error_boundary.js index 5040100834a..f47844c3cfd 100644 --- a/src/components/error_boundary/error_boundary.js +++ b/src/components/error_boundary/error_boundary.js @@ -42,9 +42,9 @@ export class EuiErrorBoundary extends Component {

Error

-
+              
                 

- {this.state.error && this.state.error.toString()} + {this.state.error && this.state.error.stack}

diff --git a/src/components/error_boundary/error_boundary.test.js b/src/components/error_boundary/error_boundary.test.js index 8ece71c12e7..b269d7194e2 100644 --- a/src/components/error_boundary/error_boundary.test.js +++ b/src/components/error_boundary/error_boundary.test.js @@ -11,33 +11,35 @@ const GoodComponent = () => (
No error
); +const errorMessage = 'I\'m here to kick butt and chew bubblegum.\n\n\And I\'m all out of gum.'; + const BadComponent = () => { - throw new Error('I\'m here to kick butt and chew bubblegum.\n\n\And I\'m all out of gum.'); + throw new Error(errorMessage); }; describe('EuiErrorBoundary', () => { test('is rendered without an error', () => { - const component = mount( + const component = takeMountedSnapshot(mount( - ); + )); - expect(takeMountedSnapshot(component)) - .toMatchSnapshot(); + expect(component).toMatchSnapshot(); }); test('is rendered with an error', () => { // Prevent the React boundary error from appearing in the terminal. spyOn(console, 'error'); // eslint-disable-line no-undef - const component = mount( + // Because the error contains the stack trace, it's non-deterministic. So we'll just check that + // it contains our error message. + const errorText = mount( - ); + ).text(); - expect(takeMountedSnapshot(component)) - .toMatchSnapshot(); + expect(errorText).toContain(errorMessage); }); });