@scality/core-ui 0.169.0 → 0.170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/buttonv2/Buttonv2.component.js +1 -1
- package/dist/components/date/FormattedDateTime.d.ts +41 -2
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +55 -8
- package/dist/components/date/FormattedDateTime.spec.js +12 -3
- package/dist/components/layout/v2/index.d.ts +2 -1
- package/dist/components/layout/v2/index.d.ts.map +1 -1
- package/dist/components/layout/v2/index.js +3 -3
- package/dist/style/theme.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/barchartv2/ChartTooltip.test.tsx +1 -1
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +1 -1
- package/src/lib/components/date/FormattedDateTime.spec.tsx +27 -2
- package/src/lib/components/date/FormattedDateTime.tsx +61 -11
- package/src/lib/components/layout/v2/index.tsx +5 -3
- package/src/lib/style/theme.ts +1 -1
- package/stories/formattedate.stories.tsx +7 -0
- package/stories/layout.stories.tsx +19 -0
|
@@ -99,6 +99,7 @@ export const ButtonStyled = styled.button `
|
|
|
99
99
|
case 'outline':
|
|
100
100
|
return css `
|
|
101
101
|
border: ${spacing.r1} solid transparent;
|
|
102
|
+
border-color: ${brand.border}; // fallback for linear-gradient button themes
|
|
102
103
|
border-color: ${brand.buttonSecondary};
|
|
103
104
|
background-color: transparent;
|
|
104
105
|
color: ${brand.textPrimary};
|
|
@@ -125,7 +126,6 @@ export const ButtonStyled = styled.button `
|
|
|
125
126
|
position: absolute;
|
|
126
127
|
inset: 0;
|
|
127
128
|
padding: ${spacing.r1};
|
|
128
|
-
background-image: ${brand.buttonSecondary};
|
|
129
129
|
border-radius: inherit;
|
|
130
130
|
mask: linear-gradient(white, white) content-box, linear-gradient(white, white);
|
|
131
131
|
mask-composite: exclude;
|
|
@@ -1,17 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Long date formatter, with weekday, year, month and day. Used for describing long term date.
|
|
3
|
+
* @example Wednesday 6 October 2025
|
|
4
|
+
*/
|
|
1
5
|
export declare const LONG_DATE_FORMATER: Intl.DateTimeFormat;
|
|
2
6
|
/**
|
|
3
7
|
* @description Long date formatter, without weekday.
|
|
4
8
|
* @example 01 September 2025
|
|
5
9
|
*/
|
|
6
10
|
export declare const LONG_DATE_FORMATER_WITHOUT_WEEKDAY: Intl.DateTimeFormat;
|
|
11
|
+
/**
|
|
12
|
+
* @description Date formatter, with year, month and day. Used for describing long term date.
|
|
13
|
+
* @example 2025-01-01
|
|
14
|
+
*/
|
|
7
15
|
export declare const DATE_FORMATER: Intl.DateTimeFormat;
|
|
16
|
+
/**
|
|
17
|
+
* @description Day month formatter, with weekday, day and month. Used for describing long term date.
|
|
18
|
+
* @example Wed 6 Oct
|
|
19
|
+
*/
|
|
8
20
|
export declare const DAY_MONTH_FORMATER: Intl.DateTimeFormat;
|
|
21
|
+
/**
|
|
22
|
+
* @description Time formatter, with hour, minute and second. Used for describing long term date.
|
|
23
|
+
* @example 18:33:00
|
|
24
|
+
*/
|
|
9
25
|
export declare const TIME_SECOND_FORMATER: Intl.DateTimeFormat;
|
|
26
|
+
/**
|
|
27
|
+
* @description Time formatter, with hour and minute. Used for describing long term date.
|
|
28
|
+
* @example 18:33
|
|
29
|
+
*/
|
|
10
30
|
export declare const TIME_FORMATER: Intl.DateTimeFormat;
|
|
31
|
+
/**
|
|
32
|
+
* @description Day month abbreviated hour minute second formatter. Used for describing long term date.
|
|
33
|
+
* @example 6 Oct 18:33:00
|
|
34
|
+
*/
|
|
11
35
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND: Intl.DateTimeFormat;
|
|
12
36
|
/**
|
|
13
|
-
* @description Day month abbreviated hour minute formatter
|
|
14
|
-
* @example
|
|
37
|
+
* @description Day month abbreviated hour minute formatter. Used for describing long term date.
|
|
38
|
+
* @example 6 Oct 18:33
|
|
15
39
|
*/
|
|
16
40
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE: Intl.DateTimeFormat;
|
|
17
41
|
/**
|
|
@@ -28,6 +52,21 @@ type FormattedDateTimeProps = {
|
|
|
28
52
|
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second' | 'long-date' | 'long-date-without-weekday' | 'chart-date' | 'year-month-day' | 'month-day';
|
|
29
53
|
value: Date;
|
|
30
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* @description Formats the date and time according to the format specified.
|
|
57
|
+
* @example
|
|
58
|
+
* date: '2025-01-01'
|
|
59
|
+
* 'date-time': '2025-01-01 00:00'
|
|
60
|
+
* 'date-time-second': '2025-01-01 00:00:00'
|
|
61
|
+
* time: '00:00'
|
|
62
|
+
* 'time-second': '00:00:00'
|
|
63
|
+
* relative: '1 month ago'
|
|
64
|
+
* 'day-month-abbreviated-hour-minute': '6 Oct 18:33'
|
|
65
|
+
* 'day-month-abbreviated-hour-minute-second': '6 Oct 18:33:00'
|
|
66
|
+
* 'long-date': 'Wednesday 6 October 2025'
|
|
67
|
+
* 'chart-date': '6 Oct'
|
|
68
|
+
* 'year-month-day': '2025-10-06'
|
|
69
|
+
*/
|
|
31
70
|
export declare const FormattedDateTime: ({ format, value, }: FormattedDateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
71
|
export {};
|
|
33
72
|
//# sourceMappingURL=FormattedDateTime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kCAAkC,qBAI7C,CAAC;AAEH,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qBAInC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,qBAG9B,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,2BAA2B,GAC3B,YAAY,GACZ,gBAAgB,GAChB,WAAW,CAAC;IAEhB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kCAAkC,qBAI7C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qBAInC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,qBAG9B,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,2BAA2B,GAC3B,YAAY,GACZ,gBAAgB,GAChB,WAAW,CAAC;IAEhB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,4CAsIxB,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getDateDaysDiff } from './dateDiffer';
|
|
3
3
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
4
|
+
/**
|
|
5
|
+
* @description Long date formatter, with weekday, year, month and day. Used for describing long term date.
|
|
6
|
+
* @example Wednesday 6 October 2025
|
|
7
|
+
*/
|
|
4
8
|
export const LONG_DATE_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
5
9
|
weekday: 'long',
|
|
6
10
|
year: 'numeric',
|
|
7
11
|
month: 'long',
|
|
8
|
-
day: '
|
|
12
|
+
day: '2-digit',
|
|
9
13
|
});
|
|
10
14
|
/**
|
|
11
15
|
* @description Long date formatter, without weekday.
|
|
@@ -16,30 +20,50 @@ export const LONG_DATE_FORMATER_WITHOUT_WEEKDAY = Intl.DateTimeFormat('en-GB', {
|
|
|
16
20
|
month: 'long',
|
|
17
21
|
day: '2-digit',
|
|
18
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* @description Date formatter, with year, month and day. Used for describing long term date.
|
|
25
|
+
* @example 2025-01-01
|
|
26
|
+
*/
|
|
19
27
|
export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
20
28
|
year: 'numeric',
|
|
21
29
|
month: '2-digit',
|
|
22
30
|
day: '2-digit',
|
|
23
31
|
hour12: false,
|
|
24
32
|
});
|
|
33
|
+
/**
|
|
34
|
+
* @description Day month formatter, with weekday, day and month. Used for describing long term date.
|
|
35
|
+
* @example Wed 6 Oct
|
|
36
|
+
*/
|
|
25
37
|
export const DAY_MONTH_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
26
38
|
weekday: 'short',
|
|
27
39
|
day: '2-digit',
|
|
28
40
|
month: 'short',
|
|
29
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* @description Time formatter, with hour, minute and second. Used for describing long term date.
|
|
44
|
+
* @example 18:33:00
|
|
45
|
+
*/
|
|
30
46
|
export const TIME_SECOND_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
31
47
|
hour12: false,
|
|
32
48
|
hour: '2-digit',
|
|
33
49
|
minute: '2-digit',
|
|
34
50
|
second: '2-digit',
|
|
35
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* @description Time formatter, with hour and minute. Used for describing long term date.
|
|
54
|
+
* @example 18:33
|
|
55
|
+
*/
|
|
36
56
|
export const TIME_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
37
57
|
hour12: false,
|
|
38
58
|
hour: '2-digit',
|
|
39
59
|
minute: '2-digit',
|
|
40
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* @description Day month abbreviated hour minute second formatter. Used for describing long term date.
|
|
63
|
+
* @example 6 Oct 18:33:00
|
|
64
|
+
*/
|
|
41
65
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat('en-GB', {
|
|
42
|
-
day: '
|
|
66
|
+
day: '2-digit',
|
|
43
67
|
month: 'short',
|
|
44
68
|
hour: '2-digit',
|
|
45
69
|
minute: '2-digit',
|
|
@@ -47,11 +71,11 @@ export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat('en-
|
|
|
47
71
|
hour12: false,
|
|
48
72
|
});
|
|
49
73
|
/**
|
|
50
|
-
* @description Day month abbreviated hour minute formatter
|
|
51
|
-
* @example
|
|
74
|
+
* @description Day month abbreviated hour minute formatter. Used for describing long term date.
|
|
75
|
+
* @example 6 Oct 18:33
|
|
52
76
|
*/
|
|
53
77
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
54
|
-
day: '
|
|
78
|
+
day: '2-digit',
|
|
55
79
|
month: 'short',
|
|
56
80
|
hour: '2-digit',
|
|
57
81
|
minute: '2-digit',
|
|
@@ -82,6 +106,21 @@ const isItFutureOrIsItPast = (timeDiff, stringToBeFormatted) => {
|
|
|
82
106
|
return `in ${stringToBeFormatted}`;
|
|
83
107
|
}
|
|
84
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* @description Formats the date and time according to the format specified.
|
|
111
|
+
* @example
|
|
112
|
+
* date: '2025-01-01'
|
|
113
|
+
* 'date-time': '2025-01-01 00:00'
|
|
114
|
+
* 'date-time-second': '2025-01-01 00:00:00'
|
|
115
|
+
* time: '00:00'
|
|
116
|
+
* 'time-second': '00:00:00'
|
|
117
|
+
* relative: '1 month ago'
|
|
118
|
+
* 'day-month-abbreviated-hour-minute': '6 Oct 18:33'
|
|
119
|
+
* 'day-month-abbreviated-hour-minute-second': '6 Oct 18:33:00'
|
|
120
|
+
* 'long-date': 'Wednesday 6 October 2025'
|
|
121
|
+
* 'chart-date': '6 Oct'
|
|
122
|
+
* 'year-month-day': '2025-10-06'
|
|
123
|
+
*/
|
|
85
124
|
export const FormattedDateTime = ({ format, value, }) => {
|
|
86
125
|
switch (format) {
|
|
87
126
|
case 'date':
|
|
@@ -116,15 +155,23 @@ export const FormattedDateTime = ({ format, value, }) => {
|
|
|
116
155
|
}
|
|
117
156
|
return (_jsx(Tooltip, { overlay: _jsx(FormattedDateTime, { format: "date-time-second", value: value }), children: "few seconds ago" }));
|
|
118
157
|
case 'day-month-abbreviated-hour-minute':
|
|
119
|
-
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value)
|
|
158
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value)
|
|
159
|
+
.replace(',', '')
|
|
160
|
+
.replace(/Sept/g, 'Sep') }));
|
|
120
161
|
case 'day-month-abbreviated-hour-minute-second':
|
|
121
|
-
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
162
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
163
|
+
.replace(',', '')
|
|
164
|
+
// replace Sept with Sep to keep 3 letter month
|
|
165
|
+
.replace(/Sept/g, 'Sep') }));
|
|
122
166
|
case 'long-date':
|
|
123
167
|
return _jsx(_Fragment, { children: LONG_DATE_FORMATER.format(value) });
|
|
124
168
|
case 'long-date-without-weekday':
|
|
125
169
|
return _jsx(_Fragment, { children: LONG_DATE_FORMATER_WITHOUT_WEEKDAY.format(value) });
|
|
126
170
|
case 'chart-date':
|
|
127
|
-
return _jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value)
|
|
171
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value)
|
|
172
|
+
.replace(/[ ,]/g, '')
|
|
173
|
+
// replace Sept with Sep to keep 3 letter month
|
|
174
|
+
.replace(/Sept/g, 'Sep') }));
|
|
128
175
|
case 'year-month-day':
|
|
129
176
|
return _jsx(_Fragment, { children: YEAR_MONTH_DAY_FORMATTER.format(value) });
|
|
130
177
|
case 'month-day':
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { FormattedDateTime } from './FormattedDateTime';
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
@@ -141,12 +141,21 @@ describe('FormatttedDateTime', () => {
|
|
|
141
141
|
//S
|
|
142
142
|
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-10-06T18:33:00Z') }));
|
|
143
143
|
//V
|
|
144
|
-
expect(screen.getByText('
|
|
144
|
+
expect(screen.getByText('06 Oct 18:33')).toBeInTheDocument();
|
|
145
145
|
});
|
|
146
146
|
it('should display the date in the expected format of date in the chart', () => {
|
|
147
147
|
//S
|
|
148
148
|
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-10-06T18:33:00Z') }));
|
|
149
149
|
//V
|
|
150
|
-
expect(screen.getByText('
|
|
150
|
+
expect(screen.getByText('06 Oct 18:33:00')).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
it('should display 3 letter month for September date', () => {
|
|
153
|
+
//S
|
|
154
|
+
render(_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "chart-date", value: new Date('2022-09-06T18:33:00Z') })] }));
|
|
155
|
+
//V
|
|
156
|
+
expect(screen.getByText(/06 Sep 18:33/)).toBeInTheDocument();
|
|
157
|
+
expect(screen.getByText(/06 Sep 18:33:00/)).toBeInTheDocument();
|
|
158
|
+
expect(screen.getByText(/Tue06Sep/)).toBeInTheDocument();
|
|
159
|
+
expect(screen.queryByText(/Sept/)).not.toBeInTheDocument();
|
|
151
160
|
});
|
|
152
161
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
export declare function Layout({ children: app, headerNavigation, }: {
|
|
2
|
+
export declare function Layout({ children: app, headerNavigation, variant, }: {
|
|
3
3
|
children: ReactElement | ReactElement[];
|
|
4
4
|
headerNavigation: ReactElement;
|
|
5
|
+
variant?: 'transparent';
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/v2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgBrC,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EAAE,GAAG,EACb,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/v2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgBrC,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EAAE,GAAG,EACb,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACxC,gBAAgB,EAAE,YAAY,CAAC;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,2CAOA"}
|
|
@@ -6,11 +6,11 @@ const LayoutContainer = styled.div `
|
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
height: 100vh;
|
|
8
8
|
box-sizing: border-box;
|
|
9
|
-
background: ${
|
|
9
|
+
background: ${props => props.variant === 'transparent' ? 'transparent' : props.theme.backgroundLevel1};
|
|
10
10
|
`;
|
|
11
11
|
const Navigation = styled.div `
|
|
12
12
|
height: ${navbarHeight};
|
|
13
13
|
`;
|
|
14
|
-
export function Layout({ children: app, headerNavigation, }) {
|
|
15
|
-
return (_jsxs(LayoutContainer, { className: "layout-container", children: [_jsx(Navigation, { children: headerNavigation }), app] }));
|
|
14
|
+
export function Layout({ children: app, headerNavigation, variant, }) {
|
|
15
|
+
return (_jsxs(LayoutContainer, { className: "layout-container", variant: variant, children: [_jsx(Navigation, { children: headerNavigation }), app] }));
|
|
16
16
|
}
|
package/dist/style/theme.js
CHANGED
|
@@ -121,7 +121,7 @@ export const coreUIAvailableThemes = {
|
|
|
121
121
|
selectedActive: '#037AFF',
|
|
122
122
|
highlight: '#1A3C75',
|
|
123
123
|
border: '#4A4A4A',
|
|
124
|
-
buttonPrimary: 'linear-gradient(130deg, #9355E7 0%, #2E4AA3
|
|
124
|
+
buttonPrimary: 'linear-gradient(130deg, #9355E7 0%, #2E4AA3 60%)',
|
|
125
125
|
buttonSecondary: 'linear-gradient(130deg, #595A78 0%, #44455F 100%)',
|
|
126
126
|
buttonDelete: '#3D0808',
|
|
127
127
|
infoPrimary: '#8E8EAC',
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ describe('ChartTooltip', () => {
|
|
|
27
27
|
successValue: () => screen.queryByText(SUCCESS_VALUE),
|
|
28
28
|
failed: () => screen.queryByText(/Failed/),
|
|
29
29
|
failedValue: () => screen.queryByText(FAILED_VALUE),
|
|
30
|
-
date: () => screen.queryByText(/Monday,
|
|
30
|
+
date: () => screen.queryByText(/Monday, 01 July 2024/),
|
|
31
31
|
time: () => screen.queryByText(/00:00/),
|
|
32
32
|
};
|
|
33
33
|
it('should render the ChartTooltip component', () => {
|
|
@@ -118,6 +118,7 @@ export const ButtonStyled = styled.button<Props>`
|
|
|
118
118
|
case 'outline':
|
|
119
119
|
return css`
|
|
120
120
|
border: ${spacing.r1} solid transparent;
|
|
121
|
+
border-color: ${brand.border}; // fallback for linear-gradient button themes
|
|
121
122
|
border-color: ${brand.buttonSecondary};
|
|
122
123
|
background-color: transparent;
|
|
123
124
|
color: ${brand.textPrimary};
|
|
@@ -144,7 +145,6 @@ export const ButtonStyled = styled.button<Props>`
|
|
|
144
145
|
position: absolute;
|
|
145
146
|
inset: 0;
|
|
146
147
|
padding: ${spacing.r1};
|
|
147
|
-
background-image: ${brand.buttonSecondary};
|
|
148
148
|
border-radius: inherit;
|
|
149
149
|
mask: linear-gradient(white, white) content-box, linear-gradient(white, white);
|
|
150
150
|
mask-composite: exclude;
|
|
@@ -224,7 +224,7 @@ describe('FormatttedDateTime', () => {
|
|
|
224
224
|
/>,
|
|
225
225
|
);
|
|
226
226
|
//V
|
|
227
|
-
expect(screen.getByText('
|
|
227
|
+
expect(screen.getByText('06 Oct 18:33')).toBeInTheDocument();
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
it('should display the date in the expected format of date in the chart', () => {
|
|
@@ -236,6 +236,31 @@ describe('FormatttedDateTime', () => {
|
|
|
236
236
|
/>,
|
|
237
237
|
);
|
|
238
238
|
//V
|
|
239
|
-
expect(screen.getByText('
|
|
239
|
+
expect(screen.getByText('06 Oct 18:33:00')).toBeInTheDocument();
|
|
240
|
+
});
|
|
241
|
+
it('should display 3 letter month for September date', () => {
|
|
242
|
+
//S
|
|
243
|
+
render(
|
|
244
|
+
<>
|
|
245
|
+
<FormattedDateTime
|
|
246
|
+
format="day-month-abbreviated-hour-minute"
|
|
247
|
+
value={new Date('2022-09-06T18:33:00Z')}
|
|
248
|
+
/>
|
|
249
|
+
<FormattedDateTime
|
|
250
|
+
format="day-month-abbreviated-hour-minute-second"
|
|
251
|
+
value={new Date('2022-09-06T18:33:00Z')}
|
|
252
|
+
/>
|
|
253
|
+
|
|
254
|
+
<FormattedDateTime
|
|
255
|
+
format="chart-date"
|
|
256
|
+
value={new Date('2022-09-06T18:33:00Z')}
|
|
257
|
+
/>
|
|
258
|
+
</>,
|
|
259
|
+
);
|
|
260
|
+
//V
|
|
261
|
+
expect(screen.getByText(/06 Sep 18:33/)).toBeInTheDocument();
|
|
262
|
+
expect(screen.getByText(/06 Sep 18:33:00/)).toBeInTheDocument();
|
|
263
|
+
expect(screen.getByText(/Tue06Sep/)).toBeInTheDocument();
|
|
264
|
+
expect(screen.queryByText(/Sept/)).not.toBeInTheDocument();
|
|
240
265
|
});
|
|
241
266
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { getDateDaysDiff } from './dateDiffer';
|
|
2
2
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @description Long date formatter, with weekday, year, month and day. Used for describing long term date.
|
|
6
|
+
* @example Wednesday 6 October 2025
|
|
7
|
+
*/
|
|
4
8
|
export const LONG_DATE_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
5
9
|
weekday: 'long',
|
|
6
10
|
year: 'numeric',
|
|
7
11
|
month: 'long',
|
|
8
|
-
day: '
|
|
12
|
+
day: '2-digit',
|
|
9
13
|
});
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -18,6 +22,10 @@ export const LONG_DATE_FORMATER_WITHOUT_WEEKDAY = Intl.DateTimeFormat('en-GB', {
|
|
|
18
22
|
day: '2-digit',
|
|
19
23
|
});
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @description Date formatter, with year, month and day. Used for describing long term date.
|
|
27
|
+
* @example 2025-01-01
|
|
28
|
+
*/
|
|
21
29
|
export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
22
30
|
year: 'numeric',
|
|
23
31
|
month: '2-digit',
|
|
@@ -25,12 +33,20 @@ export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
|
25
33
|
hour12: false,
|
|
26
34
|
});
|
|
27
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @description Day month formatter, with weekday, day and month. Used for describing long term date.
|
|
38
|
+
* @example Wed 6 Oct
|
|
39
|
+
*/
|
|
28
40
|
export const DAY_MONTH_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
29
41
|
weekday: 'short',
|
|
30
42
|
day: '2-digit',
|
|
31
43
|
month: 'short',
|
|
32
44
|
});
|
|
33
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @description Time formatter, with hour, minute and second. Used for describing long term date.
|
|
48
|
+
* @example 18:33:00
|
|
49
|
+
*/
|
|
34
50
|
export const TIME_SECOND_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
35
51
|
hour12: false,
|
|
36
52
|
hour: '2-digit',
|
|
@@ -38,16 +54,24 @@ export const TIME_SECOND_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
|
38
54
|
second: '2-digit',
|
|
39
55
|
});
|
|
40
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @description Time formatter, with hour and minute. Used for describing long term date.
|
|
59
|
+
* @example 18:33
|
|
60
|
+
*/
|
|
41
61
|
export const TIME_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
42
62
|
hour12: false,
|
|
43
63
|
hour: '2-digit',
|
|
44
64
|
minute: '2-digit',
|
|
45
65
|
});
|
|
46
66
|
|
|
67
|
+
/**
|
|
68
|
+
* @description Day month abbreviated hour minute second formatter. Used for describing long term date.
|
|
69
|
+
* @example 6 Oct 18:33:00
|
|
70
|
+
*/
|
|
47
71
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat(
|
|
48
72
|
'en-GB',
|
|
49
73
|
{
|
|
50
|
-
day: '
|
|
74
|
+
day: '2-digit',
|
|
51
75
|
month: 'short',
|
|
52
76
|
hour: '2-digit',
|
|
53
77
|
minute: '2-digit',
|
|
@@ -57,11 +81,11 @@ export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat(
|
|
|
57
81
|
);
|
|
58
82
|
|
|
59
83
|
/**
|
|
60
|
-
* @description Day month abbreviated hour minute formatter
|
|
61
|
-
* @example
|
|
84
|
+
* @description Day month abbreviated hour minute formatter. Used for describing long term date.
|
|
85
|
+
* @example 6 Oct 18:33
|
|
62
86
|
*/
|
|
63
87
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
64
|
-
day: '
|
|
88
|
+
day: '2-digit',
|
|
65
89
|
month: 'short',
|
|
66
90
|
hour: '2-digit',
|
|
67
91
|
minute: '2-digit',
|
|
@@ -117,6 +141,21 @@ const isItFutureOrIsItPast = (
|
|
|
117
141
|
}
|
|
118
142
|
};
|
|
119
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @description Formats the date and time according to the format specified.
|
|
146
|
+
* @example
|
|
147
|
+
* date: '2025-01-01'
|
|
148
|
+
* 'date-time': '2025-01-01 00:00'
|
|
149
|
+
* 'date-time-second': '2025-01-01 00:00:00'
|
|
150
|
+
* time: '00:00'
|
|
151
|
+
* 'time-second': '00:00:00'
|
|
152
|
+
* relative: '1 month ago'
|
|
153
|
+
* 'day-month-abbreviated-hour-minute': '6 Oct 18:33'
|
|
154
|
+
* 'day-month-abbreviated-hour-minute-second': '6 Oct 18:33:00'
|
|
155
|
+
* 'long-date': 'Wednesday 6 October 2025'
|
|
156
|
+
* 'chart-date': '6 Oct'
|
|
157
|
+
* 'year-month-day': '2025-10-06'
|
|
158
|
+
*/
|
|
120
159
|
export const FormattedDateTime = ({
|
|
121
160
|
format,
|
|
122
161
|
value,
|
|
@@ -219,15 +258,19 @@ export const FormattedDateTime = ({
|
|
|
219
258
|
);
|
|
220
259
|
case 'day-month-abbreviated-hour-minute':
|
|
221
260
|
return (
|
|
222
|
-
<>
|
|
261
|
+
<>
|
|
262
|
+
{DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value)
|
|
263
|
+
.replace(',', '')
|
|
264
|
+
.replace(/Sept/g, 'Sep')}
|
|
265
|
+
</>
|
|
223
266
|
);
|
|
224
267
|
case 'day-month-abbreviated-hour-minute-second':
|
|
225
268
|
return (
|
|
226
269
|
<>
|
|
227
|
-
{DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
228
|
-
',',
|
|
229
|
-
|
|
230
|
-
|
|
270
|
+
{DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
271
|
+
.replace(',', '')
|
|
272
|
+
// replace Sept with Sep to keep 3 letter month
|
|
273
|
+
.replace(/Sept/g, 'Sep')}
|
|
231
274
|
</>
|
|
232
275
|
);
|
|
233
276
|
case 'long-date':
|
|
@@ -235,7 +278,14 @@ export const FormattedDateTime = ({
|
|
|
235
278
|
case 'long-date-without-weekday':
|
|
236
279
|
return <>{LONG_DATE_FORMATER_WITHOUT_WEEKDAY.format(value)}</>;
|
|
237
280
|
case 'chart-date':
|
|
238
|
-
return
|
|
281
|
+
return (
|
|
282
|
+
<>
|
|
283
|
+
{DAY_MONTH_FORMATER.format(value)
|
|
284
|
+
.replace(/[ ,]/g, '')
|
|
285
|
+
// replace Sept with Sep to keep 3 letter month
|
|
286
|
+
.replace(/Sept/g, 'Sep')}
|
|
287
|
+
</>
|
|
288
|
+
);
|
|
239
289
|
case 'year-month-day':
|
|
240
290
|
return <>{YEAR_MONTH_DAY_FORMATTER.format(value)}</>;
|
|
241
291
|
case 'month-day':
|
|
@@ -2,12 +2,12 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { navbarHeight } from '../../../style/theme';
|
|
4
4
|
|
|
5
|
-
const LayoutContainer = styled.div
|
|
5
|
+
const LayoutContainer = styled.div<{ variant?: 'transparent' }>`
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
height: 100vh;
|
|
9
9
|
box-sizing: border-box;
|
|
10
|
-
background: ${
|
|
10
|
+
background: ${props => props.variant === 'transparent' ? 'transparent' : props.theme.backgroundLevel1};
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
13
|
const Navigation = styled.div`
|
|
@@ -17,12 +17,14 @@ const Navigation = styled.div`
|
|
|
17
17
|
export function Layout({
|
|
18
18
|
children: app,
|
|
19
19
|
headerNavigation,
|
|
20
|
+
variant,
|
|
20
21
|
}: {
|
|
21
22
|
children: ReactElement | ReactElement[];
|
|
22
23
|
headerNavigation: ReactElement;
|
|
24
|
+
variant?: 'transparent';
|
|
23
25
|
}) {
|
|
24
26
|
return (
|
|
25
|
-
<LayoutContainer className="layout-container">
|
|
27
|
+
<LayoutContainer className="layout-container" variant={variant}>
|
|
26
28
|
<Navigation>{headerNavigation}</Navigation>
|
|
27
29
|
{app}
|
|
28
30
|
</LayoutContainer>
|
package/src/lib/style/theme.ts
CHANGED
|
@@ -150,7 +150,7 @@ export const coreUIAvailableThemes: Record<CoreUIThemeName, CoreUITheme> = {
|
|
|
150
150
|
selectedActive: '#037AFF',
|
|
151
151
|
highlight: '#1A3C75',
|
|
152
152
|
border: '#4A4A4A',
|
|
153
|
-
buttonPrimary: 'linear-gradient(130deg, #9355E7 0%, #2E4AA3
|
|
153
|
+
buttonPrimary: 'linear-gradient(130deg, #9355E7 0%, #2E4AA3 60%)',
|
|
154
154
|
buttonSecondary: 'linear-gradient(130deg, #595A78 0%, #44455F 100%)',
|
|
155
155
|
buttonDelete: '#3D0808',
|
|
156
156
|
infoPrimary: '#8E8EAC',
|
|
@@ -24,6 +24,13 @@ export const FormattedDate = {
|
|
|
24
24
|
'time' as const,
|
|
25
25
|
'time-second' as const,
|
|
26
26
|
'relative' as const,
|
|
27
|
+
'day-month-abbreviated-hour-minute' as const,
|
|
28
|
+
'day-month-abbreviated-hour-minute-second' as const,
|
|
29
|
+
'long-date' as const,
|
|
30
|
+
'long-date-without-weekday' as const,
|
|
31
|
+
'chart-date' as const,
|
|
32
|
+
'year-month-day' as const,
|
|
33
|
+
'month-day' as const,
|
|
27
34
|
].map((format) => (
|
|
28
35
|
<tr key={format}>
|
|
29
36
|
<td>{format}</td>
|
|
@@ -123,6 +123,25 @@ export const Layout2MainContentOnly = {
|
|
|
123
123
|
),
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
export const Layout2TransparentBackground = {
|
|
127
|
+
render: () => (
|
|
128
|
+
<Layout2
|
|
129
|
+
variant='transparent'
|
|
130
|
+
headerNavigation={
|
|
131
|
+
<HeaderComponent>
|
|
132
|
+
<h3>Header navigation</h3>
|
|
133
|
+
</HeaderComponent>
|
|
134
|
+
}
|
|
135
|
+
>
|
|
136
|
+
<AppContainer>
|
|
137
|
+
<AppContainer.MainContent hasTopMargin>
|
|
138
|
+
Main content
|
|
139
|
+
</AppContainer.MainContent>
|
|
140
|
+
</AppContainer>
|
|
141
|
+
</Layout2>
|
|
142
|
+
),
|
|
143
|
+
};
|
|
144
|
+
|
|
126
145
|
export const Layout2OverallSummaryAndMainContent = {
|
|
127
146
|
render: () => (
|
|
128
147
|
<Layout2
|