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

Simplify accordion button markup #10

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/legacy/ui/public/vis/editors/default/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,11 @@
.visEditorSidebar__aggGroup .euiAccordion__button {
padding-left: 2px;
}

.visEditorSidebar__aggGroupAccordionButtonContent {
font-size: $euiFontSizeS;

span {
color: $euiColorDarkShade;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, Fragment } from 'react';
import {
EuiAccordion,
EuiToolTip,
Expand Down Expand Up @@ -121,6 +121,17 @@ function DefaultEditorAgg({
const renderAggButtons = () => {
const actionIcons = [];

if (showError) {
actionIcons.push({
id: 'hasErrors',
color: 'danger',
type: 'alert',
tooltip: i18n.translate('common.ui.vis.editors.agg.errorsAriaLabel', {
defaultMessage: 'Aggregation has errors',
}),
dataTestSubj: 'hasErrorsAggregationIcon',
});
}
if (agg.enabled && isRemovable) {
actionIcons.push({
id: 'disableAggregation',
Expand Down Expand Up @@ -202,35 +213,18 @@ function DefaultEditorAgg({
};

const buttonContent = (
<EuiFlexGroup gutterSize="xs" alignItems="baseline" responsive={false}>
<EuiFlexItem grow={false}>{agg.schema.title}</EuiFlexItem>
<EuiFlexItem className="eui-textTruncate">
{showDescription && (
<EuiText size="s" color="subdued">
<p className="eui-textTruncate">{aggDescription}</p>
</EuiText>
)}
{showError && (
<EuiTextColor
color="danger"
aria-label={i18n.translate('common.ui.vis.editors.agg.errorsAriaLabel', {
defaultMessage: 'Aggregation has errors',
})}
>
<h6>
<FormattedMessage id="common.ui.vis.editors.agg.errorsText" defaultMessage="Errors" />
</h6>
</EuiTextColor>
)}
</EuiFlexItem>
</EuiFlexGroup>
<Fragment>
{agg.schema.title} {showDescription && <span>{aggDescription}</span>}
</Fragment>
);

return (
<EuiAccordion
id={`visEditorAggAccordion${agg.id}`}
initialIsOpen={isEditorOpen}
buttonContent={buttonContent}
buttonClassName="eui-textTruncate"
buttonContentClassName="visEditorSidebar__aggGroupAccordionButtonContent eui-textTruncate"
className="visEditorSidebar__section visEditorSidebar__collapsible visEditorSidebar__collapsible--marginBottom"
aria-label={i18n.translate('common.ui.vis.editors.agg.toggleEditorButtonAriaLabel', {
defaultMessage: 'Toggle {schema} editor',
Expand Down