mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
GrafanaUI: Update FilterPill active state and ToolbarButton active state (#70396)
This commit is contained in:
@@ -50,6 +50,11 @@ export interface ThemeColorsBase<TColor> {
|
|||||||
action: {
|
action: {
|
||||||
/** Used for selected menu item / select option */
|
/** Used for selected menu item / select option */
|
||||||
selected: string;
|
selected: string;
|
||||||
|
/**
|
||||||
|
* @alpha (Do not use from plugins)
|
||||||
|
* Used for selected items when background only change is not enough (Currently only used for FilterPill)
|
||||||
|
**/
|
||||||
|
selectedBorder: string;
|
||||||
/** Used for hovered menu item / select option */
|
/** Used for hovered menu item / select option */
|
||||||
hover: string;
|
hover: string;
|
||||||
/** Used for button/colored background hover opacity */
|
/** Used for button/colored background hover opacity */
|
||||||
@@ -143,6 +148,7 @@ class DarkColors implements ThemeColorsBase<Partial<ThemeRichColor>> {
|
|||||||
action = {
|
action = {
|
||||||
hover: `rgba(${this.whiteBase}, 0.16)`,
|
hover: `rgba(${this.whiteBase}, 0.16)`,
|
||||||
selected: `rgba(${this.whiteBase}, 0.12)`,
|
selected: `rgba(${this.whiteBase}, 0.12)`,
|
||||||
|
selectedBorder: palette.orangeDarkMain,
|
||||||
focus: `rgba(${this.whiteBase}, 0.16)`,
|
focus: `rgba(${this.whiteBase}, 0.16)`,
|
||||||
hoverOpacity: 0.08,
|
hoverOpacity: 0.08,
|
||||||
disabledText: this.text.disabled,
|
disabledText: this.text.disabled,
|
||||||
@@ -224,6 +230,7 @@ class LightColors implements ThemeColorsBase<Partial<ThemeRichColor>> {
|
|||||||
action = {
|
action = {
|
||||||
hover: `rgba(${this.blackBase}, 0.12)`,
|
hover: `rgba(${this.blackBase}, 0.12)`,
|
||||||
selected: `rgba(${this.blackBase}, 0.08)`,
|
selected: `rgba(${this.blackBase}, 0.08)`,
|
||||||
|
selectedBorder: palette.orangeLightMain,
|
||||||
hoverOpacity: 0.08,
|
hoverOpacity: 0.08,
|
||||||
focus: `rgba(${this.blackBase}, 0.12)`,
|
focus: `rgba(${this.blackBase}, 0.12)`,
|
||||||
disabledBackground: `rgba(${this.blackBase}, 0.04)`,
|
disabledBackground: `rgba(${this.blackBase}, 0.04)`,
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid ${theme.colors.background.secondary};
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: ${theme.colors.action.hover};
|
background: ${theme.colors.action.hover};
|
||||||
@@ -47,7 +49,7 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
`,
|
`,
|
||||||
selected: css`
|
selected: css`
|
||||||
color: ${theme.colors.text.primary};
|
color: ${theme.colors.text.primary};
|
||||||
background: ${theme.colors.action.selected};
|
border: 1px solid #ff780a;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: ${theme.colors.action.focus};
|
background: ${theme.colors.action.focus};
|
||||||
|
|||||||
@@ -130,10 +130,10 @@ export const Examples: StoryFn<typeof ToolbarButton> = (args) => {
|
|||||||
<br />
|
<br />
|
||||||
Wrapped in noSpacing ButtonGroup
|
Wrapped in noSpacing ButtonGroup
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<ToolbarButton variant="canvas" icon="clock-nine" tooltip="Time picker">
|
<ToolbarButton variant="active" icon="clock-nine" tooltip="Time picker">
|
||||||
2020-10-02
|
2020-10-02
|
||||||
</ToolbarButton>
|
</ToolbarButton>
|
||||||
<ToolbarButton variant="canvas" icon="search-minus" />
|
<ToolbarButton variant="active" icon="search-minus" />
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
<br />
|
<br />
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
|
|||||||
@@ -195,16 +195,22 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
canvas: defaultOld,
|
canvas: defaultOld,
|
||||||
active: css`
|
active: cx(
|
||||||
color: ${theme.v1.palette.orangeDark};
|
defaultOld,
|
||||||
border-color: ${theme.v1.palette.orangeDark};
|
css(`
|
||||||
background-color: transparent;
|
&::before {
|
||||||
|
display: block;
|
||||||
&:hover {
|
content: ' ';
|
||||||
color: ${theme.colors.text.primary};
|
position: absolute;
|
||||||
background: ${theme.colors.emphasize(theme.colors.background.canvas, 0.03)};
|
left: 0;
|
||||||
}
|
right: 0;
|
||||||
`,
|
height: 2px;
|
||||||
|
bottom: 0px;
|
||||||
|
border-radius: ${theme.shape.radius.default};
|
||||||
|
background-image: ${theme.colors.gradients.brandHorizontal};
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
),
|
||||||
primary: css(primaryVariant),
|
primary: css(primaryVariant),
|
||||||
destructive: css(destructiveVariant),
|
destructive: css(destructiveVariant),
|
||||||
narrow: css`
|
narrow: css`
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { css, cx } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { Button, HorizontalGroup, useTheme2 } from '@grafana/ui';
|
import { HorizontalGroup, ToolbarButton, useTheme2 } from '@grafana/ui';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
addQueryRowButtonDisabled?: boolean;
|
addQueryRowButtonDisabled?: boolean;
|
||||||
@@ -23,6 +23,7 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function SecondaryActions(props: Props) {
|
export function SecondaryActions(props: Props) {
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const styles = getStyles(theme);
|
const styles = getStyles(theme);
|
||||||
@@ -30,36 +31,34 @@ export function SecondaryActions(props: Props) {
|
|||||||
<div className={styles.containerMargin}>
|
<div className={styles.containerMargin}>
|
||||||
<HorizontalGroup>
|
<HorizontalGroup>
|
||||||
{!props.addQueryRowButtonHidden && (
|
{!props.addQueryRowButtonHidden && (
|
||||||
<Button
|
<ToolbarButton
|
||||||
variant="secondary"
|
variant="canvas"
|
||||||
aria-label="Add row button"
|
aria-label="Add row button"
|
||||||
onClick={props.onClickAddQueryRowButton}
|
onClick={props.onClickAddQueryRowButton}
|
||||||
disabled={props.addQueryRowButtonDisabled}
|
disabled={props.addQueryRowButtonDisabled}
|
||||||
icon="plus"
|
icon="plus"
|
||||||
>
|
>
|
||||||
Add query
|
Add query
|
||||||
</Button>
|
</ToolbarButton>
|
||||||
)}
|
)}
|
||||||
{!props.richHistoryRowButtonHidden && (
|
{!props.richHistoryRowButtonHidden && (
|
||||||
<Button
|
<ToolbarButton
|
||||||
variant="secondary"
|
variant={props.richHistoryButtonActive ? 'active' : 'canvas'}
|
||||||
aria-label="Rich history button"
|
aria-label="Rich history button"
|
||||||
className={cx({ ['explore-active-button']: props.richHistoryButtonActive })}
|
|
||||||
onClick={props.onClickRichHistoryButton}
|
onClick={props.onClickRichHistoryButton}
|
||||||
icon="history"
|
icon="history"
|
||||||
>
|
>
|
||||||
Query history
|
Query history
|
||||||
</Button>
|
</ToolbarButton>
|
||||||
)}
|
)}
|
||||||
<Button
|
<ToolbarButton
|
||||||
variant="secondary"
|
variant={props.queryInspectorButtonActive ? 'active' : 'canvas'}
|
||||||
aria-label="Query inspector button"
|
aria-label="Query inspector button"
|
||||||
className={cx({ ['explore-active-button']: props.queryInspectorButtonActive })}
|
|
||||||
onClick={props.onClickQueryInspectorButton}
|
onClick={props.onClickQueryInspectorButton}
|
||||||
icon="info-circle"
|
icon="info-circle"
|
||||||
>
|
>
|
||||||
Inspector
|
Inspector
|
||||||
</Button>
|
</ToolbarButton>
|
||||||
</HorizontalGroup>
|
</HorizontalGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
.explore-active-button {
|
|
||||||
box-shadow: $btn-active-box-shadow;
|
|
||||||
border: 1px solid $orange-dark !important;
|
|
||||||
color: $orange-dark !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: this is used in Loki & Prometheus, move it
|
// TODO: this is used in Loki & Prometheus, move it
|
||||||
.explore-input-margin {
|
.explore-input-margin {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
|
|||||||
Reference in New Issue
Block a user