@platformatic/ui-components 0.1.48 → 0.1.50

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 (152) hide show
  1. package/.github/workflows/ci.yml +26 -26
  2. package/.nvmrc +1 -1
  3. package/LICENSE +201 -201
  4. package/README.md +30 -30
  5. package/fonts/Montserrat/README.txt +81 -81
  6. package/index.html +12 -12
  7. package/index.js +71 -71
  8. package/package.json +76 -76
  9. package/postcss.config.cjs +8 -8
  10. package/public/api-icon-closed.svg +6 -6
  11. package/public/api-icon.svg +9 -9
  12. package/src/App.jsx +12 -12
  13. package/src/components/BorderedBox.jsx +18 -18
  14. package/src/components/BorderedBox.module.css +8 -8
  15. package/src/components/BorderedText.jsx +8 -8
  16. package/src/components/BorderedText.module.css +2 -2
  17. package/src/components/Box.jsx +14 -14
  18. package/src/components/Box.module.css +7 -7
  19. package/src/components/Button.jsx +95 -95
  20. package/src/components/Button.module.css +127 -127
  21. package/src/components/ButtonFullRounded.jsx +17 -17
  22. package/src/components/ButtonFullRounded.module.css +28 -28
  23. package/src/components/Checkbox.jsx +11 -11
  24. package/src/components/Checkbox.module.css +18 -18
  25. package/src/components/Common.module.css +28 -28
  26. package/src/components/DetailedMetric.jsx +32 -32
  27. package/src/components/DetailedMetric.module.css +2 -2
  28. package/src/components/DropDown.jsx +36 -36
  29. package/src/components/DropDown.module.css +27 -27
  30. package/src/components/FollowUs.jsx +35 -35
  31. package/src/components/FollowUs.module.css +11 -11
  32. package/src/components/GHLoginButton.jsx +14 -14
  33. package/src/components/HorizontalSeparator.jsx +15 -15
  34. package/src/components/HorizontalSeparator.module.css +26 -26
  35. package/src/components/InfoBox.jsx +50 -50
  36. package/src/components/InfoBox.module.css +5 -5
  37. package/src/components/List.jsx +20 -20
  38. package/src/components/List.module.css +11 -11
  39. package/src/components/ListElement.jsx +23 -23
  40. package/src/components/ListElement.module.css +23 -23
  41. package/src/components/Loadable.jsx +34 -34
  42. package/src/components/Loadable.module.css +13 -13
  43. package/src/components/Loader.jsx +22 -22
  44. package/src/components/Loader.module.css +13 -13
  45. package/src/components/LoginButton.jsx +17 -17
  46. package/src/components/LoginButton.module.css +7 -7
  47. package/src/components/LoginButton.test.jsx +25 -25
  48. package/src/components/Logo.jsx +62 -62
  49. package/src/components/Logo.module.css +5 -5
  50. package/src/components/Main.jsx +33 -33
  51. package/src/components/MetricValue.jsx +15 -15
  52. package/src/components/MetricValue.module.css +9 -9
  53. package/src/components/Modal.jsx +93 -93
  54. package/src/components/Modal.module.css +50 -50
  55. package/src/components/PlatformaticIcon.jsx +57 -57
  56. package/src/components/PlatformaticIcon.module.css +2 -2
  57. package/src/components/Playground.jsx +9 -9
  58. package/src/components/SearchBar.jsx +63 -63
  59. package/src/components/SearchBar.module.css +20 -20
  60. package/src/components/Sidebar.jsx +153 -153
  61. package/src/components/Sidebar.module.css +66 -66
  62. package/src/components/SimpleMetric.jsx +28 -28
  63. package/src/components/SimpleMetric.module.css +6 -6
  64. package/src/components/Status.jsx +26 -26
  65. package/src/components/TabbedWindow.jsx +39 -39
  66. package/src/components/TabbedWindow.module.css +16 -16
  67. package/src/components/TextWithLabel.jsx +11 -11
  68. package/src/components/TextWithLabel.module.css +8 -8
  69. package/src/components/Versions.jsx +9 -9
  70. package/src/components/VerticalSeparator.jsx +5 -5
  71. package/src/components/forms/Field.jsx +53 -20
  72. package/src/components/forms/Field.module.css +23 -17
  73. package/src/components/forms/Input.jsx +80 -87
  74. package/src/components/forms/Input.module.css +28 -28
  75. package/src/components/forms/Preview.jsx +75 -77
  76. package/src/components/forms/Preview.module.css +14 -14
  77. package/src/components/forms/ToggleSwitch.jsx +18 -18
  78. package/src/components/forms/ToggleSwitch.module.css +42 -42
  79. package/src/components/forms/index.js +8 -8
  80. package/src/components/icons/ApiEmptyIcon.jsx +107 -107
  81. package/src/components/icons/ApiIcon.jsx +29 -29
  82. package/src/components/icons/ApiIconClosed.jsx +19 -19
  83. package/src/components/icons/AppEmptyIcon.jsx +94 -94
  84. package/src/components/icons/AppIcon.jsx +38 -38
  85. package/src/components/icons/AppListIcon.jsx +73 -73
  86. package/src/components/icons/Calendar1Icon.jsx +54 -54
  87. package/src/components/icons/Calendar7Icon.jsx +55 -55
  88. package/src/components/icons/CalendarIcon.jsx +56 -56
  89. package/src/components/icons/CircleAddIcon.jsx +40 -40
  90. package/src/components/icons/CircleBackIcon.jsx +51 -51
  91. package/src/components/icons/CircleCheckMarkIcon.jsx +66 -0
  92. package/src/components/icons/CircleCloseHoverIcon.jsx +42 -42
  93. package/src/components/icons/CircleCloseIcon.jsx +32 -32
  94. package/src/components/icons/CircleExclamationIcon.jsx +29 -29
  95. package/src/components/icons/CloseIcon.jsx +31 -31
  96. package/src/components/icons/CopyIcon.jsx +75 -46
  97. package/src/components/icons/CreatedWorkspaceIcon.jsx +70 -70
  98. package/src/components/icons/DynamicWorkspaceIcon.jsx +125 -125
  99. package/src/components/icons/EditIcon.jsx +38 -0
  100. package/src/components/icons/GearIcon.jsx +40 -40
  101. package/src/components/icons/Icons.module.css +29 -29
  102. package/src/components/icons/LiveIcon.jsx +43 -43
  103. package/src/components/icons/MetricsIcon.jsx +52 -52
  104. package/src/components/icons/PlayIcon.jsx +20 -20
  105. package/src/components/icons/PullRequestIcon.jsx +35 -35
  106. package/src/components/icons/StaticWorkspaceIcon.jsx +119 -119
  107. package/src/components/icons/StopIcon.jsx +21 -21
  108. package/src/components/icons/TerminalIcon.jsx +22 -22
  109. package/src/components/icons/TriangleExclamationIcon.jsx +26 -26
  110. package/src/components/icons/UpgradeIcon.jsx +48 -48
  111. package/src/components/icons/index.js +63 -59
  112. package/src/components/layouts/Layout.jsx +11 -11
  113. package/src/components/layouts/TwoColumnsLayout.jsx +12 -12
  114. package/src/components/layouts/TwoColumnsLayout.module.css +9 -9
  115. package/src/hooks/useEscapeKey.js +20 -20
  116. package/src/lib/utils.js +23 -23
  117. package/src/main.jsx +9 -9
  118. package/src/stories/BorderedBox.stories.jsx +33 -33
  119. package/src/stories/BorderedText.stories.jsx +24 -24
  120. package/src/stories/Button.stories.jsx +114 -114
  121. package/src/stories/ButtonFullRounded.stories.jsx +61 -61
  122. package/src/stories/Checkbox.stories.jsx +27 -27
  123. package/src/stories/DetailedMetric.stories.jsx +33 -33
  124. package/src/stories/DropDown.stories.jsx +62 -62
  125. package/src/stories/FollowUs.stories.jsx +14 -14
  126. package/src/stories/GHLoginButton.stories.jsx +14 -14
  127. package/src/stories/HorizontalSeparator.stories.jsx +12 -12
  128. package/src/stories/InfoBox.stories.jsx +46 -46
  129. package/src/stories/Introduction.stories.mdx +211 -211
  130. package/src/stories/List.stories.jsx +29 -29
  131. package/src/stories/ListElement.stories.jsx +15 -15
  132. package/src/stories/Loadable.stories.jsx +75 -75
  133. package/src/stories/Loader.stories.jsx +44 -44
  134. package/src/stories/LoginButton.stories.jsx +15 -15
  135. package/src/stories/Logo.stories.jsx +17 -17
  136. package/src/stories/Modal.stories.jsx +100 -100
  137. package/src/stories/PlatformaticIcon.stories.jsx +51 -35
  138. package/src/stories/SearchBar.stories.jsx +28 -28
  139. package/src/stories/Sidebar.stories.jsx +61 -61
  140. package/src/stories/SimpleMetric.stories.jsx +41 -41
  141. package/src/stories/Status.stories.jsx +31 -31
  142. package/src/stories/TextWithLabel.stories.jsx +25 -25
  143. package/src/stories/TwoColumnsLayout.stories.jsx +42 -42
  144. package/src/stories/forms/Field.stories.jsx +89 -81
  145. package/src/stories/forms/Input.stories.jsx +89 -69
  146. package/src/stories/forms/Preview.stories.jsx +57 -57
  147. package/src/stories/forms/ToggleSwitch.stories.jsx +15 -15
  148. package/src/stories/icons/Icons.stories.jsx +74 -74
  149. package/src/styles/main.css +15 -15
  150. package/tailwind.config.cjs +60 -60
  151. package/vite.config.js +6 -6
  152. package/vitest.config.js +14 -14
@@ -1,17 +1,17 @@
1
- .tabbed-container {
2
- @apply bg-main-dark-blue;
3
- }
4
-
5
- .tabs-header {
6
- @apply flex justify-start text-white uppercase hover:cursor-pointer mb-4 tracking-super-widest h-[2rem];
7
- }
8
- .tab {
9
- @apply mx-8 min-w-[105px] text-center text-sm first:ml-0 last:mr-0;
10
- }
11
- .selected-tab {
12
- @apply underline text-main-green underline-offset-8 font-bold;
13
- }
14
-
15
- .tabs-content {
16
- @apply h-screen
1
+ .tabbed-container {
2
+ @apply bg-main-dark-blue;
3
+ }
4
+
5
+ .tabs-header {
6
+ @apply flex justify-start text-white uppercase hover:cursor-pointer mb-4 tracking-super-widest h-[2rem];
7
+ }
8
+ .tab {
9
+ @apply mx-8 min-w-[105px] text-center text-sm first:ml-0 last:mr-0;
10
+ }
11
+ .selected-tab {
12
+ @apply underline text-main-green underline-offset-8 font-bold;
13
+ }
14
+
15
+ .tabs-content {
16
+ @apply h-screen
17
17
  }
@@ -1,11 +1,11 @@
1
- import React from 'react'
2
- import styles from './TextWithLabel.module.css'
3
- export default function TextWithLabel ({ label, text, children }) {
4
- return (
5
- <div className={styles.container}>
6
- <span className={styles.label}>{label}:</span>
7
- {text && <span className={styles.text}>{text}</span>}
8
- {children && <span>{children}</span>}
9
- </div>
10
- )
11
- }
1
+ import React from 'react'
2
+ import styles from './TextWithLabel.module.css'
3
+ export default function TextWithLabel ({ label, text, children }) {
4
+ return (
5
+ <div className={styles.container}>
6
+ <span className={styles.label}>{label}:</span>
7
+ {text && <span className={styles.text}>{text}</span>}
8
+ {children && <span>{children}</span>}
9
+ </div>
10
+ )
11
+ }
@@ -1,9 +1,9 @@
1
- .container {
2
- @apply text-white
3
- }
4
- .label {
5
- @apply font-thin mr-2;
6
- }
7
- .text {
8
- @apply font-semibold;
1
+ .container {
2
+ @apply text-white
3
+ }
4
+ .label {
5
+ @apply font-thin mr-2;
6
+ }
7
+ .text {
8
+ @apply font-semibold;
9
9
  }
@@ -1,9 +1,9 @@
1
- 'use strict'
2
- import React from 'react'
3
- import BorderedBox from './BorderedBox'
4
-
5
- export default function Versions () {
6
- return (
7
- <BorderedBox color='green'>Versions</BorderedBox>
8
- )
9
- }
1
+ 'use strict'
2
+ import React from 'react'
3
+ import BorderedBox from './BorderedBox'
4
+
5
+ export default function Versions () {
6
+ return (
7
+ <BorderedBox color='green'>Versions</BorderedBox>
8
+ )
9
+ }
@@ -1,5 +1,5 @@
1
- 'use strict'
2
- import React from 'react'
3
- export default function VerticalSeparator () {
4
- return <span className='text-dark-green m-3'> | </span>
5
- }
1
+ 'use strict'
2
+ import React from 'react'
3
+ export default function VerticalSeparator () {
4
+ return <span className='text-dark-green m-3'> | </span>
5
+ }
@@ -1,20 +1,53 @@
1
- import React from 'react'
2
- import styles from './Field.module.css'
3
- import HorizontalSeparator from '../HorizontalSeparator'
4
-
5
- export default function Field ({ title, helper, children, disabled }) {
6
- let className = `${styles.container}`
7
- if (disabled) className += ` ${styles.disabled}`
8
- return (
9
- <>
10
- <div className={className}>
11
- <p className={styles.title}>{title}</p>
12
- <p className={styles.helper}>{helper}</p>
13
- <div className={styles.content}>
14
- {children}
15
- </div>
16
- </div>
17
- <HorizontalSeparator color='main-dark-green' opacity={20} marginBottom={10} marginTop={10} />
18
- </>
19
- )
20
- }
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import styles from './Field.module.css'
4
+
5
+ function Field ({ title, titleColor, helper, children, disabled }) {
6
+ let className = `${styles.container}`
7
+ if (disabled) className += ` ${styles.disabled}`
8
+ let classnameTitle = `${styles.title} `
9
+ classnameTitle += styles[`text-color-${titleColor}`]
10
+
11
+ return (
12
+ <div className={className}>
13
+ <p className={classnameTitle}>{title}</p>
14
+ <p className={styles.helper}>{helper}</p>
15
+ <div className={styles.content}>
16
+ {children}
17
+ </div>
18
+ </div>
19
+ )
20
+ }
21
+
22
+ Field.propTypes = {
23
+ /**
24
+ * title
25
+ */
26
+ title: PropTypes.string,
27
+ /**
28
+ * titleColor
29
+ */
30
+ titleColor: PropTypes.oneOf(['error-red', 'main-dark-blue']),
31
+ /**
32
+ * helper
33
+ */
34
+ helper: PropTypes.string,
35
+ /**
36
+ * color of border
37
+ */
38
+ children: PropTypes.node,
39
+ /**
40
+ * disabled
41
+ */
42
+ disabled: PropTypes.bool
43
+ }
44
+
45
+ Field.defaultProps = {
46
+ title: '',
47
+ titleColor: 'main-dark-blue',
48
+ helper: '',
49
+ children: null,
50
+ disabled: false
51
+ }
52
+
53
+ export default Field
@@ -1,18 +1,24 @@
1
- .container {
2
- @apply flex flex-col;
3
- }
4
- .title{
5
- @apply text-xl font-semibold text-main-dark-blue;
6
- }
7
- .helper{
8
- @apply text-sm text-main-dark-blue pb-4;
9
- }
10
- .content {
11
- @apply flex gap-x-1 w-full;
12
- }
13
- .content button {
14
- @apply shrink-0;
15
- }
16
- .disabled {
17
- @apply opacity-20;
1
+ .container {
2
+ @apply flex flex-col;
3
+ }
4
+ .title {
5
+ @apply text-xl font-semibold;
6
+ }
7
+ .text-color-main-dark-blue {
8
+ @apply text-main-dark-blue;
9
+ }
10
+ .text-color-error-red {
11
+ @apply text-error-red;
12
+ }
13
+ .helper{
14
+ @apply text-sm pb-4;
15
+ }
16
+ .content {
17
+ @apply flex gap-x-1 w-full;
18
+ }
19
+ .content button {
20
+ @apply shrink-0;
21
+ }
22
+ .disabled {
23
+ @apply opacity-20;
18
24
  }
@@ -1,87 +1,80 @@
1
- 'use strict'
2
- import React from 'react'
3
- import PropTypes from 'prop-types'
4
- import styles from './Input.module.css'
5
- import commonStyles from '../Common.module.css'
6
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
7
-
8
- function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled, beforeInputIcon, beforeInputIconColor, afterInputIcon, afterInputIconColor, onClickBeforeIcon }) {
9
- let className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + commonStyles.padded
10
- const showError = errorMessage.length > 0
11
- if (showError) className += ' ' + commonStyles['bordered--error-red']
12
- const classNameBeforeInput = `${styles.beforeInputIcon} ` + styles[`color-${beforeInputIconColor}`]
13
- return (
14
- <div className={styles.container}>
15
- <div className={className}>
16
- {beforeInputIcon && <FontAwesomeIcon icon={beforeInputIcon} className={classNameBeforeInput} data-testid='before-icon' color='white' onClick={() => onClickBeforeIcon()} />}
17
- <input type='text' name={name} value={value} placeholder={placeholder} className={styles.fullWidth} onChange={onChange} disabled={disabled} />
18
- {afterInputIcon && <FontAwesomeIcon icon={afterInputIcon} className={styles[`color-${afterInputIconColor}`]} data-testid='after-icon' />}
19
- </div>
20
- {showError && <span className={commonStyles['error-message']}>{errorMessage}</span>}
21
- </div>
22
- )
23
- }
24
-
25
- Input.propTypes = {
26
- /**
27
- * placeholder
28
- */
29
- placeholder: PropTypes.string,
30
- /**
31
- * value
32
- */
33
- value: PropTypes.string,
34
- /**
35
- * name
36
- */
37
- name: PropTypes.string,
38
- /**
39
- * color of border
40
- */
41
- borderColor: PropTypes.oneOf(['main-green', 'main-dark-blue']),
42
- /**
43
- * onChange
44
- */
45
- onChange: PropTypes.func,
46
- /**
47
- * Disabled
48
- */
49
- disabled: PropTypes.bool,
50
- /**
51
- * beforeInputIcon
52
- */
53
- beforeInputIcon: PropTypes.object,
54
- /**
55
- * beforeInputIconColor
56
- */
57
- beforeInputIconColor: PropTypes.oneOf(['error-red', 'main-dark-blue', 'white']),
58
- /**
59
- * afterInputIcon
60
- */
61
- afterInputIcon: PropTypes.object,
62
- /**
63
- * afterInputIconColor
64
- */
65
- afterInputIconColor: PropTypes.oneOf(['error-red', 'main-dark-blue', 'white']),
66
- /**
67
- * onClickBeforeIcon
68
- */
69
- onClickBeforeIcon: PropTypes.func
70
- }
71
-
72
- Input.defaultProps = {
73
- placeholder: '',
74
- value: null,
75
- name: '',
76
- borderColor: 'main-green',
77
- errorMessage: '',
78
- onChange: () => {},
79
- disabled: false,
80
- beforeInputIcon: null,
81
- beforeInputIconColor: 'main-dark-blue',
82
- afterInputIcon: null,
83
- onClickBeforeIcon: () => {},
84
- afterInputIconColor: 'main-dark-blue'
85
- }
86
-
87
- export default Input
1
+ 'use strict'
2
+ import React from 'react'
3
+ import PropTypes from 'prop-types'
4
+ import styles from './Input.module.css'
5
+ import commonStyles from '../Common.module.css'
6
+ import PlatformaticIcon from '../PlatformaticIcon'
7
+
8
+ function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled, beforeIcon, afterIcon }) {
9
+ let className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + commonStyles.padded
10
+ const showError = errorMessage.length > 0
11
+ if (showError) className += ' ' + commonStyles['bordered--error-red']
12
+
13
+ return (
14
+ <div className={styles.container}>
15
+ <div className={className}>
16
+ {beforeIcon && <PlatformaticIcon iconName={beforeIcon.iconName} classes={styles.beforeInputIcon} size='small' data-testid='before-icon' color={beforeIcon.color} onClick={() => beforeIcon.onClick()} />}
17
+ <input type='text' name={name} value={value} placeholder={placeholder} className={styles.fullWidth} onChange={onChange} disabled={disabled} />
18
+ {afterIcon && <PlatformaticIcon iconName={afterIcon.iconName} color={afterIcon.color} data-testid='after-icon' onClick={null} />}
19
+ </div>
20
+ {showError && <span className={commonStyles['error-message']}>{errorMessage}</span>}
21
+ </div>
22
+ )
23
+ }
24
+
25
+ Input.propTypes = {
26
+ /**
27
+ * placeholder
28
+ */
29
+ placeholder: PropTypes.string,
30
+ /**
31
+ * value
32
+ */
33
+ value: PropTypes.string,
34
+ /**
35
+ * name
36
+ */
37
+ name: PropTypes.string,
38
+ /**
39
+ * color of border
40
+ */
41
+ borderColor: PropTypes.oneOf(['main-green', 'main-dark-blue']),
42
+ /**
43
+ * onChange
44
+ */
45
+ onChange: PropTypes.func,
46
+ /**
47
+ * Disabled
48
+ */
49
+ disabled: PropTypes.bool,
50
+ /**
51
+ * beforeIcon: PlatformaticIcon props
52
+ */
53
+ beforeIcon: PropTypes.shape({
54
+ iconName: PropTypes.string,
55
+ color: PropTypes.string,
56
+ onClick: PropTypes.func
57
+ }),
58
+ /**
59
+ * afterIcon: PlatformaticIcon props
60
+ */
61
+ afterIcon: PropTypes.shape({
62
+ iconName: PropTypes.string,
63
+ color: PropTypes.string,
64
+ onClick: PropTypes.func
65
+ })
66
+ }
67
+
68
+ Input.defaultProps = {
69
+ placeholder: '',
70
+ value: '',
71
+ name: '',
72
+ borderColor: 'main-green',
73
+ errorMessage: '',
74
+ onChange: () => {},
75
+ disabled: false,
76
+ beforeIcon: null,
77
+ afterIcon: null
78
+ }
79
+
80
+ export default Input
@@ -1,28 +1,28 @@
1
- .container {
2
- @apply flex flex-col w-full relative;
3
- }
4
- .inputContainer {
5
- @apply flex h-10 border border-solid box-border rounded-md;
6
- }
7
- .fullWidth {
8
- @apply w-full;
9
- }
10
- .input {
11
- @apply focus:outline-none focus-within:outline-none focus-visible:outline-none;
12
- }
13
- .beforeInputIcon {
14
- @apply ml-1 mr-3 cursor-pointer;
15
- }
16
- .color-main-dark-blue {
17
- @apply text-main-dark-blue;
18
- }
19
- .color-error-red{
20
- @apply text-error-red;
21
- }
22
- .color-white{
23
- @apply text-white;
24
- }
25
-
26
- [type='text']:focus {
27
- outline: none;
28
- }
1
+ .container {
2
+ @apply flex flex-col w-full relative;
3
+ }
4
+ .inputContainer {
5
+ @apply flex h-10 border border-solid box-border rounded-md;
6
+ }
7
+ .fullWidth {
8
+ @apply w-full;
9
+ }
10
+ .input {
11
+ @apply focus:outline-none focus-within:outline-none focus-visible:outline-none;
12
+ }
13
+ .beforeInputIcon {
14
+ @apply ml-1 mr-3;
15
+ }
16
+ .color-main-dark-blue {
17
+ @apply text-main-dark-blue;
18
+ }
19
+ .color-error-red{
20
+ @apply text-error-red;
21
+ }
22
+ .color-white{
23
+ @apply text-white;
24
+ }
25
+
26
+ [type='text']:focus {
27
+ outline: none;
28
+ }
@@ -1,77 +1,75 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import styles from './Preview.module.css'
4
- import HorizontalSeparator from '../HorizontalSeparator'
5
- import PlatformaticIcon from '../PlatformaticIcon'
6
-
7
- function renderLink (value) {
8
- return (<a className={styles.link} href={value} target='_blank' rel='noreferrer'>{value}</a>)
9
- }
10
-
11
- function renderParagraph (value, afterValueIcon, afterValueIconColor, onClickAfterValueIcon) {
12
- return (
13
- <>
14
- <p className={styles.value}>
15
- {value}
16
- {afterValueIcon && (<PlatformaticIcon iconName={afterValueIcon} color={afterValueIconColor} classes={styles.afterIcon} onClick={() => onClickAfterValueIcon} />)}
17
- </p>
18
- </>
19
- )
20
- }
21
- function Preview ({ title, value, isLink, children, afterValueIcon, afterValueIconColor, onClickAfterValueIcon }) {
22
- return (
23
- <>
24
- <div className={styles.container}>
25
- <p className={styles.title}>{title}</p>
26
- {isLink ? renderLink(value) : renderParagraph(value, afterValueIcon, afterValueIconColor, onClickAfterValueIcon)}
27
- </div>
28
- {children}
29
- <HorizontalSeparator color='main-dark-green' opacity={20} marginBottom={10} marginTop={10} />
30
- </>
31
- )
32
- }
33
-
34
- Preview.propTypes = {
35
- /**
36
- * title
37
- */
38
- title: PropTypes.string,
39
- /**
40
- * value
41
- */
42
- value: PropTypes.oneOfType([
43
- PropTypes.string,
44
- PropTypes.number
45
- ]),
46
- /**
47
- * isLink
48
- */
49
- isLink: PropTypes.bool,
50
- /**
51
- * color of border
52
- */
53
- children: PropTypes.node,
54
- /**
55
- * afterValueIcon
56
- */
57
- afterValueIcon: PropTypes.string,
58
- /**
59
- * afterValueIconColor
60
- */
61
- afterValueIconColor: PropTypes.oneOf(['error-red', 'main-dark-blue', 'white']),
62
- /**
63
- * onClickAfterValueIcon
64
- */
65
- onClickAfterValueIcon: PropTypes.func
66
- }
67
-
68
- Preview.defaultProps = {
69
- title: '',
70
- value: '',
71
- isLink: false,
72
- afterValueIconColor: 'main-dark-blue',
73
- afterValueIcon: null,
74
- onClickAfterValueIcon: () => {}
75
- }
76
-
77
- export default Preview
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import styles from './Preview.module.css'
4
+ import PlatformaticIcon from '../PlatformaticIcon'
5
+
6
+ function renderLink (value) {
7
+ return (<a className={styles.link} href={value} target='_blank' rel='noreferrer'>{value}</a>)
8
+ }
9
+
10
+ function renderParagraph (value, afterValueIcon, afterValueIconColor, onClickAfterValueIcon) {
11
+ return (
12
+ <>
13
+ <p className={styles.value}>
14
+ {value}
15
+ {afterValueIcon && (<PlatformaticIcon iconName={afterValueIcon} color={afterValueIconColor} classes={styles.afterIcon} onClick={() => onClickAfterValueIcon} />)}
16
+ </p>
17
+ </>
18
+ )
19
+ }
20
+ function Preview ({ title, value, isLink, children, afterValueIcon, afterValueIconColor, onClickAfterValueIcon }) {
21
+ return (
22
+ <>
23
+ <div className={styles.container}>
24
+ <p className={styles.title}>{title}</p>
25
+ {isLink ? renderLink(value) : renderParagraph(value, afterValueIcon, afterValueIconColor, onClickAfterValueIcon)}
26
+ </div>
27
+ {children}
28
+ </>
29
+ )
30
+ }
31
+
32
+ Preview.propTypes = {
33
+ /**
34
+ * title
35
+ */
36
+ title: PropTypes.string,
37
+ /**
38
+ * value
39
+ */
40
+ value: PropTypes.oneOfType([
41
+ PropTypes.string,
42
+ PropTypes.number
43
+ ]),
44
+ /**
45
+ * isLink
46
+ */
47
+ isLink: PropTypes.bool,
48
+ /**
49
+ * color of border
50
+ */
51
+ children: PropTypes.node,
52
+ /**
53
+ * afterValueIcon
54
+ */
55
+ afterValueIcon: PropTypes.string,
56
+ /**
57
+ * afterValueIconColor
58
+ */
59
+ afterValueIconColor: PropTypes.oneOf(['error-red', 'main-dark-blue', 'white']),
60
+ /**
61
+ * onClickAfterValueIcon
62
+ */
63
+ onClickAfterValueIcon: PropTypes.func
64
+ }
65
+
66
+ Preview.defaultProps = {
67
+ title: '',
68
+ value: '',
69
+ isLink: false,
70
+ afterValueIconColor: 'main-dark-blue',
71
+ afterValueIcon: null,
72
+ onClickAfterValueIcon: () => {}
73
+ }
74
+
75
+ export default Preview
@@ -1,15 +1,15 @@
1
- .container {
2
- @apply flex flex-col
3
- }
4
- .title {
5
- @apply text-sm text-main-dark-blue pb-1;
6
- }
7
- .value {
8
- @apply text-xl font-semibold text-main-dark-blue inline-flex;
9
- }
10
- .link {
11
- @apply font-semibold;
12
- }
13
- .afterIcon {
14
- @apply ml-3;
1
+ .container {
2
+ @apply flex flex-col
3
+ }
4
+ .title {
5
+ @apply text-sm text-main-dark-blue pb-1;
6
+ }
7
+ .value {
8
+ @apply text-xl font-semibold text-main-dark-blue inline-flex;
9
+ }
10
+ .link {
11
+ @apply font-semibold;
12
+ }
13
+ .afterIcon {
14
+ @apply ml-3;
15
15
  }