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

[Lens] Color in dimension trigger #76871

Merged
merged 29 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dc03598
implement color indicators
flash1293 Sep 7, 2020
1118d0c
add icon for color by
flash1293 Sep 7, 2020
66f4bd1
fix styling
flash1293 Sep 7, 2020
5d0192e
Merge remote-tracking branch 'upstream/master' into lens/color-in-dim…
flash1293 Sep 18, 2020
d5ba1b3
expose active data in some places
flash1293 Oct 7, 2020
be3dd02
Merge remote-tracking branch 'upstream/master' into lens/expose-activ…
flash1293 Nov 4, 2020
696f791
add active data to all relevant places
flash1293 Nov 4, 2020
1490d31
Fix bugs
flash1293 Nov 4, 2020
f3ca265
fix types
flash1293 Nov 4, 2020
a78946a
add tests
flash1293 Nov 4, 2020
c751be7
Merge remote-tracking branch 'upstream/master' into lens/expose-activ…
flash1293 Nov 4, 2020
8a695d1
remove leftover
flash1293 Nov 4, 2020
3820cfa
add test for expression renderer component
flash1293 Nov 4, 2020
4de8419
Merge branch 'lens/expose-active-data' into lens/color-in-dimension-t…
flash1293 Nov 4, 2020
9e4fb2e
add series and palette indicator
flash1293 Nov 4, 2020
2de1df2
Merge remote-tracking branch 'upstream/master' into lens/expose-activ…
flash1293 Nov 4, 2020
ec31106
update docs
flash1293 Nov 4, 2020
4d708bc
Merge branch 'lens/expose-active-data' into lens/color-in-dimension-t…
flash1293 Nov 4, 2020
b58abd4
put stubs in place for things to test
flash1293 Nov 4, 2020
9cff0b2
Merge remote-tracking branch 'upstream/master' into lens/color-in-dim…
flash1293 Nov 5, 2020
9c80ec2
fix tests and stuff
flash1293 Nov 5, 2020
61e4849
Merge remote-tracking branch 'upstream/master' into lens/color-in-dim…
flash1293 Nov 6, 2020
d32cb66
Merge branch 'master' into lens/color-in-dimension-trigger
kibanamachine Nov 9, 2020
723a3db
Merge remote-tracking branch 'upstream/master' into lens/color-in-dim…
flash1293 Nov 11, 2020
8ed06f8
review comments
flash1293 Nov 11, 2020
188ed08
simplify
flash1293 Nov 11, 2020
b9b6dc5
merge remote-tracking branch 'upstream/master' into lens/color-in-dim…
flash1293 Nov 16, 2020
82580bf
review fixes
flash1293 Nov 16, 2020
4e0a21f
remove unused css class
flash1293 Nov 16, 2020
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
25 changes: 22 additions & 3 deletions src/plugins/charts/public/services/palettes/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PaletteService } from './service';
import { PaletteDefinition, SeriesLayer } from './types';

export const getPaletteRegistry = () => {
const mockPalette: jest.Mocked<PaletteDefinition> = {
const mockPalette1: jest.Mocked<PaletteDefinition> = {
id: 'default',
title: 'My Palette',
getColor: jest.fn((_: SeriesLayer[]) => 'black'),
Expand All @@ -41,9 +41,28 @@ export const getPaletteRegistry = () => {
})),
};

const mockPalette2: jest.Mocked<PaletteDefinition> = {
id: 'mocked',
title: 'Mocked Palette',
getColor: jest.fn((_: SeriesLayer[]) => 'blue'),
getColors: jest.fn((num: number) => ['blue', 'yellow']),
toExpression: jest.fn(() => ({
type: 'expression',
chain: [
{
type: 'function',
function: 'system_palette',
arguments: {
name: ['mocked'],
},
},
],
})),
};

return {
get: (_: string) => mockPalette,
getAll: () => [mockPalette],
get: (name: string) => (name !== 'default' ? mockPalette2 : mockPalette1),
getAll: () => [mockPalette1, mockPalette2],
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe('Datatable Visualization', () => {
state: { layers: [layer] },
frame,
}).groups[1].accessors
).toEqual(['c', 'b']);
).toEqual([{ columnId: 'c' }, { columnId: 'b' }]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ export const datatableVisualization: Visualization<DatatableVisualizationState>
defaultMessage: 'Break down by',
}),
layerId: state.layers[0].layerId,
accessors: sortedColumns.filter(
(c) => datasource!.getOperationForColumnId(c)?.isBucketed
),
accessors: sortedColumns
.filter((c) => datasource!.getOperationForColumnId(c)?.isBucketed)
.map((accessor) => ({ columnId: accessor })),
supportsMoreColumns: true,
filterOperations: (op) => op.isBucketed,
dataTestSubj: 'lnsDatatable_column',
Expand All @@ -162,9 +162,9 @@ export const datatableVisualization: Visualization<DatatableVisualizationState>
defaultMessage: 'Metrics',
}),
layerId: state.layers[0].layerId,
accessors: sortedColumns.filter(
(c) => !datasource!.getOperationForColumnId(c)?.isBucketed
),
accessors: sortedColumns
.filter((c) => !datasource!.getOperationForColumnId(c)?.isBucketed)
.map((accessor) => ({ columnId: accessor })),
supportsMoreColumns: true,
filterOperations: (op) => !op.isBucketed,
required: true,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/drag_drop/drag_drop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// Drop area will be replacing existing content
.lnsDragDrop-isReplacing {
&,
.lnsLayerPanel__triggerLink {
.lnsLayerPanel__triggerText {
text-decoration: line-through;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AccessorConfig } from '../../../types';

export function ColorIndicator({
accessorConfig,
children,
}: {
accessorConfig: AccessorConfig;
children: React.ReactChild;
}) {
let indicatorIcon = null;
if (accessorConfig.triggerIcon && accessorConfig.triggerIcon !== 'none') {
const baseIconProps = {
size: 's',
className: 'lnsLayerPanel__colorIndicator',
} as const;

indicatorIcon = (
<EuiFlexItem grow={false}>
{accessorConfig.triggerIcon === 'color' && accessorConfig.color && (
<EuiIcon
{...baseIconProps}
color={accessorConfig.color}
type="stopFilled"
aria-label={i18n.translate('xpack.lens.editorFrame.colorIndicatorLabel', {
defaultMessage: 'Color of this dimension: {hex}',
values: {
hex: accessorConfig.color,
},
})}
/>
)}
{accessorConfig.triggerIcon === 'disabled' && (
<EuiIcon
{...baseIconProps}
type="stopSlash"
color="subdued"
aria-label={i18n.translate('xpack.lens.editorFrame.noColorIndicatorLabel', {
defaultMessage: 'This dimension does not have an individual color',
})}
/>
)}
{accessorConfig.triggerIcon === 'colorBy' && (
<EuiIcon
{...baseIconProps}
type="brush"
color="text"
aria-label={i18n.translate('xpack.lens.editorFrame.paletteColorIndicatorLabel', {
defaultMessage: 'This dimension is using a palette',
})}
/>
)}
</EuiFlexItem>
);
}

return (
<EuiFlexGroup gutterSize="none" alignItems="center">
{indicatorIcon}
<EuiFlexItem>{children}</EuiFlexItem>
</EuiFlexGroup>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
align-items: center;
overflow: hidden;
min-height: $euiSizeXXL;
position: relative;

// NativeRenderer is messing this up
> div {
Expand Down Expand Up @@ -80,28 +81,18 @@
margin-right: $euiSizeS;
}

.lnsLayerPanel__triggerLink {
.lnsLayerPanel__triggerText {
width: 100%;
padding: $euiSizeS;
min-height: $euiSizeXXL - 2;
word-break: break-word;

&:focus {
background-color: transparent !important; // sass-lint:disable-line no-important
outline: none !important; // sass-lint:disable-line no-important
}

&:focus .lnsLayerPanel__triggerLinkLabel,
&:focus-within .lnsLayerPanel__triggerLinkLabel {
background-color: transparentize($euiColorVis1, .9);
}
}

.lnsLayerPanel__triggerLinkLabel {
.lnsLayerPanel__triggerTextLabel {
transition: background-color $euiAnimSpeedFast ease-in-out;
}

.lnsLayerPanel__triggerLinkContent {
.lnsLayerPanel__triggerTextContent {
// Make EUI button content not centered
justify-content: flex-start;
padding: 0 !important; // sass-lint:disable-line no-important
Expand All @@ -111,3 +102,32 @@
.lnsLayerPanel__styleEditor {
padding: 0 $euiSizeS $euiSizeS;
}

.lnsLayerPanel__colorIndicator {
margin-left: $euiSizeS;
}

.lnsLayerPanel__paletteContainer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}

.lnsLayerPanel__paletteColor {
height: $euiSizeXS;
}

.lnsLayerPanel__dimensionLink {
width: 100%;

&:focus {
background-color: transparent !important; // sass-lint:disable-line no-important
outline: none !important; // sass-lint:disable-line no-important
}

&:focus .lnsLayerPanel__triggerTextLabel,
&:focus-within .lnsLayerPanel__triggerTextLabel {
background-color: transparentize($euiColorVis1, .9);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['x'],
accessors: [{ columnId: 'x' }],
filterOperations: () => true,
supportsMoreColumns: false,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['x'],
accessors: [{ columnId: 'x' }],
filterOperations: () => true,
supportsMoreColumns: false,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['newid'],
accessors: [{ columnId: 'newid' }],
filterOperations: () => true,
supportsMoreColumns: true,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['newid'],
accessors: [{ columnId: 'newid' }],
filterOperations: () => true,
supportsMoreColumns: false,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['newid'],
accessors: [{ columnId: 'newid' }],
filterOperations: () => true,
supportsMoreColumns: false,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['a'],
accessors: [{ columnId: 'a' }],
filterOperations: () => true,
supportsMoreColumns: true,
dataTestSubj: 'lnsGroup',
Expand Down Expand Up @@ -416,15 +416,15 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['a'],
accessors: [{ columnId: 'a' }],
filterOperations: () => true,
supportsMoreColumns: false,
dataTestSubj: 'lnsGroupA',
},
{
groupLabel: 'B',
groupId: 'b',
accessors: ['b'],
accessors: [{ columnId: 'b' }],
filterOperations: () => true,
supportsMoreColumns: true,
dataTestSubj: 'lnsGroupB',
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('LayerPanel', () => {
{
groupLabel: 'A',
groupId: 'a',
accessors: ['a', 'b'],
accessors: [{ columnId: 'a' }, { columnId: 'b' }],
filterOperations: () => true,
supportsMoreColumns: true,
dataTestSubj: 'lnsGroup',
Expand Down
Loading