@platformatic/ui-components 0.1.17 → 0.1.19
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 +2 -0
- package/package.json +2 -1
- package/src/components/ApiDetail.jsx +0 -9
- package/src/components/DropDown.jsx +35 -0
- package/src/components/DropDown.module.css +23 -0
- package/src/components/SimpleMetric.jsx +21 -12
- package/src/stories/DetailedMetric.stories.jsx +2 -19
- package/src/stories/DropDown.stories.jsx +43 -0
- package/src/stories/SimpleMetric.stories.jsx +6 -3
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import BorderedText from './src/components/BorderedText'
|
|
|
7
7
|
import Box from './src/components/Box'
|
|
8
8
|
import Button from './src/components/Button'
|
|
9
9
|
import DetailedMetric from './src/components/DetailedMetric'
|
|
10
|
+
import DropDown from './src/components/DropDown'
|
|
10
11
|
import FollowUs from './src/components/FollowUs'
|
|
11
12
|
import FrontpageBackground from './src/components/FrontpageBackground'
|
|
12
13
|
import GHLoginButton from './src/components/GHLoginButton'
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
Box,
|
|
36
37
|
Button,
|
|
37
38
|
DetailedMetric,
|
|
39
|
+
DropDown,
|
|
38
40
|
FollowUs,
|
|
39
41
|
FrontpageBackground,
|
|
40
42
|
HorizontalSeparator,
|
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.
|
|
4
|
+
"version": "0.1.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"scripts": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"postcss": "^8.4.17",
|
|
27
27
|
"react": "^18.2.0",
|
|
28
28
|
"react-dom": "^18.2.0",
|
|
29
|
+
"react-tooltip": "^4.4.3",
|
|
29
30
|
"storybook-tailwind-foundations": "^1.1.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
@@ -4,7 +4,6 @@ import Endpoints from './Api/Endpoints'
|
|
|
4
4
|
import BorderedBox from './BorderedBox'
|
|
5
5
|
import BorderedText from './BorderedText'
|
|
6
6
|
import HorizontalSeparator from './HorizontalSeparator'
|
|
7
|
-
import TwoColumnsLayout from './layouts/TwoColumnsLayout'
|
|
8
7
|
import TextWithLabel from './TextWithLabel'
|
|
9
8
|
import VerticalSeparator from './VerticalSeparator'
|
|
10
9
|
import React from 'react'
|
|
@@ -35,14 +34,6 @@ export default function ApiDetails (props) {
|
|
|
35
34
|
<span className='mr-2'>Endpoints: </span><Endpoints graphql={graphql} openapi={openapi} />
|
|
36
35
|
</div>
|
|
37
36
|
</BorderedBox>
|
|
38
|
-
<TwoColumnsLayout>
|
|
39
|
-
<BorderedBox>
|
|
40
|
-
Connected Clients
|
|
41
|
-
</BorderedBox>
|
|
42
|
-
<BorderedBox>
|
|
43
|
-
Failure Rate
|
|
44
|
-
</BorderedBox>
|
|
45
|
-
</TwoColumnsLayout>
|
|
46
37
|
</>
|
|
47
38
|
|
|
48
39
|
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import styles from './DropDown.module.css'
|
|
5
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
6
|
+
import { faChevronLeft, faChevronDown } from '@fortawesome/free-solid-svg-icons'
|
|
7
|
+
export default function DropDown (props) {
|
|
8
|
+
const { header, items, align = 'left' } = props
|
|
9
|
+
const [open, setOpen] = useState(false)
|
|
10
|
+
function handleOpen () {
|
|
11
|
+
setOpen(!open)
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
<div className={`${styles.dropDown} ${styles[align]}`}>
|
|
15
|
+
<span className={styles.header} onClick={handleOpen}>
|
|
16
|
+
{header}
|
|
17
|
+
{!open && <FontAwesomeIcon className={styles.arrow} icon={faChevronLeft} />}
|
|
18
|
+
{open && <FontAwesomeIcon className={styles.arrow} icon={faChevronDown} />}
|
|
19
|
+
</span>
|
|
20
|
+
{open && (
|
|
21
|
+
<div className={styles.menu}>
|
|
22
|
+
{items.map((item, index) => {
|
|
23
|
+
return (
|
|
24
|
+
<div className={styles.item} key={index}>
|
|
25
|
+
{item}
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
})}
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.dropDown {
|
|
2
|
+
@apply mx-4 relative flex flex-col;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.right {
|
|
6
|
+
@apply items-end;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.left {
|
|
10
|
+
@apply items-start;
|
|
11
|
+
}
|
|
12
|
+
.arrow {
|
|
13
|
+
@apply ml-2;
|
|
14
|
+
}
|
|
15
|
+
.header {
|
|
16
|
+
@apply hover:cursor-pointer
|
|
17
|
+
}
|
|
18
|
+
.menu {
|
|
19
|
+
@apply absolute border-solid border border-main-green p-4 bg-dark-blue mt-8 rounded-md;
|
|
20
|
+
}
|
|
21
|
+
.item {
|
|
22
|
+
@apply mb-2
|
|
23
|
+
}
|
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
5
|
-
|
|
5
|
+
// The icon that is in design is not in the free version of fontawesome
|
|
6
|
+
// Temporary using this one
|
|
7
|
+
import { faCircleExclamation } from '@fortawesome/free-solid-svg-icons'
|
|
8
|
+
import ReactTooltip from 'react-tooltip'
|
|
6
9
|
import BorderedBox from './BorderedBox'
|
|
7
10
|
import styles from './SimpleMetric.module.css'
|
|
8
11
|
import MetricValue from './MetricValue'
|
|
9
12
|
|
|
10
|
-
export default function SimpleMetric ({ title, pre, color, unit, value, children }) {
|
|
13
|
+
export default function SimpleMetric ({ title, pre, color, unit, value, tooltip, children }) {
|
|
11
14
|
return (
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
<>
|
|
16
|
+
<BorderedBox>
|
|
17
|
+
<div className={styles.header}>
|
|
18
|
+
<span className={styles.title}>{title}</span>
|
|
19
|
+
<FontAwesomeIcon
|
|
20
|
+
icon={faCircleExclamation}
|
|
21
|
+
data-tip={tooltip}
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<MetricValue pre={pre} color={color} unit={unit} value={value} />
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
</BorderedBox>
|
|
29
|
+
<ReactTooltip />
|
|
30
|
+
</>
|
|
22
31
|
)
|
|
23
32
|
}
|
|
@@ -16,6 +16,8 @@ Default.args = {
|
|
|
16
16
|
color: 'green',
|
|
17
17
|
unit: 'ms',
|
|
18
18
|
value: 120,
|
|
19
|
+
pre: 'P90',
|
|
20
|
+
tooltip: 'This is a tooltip for the metric',
|
|
19
21
|
leftDetail: {
|
|
20
22
|
value: 600,
|
|
21
23
|
unit: 'ms',
|
|
@@ -29,22 +31,3 @@ Default.args = {
|
|
|
29
31
|
pre: 'P95'
|
|
30
32
|
}
|
|
31
33
|
}
|
|
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,43 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
import DropDown from '../components/DropDown'
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Platformatic/DropDown',
|
|
5
|
+
component: DropDown,
|
|
6
|
+
decorators: [dd => <div className='text-white'>{dd()}</div>]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Template = (args) => <DropDown {...args} />
|
|
10
|
+
export const DefaultAlignment = Template.bind({})
|
|
11
|
+
|
|
12
|
+
DefaultAlignment.args = {
|
|
13
|
+
header: 'My Menu',
|
|
14
|
+
items: [
|
|
15
|
+
<span key='1'>Menu 1</span>,
|
|
16
|
+
<span key='2'>Menu 2</span>,
|
|
17
|
+
<span key='3'>This is a very long menu item</span>
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AlignRight = Template.bind({})
|
|
22
|
+
|
|
23
|
+
AlignRight.args = {
|
|
24
|
+
header: 'My Menu',
|
|
25
|
+
align: 'right',
|
|
26
|
+
items: [
|
|
27
|
+
<span key='1'>Menu 1</span>,
|
|
28
|
+
<span key='2'>Menu 2</span>,
|
|
29
|
+
<span key='3'>This is a very long menu item</span>
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const AlignLeft = Template.bind({})
|
|
34
|
+
|
|
35
|
+
AlignLeft.args = {
|
|
36
|
+
header: 'My Menu',
|
|
37
|
+
align: 'left',
|
|
38
|
+
items: [
|
|
39
|
+
<span key='1'>Menu 1</span>,
|
|
40
|
+
<span key='2'>Menu 2</span>,
|
|
41
|
+
<span key='3'>This is a very long menu item</span>
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -15,7 +15,8 @@ Green.args = {
|
|
|
15
15
|
title: 'Requests',
|
|
16
16
|
color: 'green',
|
|
17
17
|
unit: 'ms',
|
|
18
|
-
value: 120
|
|
18
|
+
value: 120,
|
|
19
|
+
tooltip: 'This is a tooltip for the metric'
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const Red = Template.bind({})
|
|
@@ -24,7 +25,8 @@ Red.args = {
|
|
|
24
25
|
title: 'Requests',
|
|
25
26
|
color: 'red',
|
|
26
27
|
unit: 'ms',
|
|
27
|
-
value: 120
|
|
28
|
+
value: 120,
|
|
29
|
+
tooltip: 'This is a tooltip for the metric'
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export const WithPrefix = Template.bind({})
|
|
@@ -34,5 +36,6 @@ WithPrefix.args = {
|
|
|
34
36
|
color: 'green',
|
|
35
37
|
unit: 'ms',
|
|
36
38
|
value: 120,
|
|
37
|
-
pre: 'P90'
|
|
39
|
+
pre: 'P90',
|
|
40
|
+
tooltip: 'This is a tooltip for the metric'
|
|
38
41
|
}
|