grafana/public/app/features/explore/TimeSyncButton.tsx
Torkel Ödegaard 80294b2dbf
TimeRangePicker: Updates components to use new ToolbarButton & ButtonGroup (#30570)
* WIP: Using new components

* Progress

* Everything looks to be working

* Explore: Replaces navbar-button and overriden explore button css classes with ToolbarButton and cleans up scss & markup, removes ResponsiveButton (#30571)

* Explore: Replaces navbar-button and overriden explore button css classes with ToolbarButton and cleans up scss & markup, removes ResponsiveButton

* Change live button text when paused

* Fixed story

* For the dashboard toolbar button I need a transparent button so I refactored the states/variants into a new ToolbarButtonVariatn

* Changing my mind on the transparent variant

* review fixes

* Review fixes
2021-01-25 14:01:54 +01:00

29 lines
736 B
TypeScript

import React from 'react';
import { Tooltip, ToolbarButton } from '@grafana/ui';
interface TimeSyncButtonProps {
isSynced: boolean;
onClick: () => void;
}
export function TimeSyncButton(props: TimeSyncButtonProps) {
const { onClick, isSynced } = props;
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">
<ToolbarButton
icon="link"
variant={isSynced ? 'active' : 'default'}
aria-label={isSynced ? 'Synced times' : 'Unsynced times'}
onClick={onClick}
/>
</Tooltip>
);
}