mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
import { css } from 'emotion';
|
|
|
|
import { Tooltip, useTheme, stylesFactory } from '@grafana/ui';
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
|
return {
|
|
timePickerSynced: css`
|
|
label: timePickerSynced;
|
|
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;
|
|
`,
|
|
};
|
|
});
|
|
|
|
interface TimeSyncButtonProps {
|
|
isSynced: boolean;
|
|
onClick: () => void;
|
|
}
|
|
|
|
export function TimeSyncButton(props: TimeSyncButtonProps) {
|
|
const { onClick, isSynced } = props;
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
const syncTimesTooltip = () => {
|
|
const { isSynced } = props;
|
|
const tooltip = isSynced ? 'Unsync all views' : 'Sync all views to this time range';
|
|
return <>{tooltip}</>;
|
|
};
|
|
|
|
return (
|
|
<Tooltip content={syncTimesTooltip} placement="bottom">
|
|
<button
|
|
className={classNames('btn navbar-button navbar-button--attached', {
|
|
[styles.timePickerSynced]: isSynced,
|
|
})}
|
|
aria-label={isSynced ? 'Synced times' : 'Unsynced times'}
|
|
onClick={() => onClick()}
|
|
>
|
|
<i className="fa fa-link" />
|
|
</button>
|
|
</Tooltip>
|
|
);
|
|
}
|