|
|
@@ -2,28 +2,30 @@ import React from 'react';
|
|
|
import classNames from 'classnames';
|
|
|
import { css } from 'emotion';
|
|
|
import memoizeOne from 'memoize-one';
|
|
|
-import { GrafanaTheme, GrafanaThemeType, useTheme } from '@grafana/ui';
|
|
|
import tinycolor from 'tinycolor2';
|
|
|
+import { CSSTransition } from 'react-transition-group';
|
|
|
|
|
|
-const orangeDark = '#FF780A';
|
|
|
-const orangeDarkLighter = tinycolor(orangeDark)
|
|
|
- .lighten(10)
|
|
|
- .toString();
|
|
|
-const orangeLight = '#ED5700';
|
|
|
-const orangeLightLighter = tinycolor(orangeLight)
|
|
|
- .lighten(10)
|
|
|
- .toString();
|
|
|
+import { GrafanaTheme, GrafanaThemeType, useTheme } from '@grafana/ui';
|
|
|
|
|
|
const getStyles = memoizeOne((theme: GrafanaTheme) => {
|
|
|
- const orange = theme.type === GrafanaThemeType.Dark ? orangeDark : orangeLight;
|
|
|
- const orangeLighter = theme.type === GrafanaThemeType.Dark ? orangeDarkLighter : orangeLightLighter;
|
|
|
- const textColor = theme.type === GrafanaThemeType.Dark ? theme.colors.white : theme.colors.black;
|
|
|
+ const orange = theme.type === GrafanaThemeType.Dark ? '#FF780A' : '#ED5700';
|
|
|
+ const orangeLighter = tinycolor(orange)
|
|
|
+ .lighten(10)
|
|
|
+ .toString();
|
|
|
+ const pulseTextColor = tinycolor(orange)
|
|
|
+ .desaturate(90)
|
|
|
+ .toString();
|
|
|
|
|
|
return {
|
|
|
noRightBorderStyle: css`
|
|
|
label: noRightBorderStyle;
|
|
|
border-right: 0;
|
|
|
`,
|
|
|
+ liveButton: css`
|
|
|
+ label: liveButton;
|
|
|
+ transition: background-color 1s, border-color 1s, color 1s;
|
|
|
+ margin: 0;
|
|
|
+ `,
|
|
|
isLive: css`
|
|
|
label: isLive;
|
|
|
border-color: ${orange};
|
|
|
@@ -43,7 +45,7 @@ const getStyles = memoizeOne((theme: GrafanaTheme) => {
|
|
|
label: isPaused;
|
|
|
border-color: ${orange};
|
|
|
background: transparent;
|
|
|
- animation: pulse 2s ease-out 0s infinite normal forwards;
|
|
|
+ animation: pulse 3s ease-out 0s infinite normal forwards;
|
|
|
&:focus {
|
|
|
border-color: ${orange};
|
|
|
}
|
|
|
@@ -53,16 +55,40 @@ const getStyles = memoizeOne((theme: GrafanaTheme) => {
|
|
|
}
|
|
|
@keyframes pulse {
|
|
|
0% {
|
|
|
- color: ${textColor};
|
|
|
+ color: ${pulseTextColor};
|
|
|
}
|
|
|
50% {
|
|
|
color: ${orange};
|
|
|
}
|
|
|
100% {
|
|
|
- color: ${textColor};
|
|
|
+ color: ${pulseTextColor};
|
|
|
}
|
|
|
}
|
|
|
`,
|
|
|
+ stopButtonEnter: css`
|
|
|
+ label: stopButtonEnter;
|
|
|
+ width: 0;
|
|
|
+ opacity: 0;
|
|
|
+ overflow: hidden;
|
|
|
+ `,
|
|
|
+ stopButtonEnterActive: css`
|
|
|
+ label: stopButtonEnterActive;
|
|
|
+ opacity: 1;
|
|
|
+ width: 32px;
|
|
|
+ transition: opacity 500ms ease-in 50ms, width 500ms ease-in 50ms;
|
|
|
+ `,
|
|
|
+ stopButtonExit: css`
|
|
|
+ label: stopButtonExit;
|
|
|
+ width: 32px;
|
|
|
+ opacity: 1;
|
|
|
+ overflow: hidden;
|
|
|
+ `,
|
|
|
+ stopButtonExitActive: css`
|
|
|
+ label: stopButtonExitActive;
|
|
|
+ opacity: 0;
|
|
|
+ width: 0;
|
|
|
+ transition: opacity 500ms ease-in 50ms, width 500ms ease-in 50ms;
|
|
|
+ `,
|
|
|
};
|
|
|
});
|
|
|
|
|
|
@@ -82,9 +108,9 @@ export function LiveTailButton(props: LiveTailButtonProps) {
|
|
|
const onClickMain = isLive ? (isPaused ? resume : pause) : start;
|
|
|
|
|
|
return (
|
|
|
- <div className="explore-toolbar-content-item">
|
|
|
+ <>
|
|
|
<button
|
|
|
- className={classNames('btn navbar-button', {
|
|
|
+ className={classNames('btn navbar-button', styles.liveButton, {
|
|
|
[`btn--radius-right-0 ${styles.noRightBorderStyle}`]: isLive,
|
|
|
[styles.isLive]: isLive && !isPaused,
|
|
|
[styles.isPaused]: isLive && isPaused,
|
|
|
@@ -94,11 +120,24 @@ export function LiveTailButton(props: LiveTailButtonProps) {
|
|
|
<i className={classNames('fa', isPaused || !isLive ? 'fa-play' : 'fa-pause')} />
|
|
|
Live tailing
|
|
|
</button>
|
|
|
- {isLive && (
|
|
|
- <button className={`btn navbar-button navbar-button--attached ${styles.isLive}`} onClick={stop}>
|
|
|
- <i className={'fa fa-stop'} />
|
|
|
- </button>
|
|
|
- )}
|
|
|
- </div>
|
|
|
+ <CSSTransition
|
|
|
+ mountOnEnter={true}
|
|
|
+ unmountOnExit={true}
|
|
|
+ timeout={500}
|
|
|
+ in={isLive}
|
|
|
+ classNames={{
|
|
|
+ enter: styles.stopButtonEnter,
|
|
|
+ enterActive: styles.stopButtonEnterActive,
|
|
|
+ exit: styles.stopButtonExit,
|
|
|
+ exitActive: styles.stopButtonExitActive,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <button className={`btn navbar-button navbar-button--attached ${styles.isLive}`} onClick={stop}>
|
|
|
+ <i className={'fa fa-stop'} />
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </CSSTransition>
|
|
|
+ </>
|
|
|
);
|
|
|
}
|