Skip to content

Commit 82e642b

Browse files
gurinder39GurinderRawala
authored andcommitted
Time range selector changes (#42)
* changed time picker dropdown designs * change time setting button * added dark and light
1 parent 1e381d6 commit 82e642b

File tree

4 files changed

+114
-126
lines changed

4 files changed

+114
-126
lines changed

packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerContent.tsx

+46-58
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { memo, useMemo, useState } from 'react';
44
import { GrafanaTheme2, isDateTime, rangeUtil, RawTimeRange, TimeOption, TimeRange, TimeZone } from '@grafana/data';
55
import { selectors } from '@grafana/e2e-selectors';
66

7-
import { useStyles2, useTheme2 } from '../../../themes';
7+
import { stylesFactory, useStyles2, useTheme2 } from '../../../themes';
88
import { getFocusStyles } from '../../../themes/mixins';
99
import { t, Trans } from '../../../utils/i18n';
1010
import { FilterInput } from '../../FilterInput/FilterInput';
@@ -79,11 +79,6 @@ export const TimePickerContentWithScreenSize = (props: PropsWithScreenSize) => {
7979
return (
8080
<div id="TimePickerContent" className={cx(styles.container, className)}>
8181
<div className={styles.body}>
82-
{isFullscreen && (
83-
<div className={styles.leftSide}>
84-
<FullScreenForm {...props} historyOptions={historyOptions} />
85-
</div>
86-
)}
8782
{(!isFullscreen || !hideQuickRanges) && (
8883
<div className={styles.rightSide}>
8984
<div className={styles.timeRangeFilter}>
@@ -102,6 +97,11 @@ export const TimePickerContentWithScreenSize = (props: PropsWithScreenSize) => {
10297
</div>
10398
</div>
10499
)}
100+
{isFullscreen && (
101+
<div className={styles.leftSide}>
102+
<FullScreenForm {...props} historyOptions={historyOptions} />
103+
</div>
104+
)}
105105
</div>
106106
{!hideTimeZone && isFullscreen && (
107107
<TimePickerFooter
@@ -193,10 +193,7 @@ const FullScreenForm = (props: FormProps) => {
193193
className={styles.container}
194194
style={{
195195
height: '100%',
196-
display: 'flex',
197-
flexDirection: 'column',
198-
justifyContent: 'center',
199-
alignItems: 'center',
196+
padding: '25px',
200197
}}
201198
>
202199
<div className={styles.title} data-testid={selectors.components.TimePicker.absoluteTimeRangeTitle}>
@@ -278,54 +275,45 @@ const useTimeOption = (raw: RawTimeRange, quickOptions: TimeOption[]): TimeOptio
278275
}, [raw, quickOptions]);
279276
};
280277

281-
const getStyles = (
282-
theme: GrafanaTheme2,
283-
isReversed?: boolean,
284-
hideQuickRanges?: boolean,
285-
isContainerTall?: boolean,
286-
isFullscreen?: boolean
287-
) => ({
288-
container: css({
289-
background: theme.colors.background.primary,
290-
boxShadow: theme.shadows.z3,
291-
width: `${isFullscreen ? '546px' : '262px'}`,
292-
borderRadius: theme.shape.radius.default,
293-
border: `1px solid ${theme.colors.border.weak}`,
294-
[`${isReversed ? 'left' : 'right'}`]: 0,
295-
display: 'flex',
296-
flexDirection: 'column',
297-
}),
298-
body: css({
299-
display: 'flex',
300-
flexDirection: 'row-reverse',
301-
height: `${isContainerTall ? '381px' : '217px'}`,
302-
maxHeight: '100vh',
303-
}),
304-
leftSide: css({
305-
display: 'flex',
306-
flexDirection: 'column',
307-
borderRight: `${isReversed ? 'none' : `1px solid ${theme.colors.border.weak}`}`,
308-
width: `${!hideQuickRanges ? '60%' : '100%'}`,
309-
overflow: 'auto',
310-
scrollbarWidth: 'thin',
311-
order: isReversed ? 1 : 0,
312-
}),
313-
rightSide: css({
314-
width: `${isFullscreen ? '40%' : '100%'}; !important`,
315-
borderRight: isReversed ? `1px solid ${theme.colors.border.weak}` : 'none',
316-
display: 'flex',
317-
flexDirection: 'column',
318-
}),
319-
timeRangeFilter: css({
320-
padding: theme.spacing(1),
321-
}),
322-
spacing: css({
323-
marginTop: '16px',
324-
}),
325-
scrollContent: css({
326-
overflowY: 'auto',
327-
scrollbarWidth: 'thin',
328-
}),
278+
const getStyles = stylesFactory((theme: GrafanaTheme2, isReversed, hideQuickRanges, isContainerTall, isFullscreen) => {
279+
return {
280+
container: css`
281+
background: ${theme.colors.background.primary};
282+
box-shadow: ${theme.shadows.z3};
283+
position: absolute;
284+
z-index: ${theme.zIndex.dropdown};
285+
width: ${isFullscreen ? '546px' : '262px'};
286+
top: 116%;
287+
border-radius: 2px;
288+
border: 1px solid ${theme.colors.border.weak};
289+
${isReversed ? 'left' : 'right'}: 0;
290+
`,
291+
body: css`
292+
display: flex;
293+
flex-direction: row-reverse;
294+
height: ${isContainerTall ? '281px' : '217px'};
295+
`,
296+
leftSide: css`
297+
display: flex;
298+
flex-direction: column;
299+
border-right: ${isReversed ? 'none' : `1px solid ${theme.colors.border.weak}`};
300+
width: ${!hideQuickRanges ? '50%' : '100%'};
301+
overflow: hidden;
302+
order: ${isReversed ? 1 : 0};
303+
`,
304+
rightSide: css`
305+
width: ${isFullscreen ? '50%' : '100%'}; !important;
306+
border-right: ${isReversed ? `1px solid ${theme.colors.border.weak}` : 'none'};
307+
display: flex;
308+
flex-direction: column;
309+
`,
310+
timeRangeFilter: css`
311+
padding: ${theme.spacing(1)};
312+
`,
313+
spacing: css`
314+
margin-top: 16px;
315+
`,
316+
};
329317
});
330318

331319
const getNarrowScreenStyles = (theme: GrafanaTheme2) => ({

packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimePickerFooter.tsx

+50-45
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as React from 'react';
66
import { getTimeZoneInfo, GrafanaTheme2, TimeZone } from '@grafana/data';
77
import { selectors } from '@grafana/e2e-selectors';
88

9-
import { useStyles2 } from '../../../themes';
9+
import { stylesFactory, useStyles2 } from '../../../themes';
1010
import { t, Trans } from '../../../utils/i18n';
1111
import { Button } from '../../Button';
1212
import { Field } from '../../Forms/Field';
@@ -63,6 +63,8 @@ export const TimePickerFooter = (props: Props) => {
6363
return null;
6464
}
6565

66+
const fnColor = theme.isDark ? '#8EC4AD' : '#3A785E';
67+
6668
return (
6769
<div>
6870
<section
@@ -79,13 +81,13 @@ export const TimePickerFooter = (props: Props) => {
7981
</div>
8082
<div className={style.spacer} />
8183
<Button
82-
data-testid={selectors.components.TimeZonePicker.changeTimeSettingsButton}
83-
variant="secondary"
8484
onClick={onToggleChangeTimeSettings}
85-
size="sm"
86-
aria-expanded={isEditing}
87-
aria-controls={timeSettingsId}
88-
icon={isEditing ? 'angle-up' : 'angle-down'}
85+
size="md"
86+
style={{
87+
backgroundColor: '#ffffff00',
88+
color: fnColor,
89+
border: `1px solid ${fnColor}`,
90+
}}
8991
>
9092
<Trans i18nKey="time-picker.footer.change-settings-button">Change time settings</Trans>
9193
</Button>
@@ -162,42 +164,45 @@ export const TimePickerFooter = (props: Props) => {
162164
);
163165
};
164166

165-
const getStyle = (theme: GrafanaTheme2) => ({
166-
container: css({
167-
borderTop: `1px solid ${theme.colors.border.weak}`,
168-
padding: theme.spacing(1.5),
169-
display: 'flex',
170-
flexDirection: 'row',
171-
justifyContent: 'space-between',
172-
alignItems: 'center',
173-
}),
174-
editContainer: css({
175-
borderTop: `1px solid ${theme.colors.border.weak}`,
176-
padding: theme.spacing(1.5),
177-
paddingTop: 0,
178-
justifyContent: 'space-between',
179-
alignItems: 'center',
180-
}),
181-
spacer: css({
182-
marginLeft: '7px',
183-
}),
184-
timeSettingContainer: css({
185-
paddingTop: theme.spacing(1),
186-
}),
187-
fiscalYearField: css({
188-
marginBottom: 0,
189-
}),
190-
timeZoneContainer: css({
191-
display: 'flex',
192-
flexDirection: 'row',
193-
justifyContent: 'space-between',
194-
alignItems: 'center',
195-
flexGrow: 1,
196-
}),
197-
timeZone: css({
198-
display: 'flex',
199-
flexDirection: 'row',
200-
alignItems: 'baseline',
201-
flexGrow: 1,
202-
}),
167+
const getStyle = stylesFactory((theme: GrafanaTheme2) => {
168+
return {
169+
container: css`
170+
border-top: 1px solid ${theme.colors.border.weak};
171+
padding: 11px;
172+
display: flex;
173+
flex-direction: row;
174+
justify-content: space-between;
175+
align-items: center;
176+
height: 60px;
177+
`,
178+
editContainer: css`
179+
border-top: 1px solid ${theme.colors.border.weak};
180+
padding: 11px;
181+
justify-content: space-between;
182+
align-items: center;
183+
padding: 7px;
184+
`,
185+
spacer: css`
186+
margin-left: 7px;
187+
`,
188+
timeSettingContainer: css`
189+
padding-top: ${theme.spacing(1)};
190+
`,
191+
fiscalYearField: css`
192+
margin-bottom: 0px;
193+
`,
194+
timeZoneContainer: css`
195+
display: flex;
196+
flex-direction: row;
197+
justify-content: space-between;
198+
align-items: center;
199+
flex-grow: 1;
200+
`,
201+
timeZone: css`
202+
display: flex;
203+
flex-direction: row;
204+
align-items: baseline;
205+
flex-grow: 1;
206+
`,
207+
};
203208
});

packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/TimeRangeContent.tsx

+11-21
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,17 @@ export const TimeRangeContent = (props: Props) => {
195195
</Field>
196196
{fyTooltip}
197197
</div>
198-
<div className={style.buttonsContainer}>
199-
<Button
200-
data-testid={selectors.components.TimePicker.copyTimeRange}
201-
icon="copy"
202-
variant="secondary"
203-
tooltip={t('time-picker.copy-paste.tooltip-copy', 'Copy time range to clipboard')}
204-
type="button"
205-
onClick={onCopy}
206-
/>
207-
<Button
208-
data-testid={selectors.components.TimePicker.pasteTimeRange}
209-
icon="clipboard-alt"
210-
variant="secondary"
211-
tooltip={t('time-picker.copy-paste.tooltip-paste', 'Paste time range')}
212-
type="button"
213-
onClick={onPaste}
214-
/>
215-
<Button data-testid={selectors.components.TimePicker.applyTimeRange} type="button" onClick={onApply}>
216-
<Trans i18nKey="time-picker.range-content.apply-button">Apply time range</Trans>
217-
</Button>
218-
</div>
198+
<Button
199+
data-testid={selectors.components.TimePicker.applyTimeRange}
200+
onClick={onApply}
201+
style={{
202+
width: '100%',
203+
textAlign: 'center',
204+
paddingLeft: '55px',
205+
}}
206+
>
207+
<Trans i18nKey="time-picker.range-content.apply-button">Apply time range</Trans>
208+
</Button>
219209

220210
<TimePickerCalendar
221211
isFullscreen={isFullscreen}

packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneDescription.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
33

44
import { GrafanaTheme2, TimeZoneInfo } from '@grafana/data';
55

6-
import { useStyles2 } from '../../../themes';
6+
import { useTheme2, useStyles2 } from '../../../themes';
77

88
interface Props {
99
info?: TimeZoneInfo;
@@ -12,12 +12,17 @@ interface Props {
1212
export const TimeZoneDescription = ({ info }: Props) => {
1313
const styles = useStyles2(getStyles);
1414
const description = useDescription(info);
15+
const { isDark } = useTheme2();
1516

1617
if (!info) {
1718
return null;
1819
}
1920

20-
return <div className={styles.description}>{description}</div>;
21+
return (
22+
<div className={styles.description} style={{ color: isDark ? '#F27A40' : '#BF470D' }}>
23+
{description}
24+
</div>
25+
);
2126
};
2227

2328
const useDescription = (info?: TimeZoneInfo): string => {

0 commit comments

Comments
 (0)