Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shared-ux] Migrate solution toolbar quick group buttons as icon button group component #126297

Merged
merged 56 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4cb7908
initial commit
rshen91 Feb 23, 2022
ce19c95
naming
rshen91 Feb 23, 2022
035c402
styling with classnames and emotion
rshen91 Feb 24, 2022
61491e0
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Feb 28, 2022
b1ac2b7
include jest test
rshen91 Feb 28, 2022
22a9ee9
Merge branch 'main' into migrate-quick-group
rshen91 Feb 28, 2022
ad80db8
fix linting
rshen91 Feb 28, 2022
7754d83
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Feb 28, 2022
2d8ec7c
update snapshot
rshen91 Mar 1, 2022
a95793a
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 1, 2022
19c9176
fix emotion styling
rshen91 Mar 1, 2022
8ff2dcf
update jest test
rshen91 Mar 1, 2022
22ca55a
update file structure to match other PRs
rshen91 Mar 2, 2022
e08dc2f
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 2, 2022
775607b
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 3, 2022
755613b
add component to index files
rshen91 Mar 3, 2022
0fa396f
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 4, 2022
71ffe4d
fix index files
rshen91 Mar 4, 2022
d167137
slightly expand the mdx file
rshen91 Mar 4, 2022
a1811af
Merge branch 'main' into migrate-quick-group
rshen91 Mar 7, 2022
bb652fb
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 7, 2022
85f6bf7
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Mar 7, 2022
f9fd60d
code review changes
rshen91 Mar 7, 2022
2b3513e
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 8, 2022
a014375
code review
rshen91 Mar 8, 2022
29a640f
update tests
rshen91 Mar 8, 2022
1a60281
Merge branch 'main' into migrate-quick-group
rshen91 Mar 8, 2022
427a208
Merge branch 'main' into migrate-quick-group
rshen91 Mar 8, 2022
074fcbf
emotion styling
rshen91 Mar 9, 2022
1e686f5
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Mar 9, 2022
74c44b5
emotion refactor
rshen91 Mar 9, 2022
13ce5dc
Merge branch 'main' into migrate-quick-group
rshen91 Mar 9, 2022
46cda11
[styles] Cleanup unnecessary and verbose styles
Mar 9, 2022
ae3e04e
[props] Removed `getLegend` from buttons and requiring `legend` on gr…
Mar 9, 2022
f43404d
code review changes
rshen91 Mar 10, 2022
7f9a717
Merge branch 'main' into migrate-quick-group
rshen91 Mar 10, 2022
f2c98ee
Merge branch 'main' into migrate-quick-group
rshen91 Mar 14, 2022
d40ce6c
Merge branch 'main' into migrate-quick-group
rshen91 Mar 14, 2022
c6d25bc
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 14, 2022
ab3ebc6
rename quick button group to icon button group
rshen91 Mar 14, 2022
7b36d41
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Mar 14, 2022
be624b1
fix file name import
rshen91 Mar 14, 2022
0c2bc8f
update jest snapshot
rshen91 Mar 14, 2022
69607d4
Merge branch 'main' into migrate-quick-group
rshen91 Mar 14, 2022
8e808ab
rename solution toolbar button to toolbarbutton
rshen91 Mar 14, 2022
e75b4b1
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Mar 14, 2022
98317ce
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 15, 2022
bbd09df
update test
rshen91 Mar 15, 2022
faab6f2
Merge branch 'main' into migrate-quick-group
rshen91 Mar 15, 2022
22f44b0
Apply suggestions from code review
rshen91 Mar 15, 2022
c37fcc3
update variable in storybook
rshen91 Mar 15, 2022
b5a304b
Merge branch 'main' into migrate-quick-group
rshen91 Mar 15, 2022
2a7e540
Merge remote-tracking branch 'upstream/main' into migrate-quick-group
rshen91 Mar 16, 2022
cf2d8cc
Merge remote-tracking branch 'origin/migrate-quick-group' into migrat…
rshen91 Mar 16, 2022
02c5423
update snapshot
rshen91 Mar 16, 2022
60f1e27
Merge branch 'main' into migrate-quick-group
rshen91 Mar 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/plugins/shared_ux/public/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const LazyExitFullScreenButton = React.lazy(() =>
}))
);

export const LazySolutionToolbarButton = React.lazy(() =>
import('./toolbar/index').then(({ SolutionToolbarButton }) => ({
default: SolutionToolbarButton,
export const LazyToolbarButton = React.lazy(() =>
import('./toolbar/index').then(({ ToolbarButton }) => ({
default: ToolbarButton,
}))
);

Expand All @@ -35,11 +35,11 @@ export const RedirectAppLinks = React.lazy(() => import('./redirect_app_links'))
export const ExitFullScreenButton = withSuspense(LazyExitFullScreenButton);

/**
* A `SolutionToolbarButton` component that is wrapped by the `withSuspense` HOC. This component can
* be used directly by consumers and will load the `LazySolutionToolbarButton` component lazily with
* A `ToolbarButton` component that is wrapped by the `withSuspense` HOC. This component can
* be used directly by consumers and will load the `LazyToolbarButton` component lazily with
* a predefined fallback and error boundary.
*/
export const SolutionToolbarButton = withSuspense(LazySolutionToolbarButton);
export const ToolbarButton = withSuspense(LazyToolbarButton);

/**
* The Lazily-loaded `NoDataViews` component. Consumers should use `React.Suspennse` or the
Expand All @@ -57,3 +57,18 @@ export const LazyNoDataViewsPage = React.lazy(() =>
* a predefined fallback and error boundary.
*/
export const NoDataViewsPage = withSuspense(LazyNoDataViewsPage);

/**
* The Lazily-loaded `IconButtonGroup` component. Consumers should use `React.Suspennse` or the
* `withSuspense` HOC to load this component.
*/
export const LazyIconButtonGroup = React.lazy(() =>
import('./toolbar/index').then(({ IconButtonGroup }) => ({
default: IconButtonGroup,
}))
);

/**
* The IconButtonGroup component that is wrapped by the `withSuspence` HOC.
*/
export const IconButtonGroup = withSuspense(LazyIconButtonGroup);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: sharedUX/Components/Toolbar/Icon_Button_Group
slug: /shared-ux/components/toolbar/icon_button_group
title: Toolbar Icon Button Group
summary: 'An array of icon-only buttons for use in a toolbar'
tags: ['shared-ux', 'component']
date: 2022-02-23
---

> This documentation is in-progress.

This component requires a prop that consists of a series of buttons that can then be displayed based on the number of buttons desired. An example of a button that can be part of an array of icon buttons is included below:

```
{
label: 'Text',
onClick: clickHandler,
iconType: 'visText',
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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 { action } from '@storybook/addon-actions';
import { Story } from '@storybook/react';
import React from 'react';
import { IconButtonGroup } from './icon_button_group';
import mdx from './icon_button_group.mdx';

export default {
title: 'Toolbar/Icon Button Group',
description: 'A collection of buttons that is a part of a toolbar.',
parameters: {
docs: {
page: mdx,
},
},
};

const quickButtons = [
{
label: 'Text',
onClick: action('onTextClick'),
iconType: 'visText',
title: 'Text as markdown',
},
{
label: 'Control',
onClick: action('onControlClick'),
iconType: 'controlsHorizontal',
},
{
label: 'Link',
onClick: action('onLinkClick'),
iconType: 'link',
},
{
label: 'Image',
onClick: action('onImageClick'),
iconType: 'image',
},
{
label: 'Markup',
onClick: action('onMarkupClick'),
iconType: 'visVega',
},
];

export const ConnectedComponent: Story<{ buttonCount: number }> = ({ buttonCount }) => {
return (
<IconButtonGroup legend="Example icon group" buttons={quickButtons.slice(0, buttonCount)} />
);
};

ConnectedComponent.argTypes = {
buttonCount: {
defaultValue: 2,
control: {
type: 'number',
min: 1,
max: 5,
step: 1,
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 { UseEuiTheme } from '@elastic/eui';

export const IconButtonGroupStyles = ({ euiTheme }: UseEuiTheme) => {
return {
button: {
'&.euiButtonGroupButton': {
backgroundColor: euiTheme.colors.emptyShade,
border: `${euiTheme.border.thin} !important`,
'&:first-of-type': {
borderTopLeftRadius: `${euiTheme.border.radius.medium} !important`,
borderBottomLeftRadius: `${euiTheme.border.radius.medium} !important`,
},
'&:last-of-type': {
borderTopRightRadius: `${euiTheme.border.radius.medium} !important`,
borderBottomRightRadius: `${euiTheme.border.radius.medium} !important`,
},
},
},
};
};
Loading