@platformatic/ui-components 0.17.1 → 0.17.3

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/index.js CHANGED
@@ -25,6 +25,7 @@ import LoginButton from './src/components/LoginButton'
25
25
  import Logo from './src/components/Logo'
26
26
  import LogoDropDown from './src/components/LogoDropDown'
27
27
  import Logos from './src/components/logos'
28
+ import MetricInfoBox from './src/components/MetricInfoBox'
28
29
  import Modal from './src/components/Modal'
29
30
  import ModalDirectional from './src/components/ModalDirectional'
30
31
  import ModalStepsForward from './src/components/ModalStepsForward'
@@ -41,6 +42,7 @@ import TooltipAbsolute from './src/components/TooltipAbsolute'
41
42
  import TabbedWindow from './src/components/TabbedWindow'
42
43
  import Tag from './src/components/Tag'
43
44
  import TextWithLabel from './src/components/TextWithLabel'
45
+ import TrendMetric from './src/components/TrendMetric'
44
46
  import TwoColumnsLayout from './src/components/layouts/TwoColumnsLayout'
45
47
  import Versions from './src/components/Versions'
46
48
  import VerticalSeparator from './src/components/VerticalSeparator'
@@ -61,8 +63,9 @@ export {
61
63
  GHLoginButton,
62
64
  Forms,
63
65
  Icons,
64
- Logos,
65
66
  InfoBox,
67
+ Logos,
68
+ MetricInfoBox,
66
69
  Sidebar,
67
70
  Layout,
68
71
  List,
@@ -87,6 +90,7 @@ export {
87
90
  TabbedWindow,
88
91
  Tag,
89
92
  TextWithLabel,
93
+ TrendMetric,
90
94
  Tooltip,
91
95
  TooltipAbsolute,
92
96
  TwoColumnsLayout,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.17.1",
4
+ "version": "0.17.3",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -1,23 +1,14 @@
1
1
  import React, { useState } from 'react'
2
2
  import styles from './MetricInfoBox.module.css'
3
- import TrendDownIcon from './icons/TrendDownIcon'
4
- import TrendUpIcon from './icons/TrendUpIcon'
5
- import TrendLine from './TrendLine'
6
3
  import Tooltip from './Tooltip'
7
4
  import { DIRECTION_TOP, POSITION_CENTER, MEDIUM, WHITE } from './constants'
8
5
  import PlatformaticIcon from './PlatformaticIcon'
9
6
 
10
7
  export default function MetricInfoBox ({
11
8
  title,
12
- value,
13
- unit,
14
- data = [],
15
- helper,
16
- tooltip,
17
- showGraph = false
9
+ children,
10
+ tooltip = null
18
11
  }) {
19
- // set trend variable up or down, depending on the first and last value of the data array
20
- const trend = data[0] > data[data.length - 1] ? 'up' : 'down'
21
12
  const [tooltipVisible, setTooltipVisible] = useState(false)
22
13
 
23
14
  return (
@@ -51,28 +42,7 @@ export default function MetricInfoBox ({
51
42
  )}
52
43
  </div>
53
44
  <div className={styles.content}>
54
- <div className={styles.contentText}>
55
- <div>
56
- <div className={styles.value}>
57
- <span className={styles.valueNumber}>{value}</span>
58
- <span className={styles.valueUnit}>{unit}</span>
59
- <div className={styles.trend}>
60
- {trend === 'up' ? <TrendUpIcon color='white' /> : <TrendDownIcon color='white' />}
61
- </div>
62
- </div>
63
-
64
- </div>
65
- <div className={styles.helperBox}>
66
- {helper}
67
- </div>
68
-
69
- </div>
70
-
71
- {showGraph && (
72
- <div className={styles.contentGraph}>
73
- <TrendLine yValues={data} />
74
- </div>
75
- )}
45
+ {children}
76
46
  </div>
77
47
 
78
48
  </div>
@@ -18,25 +18,3 @@
18
18
  @apply flex items-center justify-center gap-4;
19
19
  }
20
20
 
21
- .contentText {
22
- @apply flex flex-col gap-2 items-center justify-center;
23
- }
24
- .value {
25
- @apply flex gap-4 items-center justify-center;
26
- }
27
-
28
- .valueNumber {
29
- @apply text-[24px] font-semibold text-white;
30
- }
31
-
32
- .valueUnit {
33
- @apply text-[16px] font-normal text-white/70;
34
- }
35
-
36
- .helperBox {
37
- @apply text-[14px] font-normal text-white/70;
38
- }
39
-
40
- .contentGraph {
41
- @apply w-[210px] h-[60px];
42
- }
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import styles from './TrendMetric.module.css'
3
+ import TrendUpIcon from './icons/TrendUpIcon'
4
+ import TrendDownIcon from './icons/TrendDownIcon'
5
+ import TrendLine from './TrendLine'
6
+
7
+ export default function TrendMetric ({ value, unit, helper, showGraph = false, data }) {
8
+ // set trend variable up or down, depending on the first and last value of the data array
9
+ const trend = data[0] > data[data.length - 1] ? 'up' : 'down'
10
+
11
+ return (
12
+ <div className={styles.container}>
13
+ <div className={styles.contentText}>
14
+ <div>
15
+ <div className={styles.value}>
16
+ <span className={styles.valueNumber}>{value}</span>
17
+ <span className={styles.valueUnit}>{unit}</span>
18
+ <div className={styles.trend}>
19
+ {trend === 'up' ? <TrendUpIcon color='white' /> : <TrendDownIcon color='white' />}
20
+ </div>
21
+ </div>
22
+
23
+ </div>
24
+ <div className={styles.helperBox}>
25
+ {helper}
26
+ </div>
27
+
28
+ </div>
29
+
30
+ {showGraph && (
31
+ <div className={styles.contentGraph}>
32
+ <TrendLine yValues={data} />
33
+ </div>
34
+ )}
35
+ </div>
36
+ )
37
+ }
@@ -0,0 +1,25 @@
1
+ .contentText {
2
+ @apply flex flex-col gap-2 items-center justify-center;
3
+ }
4
+ .value {
5
+ @apply flex gap-4 items-center justify-center;
6
+ }
7
+
8
+ .valueNumber {
9
+ @apply text-[24px] font-semibold text-white;
10
+ }
11
+
12
+ .valueUnit {
13
+ @apply text-[16px] font-normal text-white/70;
14
+ }
15
+
16
+ .helperBox {
17
+ @apply text-[14px] font-normal text-white/70;
18
+ }
19
+
20
+ .contentGraph {
21
+ @apply w-[210px] h-[60px];
22
+ }
23
+ .container {
24
+ @apply flex items-center justify-center gap-4;
25
+ }
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import MetricInfoBox from '../components/MetricInfoBox'
3
+ import TrendMetric from '../components/TrendMetric'
3
4
 
4
5
  export default {
5
6
  title: 'Platformatic/Metrics/MetricInfoBox',
@@ -9,31 +10,40 @@ export default {
9
10
  export const Default = () => (
10
11
  <MetricInfoBox
11
12
  title='Memory Allocation & Usage'
12
- value={50}
13
- unit='MB'
14
- data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
15
- helper='Average Usage'
16
- />
13
+ >
14
+ <TrendMetric
15
+ value={50}
16
+ unit='MB'
17
+ data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
18
+ helper='Average Usage'
19
+ />
20
+ </MetricInfoBox>
17
21
  )
18
22
  export const WithGraph = () => (
19
23
  <MetricInfoBox
20
24
  title='Memory Allocation & Usage'
21
- value={50}
22
- unit='MB'
23
- data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
24
- helper='Average Usage'
25
- showGraph
26
- />
25
+ >
26
+ <TrendMetric
27
+ value={50}
28
+ unit='MB'
29
+ data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
30
+ helper='Average Usage'
31
+ showGraph
32
+ />
33
+ </MetricInfoBox>
27
34
  )
28
35
 
29
36
  export const WithTooltip = () => (
30
37
  <MetricInfoBox
31
38
  title='Memory Allocation & Usage'
32
- value={50}
33
- unit='MB'
34
- data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
35
- helper='Average Usage'
36
- showGraph
37
39
  tooltip='This is a tooltip'
38
- />
40
+ >
41
+ <TrendMetric
42
+ value={50}
43
+ unit='MB'
44
+ data={[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]}
45
+ helper='Average Usage'
46
+ showGraph
47
+ />
48
+ </MetricInfoBox>
39
49
  )