From a6f9336ea15c680302ce669f04bc3e5256eb57a7 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 12 Jul 2024 14:47:12 +0100 Subject: [PATCH] Chore: SCSS cleanup (#90366) * migrate _type styles * migrate queryEditor styles --- .../src/themes/GlobalStyles/GlobalStyles.tsx | 4 +- .../src/themes/GlobalStyles/elements.ts | 95 +++++- .../src/themes/GlobalStyles/markdownStyles.ts | 45 ++- .../src/themes/GlobalStyles/queryEditor.ts | 60 ++++ .../src/themes/GlobalStyles/queryPart.ts | 15 - .../AccessControl/PermissionListItem.tsx | 6 +- public/sass/_angular.scss | 8 + public/sass/_grafana.scss | 2 - public/sass/base/_type.scss | 275 ------------------ public/sass/components/_query_editor.scss | 118 -------- 10 files changed, 213 insertions(+), 415 deletions(-) create mode 100644 packages/grafana-ui/src/themes/GlobalStyles/queryEditor.ts delete mode 100644 packages/grafana-ui/src/themes/GlobalStyles/queryPart.ts delete mode 100644 public/sass/base/_type.scss delete mode 100644 public/sass/components/_query_editor.scss diff --git a/packages/grafana-ui/src/themes/GlobalStyles/GlobalStyles.tsx b/packages/grafana-ui/src/themes/GlobalStyles/GlobalStyles.tsx index 05a8154b701..7755fc4d738 100644 --- a/packages/grafana-ui/src/themes/GlobalStyles/GlobalStyles.tsx +++ b/packages/grafana-ui/src/themes/GlobalStyles/GlobalStyles.tsx @@ -16,7 +16,7 @@ import { getJsonFormatterStyles } from './jsonFormatter'; import { getLegacySelectStyles } from './legacySelect'; import { getMarkdownStyles } from './markdownStyles'; import { getPageStyles } from './page'; -import { getQueryPartStyles } from './queryPart'; +import { getQueryEditorStyles } from './queryEditor'; import { getRcTimePickerStyles } from './rcTimePicker'; import { getSkeletonStyles } from './skeletonStyles'; import { getSlateStyles } from './slate'; @@ -42,7 +42,7 @@ export function GlobalStyles() { getCardStyles(theme), getMarkdownStyles(theme), getPageStyles(theme), - getQueryPartStyles(theme), + getQueryEditorStyles(theme), getRcTimePickerStyles(theme), getSkeletonStyles(theme), getSlateStyles(theme), diff --git a/packages/grafana-ui/src/themes/GlobalStyles/elements.ts b/packages/grafana-ui/src/themes/GlobalStyles/elements.ts index 9f8164559a5..59d68dd7b3c 100644 --- a/packages/grafana-ui/src/themes/GlobalStyles/elements.ts +++ b/packages/grafana-ui/src/themes/GlobalStyles/elements.ts @@ -54,8 +54,9 @@ export function getElementStyles(theme: GrafanaTheme2) { }, // Ex: 14px base font * 85% = about 12px - small: { + 'small, .small': { fontSize: theme.typography.bodySmall.fontSize, + fontWeight: 'normal', }, 'b, strong': { @@ -71,6 +72,62 @@ export function getElementStyles(theme: GrafanaTheme2) { fontStyle: 'normal', }, + blockquote: { + padding: theme.spacing(0, 0, 0, 2), + margin: theme.spacing(0, 0, 2), + borderLeft: `5px solid ${theme.v1.palette.gray3}`, + p: { + marginBottom: 0, + fontSize: theme.typography.fontSize * 1.25, + fontWeight: 300, + lineHeight: 1.25, + }, + small: { + display: 'block', + lineHeight: theme.typography.body.lineHeight, + color: theme.v1.palette.gray2, + '&:before': { + content: "'\\2014 \\00A0'", + }, + }, + }, + + // Quotes + 'q:before, q:after, blockquote:before, blockquote:after': { + content: "''", + }, + + // Addresses + address: { + display: 'block', + marginBottom: theme.spacing(2), + fontStyle: 'normal', + lineHeight: theme.typography.body.lineHeight, + }, + + 'a.external-link': { + color: theme.colors.text.link, + textDecoration: 'normal', + + '&:hover': { + color: theme.colors.text.link, + textDecoration: 'underline', + }, + }, + + '.link': { + color: theme.colors.text.primary, + cursor: 'pointer', + }, + + '.link:hover': { + color: theme.colors.text.maxContrast, + }, + + '.pointer': { + cursor: 'pointer', + }, + 'audio, canvas, progress, video': { display: 'inline-block', verticalAlign: 'baseline', @@ -86,6 +143,7 @@ export function getElementStyles(theme: GrafanaTheme2) { // Address styling not present in Safari. 'abbr[title]': { borderBottom: '1px dotted', + cursor: 'help', }, dfn: { fontStyle: 'italic', @@ -105,6 +163,37 @@ export function getElementStyles(theme: GrafanaTheme2) { bottom: '-0.25em', }, + hr: { + marginTop: theme.spacing(2), + marginBottom: theme.spacing(2), + border: 0, + borderTop: `1px solid ${theme.colors.border.medium}`, + }, + + 'mark, .mark': { + background: theme.colors.warning.main, + }, + + 'ul, ol': { + padding: 0, + }, + 'ul ul, ul ol, ol ol, ol ul': { + marginBottom: 0, + }, + li: { + lineHeight: theme.typography.body.lineHeight, + }, + + dl: { + marginBottom: theme.spacing(2), + }, + 'dt, dd': { + lineHeight: theme.typography.body.lineHeight, + }, + dt: { + fontWeight: theme.typography.fontWeightMedium, + }, + // 1. Correct color not being inherited. // Known issue: affects color of disabled elements. // 2. Correct font properties not being inherited. @@ -143,6 +232,10 @@ export function getElementStyles(theme: GrafanaTheme2) { borderSpacing: 0, }, + th: { + fontWeight: theme.typography.fontWeightMedium, + }, + 'td, th': { padding: 0, }, diff --git a/packages/grafana-ui/src/themes/GlobalStyles/markdownStyles.ts b/packages/grafana-ui/src/themes/GlobalStyles/markdownStyles.ts index 07830bd07e8..3ab259d5203 100644 --- a/packages/grafana-ui/src/themes/GlobalStyles/markdownStyles.ts +++ b/packages/grafana-ui/src/themes/GlobalStyles/markdownStyles.ts @@ -4,6 +4,49 @@ import { GrafanaTheme2 } from '@grafana/data'; export function getMarkdownStyles(theme: GrafanaTheme2) { return css({ - // TODO copy from _utils.scss + '.markdown-html': { + img: { + maxWidth: '100%', + }, + + 'ul, ol': { + paddingLeft: theme.spacing(3), + marginBottom: theme.spacing(2), + }, + + table: { + marginBottom: theme.spacing(2), + 'td, th': { + padding: theme.spacing(0.5, 1), + }, + th: { + fontWeight: theme.typography.fontWeightMedium, + background: theme.colors.background.secondary, + }, + }, + + 'table, th, td': { + border: `1px solid ${theme.colors.border.medium}`, + borderCollapse: 'collapse', + }, + + a: { + color: theme.colors.text.link, + textDecoration: 'none', + + '&:hover': { + color: theme.colors.text.link, + textDecoration: 'underline', + }, + }, + + 'p:last-child': { + marginBottom: 0, + }, + + 'table:last-child, ul:last-child, ol:last-child': { + marginBottom: 0, + }, + }, }); } diff --git a/packages/grafana-ui/src/themes/GlobalStyles/queryEditor.ts b/packages/grafana-ui/src/themes/GlobalStyles/queryEditor.ts new file mode 100644 index 00000000000..bf3d303ec30 --- /dev/null +++ b/packages/grafana-ui/src/themes/GlobalStyles/queryEditor.ts @@ -0,0 +1,60 @@ +import { css } from '@emotion/react'; + +import { GrafanaTheme2 } from '@grafana/data'; + +export function getQueryEditorStyles(theme: GrafanaTheme2) { + return css({ + '.query-editor-row': { + marginBottom: '2px', + + '&--disabled': { + '.query-keyword': { + color: theme.colors.text.secondary, + }, + }, + }, + '.query-keyword': { + fontWeight: theme.typography.fontWeightMedium, + color: `${theme.colors.primary.text} !important`, + }, + '.query-part': { + backgroundColor: theme.colors.background.secondary, + + '&:hover': { + background: theme.colors.emphasize(theme.colors.background.secondary, 0.03), + }, + }, + '.query-segment-operator': { + color: `${theme.v1.palette.orange} !important`, + }, + '.tight-form-func': { + background: theme.colors.background.secondary, + }, + + 'input[type="text"].tight-form-func-param': { + fontSize: theme.typography.bodySmall.fontSize, + background: 'transparent', + border: 'none', + margin: 0, + padding: 0, + }, + + '.tight-form-func-controls': { + textAlign: 'center', + + '.fa-arrow-left': { + float: 'left', + position: 'relative', + top: 2, + }, + '.fa-arrow-right': { + float: 'right', + position: 'relative', + top: 2, + }, + '.fa-remove': { + marginLeft: '10px', + }, + }, + }); +} diff --git a/packages/grafana-ui/src/themes/GlobalStyles/queryPart.ts b/packages/grafana-ui/src/themes/GlobalStyles/queryPart.ts deleted file mode 100644 index 982e3158328..00000000000 --- a/packages/grafana-ui/src/themes/GlobalStyles/queryPart.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { css } from '@emotion/react'; - -import { GrafanaTheme2 } from '@grafana/data'; - -export function getQueryPartStyles(theme: GrafanaTheme2) { - return css({ - '.query-part': { - backgroundColor: theme.colors.background.secondary, - - '&:hover': { - background: theme.colors.emphasize(theme.colors.background.secondary, 0.03), - }, - }, - }); -} diff --git a/public/app/core/components/AccessControl/PermissionListItem.tsx b/public/app/core/components/AccessControl/PermissionListItem.tsx index fcb5188e067..2409dc0560a 100644 --- a/public/app/core/components/AccessControl/PermissionListItem.tsx +++ b/public/app/core/components/AccessControl/PermissionListItem.tsx @@ -20,7 +20,7 @@ export const PermissionListItem = ({ item, permissionLevels, canSet, onRemove, o {getAvatar(item)} {getDescription(item)} - {item.isInherited && Inherited from folder} + {item.isInherited && Inherited from folder}