diff --git a/packages/kbn-shared-ux-components/src/index.ts b/packages/kbn-shared-ux-components/src/index.ts index a43b53a6e7cd1..c5e719a904ebd 100644 --- a/packages/kbn-shared-ux-components/src/index.ts +++ b/packages/kbn-shared-ux-components/src/index.ts @@ -41,6 +41,11 @@ export const ExitFullScreenButton = withSuspense(LazyExitFullScreenButton); */ export const ToolbarButton = withSuspense(LazyToolbarButton); +/** + * An example of the solution toolbar button + */ +export { AddFromLibraryButton } from './toolbar'; + /** * The Lazily-loaded `NoDataViews` component. Consumers should use `React.Suspennse` or the * `withSuspense` HOC to load this component. diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/__snapshots__/add_from_library.test.tsx.snap b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/__snapshots__/add_from_library.test.tsx.snap new file mode 100644 index 0000000000000..4cdc858c7e50c --- /dev/null +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/__snapshots__/add_from_library.test.tsx.snap @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` is rendered 1`] = ` + + + + + + + + + +`; diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.mdx b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.mdx new file mode 100644 index 0000000000000..f6a2f92cd41eb --- /dev/null +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.mdx @@ -0,0 +1,10 @@ +--- +id: sharedUX/Components/AddFromLibraryButton +slug: /shared-ux/components/toolbar/buttons/add_from_library +title: Add From Library Button +summary: An example of the primary button +tags: ['shared-ux', 'component'] +date: 2022-03-18 +--- + +This button is an example of the primary button. diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.stories.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.stories.tsx new file mode 100644 index 0000000000000..ea50431545028 --- /dev/null +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.stories.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { AddFromLibraryButton } from './add_from_library'; +import mdx from './add_from_library.mdx'; + +export default { + title: 'Toolbar/Buttons/Add From Library Button', + description: 'An implementation of the solution toolbar primary button', + parameters: { + docs: { + page: mdx, + }, + }, +}; + +export const Component = () => { + return ; +}; diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.test.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.test.tsx new file mode 100644 index 0000000000000..a2ba1d8bff174 --- /dev/null +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.test.tsx @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { mount as enzymeMount } from 'enzyme'; +import React from 'react'; +import { AddFromLibraryButton } from './add_from_library'; + +describe('', () => { + test('is rendered', () => { + const component = enzymeMount(); + + expect(component).toMatchSnapshot(); + }); +}); diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.tsx new file mode 100644 index 0000000000000..190edc8f29491 --- /dev/null +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/add_from_library/add_from_library.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { ToolbarButton, Props as ToolbarButtonProps } from '../primary/primary'; + +export type Props = Omit; + +const label = { + getLibraryButtonLabel: () => + i18n.translate('sharedUXComponents.toolbar.buttons.addFromLibrary.libraryButtonLabel', { + defaultMessage: 'Add from library', + }), +}; + +export const AddFromLibraryButton = ({ onClick, ...rest }: Props) => ( + +); diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/icon_button_group/icon_button_group.stories.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/icon_button_group/icon_button_group.stories.tsx index c30f015325672..988a5bddd513f 100644 --- a/packages/kbn-shared-ux-components/src/toolbar/buttons/icon_button_group/icon_button_group.stories.tsx +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/icon_button_group/icon_button_group.stories.tsx @@ -13,7 +13,7 @@ import { IconButtonGroup } from './icon_button_group'; import mdx from './icon_button_group.mdx'; export default { - title: 'Toolbar/Icon Button Group', + title: 'Toolbar/Buttons/Icon Button Group', description: 'A collection of buttons that is a part of a toolbar.', parameters: { docs: { diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.mdx b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.mdx index 489596e771c29..c1fa431f39bdc 100644 --- a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.mdx +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.mdx @@ -1,7 +1,7 @@ --- -id: sharedUX/Components/Toolbar/Primary_Button +id: sharedUX/Components/ToolbarButton slug: /shared-ux/components/toolbar/buttons/primary -title: Toolbar Button +title: Solution Toolbar Button summary: An opinionated implementation of the toolbar extracted to just the button. tags: ['shared-ux', 'component'] date: 2022-02-17 @@ -9,4 +9,4 @@ date: 2022-02-17 > This documentation is in-progress. -This button is a part of the toolbar component. This button has primary styling and requires a `label`. Interaction (`onClick`) handlers and `iconType`s are supported as an extension of EuiButtonProps. Icons are always on the left of any labels within the button. +This button is a part of the solution toolbar component. This button has primary styling and requires a label. OnClick handlers and icon types are supported as an extension of EuiButtonProps. Icons are always on the left of any labels within the button. diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.stories.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.stories.tsx index 0388cccb60c3f..a81be610c1508 100644 --- a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.stories.tsx +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.stories.tsx @@ -12,7 +12,7 @@ import { ToolbarButton } from './primary'; import mdx from './primary.mdx'; export default { - title: 'Toolbar/Primary button', + title: 'Toolbar/Buttons/Primary button', description: 'A primary button that is a part of a toolbar.', parameters: { docs: { diff --git a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.test.tsx b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.test.tsx index e93d537a40ce5..3e0e153f453e5 100644 --- a/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.test.tsx +++ b/packages/kbn-shared-ux-components/src/toolbar/buttons/primary/primary.test.tsx @@ -27,10 +27,6 @@ describe('', () => { enzymeMount({element}); }); - afterEach(() => { - jest.resetAllMocks(); - }); - test('is rendered', () => { const component = mount(); diff --git a/packages/kbn-shared-ux-components/src/toolbar/index.ts b/packages/kbn-shared-ux-components/src/toolbar/index.ts index e68abf2916a72..513f81c1ddfc7 100644 --- a/packages/kbn-shared-ux-components/src/toolbar/index.ts +++ b/packages/kbn-shared-ux-components/src/toolbar/index.ts @@ -5,6 +5,6 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - export { ToolbarButton } from './buttons/primary/primary'; export { IconButtonGroup } from './buttons/icon_button_group/icon_button_group'; +export { AddFromLibraryButton } from './buttons/add_from_library/add_from_library';