@platformatic/ui-components 0.1.16 → 0.1.17

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
@@ -6,6 +6,7 @@ import BorderedBox from './src/components/BorderedBox'
6
6
  import BorderedText from './src/components/BorderedText'
7
7
  import Box from './src/components/Box'
8
8
  import Button from './src/components/Button'
9
+ import DetailedMetric from './src/components/DetailedMetric'
9
10
  import FollowUs from './src/components/FollowUs'
10
11
  import FrontpageBackground from './src/components/FrontpageBackground'
11
12
  import GHLoginButton from './src/components/GHLoginButton'
@@ -19,6 +20,7 @@ import Logo from './src/components/Logo'
19
20
  import Playground from './src/components/Playground'
20
21
  import PullRequest from './src/components/PullRequest'
21
22
  import SearchBar from './src/components/SearchBar'
23
+ import SimpleMetric from './src/components/SimpleMetric'
22
24
  import Status from './src/components/Status'
23
25
  import TabbedWindow from './src/components/TabbedWindow'
24
26
  import TextWithLabel from './src/components/TextWithLabel'
@@ -32,6 +34,7 @@ export {
32
34
  BorderedText,
33
35
  Box,
34
36
  Button,
37
+ DetailedMetric,
35
38
  FollowUs,
36
39
  FrontpageBackground,
37
40
  HorizontalSeparator,
@@ -45,6 +48,7 @@ export {
45
48
  Playground,
46
49
  PullRequest,
47
50
  SearchBar,
51
+ SimpleMetric,
48
52
  Status,
49
53
  TabbedWindow,
50
54
  TextWithLabel,
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.1.16",
4
+ "version": "0.1.17",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "scripts": {
@@ -5,55 +5,12 @@ import BorderedBox from './BorderedBox'
5
5
  import BorderedText from './BorderedText'
6
6
  import HorizontalSeparator from './HorizontalSeparator'
7
7
  import TwoColumnsLayout from './layouts/TwoColumnsLayout'
8
- import StatsView from './StatsView'
9
8
  import TextWithLabel from './TextWithLabel'
10
9
  import VerticalSeparator from './VerticalSeparator'
11
10
  import React from 'react'
12
11
  import styles from './ApiDetail.module.css'
13
12
  export default function ApiDetails (props) {
14
13
  const { url, repository, version, openapi, graphql, source, lastDeploy } = props
15
- const requestStats = {
16
- mainStat: {
17
- value: 12,
18
- label: 'Total',
19
- color: 'green'
20
- },
21
- otherStats: [
22
- {
23
- value: 8,
24
- label: 'per minute',
25
- color: 'green'
26
- },
27
- {
28
- value: 0.5,
29
- label: 'per second',
30
- color: 'green'
31
- }
32
- ]
33
- }
34
-
35
- const latencyStats = {
36
- mainStat: {
37
- value: 150,
38
- label: 'ms',
39
- color: 'green',
40
- pre: 'P90'
41
- },
42
- otherStats: [
43
- {
44
- value: 600,
45
- label: 'ms',
46
- color: 'green',
47
- pre: 'P99'
48
- },
49
- {
50
- value: 4.42,
51
- label: 's',
52
- color: 'green',
53
- pre: 'P95'
54
- }
55
- ]
56
- }
57
14
  return (
58
15
  <>
59
16
  <BorderedBox classes='api-data'>
@@ -78,23 +35,6 @@ export default function ApiDetails (props) {
78
35
  <span className='mr-2'>Endpoints: </span><Endpoints graphql={graphql} openapi={openapi} />
79
36
  </div>
80
37
  </BorderedBox>
81
- <TwoColumnsLayout>
82
- <BorderedBox>
83
- <StatsView
84
- title='Requests'
85
- tooltip='Number of requests'
86
- stats={requestStats}
87
- />
88
- </BorderedBox>
89
- <BorderedBox>
90
- <StatsView
91
- title='Latency'
92
- tooltip='Request Latency'
93
- stats={latencyStats}
94
- />
95
- </BorderedBox>
96
- </TwoColumnsLayout>
97
-
98
38
  <TwoColumnsLayout>
99
39
  <BorderedBox>
100
40
  Connected Clients
@@ -1,6 +1,10 @@
1
+ 'use strict'
2
+
3
+ import React from 'react'
1
4
  import styles from './Button.module.css'
2
5
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3
- export default function Button ({ icon, label, onClick, primary, color, ...props }) {
6
+ export default function Button (props) {
7
+ const { icon, label, primary, color } = props
4
8
  let buttonClass = 'primary'
5
9
  if (!primary) {
6
10
  buttonClass = 'secondary'
@@ -11,7 +15,7 @@ export default function Button ({ icon, label, onClick, primary, color, ...props
11
15
  colorClass = 'red'
12
16
  }
13
17
  return (
14
- <button className={`${styles.button} ${styles[buttonClass + '-' + colorClass]}`}>
18
+ <button className={`${styles.button} ${styles[buttonClass + '-' + colorClass]}`} {...props}>
15
19
  {icon ? <FontAwesomeIcon icon={icon} className='mr-2' data-testid='button-icon' /> : null}
16
20
  <span>{label}</span>
17
21
  </button>
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ import React from 'react'
4
+ import SimpleMetric from './SimpleMetric'
5
+ import HorizontalSeparator from './HorizontalSeparator'
6
+ import VerticalSeparator from './VerticalSeparator'
7
+ import styles from './DetailedMetric.module.css'
8
+ import MetricValue from './MetricValue'
9
+ export default function DetailedMetric (props) {
10
+ const { leftDetail, rightDetail } = props
11
+ return (
12
+ <SimpleMetric {...props}>
13
+ <HorizontalSeparator />
14
+ <div className={styles.detailContainer}>
15
+ <MetricValue
16
+ pre={leftDetail.pre}
17
+ unit={leftDetail.unit}
18
+ color={leftDetail.color}
19
+ value={leftDetail.value}
20
+ />
21
+ <VerticalSeparator />
22
+ <MetricValue
23
+ pre={rightDetail.pre}
24
+ unit={rightDetail.unit}
25
+ color={rightDetail.color}
26
+ value={rightDetail.value}
27
+ />
28
+ </div>
29
+ </SimpleMetric>
30
+
31
+ )
32
+ }
@@ -0,0 +1,3 @@
1
+ .detailContainer {
2
+ @apply flex items-center justify-around;
3
+ }
@@ -1,4 +1,5 @@
1
1
  'use strict'
2
+ import React from 'react'
2
3
  import styles from './Input.module.css'
3
4
  import commonStyles from './Common.module.css'
4
5
  export default function Input ({ placeholder, value, name }) {
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+ import React from 'react'
3
+ import styles from './MetricValue.module.css'
4
+ import { getColor } from '../lib/utils'
5
+ export default function MetricValue ({ pre, color, value, unit }) {
6
+ return (
7
+ <div className={styles.metric}>
8
+ {pre && <span>{pre}</span>}
9
+ <span className={`${styles.value} ${getColor('text', color)}`}>
10
+ {value}
11
+ </span>
12
+ <span>{unit}</span>
13
+ </div>
14
+ )
15
+ }
@@ -0,0 +1,8 @@
1
+ .metric {
2
+ @apply flex justify-center items-center;
3
+ gap: 1rem;
4
+ }
5
+
6
+ .value {
7
+ @apply text-5xl
8
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ import React from 'react'
4
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
5
+ import { faCircleInfo } from '@fortawesome/free-solid-svg-icons'
6
+ import BorderedBox from './BorderedBox'
7
+ import styles from './SimpleMetric.module.css'
8
+ import MetricValue from './MetricValue'
9
+
10
+ export default function SimpleMetric ({ title, pre, color, unit, value, children }) {
11
+ return (
12
+ <BorderedBox>
13
+ <div className={styles.header}>
14
+ <span className={styles.title}>{title}</span>
15
+ <FontAwesomeIcon icon={faCircleInfo} className='text-white' />
16
+ </div>
17
+ <div>
18
+ <MetricValue pre={pre} color={color} unit={unit} value={value} />
19
+ {children}
20
+ </div>
21
+ </BorderedBox>
22
+ )
23
+ }
@@ -0,0 +1,7 @@
1
+ .header {
2
+ @apply flex justify-between items-center font-bold;
3
+ }
4
+
5
+ .title {
6
+ @apply text-xl;
7
+ }
@@ -0,0 +1,50 @@
1
+ 'use strict'
2
+
3
+ import DetailedMetric from '../components/DetailedMetric'
4
+
5
+ export default {
6
+ title: 'Platformatic/DetailedMetric',
7
+ component: DetailedMetric
8
+ }
9
+
10
+ const Template = (args) => <DetailedMetric {...args} />
11
+
12
+ export const Default = Template.bind({})
13
+
14
+ Default.args = {
15
+ title: 'Requests',
16
+ color: 'green',
17
+ unit: 'ms',
18
+ value: 120,
19
+ leftDetail: {
20
+ value: 600,
21
+ unit: 'ms',
22
+ color: 'green',
23
+ pre: 'P99'
24
+ },
25
+ rightDetail: {
26
+ value: 4.42,
27
+ unit: 's',
28
+ color: 'green',
29
+ pre: 'P95'
30
+ }
31
+ }
32
+
33
+ // export const Red = Template.bind({})
34
+
35
+ // Red.args = {
36
+ // title: 'Requests',
37
+ // color: 'red',
38
+ // unit: 'ms',
39
+ // value: 120
40
+ // }
41
+
42
+ // export const WithPrefix = Template.bind({})
43
+
44
+ // WithPrefix.args = {
45
+ // title: 'Requests',
46
+ // color: 'green',
47
+ // unit: 'ms',
48
+ // value: 120,
49
+ // pre: 'P90'
50
+ // }
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ import SimpleMetric from '../components/SimpleMetric'
4
+
5
+ export default {
6
+ title: 'Platformatic/SimpleMetric',
7
+ component: SimpleMetric
8
+ }
9
+
10
+ const Template = (args) => <SimpleMetric {...args} />
11
+
12
+ export const Green = Template.bind({})
13
+
14
+ Green.args = {
15
+ title: 'Requests',
16
+ color: 'green',
17
+ unit: 'ms',
18
+ value: 120
19
+ }
20
+
21
+ export const Red = Template.bind({})
22
+
23
+ Red.args = {
24
+ title: 'Requests',
25
+ color: 'red',
26
+ unit: 'ms',
27
+ value: 120
28
+ }
29
+
30
+ export const WithPrefix = Template.bind({})
31
+
32
+ WithPrefix.args = {
33
+ title: 'Requests',
34
+ color: 'green',
35
+ unit: 'ms',
36
+ value: 120,
37
+ pre: 'P90'
38
+ }
@@ -1,16 +0,0 @@
1
- 'use strict'
2
- import React from 'react'
3
- import { getColor } from '../lib/utils'
4
- export default function StatValue (props) {
5
- const { value, color, label, pre } = props
6
- return (
7
- <>
8
- {pre && <span>{pre}</span>}
9
- <span className={`text-5xl ${getColor('text', color)}`}>
10
- {value}
11
- </span>
12
- <span>{label}</span>
13
- </>
14
-
15
- )
16
- }
@@ -1,47 +0,0 @@
1
- 'use strict'
2
-
3
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4
- import { faCircleInfo } from '@fortawesome/free-solid-svg-icons'
5
- import styles from './StatsView.module.css'
6
- import HorizontalSeparator from './HorizontalSeparator'
7
- import VerticalSeparator from './VerticalSeparator'
8
- import StatValue from './StatValue'
9
- import React from 'react'
10
- export default function StatsView (props) {
11
- const { title, stats } = props
12
- const mainStat = stats.mainStat
13
- const otherStats = stats.otherStats
14
- return (
15
- <>
16
- <div className={styles['stats-header']}>
17
- <span className='text-xl'>{title}</span>
18
- <FontAwesomeIcon icon={faCircleInfo} className='text-white' />
19
- </div>
20
- <div className={styles['stats-content']}>
21
- {mainStat && (
22
- <div className={styles['stats-main-stat']}>
23
- <StatValue pre={mainStat.pre} label={mainStat.label} color={mainStat.color} value={mainStat.value} />
24
- </div>
25
- )}
26
- {otherStats && (
27
- <>
28
- <HorizontalSeparator />
29
- <div className='flex items-center justify-around'>
30
- <div className={styles['stats-main-stat']}>
31
- <StatValue pre={otherStats[0].pre} label={otherStats[0].label} color={otherStats[0].color} value={otherStats[0].value} />
32
- </div>
33
-
34
- <VerticalSeparator />
35
- <div className={styles['stats-main-stat']}>
36
- <StatValue pre={otherStats[1].pre} label={otherStats[1].label} color={otherStats[1].color} value={otherStats[1].value} />
37
- </div>
38
- </div>
39
-
40
- </>
41
-
42
- )}
43
- </div>
44
-
45
- </>
46
- )
47
- }
@@ -1,10 +0,0 @@
1
- .stats-header {
2
- @apply flex justify-between items-center font-bold;
3
- }
4
- .stats-main-stat {
5
- @apply flex justify-center items-center;
6
- gap: 1rem;
7
- }
8
- .stats-other-stats {
9
-
10
- }