Commit dfeee3dd by Ivana Huckova Committed by GitHub

grafana/ui: Add synced timepickers styling to TimePicker (#21598)

parent e84a047a
// Libraries // Libraries
import React, { PureComponent, memo, FormEvent } from 'react'; import React, { PureComponent, memo, FormEvent } from 'react';
import { css } from 'emotion'; import { css, cx } from 'emotion';
import classNames from 'classnames';
// Components // Components
import { Tooltip } from '../Tooltip/Tooltip'; import { Tooltip } from '../Tooltip/Tooltip';
...@@ -70,6 +69,23 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { ...@@ -70,6 +69,23 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
font-size: ${theme.typography.size.md}; font-size: ${theme.typography.size.md};
} }
`, `,
syncedTimePicker: css`
label: syncedTimePicker;
border-color: ${theme.colors.orangeDark};
background-image: none;
background-color: transparent;
color: ${theme.colors.orangeDark};
&:focus,
:hover {
color: ${theme.colors.orangeDark};
background-image: none;
background-color: transparent;
}
`,
noRightBorderStyle: css`
label: noRightBorderStyle;
border-right: 0;
`,
}; };
}); });
...@@ -140,6 +156,12 @@ export class UnthemedTimePicker extends PureComponent<Props, State> { ...@@ -140,6 +156,12 @@ export class UnthemedTimePicker extends PureComponent<Props, State> {
const { isOpen } = this.state; const { isOpen } = this.state;
const styles = getStyles(theme); const styles = getStyles(theme);
const hasAbsolute = isDateTime(value.raw.from) || isDateTime(value.raw.to); const hasAbsolute = isDateTime(value.raw.from) || isDateTime(value.raw.to);
const syncedTimePicker = timeSyncButton && isSynced;
const timePickerIconClass = cx('fa fa-clock-o fa-fw', { ['icon-brand-gradient']: syncedTimePicker });
const timePickerButtonClass = cx('btn navbar-button navbar-button--zoom', {
[`btn--radius-right-0 ${styles.noRightBorderStyle}`]: !!timeSyncButton,
[`explore-active-button-glow ${styles.syncedTimePicker}`]: syncedTimePicker,
});
return ( return (
<div className={styles.container}> <div className={styles.container}>
...@@ -151,12 +173,8 @@ export class UnthemedTimePicker extends PureComponent<Props, State> { ...@@ -151,12 +173,8 @@ export class UnthemedTimePicker extends PureComponent<Props, State> {
)} )}
<div> <div>
<Tooltip content={<TimePickerTooltip timeRange={value} />} placement="bottom"> <Tooltip content={<TimePickerTooltip timeRange={value} />} placement="bottom">
<button <button aria-label="TimePicker Open Button" className={timePickerButtonClass} onClick={this.onOpen}>
aria-label="TimePicker Open Button" <i className={timePickerIconClass} />
className="btn navbar-button navbar-button--zoom"
onClick={this.onOpen}
>
<i className={classNames('fa fa-clock-o fa-fw', isSynced && timeSyncButton && 'icon-brand-gradient')} />
<TimePickerButtonLabel {...this.props} /> <TimePickerButtonLabel {...this.props} />
<span className={styles.caretIcon}> <span className={styles.caretIcon}>
{isOpen ? <i className="fa fa-caret-up fa-fw" /> : <i className="fa fa-caret-down fa-fw" />} {isOpen ? <i className="fa fa-caret-up fa-fw" /> : <i className="fa fa-caret-down fa-fw" />}
......
...@@ -24,6 +24,14 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { ...@@ -24,6 +24,14 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
label: noRightBorderStyle; label: noRightBorderStyle;
border-right: 0; border-right: 0;
`, `,
/*
* Required top-padding, otherwise is fa-link icon in active state
* cut off on top due to fontAwesome icon position
*/
topPadding: css`
label: topPadding;
padding-top: 1px;
`,
}; };
}); });
...@@ -52,7 +60,7 @@ export function TimeSyncButton(props: TimeSyncButtonProps) { ...@@ -52,7 +60,7 @@ export function TimeSyncButton(props: TimeSyncButtonProps) {
aria-label={isSynced ? 'Synced times' : 'Unsynced times'} aria-label={isSynced ? 'Synced times' : 'Unsynced times'}
onClick={() => onClick()} onClick={() => onClick()}
> >
<i className={classNames('fa fa-link', isSynced && 'icon-brand-gradient')} /> <i className={classNames('fa fa-link', styles.topPadding, isSynced && 'icon-brand-gradient')} />
</button> </button>
</Tooltip> </Tooltip>
); );
......
...@@ -21,7 +21,7 @@ exports[`TimeSyncButton should render component 1`] = ` ...@@ -21,7 +21,7 @@ exports[`TimeSyncButton should render component 1`] = `
onMouseLeave={[Function]} onMouseLeave={[Function]}
> >
<i <i
className="fa fa-link icon-brand-gradient" className="fa fa-link css-xmj56l-topPadding icon-brand-gradient"
/> />
</button> </button>
</PopoverController> </PopoverController>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment