Skip to content

Commit

Permalink
Make toolbar_button a shared component (#88386)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreadelrio authored Jan 25, 2021
1 parent 2ae2692 commit fb536f5
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './ui_settings';
export * from './field_icon';
export * from './field_button';
export * from './table_list_view';
export * from './toolbar_button';
export * from './split_panel';
export * from './react_router_navigate';
export { ValidatedDualRange, Value } from './validated_range';
Expand Down

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

9 changes: 9 additions & 0 deletions src/plugins/kibana_react/public/toolbar_button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

export * from './toolbar_button';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.lnsToolbarButton {
.kbnToolbarButton {
line-height: $euiButtonHeight; // Keeps alignment of text and chart icon
background-color: $euiColorEmptyShade;

Expand All @@ -15,46 +15,45 @@
pointer-events: initial;
}

.lnsToolbarButton__text > svg {
.kbnToolbarButton__text > svg {
margin-top: -1px; // Just some weird alignment issue when icon is the child not the `iconType`
}

.lnsToolbarButton__text:empty {
.kbnToolbarButton__text:empty {
margin: 0;
}

// Toolbar buttons don't look good with centered text when fullWidth
&[class*='fullWidth'] {
text-align: left;

.lnsToolbarButton__content {
.kbnToolbarButton__content {
justify-content: space-between;
}
}

}

.lnsToolbarButton--groupLeft {
.kbnToolbarButton--groupLeft {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}

.lnsToolbarButton--groupCenter {
.kbnToolbarButton--groupCenter {
border-radius: 0;
border-left: none;
}

.lnsToolbarButton--groupRight {
.kbnToolbarButton--groupRight {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: none;
}

.lnsToolbarButton--bold {
.kbnToolbarButton--bold {
font-weight: $euiFontWeightBold;
}

.lnsToolbarButton--s {
.kbnToolbarButton--s {
box-shadow: none !important; // sass-lint:disable-line no-important
font-size: $euiFontSizeS;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import React from 'react';
import { shallow } from 'enzyme';
import { ToolbarButton, POSITIONS, WEIGHTS, TOOLBAR_BUTTON_SIZES } from './toolbar_button';

const noop = () => {};

describe('sizes', () => {
TOOLBAR_BUTTON_SIZES.forEach((size) => {
test(`${size} is applied`, () => {
const component = shallow(<ToolbarButton onClick={noop} size={size} />);
expect(component).toMatchSnapshot();
});
});
});

describe('positions', () => {
POSITIONS.forEach((position) => {
test(`${position} is applied`, () => {
const component = shallow(<ToolbarButton onClick={noop} groupPosition={position} />);
expect(component).toMatchSnapshot();
});
});
});

describe('font weights', () => {
WEIGHTS.forEach((weight) => {
test(`${weight} is applied`, () => {
const component = shallow(<ToolbarButton onClick={noop} fontWeight={weight} />);
expect(component).toMatchSnapshot();
});
});
});

describe('hasArrow', () => {
it('is rendered', () => {
const component = shallow(<ToolbarButton onClick={noop} hasArrow />);
expect(component).toMatchSnapshot();
});
});
Loading

0 comments on commit fb536f5

Please sign in to comment.