@platformatic/ui-components 0.1.31 → 0.1.33

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.
Files changed (102) hide show
  1. package/.github/workflows/ci.yml +26 -26
  2. package/.nvmrc +1 -1
  3. package/LICENSE +201 -201
  4. package/README.md +26 -26
  5. package/dist/main.css +31 -18
  6. package/fonts/Montserrat/README.txt +81 -81
  7. package/index.html +12 -12
  8. package/index.js +58 -58
  9. package/package.json +76 -76
  10. package/postcss.config.cjs +8 -8
  11. package/public/api-icon-closed.svg +6 -6
  12. package/public/api-icon.svg +9 -9
  13. package/src/App.jsx +12 -12
  14. package/src/components/BorderedBox.jsx +16 -16
  15. package/src/components/BorderedBox.module.css +2 -2
  16. package/src/components/BorderedText.jsx +8 -8
  17. package/src/components/BorderedText.module.css +2 -2
  18. package/src/components/Box.jsx +14 -14
  19. package/src/components/Box.module.css +7 -7
  20. package/src/components/Button.jsx +23 -23
  21. package/src/components/Button.module.css +20 -20
  22. package/src/components/Common.module.css +7 -7
  23. package/src/components/DetailedMetric.jsx +32 -32
  24. package/src/components/DetailedMetric.module.css +2 -2
  25. package/src/components/DropDown.jsx +35 -35
  26. package/src/components/DropDown.module.css +22 -22
  27. package/src/components/FollowUs.jsx +35 -35
  28. package/src/components/FollowUs.module.css +11 -11
  29. package/src/components/GHLoginButton.jsx +14 -14
  30. package/src/components/HorizontalSeparator.jsx +9 -5
  31. package/src/components/Input.jsx +11 -11
  32. package/src/components/Input.module.css +7 -7
  33. package/src/components/List.jsx +20 -20
  34. package/src/components/List.module.css +11 -11
  35. package/src/components/ListElement.jsx +23 -23
  36. package/src/components/ListElement.module.css +23 -23
  37. package/src/components/Loadable.jsx +34 -34
  38. package/src/components/Loadable.module.css +13 -13
  39. package/src/components/LoginButton.jsx +17 -17
  40. package/src/components/LoginButton.module.css +7 -7
  41. package/src/components/LoginButton.test.jsx +25 -25
  42. package/src/components/Logo.jsx +58 -58
  43. package/src/components/Main.jsx +33 -33
  44. package/src/components/MetricValue.jsx +15 -15
  45. package/src/components/MetricValue.module.css +7 -7
  46. package/src/components/Modal.jsx +29 -29
  47. package/src/components/Modal.module.css +24 -24
  48. package/src/components/Playground.jsx +9 -9
  49. package/src/components/SearchBar.jsx +63 -33
  50. package/src/components/SearchBar.module.css +20 -5
  51. package/src/components/SimpleMetric.jsx +32 -32
  52. package/src/components/SimpleMetric.module.css +6 -6
  53. package/src/components/Status.jsx +26 -26
  54. package/src/components/TabbedWindow.jsx +34 -34
  55. package/src/components/TabbedWindow.module.css +16 -16
  56. package/src/components/TextWithLabel.jsx +11 -11
  57. package/src/components/TextWithLabel.module.css +8 -8
  58. package/src/components/Versions.jsx +9 -9
  59. package/src/components/VerticalSeparator.jsx +5 -5
  60. package/src/components/icons/ApiEmptyIcon.jsx +107 -0
  61. package/src/components/icons/ApiIcon.jsx +29 -29
  62. package/src/components/icons/ApiIconClosed.jsx +19 -19
  63. package/src/components/icons/CloseModalIcon.jsx +26 -26
  64. package/src/components/icons/PullRequestIcon.jsx +31 -31
  65. package/src/components/icons/index.js +9 -8
  66. package/src/components/layouts/Layout.jsx +11 -11
  67. package/src/components/layouts/TwoColumnsLayout.jsx +12 -12
  68. package/src/components/layouts/TwoColumnsLayout.module.css +9 -9
  69. package/src/hooks/useEscapeKey.js +20 -20
  70. package/src/lib/utils.js +23 -23
  71. package/src/main.jsx +9 -9
  72. package/src/stories/BorderedBox.stories.jsx +33 -33
  73. package/src/stories/BorderedText.stories.jsx +24 -24
  74. package/src/stories/Button.stories.jsx +107 -107
  75. package/src/stories/DetailedMetric.stories.jsx +33 -33
  76. package/src/stories/DropDown.stories.jsx +62 -62
  77. package/src/stories/FollowUs.stories.jsx +14 -14
  78. package/src/stories/GHLoginButton.stories.jsx +14 -14
  79. package/src/stories/HorizontalSeparator.stories.jsx +12 -12
  80. package/src/stories/Input.stories.jsx +15 -15
  81. package/src/stories/Introduction.stories.mdx +211 -211
  82. package/src/stories/List.stories.jsx +29 -29
  83. package/src/stories/ListElement.stories.jsx +15 -15
  84. package/src/stories/Loadable.stories.jsx +75 -75
  85. package/src/stories/LoginButton.stories.jsx +15 -15
  86. package/src/stories/Logo.stories.jsx +17 -17
  87. package/src/stories/Modal.stories.jsx +65 -65
  88. package/src/stories/SearchBar.stories.jsx +28 -27
  89. package/src/stories/SimpleMetric.stories.jsx +41 -41
  90. package/src/stories/Status.stories.jsx +31 -31
  91. package/src/stories/TextWithLabel.stories.jsx +25 -25
  92. package/src/stories/TwoColumnsLayout.stories.jsx +42 -42
  93. package/src/styles/main.css +15 -15
  94. package/tailwind.config.cjs +37 -37
  95. package/vite.config.js +6 -6
  96. package/vitest.config.js +14 -14
  97. package/dist/api-icon-closed.svg +0 -6
  98. package/dist/api-icon.svg +0 -9
  99. package/dist/assets/index.5ac5acb7.js +0 -797
  100. package/dist/assets/index.d3f5882c.css +0 -1
  101. package/dist/index.html +0 -14
  102. package/dist/vite.svg +0 -1
@@ -1,8 +1,9 @@
1
- import ApiIcon from './ApiIcon'
2
- import ApiIconClosed from './ApiIconClosed'
3
- import CloseModalIcon from './CloseModalIcon'
4
- import PullRequestIcon from './PullRequestIcon'
5
-
6
- export default {
7
- ApiIcon, ApiIconClosed, CloseModalIcon, PullRequestIcon
8
- }
1
+ import ApiIcon from './ApiIcon'
2
+ import ApiIconClosed from './ApiIconClosed'
3
+ import ApiEmptyIcon from './ApiEmptyIcon'
4
+ import CloseModalIcon from './CloseModalIcon'
5
+ import PullRequestIcon from './PullRequestIcon'
6
+
7
+ export default {
8
+ ApiIcon, ApiIconClosed, ApiEmptyIcon, CloseModalIcon, PullRequestIcon
9
+ }
@@ -1,11 +1,11 @@
1
- 'use strict'
2
- import React from 'react'
3
-
4
- export default function Layout (props) {
5
- return (
6
- <div className='container mx-auto px-5 my-5 flex flex-col gap-10 h-screen'>
7
- {props.children}
8
- </div>
9
-
10
- )
11
- }
1
+ 'use strict'
2
+ import React from 'react'
3
+
4
+ export default function Layout (props) {
5
+ return (
6
+ <div className='container mx-auto px-5 my-5 flex flex-col gap-10 h-screen'>
7
+ {props.children}
8
+ </div>
9
+
10
+ )
11
+ }
@@ -1,12 +1,12 @@
1
- 'use strict'
2
- import React from 'react'
3
- import styles from './TwoColumnsLayout.module.css'
4
-
5
- export default function TwoColumnsLayout ({ children, gridTemplate = 'columns' }) {
6
- const className = styles[`${gridTemplate}`]
7
- return (
8
- <div className={className}>
9
- {children}
10
- </div>
11
- )
12
- }
1
+ 'use strict'
2
+ import React from 'react'
3
+ import styles from './TwoColumnsLayout.module.css'
4
+
5
+ export default function TwoColumnsLayout ({ children, gridTemplate = 'columns' }) {
6
+ const className = styles[`${gridTemplate}`]
7
+ return (
8
+ <div className={className}>
9
+ {children}
10
+ </div>
11
+ )
12
+ }
@@ -1,10 +1,10 @@
1
-
2
- .columns {
3
- @apply grid grid-cols-2 gap-x-4;
4
- }
5
- .rows {
6
- @apply grid grid-rows-2 gap-y-4;
7
- }
8
- .responsive {
9
- @apply grid grid-rows-2 gap-y-4 md:grid-cols-2 md:gap-x-4;
1
+
2
+ .columns {
3
+ @apply grid grid-cols-2 gap-x-4;
4
+ }
5
+ .rows {
6
+ @apply grid grid-rows-2 gap-y-4;
7
+ }
8
+ .responsive {
9
+ @apply grid grid-rows-2 gap-y-4 md:grid-cols-2 md:gap-x-4;
10
10
  }
@@ -1,20 +1,20 @@
1
- import { useCallback, useEffect } from 'react'
2
- const KEY_NAME_ESC = 'Escape'
3
- const KEY_EVENT_TYPE = 'keyup'
4
- function useEscapeKey (handleClose) {
5
- const handleEscKey = useCallback((event) => {
6
- if (event.key === KEY_NAME_ESC) {
7
- handleClose()
8
- }
9
- }, [handleClose])
10
-
11
- useEffect(() => {
12
- document.addEventListener(KEY_EVENT_TYPE, handleEscKey, false)
13
-
14
- return () => {
15
- document.removeEventListener(KEY_EVENT_TYPE, handleEscKey, false)
16
- }
17
- }, [handleEscKey])
18
- }
19
-
20
- export default useEscapeKey
1
+ import { useCallback, useEffect } from 'react'
2
+ const KEY_NAME_ESC = 'Escape'
3
+ const KEY_EVENT_TYPE = 'keyup'
4
+ function useEscapeKey (handleClose) {
5
+ const handleEscKey = useCallback((event) => {
6
+ if (event.key === KEY_NAME_ESC) {
7
+ handleClose()
8
+ }
9
+ }, [handleClose])
10
+
11
+ useEffect(() => {
12
+ document.addEventListener(KEY_EVENT_TYPE, handleEscKey, false)
13
+
14
+ return () => {
15
+ document.removeEventListener(KEY_EVENT_TYPE, handleEscKey, false)
16
+ }
17
+ }, [handleEscKey])
18
+ }
19
+
20
+ export default useEscapeKey
package/src/lib/utils.js CHANGED
@@ -1,23 +1,23 @@
1
- 'use strict'
2
-
3
- function getColor (type, color) {
4
- let convertedColor
5
- switch (color) {
6
- case 'green':
7
- convertedColor = 'main-green'
8
- break
9
- case 'red':
10
- convertedColor = 'error-red'
11
- break
12
- case 'white':
13
- convertedColor = 'white'
14
- break
15
- default:
16
- convertedColor = 'main-green'
17
- break
18
- }
19
- return `${type}-${convertedColor}`
20
- }
21
- export {
22
- getColor
23
- }
1
+ 'use strict'
2
+
3
+ function getColor (type, color) {
4
+ let convertedColor
5
+ switch (color) {
6
+ case 'green':
7
+ convertedColor = 'main-green'
8
+ break
9
+ case 'red':
10
+ convertedColor = 'error-red'
11
+ break
12
+ case 'white':
13
+ convertedColor = 'white'
14
+ break
15
+ default:
16
+ convertedColor = 'main-green'
17
+ break
18
+ }
19
+ return `${type}-${convertedColor}`
20
+ }
21
+ export {
22
+ getColor
23
+ }
package/src/main.jsx CHANGED
@@ -1,9 +1,9 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom/client'
3
- import App from './App'
4
- import './styles/main.css'
5
- ReactDOM.createRoot(document.getElementById('root')).render(
6
- <React.StrictMode>
7
- <App />
8
- </React.StrictMode>
9
- )
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import App from './App'
4
+ import './styles/main.css'
5
+ ReactDOM.createRoot(document.getElementById('root')).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ )
@@ -1,33 +1,33 @@
1
- 'use strict'
2
- import BorderedBox from '../components/BorderedBox'
3
- export default {
4
- title: 'Platformatic/BorderedBox',
5
- component: BorderedBox,
6
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
7
- argTypes: {
8
- color: {
9
- options: ['green', 'red', 'white'],
10
- control: { type: ' radio' }
11
- }
12
- }
13
- }
14
-
15
- // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
16
- const Template = (args) => <BorderedBox {...args}>Hello Platformatic</BorderedBox>
17
-
18
- export const Green = Template.bind({})
19
-
20
- Green.args = {
21
- color: 'green'
22
- }
23
- export const Red = Template.bind({})
24
-
25
- Red.args = {
26
- color: 'red'
27
- }
28
-
29
- export const White = Template.bind({})
30
-
31
- White.args = {
32
- color: 'white'
33
- }
1
+ 'use strict'
2
+ import BorderedBox from '../components/BorderedBox'
3
+ export default {
4
+ title: 'Platformatic/BorderedBox',
5
+ component: BorderedBox,
6
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
7
+ argTypes: {
8
+ color: {
9
+ options: ['green', 'red', 'white'],
10
+ control: { type: ' radio' }
11
+ }
12
+ }
13
+ }
14
+
15
+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
16
+ const Template = (args) => <BorderedBox {...args}>Hello Platformatic</BorderedBox>
17
+
18
+ export const Green = Template.bind({})
19
+
20
+ Green.args = {
21
+ color: 'green'
22
+ }
23
+ export const Red = Template.bind({})
24
+
25
+ Red.args = {
26
+ color: 'red'
27
+ }
28
+
29
+ export const White = Template.bind({})
30
+
31
+ White.args = {
32
+ color: 'white'
33
+ }
@@ -1,24 +1,24 @@
1
- 'use strict'
2
- import BorderedText from '../components/BorderedText'
3
- export default {
4
- title: 'Platformatic/BorderedText',
5
- component: BorderedText,
6
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
7
- argTypes: {
8
- text: { control: 'string' }
9
- }
10
- }
11
-
12
- // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
13
- const Template = (args) => <BorderedText {...args} />
14
-
15
- export const Sample = Template.bind({})
16
- // More on args: https://storybook.js.org/docs/react/writing-stories/args
17
- Sample.args = {
18
- text: 'Hello Platformatic!'
19
- }
20
- export const Version = Template.bind({})
21
-
22
- Version.args = {
23
- text: 'v1.2.3'
24
- }
1
+ 'use strict'
2
+ import BorderedText from '../components/BorderedText'
3
+ export default {
4
+ title: 'Platformatic/BorderedText',
5
+ component: BorderedText,
6
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
7
+ argTypes: {
8
+ text: { control: 'string' }
9
+ }
10
+ }
11
+
12
+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
13
+ const Template = (args) => <BorderedText {...args} />
14
+
15
+ export const Sample = Template.bind({})
16
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
17
+ Sample.args = {
18
+ text: 'Hello Platformatic!'
19
+ }
20
+ export const Version = Template.bind({})
21
+
22
+ Version.args = {
23
+ text: 'v1.2.3'
24
+ }
@@ -1,107 +1,107 @@
1
- 'use strict'
2
- import { faCheck } from '@fortawesome/free-solid-svg-icons'
3
- import { useState } from 'react'
4
- import Button from '../components/Button'
5
-
6
- export default {
7
- title: 'Platformatic/Button',
8
- component: Button,
9
- argTypes: {
10
- label: {
11
- type: 'string',
12
- control: 'text'
13
- },
14
- primary: {
15
- type: 'boolean'
16
- },
17
- color: {
18
- type: 'string',
19
- control: {
20
- type: 'radio',
21
- options: ['green', 'red']
22
- }
23
- }
24
- }
25
- }
26
-
27
- const Template = (args) => <Button {...args} />
28
-
29
- export const PrimaryGreen = Template.bind({})
30
- // More on args: https://storybook.js.org/docs/react/writing-stories/args
31
- PrimaryGreen.args = {
32
- primary: true,
33
- label: 'Primary Green',
34
- color: 'green'
35
- }
36
-
37
- export const SecondaryGreen = Template.bind({})
38
- SecondaryGreen.args = {
39
- primary: false,
40
- label: 'Secondary Green',
41
- color: 'green'
42
- }
43
-
44
- export const PrimaryWithIcon = Template.bind({})
45
- PrimaryWithIcon.args = {
46
- primary: true,
47
- label: 'Primary with Icon',
48
- icon: faCheck
49
- }
50
-
51
- export const SecondaryWithIcon = Template.bind({})
52
- SecondaryWithIcon.args = {
53
- primary: false,
54
- label: 'Secondary with Icon',
55
- icon: faCheck
56
-
57
- }
58
-
59
- export const PrimaryRed = Template.bind({})
60
- // More on args: https://storybook.js.org/docs/react/writing-stories/args
61
- PrimaryRed.args = {
62
- primary: true,
63
- label: 'Primary Red',
64
- color: 'red'
65
- }
66
-
67
- export const SecondaryRed = Template.bind({})
68
- SecondaryRed.args = {
69
- primary: false,
70
- label: 'Secondary Red',
71
- color: 'red'
72
- }
73
-
74
- const DisabledTemplate = (args) => {
75
- const [enabled, setEnabled] = useState(false)
76
- return (
77
- <div className='flex flex-col gap-y-6 text-white'>
78
- <div>
79
- <Button {...args} disabled={!enabled} onClick={() => alert('clicked')} />
80
- <span className='ml-4 text-xl'>👈 This button is {enabled ? 'enabled' : 'disabled'}</span>
81
- </div>
82
- <div>
83
- <Button label='Toggle Disabled' primary='true' onClick={() => setEnabled(!enabled)} />
84
- </div>
85
-
86
- </div>
87
-
88
- )
89
- }
90
-
91
- export const DisabledGreen = DisabledTemplate.bind({})
92
-
93
- DisabledGreen.args = {
94
- primary: true,
95
- label: 'A simple button',
96
- color: 'green',
97
- disabeld: true
98
- }
99
-
100
- export const DisabledRed = DisabledTemplate.bind({})
101
-
102
- DisabledRed.args = {
103
- primary: true,
104
- label: 'A simple button',
105
- color: 'red',
106
- disabeld: true
107
- }
1
+ 'use strict'
2
+ import { faCheck } from '@fortawesome/free-solid-svg-icons'
3
+ import { useState } from 'react'
4
+ import Button from '../components/Button'
5
+
6
+ export default {
7
+ title: 'Platformatic/Button',
8
+ component: Button,
9
+ argTypes: {
10
+ label: {
11
+ type: 'string',
12
+ control: 'text'
13
+ },
14
+ primary: {
15
+ type: 'boolean'
16
+ },
17
+ color: {
18
+ type: 'string',
19
+ control: {
20
+ type: 'radio',
21
+ options: ['green', 'red']
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ const Template = (args) => <Button {...args} />
28
+
29
+ export const PrimaryGreen = Template.bind({})
30
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
31
+ PrimaryGreen.args = {
32
+ primary: true,
33
+ label: 'Primary Green',
34
+ color: 'green'
35
+ }
36
+
37
+ export const SecondaryGreen = Template.bind({})
38
+ SecondaryGreen.args = {
39
+ primary: false,
40
+ label: 'Secondary Green',
41
+ color: 'green'
42
+ }
43
+
44
+ export const PrimaryWithIcon = Template.bind({})
45
+ PrimaryWithIcon.args = {
46
+ primary: true,
47
+ label: 'Primary with Icon',
48
+ icon: faCheck
49
+ }
50
+
51
+ export const SecondaryWithIcon = Template.bind({})
52
+ SecondaryWithIcon.args = {
53
+ primary: false,
54
+ label: 'Secondary with Icon',
55
+ icon: faCheck
56
+
57
+ }
58
+
59
+ export const PrimaryRed = Template.bind({})
60
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
61
+ PrimaryRed.args = {
62
+ primary: true,
63
+ label: 'Primary Red',
64
+ color: 'red'
65
+ }
66
+
67
+ export const SecondaryRed = Template.bind({})
68
+ SecondaryRed.args = {
69
+ primary: false,
70
+ label: 'Secondary Red',
71
+ color: 'red'
72
+ }
73
+
74
+ const DisabledTemplate = (args) => {
75
+ const [enabled, setEnabled] = useState(false)
76
+ return (
77
+ <div className='flex flex-col gap-y-6 text-white'>
78
+ <div>
79
+ <Button {...args} disabled={!enabled} onClick={() => alert('clicked')} />
80
+ <span className='ml-4 text-xl'>👈 This button is {enabled ? 'enabled' : 'disabled'}</span>
81
+ </div>
82
+ <div>
83
+ <Button label='Toggle Disabled' primary='true' onClick={() => setEnabled(!enabled)} />
84
+ </div>
85
+
86
+ </div>
87
+
88
+ )
89
+ }
90
+
91
+ export const DisabledGreen = DisabledTemplate.bind({})
92
+
93
+ DisabledGreen.args = {
94
+ primary: true,
95
+ label: 'A simple button',
96
+ color: 'green',
97
+ disabeld: true
98
+ }
99
+
100
+ export const DisabledRed = DisabledTemplate.bind({})
101
+
102
+ DisabledRed.args = {
103
+ primary: true,
104
+ label: 'A simple button',
105
+ color: 'red',
106
+ disabeld: true
107
+ }
@@ -1,33 +1,33 @@
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
- pre: 'P90',
20
- tooltip: 'This is a tooltip for the metric',
21
- leftDetail: {
22
- value: 600,
23
- unit: 'ms',
24
- color: 'green',
25
- pre: 'P99'
26
- },
27
- rightDetail: {
28
- value: 4.42,
29
- unit: 's',
30
- color: 'green',
31
- pre: 'P95'
32
- }
33
- }
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
+ pre: 'P90',
20
+ tooltip: 'This is a tooltip for the metric',
21
+ leftDetail: {
22
+ value: 600,
23
+ unit: 'ms',
24
+ color: 'green',
25
+ pre: 'P99'
26
+ },
27
+ rightDetail: {
28
+ value: 4.42,
29
+ unit: 's',
30
+ color: 'green',
31
+ pre: 'P95'
32
+ }
33
+ }