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/SCSS] Delete and migrate annotations.scss file #209074

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import './annotations.scss';
import './reference_lines/reference_lines.scss';

import React, { Fragment } from 'react';
Expand All @@ -28,6 +27,7 @@ import {
EuiPanel,
EuiSpacer,
EuiTitle,
UseEuiTheme,
} from '@elastic/eui';
import type {
EventAnnotationOutput,
Expand All @@ -39,6 +39,7 @@ import { defaultAnnotationColor, defaultAnnotationRangeColor } from '@kbn/event-
import { Datatable, DatatableColumn, DatatableRow } from '@kbn/expressions-plugin/common';
import { PointEventAnnotationRow } from '@kbn/event-annotation-plugin/common/manual_event_annotation/types';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import type { MergedAnnotation } from '../../common';
import { AnnotationIcon, hasIcon, Marker, MarkerBody } from '../helpers';
import { mapVerticalToHorizontalPlacement, LINES_MARKER_SIZE } from '../helpers';
Expand Down Expand Up @@ -67,11 +68,11 @@ const TooltipAnnotationDetails = ({
}>;
}) => {
return extraFields.length > 0 ? (
<div className="xyAnnotationTooltip__extraFields">
<div css={styles.xyAnnotationTooltipExtraFields}>
{extraFields.map((field) => (
<EuiFlexGroup gutterSize="s">
<EuiFlexItem className="xyAnnotationTooltip__extraFieldsKey">{field.name}:</EuiFlexItem>
<EuiFlexItem className="xyAnnotationTooltip__extraFieldsValue">
<EuiFlexItem css={styles.xyAnnotationTooltipExtraFieldsKey}>{field.name}:</EuiFlexItem>
<EuiFlexItem css={styles.xyAnnotationTooltipExtraFieldsValue}>
{field.formatter ? field.formatter.convert(row[field.key]) : row[field.key]}
</EuiFlexItem>
</EuiFlexGroup>
Expand Down Expand Up @@ -120,9 +121,9 @@ const createCustomTooltip =
hasBorder={false}
paddingSize="none"
borderRadius="none"
className="xyAnnotationTooltip"
css={styles.xyAnnotationTooltip}
>
<div className="xyAnnotationTooltip__rows">
<div css={styles.xyAnnotationTooltipRows}>
{rows.slice(0, DISPLAYED_COUNT_OF_ROWS).map((row, index) => {
const extraFields = getExtraFields(row, formatFactory, columns);

Expand All @@ -135,7 +136,7 @@ const createCustomTooltip =
<EuiSpacer size="xs" />
</>
)}
<div className="xyAnnotationTooltip__row">
<div css={styles.xyAnnotationTooltipRow}>
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false}>
<AnnotationIcon
Expand All @@ -161,11 +162,11 @@ const createCustomTooltip =
})}
</div>
{skippedCount ? (
<div className="xyAnnotationTooltip__skippedCount">
<div css={styles.xyAnnotationTooltipSkippedCount}>
<EuiSpacer size="xs" />
<EuiHorizontalRule margin="none" />
<EuiSpacer size="xs" />
<div className="xyAnnotationTooltip__row ">
<div css={styles.xyAnnotationTooltipRow}>
<FormattedMessage
id="expressionXY.annotations.skippedCount"
defaultMessage="+{value} more…"
Expand Down Expand Up @@ -362,9 +363,9 @@ export const Annotations = ({
hasBorder={false}
paddingSize="none"
borderRadius="none"
className="xyAnnotationTooltip"
css={styles.xyAnnotationTooltip}
>
<div className="xyAnnotationTooltip__row">
<div css={styles.xyAnnotationTooltipRow}>
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiIcon type="stopFilled" color={color} />
Expand Down Expand Up @@ -399,3 +400,39 @@ export const Annotations = ({
</>
);
};

const styles = {
xyAnnotationTooltip: css({
borderRadius: '0 !important',
}),
xyAnnotationTooltipRows: css({
// maxHeight: '60vh',
overflowY: 'hidden',
}),
xyAnnotationTooltipRow: ({ euiTheme }: UseEuiTheme) =>
css({
fontWeight: euiTheme.font.weight.regular,
padding: `${euiTheme.size.s} ${euiTheme.size.m} ${euiTheme.size.s} ${euiTheme.size.s}`,
borderRadius: '0 !important',
}),
xyAnnotationTooltipExtraFields: ({ euiTheme }: UseEuiTheme) =>
css({
color: euiTheme.colors.darkShade,
marginTop: euiTheme.size.s,
}),
xyAnnotationTooltipExtraFieldsKey: css({
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
xyAnnotationTooltipExtraFieldsValue: css({
textAlign: 'right',
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
xyAnnotationTooltipSkippedCount: ({ euiTheme }: UseEuiTheme) =>
css({
position: 'relative',
textAlign: 'right',
fontWeight: euiTheme.font.weight.regular,
}),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to keep the whole prefix-y name. The styles are collocated so it's ok to simplify:

Suggested change
const styles = {
xyAnnotationTooltip: css({
borderRadius: '0 !important',
}),
xyAnnotationTooltipRows: css({
// maxHeight: '60vh',
overflowY: 'hidden',
}),
xyAnnotationTooltipRow: ({ euiTheme }: UseEuiTheme) =>
css({
fontWeight: euiTheme.font.weight.regular,
padding: `${euiTheme.size.s} ${euiTheme.size.m} ${euiTheme.size.s} ${euiTheme.size.s}`,
borderRadius: '0 !important',
}),
xyAnnotationTooltipExtraFields: ({ euiTheme }: UseEuiTheme) =>
css({
color: euiTheme.colors.darkShade,
marginTop: euiTheme.size.s,
}),
xyAnnotationTooltipExtraFieldsKey: css({
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
xyAnnotationTooltipExtraFieldsValue: css({
textAlign: 'right',
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
xyAnnotationTooltipSkippedCount: ({ euiTheme }: UseEuiTheme) =>
css({
position: 'relative',
textAlign: 'right',
fontWeight: euiTheme.font.weight.regular,
}),
};
const styles = {
tooltip: css({
borderRadius: '0 !important',
}),
rows: css({
// maxHeight: '60vh',
overflowY: 'hidden',
}),
row: ({ euiTheme }: UseEuiTheme) =>
css({
fontWeight: euiTheme.font.weight.regular,
padding: `${euiTheme.size.s} ${euiTheme.size.m} ${euiTheme.size.s} ${euiTheme.size.s}`,
borderRadius: '0 !important',
}),
extraFields: ({ euiTheme }: UseEuiTheme) =>
css({
color: euiTheme.colors.darkShade,
marginTop: euiTheme.size.s,
}),
extraFieldKey: css({
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
extraFieldValue: css({
textAlign: 'right',
overflowWrap: 'anywhere',
hyphens: 'auto',
}),
skippedCount: ({ euiTheme }: UseEuiTheme) =>
css({
position: 'relative',
textAlign: 'right',
fontWeight: euiTheme.font.weight.regular,
}),
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I've only removed the xyAnnotation prefix here since the first style refers to the tooltip and the rest are related. Let me know if it makes sense too

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import React from 'react';
import { Position } from '@elastic/charts';
import { EuiFlexGroup, EuiIcon, EuiIconProps, EuiText } from '@elastic/eui';
import { EuiFlexGroup, EuiIcon, EuiIconProps, EuiText, useEuiFontSize } from '@elastic/eui';
import { css } from '@emotion/react';
import { UseEuiTheme } from '@elastic/eui';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { EuiFlexGroup, EuiIcon, EuiIconProps, EuiText, useEuiFontSize } from '@elastic/eui';
import { css } from '@emotion/react';
import { UseEuiTheme } from '@elastic/eui';
import { EuiFlexGroup, EuiIcon, EuiIconProps, EuiText, useEuiFontSize, UseEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import type {
IconPosition,
ReferenceLineDecorationConfig,
Expand Down Expand Up @@ -143,12 +145,12 @@ function NumberIcon({ number }: { number: number }) {
return (
<EuiFlexGroup
justifyContent="spaceAround"
className="xyAnnotationNumberIcon"
css={styles.xyAnnotationNumberIcon}
data-test-subj="xyVisGroupedAnnotationIcon"
gutterSize="none"
alignItems="center"
>
<EuiText color="ghost" className="xyAnnotationNumberIcon__text">
<EuiText color="ghost" css={[useEuiFontSize('xxxs'), styles.xyAnnotationNumberIconText]}>
{number < 10 ? number : `9+`}
</EuiText>
</EuiFlexGroup>
Expand Down Expand Up @@ -176,12 +178,14 @@ export const AnnotationIcon = ({
if (!iconConfig) {
return null;
}

return (
<EuiIcon
{...rest}
data-test-subj="xyVisAnnotationIcon"
type={iconConfig.icon || type}
className={iconConfig.shouldRotate ? rotateClassName : undefined}
css={styles.xyAnnotationIconRotate90}
/>
);
};
Expand Down Expand Up @@ -221,3 +225,24 @@ export function Marker({
}
return null;
}

const styles = {
xyAnnotationNumberIcon: ({ euiTheme }: UseEuiTheme) =>
css({
borderRadius: euiTheme.size.base,
minWidth: euiTheme.size.base,
height: euiTheme.size.base,
backgroundColor: 'currentColor',
}),
xyAnnotationNumberIconText: ({ euiTheme }: UseEuiTheme) =>
css({
fontWeight: euiTheme.font.weight.medium,
letterSpacing: '-.5px',
}),
xyAnnotationIconRotate90: css({
Comment on lines +236 to +248
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you have done in the src/platform/plugins/shared/chart_expressions/expression_xy/public/components/annotations.tsx file you can probably remove the xyAnnotation prefix on each style

'&.xyAnnotationIcon_rotate90': {
transform: 'rotate(90deg) !important',
transformOrigin: 'center',
},
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"common/**/*",
"public/**/*",
"server/**/*",
"../../../../../../typings/emotion.d.ts"
],
"kbn_references": [
{ "path": "../tsconfig.json" },
Expand Down