@platformatic/ui-components 0.1.40 → 0.1.41

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
@@ -13,7 +13,7 @@ import GHLoginButton from './src/components/GHLoginButton'
13
13
  import HorizontalSeparator from './src/components/HorizontalSeparator'
14
14
  import Forms from './src/components/forms'
15
15
  import Icons from './src/components/icons'
16
- import SideBar from './src/components/SideBar'
16
+ import Sidebar from './src/components/Sidebar'
17
17
  import Layout from './src/components/layouts/Layout'
18
18
  import List from './src/components/List'
19
19
  import ListElement from './src/components/ListElement'
@@ -46,7 +46,7 @@ export {
46
46
  GHLoginButton,
47
47
  Forms,
48
48
  Icons,
49
- SideBar,
49
+ Sidebar,
50
50
  Layout,
51
51
  List,
52
52
  ListElement,
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.40",
4
+ "version": "0.1.41",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -1,3 +1,3 @@
1
1
  .borderedBox {
2
- @apply rounded-md p-5 bg-dark-blue text-white mb-4 flex-1 gap-y-4;
2
+ @apply rounded-md p-5 bg-dark-blue text-white flex-1 gap-y-4;
3
3
  }
@@ -66,7 +66,7 @@
66
66
  .color-dark-green {
67
67
  @apply text-dark-green border-dark-green;
68
68
  }
69
- .color-main-dark-blue{
69
+ .color-main-dark-blue {
70
70
  @apply text-main-dark-blue border-main-dark-blue;
71
71
  }
72
72
  .color-dark-blue{
@@ -12,10 +12,10 @@
12
12
  @apply p-4 rounded-md mx-auto my-auto min-w-[480px] max-h-[85vh] overflow-y-auto;
13
13
  }
14
14
  .modalInfo {
15
- @apply bg-light-blue;
15
+ @apply bg-light-blue max-w-[480px];
16
16
  }
17
17
  .modalInvite {
18
- @apply bg-main-dark-blue border-light-green border shadow-wrap shadow-main-green max-w-[432px] max-h-[300px];
18
+ @apply bg-main-dark-blue border-light-green border shadow-wrap shadow-main-green max-w-[480px] max-h-[300px];
19
19
  }
20
20
  .fullscreen {
21
21
  @apply fixed top-0 left-0 bg-light-blue h-screen w-full min-h-screen min-w-full py-4 pl-20 pr-4 overflow-y-auto;
@@ -1,12 +1,22 @@
1
1
  import React, { useState } from 'react'
2
2
  import PuzzleIcon from './icons/PuzzleIcon'
3
3
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4
- import { faChevronLeft, faPlus } from '@fortawesome/free-solid-svg-icons'
5
- import styles from './SideBar.module.css'
4
+ import { faChevronLeft, faPlusCircle, faGear } from '@fortawesome/free-solid-svg-icons'
5
+ import styles from './Sidebar.module.css'
6
6
  import ReactTooltip from 'react-tooltip'
7
+ import Button from './Button'
7
8
  import HorizontalSeparator from './HorizontalSeparator'
8
- export default function SideBar (props) {
9
- const { title, defaultSelected = 0, onClickItemSelectedParent = () => {}, items = [], onClickAdd = () => {}, addTitle = 'Add' } = props
9
+
10
+ export default function Sidebar (props) {
11
+ const {
12
+ title,
13
+ defaultSelected = 0,
14
+ onClickItemSelectedParent = () => {},
15
+ items = [],
16
+ onClickAdd = () => {},
17
+ addTitle = 'Add',
18
+ onClickSettings = () => {}
19
+ } = props
10
20
  const [collapsed, setCollapsed] = useState(false)
11
21
  const [selectedItem, setSelectedItem] = useState(defaultSelected)
12
22
 
@@ -49,13 +59,17 @@ export default function SideBar (props) {
49
59
  })}
50
60
  {/* <Button label='Add' buttonClass='transparent' icon={faPlus} color='white' size='small' inClick={onClickAdd}/> */}
51
61
  <button className={`${styles.buttonItem} ${collapsed && styles.buttonItemCollapsed}`} onClick={onClickAdd}>
52
- <FontAwesomeIcon color='white' icon={faPlus} data-tip={addTitle} />
62
+ <FontAwesomeIcon color='white' icon={faPlusCircle} data-tip={addTitle} />
53
63
  {!collapsed && <span className={styles.item}>{addTitle}</span>}
54
64
  </button>
55
65
  </div>
56
66
  </>
57
67
  )}
58
68
  <HorizontalSeparator marginBottom={2} marginTop={2} />
69
+
70
+ <div className={styles.bottom}>
71
+ <Button color='white' label='Settings' type='button' onClick={() => onClickSettings()} icon={faGear} />
72
+ </div>
59
73
  </div>
60
74
  )
61
75
  }
@@ -32,6 +32,13 @@
32
32
  .items {
33
33
  @apply flex flex-col gap-y-3 py-2;
34
34
  }
35
+ .bottom {
36
+ @apply absolute left-0 bottom-[1rem] w-full px-4;
37
+ }
38
+
39
+ .bottom button {
40
+ @apply w-full;
41
+ }
35
42
 
36
43
  @keyframes fadeIn {
37
44
  0% {
@@ -3,12 +3,16 @@ import React from 'react'
3
3
  import PropTypes from 'prop-types'
4
4
  import styles from './Input.module.css'
5
5
  import commonStyles from '../Common.module.css'
6
- function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled }) {
6
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
7
+
8
+ function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled, beforeInputIcon, afterInputIcon, afterInputIconColor, onClickBeforeIcon }) {
7
9
  const className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + commonStyles.padded
8
10
  return (
9
11
  <div className={styles.container}>
10
12
  <div className={className}>
13
+ {beforeInputIcon && <FontAwesomeIcon icon={beforeInputIcon} className={styles.beforeInputIcon} data-testid='before-icon' color='white' onClick={() => onClickBeforeIcon()} />}
11
14
  <input type='text' name={name} value={value} placeholder={placeholder} className={styles.fullWidth} onChange={onChange} disabled={disabled} />
15
+ {afterInputIcon && <FontAwesomeIcon icon={afterInputIcon} className={styles[`color-${afterInputIconColor}`]} data-testid='after-icon' />}
12
16
  </div>
13
17
  {errorMessage.length > 0 && <span className={commonStyles['error-message']}>{errorMessage}</span>}
14
18
  </div>
@@ -39,7 +43,23 @@ Input.propTypes = {
39
43
  /**
40
44
  * Disabled
41
45
  */
42
- disabled: PropTypes.bool
46
+ disabled: PropTypes.bool,
47
+ /**
48
+ * beforeInputIcon
49
+ */
50
+ beforeInputIcon: PropTypes.object,
51
+ /**
52
+ * afterInputIcon
53
+ */
54
+ afterInputIcon: PropTypes.object,
55
+ /**
56
+ * afterInputIconColor
57
+ */
58
+ afterInputIconColor: PropTypes.oneOf(['error-red', 'main-dark-blue']),
59
+ /**
60
+ * onClickBeforeIcon
61
+ */
62
+ onClickBeforeIcon: PropTypes.func
43
63
  }
44
64
 
45
65
  Input.defaultProps = {
@@ -49,7 +69,11 @@ Input.defaultProps = {
49
69
  borderColor: 'main-green',
50
70
  errorMessage: '',
51
71
  onChange: () => {},
52
- disabled: false
72
+ disabled: false,
73
+ beforeInputIcon: null,
74
+ afterInputIcon: null,
75
+ onClickBeforeIcon: () => {},
76
+ afterInputIconColor: 'main-dark-blue'
53
77
  }
54
78
 
55
79
  export default Input
@@ -10,6 +10,16 @@
10
10
  .input {
11
11
  @apply focus:outline-none focus-within:outline-none focus-visible:outline-none;
12
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
+
13
23
  [type='text']:focus {
14
24
  outline: none;
15
25
  }
@@ -0,0 +1,94 @@
1
+ import React from 'react'
2
+ export default function AppEmptyIcon () {
3
+ return (
4
+ <svg
5
+ width={81}
6
+ height={80}
7
+ viewBox='0 0 81 80'
8
+ fill='none'
9
+ xmlns='http://www.w3.org/2000/svg'
10
+ >
11
+ <path
12
+ d='M34.8199 45.5671H24.4589C23.9066 45.5671 23.4589 46.0149 23.4589 46.5671V66.3802C23.4589 66.9324 23.9066 67.3802 24.4589 67.3802H56.5418C57.0941 67.3802 57.5418 66.9324 57.5418 66.3802V46.5671C57.5418 46.0149 57.0941 45.5671 56.5418 45.5671H46.1808'
13
+ stroke='#21FA90'
14
+ strokeWidth={3}
15
+ strokeLinecap='round'
16
+ />
17
+ <rect
18
+ x={34.8199}
19
+ y={67.3799}
20
+ width={11.3609}
21
+ height={5.45325}
22
+ stroke='#21FA90'
23
+ strokeWidth={3}
24
+ />
25
+ <path
26
+ d='M29.1394 73.8333C29.1394 73.281 29.5871 72.8333 30.1394 72.8333H50.8613C51.4136 72.8333 51.8613 73.281 51.8613 73.8333V76.9232H29.1394V73.8333Z'
27
+ stroke='#21FA90'
28
+ strokeWidth={3}
29
+ />
30
+ <path
31
+ d='M40.5004 42.8403L43.051 50.3765L51.3053 50.3765L44.6275 55.0342L47.1782 62.5704L40.5004 57.9128L33.8226 62.5704L36.3732 55.0342L29.6954 50.3765L37.9497 50.3765L40.5004 42.8403Z'
32
+ stroke='#21FA90'
33
+ strokeWidth={3}
34
+ strokeLinejoin='round'
35
+ />
36
+ <path
37
+ d='M19.1982 57.0413H9.25739V37.1597'
38
+ stroke='#21FA90'
39
+ strokeWidth={3}
40
+ strokeLinecap='round'
41
+ strokeLinejoin='round'
42
+ />
43
+ <path
44
+ d='M29.139 39.9999V14.4377'
45
+ stroke='#21FA90'
46
+ strokeWidth={3}
47
+ strokeLinecap='round'
48
+ strokeLinejoin='round'
49
+ />
50
+ <path
51
+ d='M61.8018 57.0414H71.7426V45.6804'
52
+ stroke='#21FA90'
53
+ strokeWidth={3}
54
+ strokeLinecap='round'
55
+ strokeLinejoin='round'
56
+ />
57
+ <path
58
+ d='M49.0207 41.4201V32.8994H58.9615V17.2781'
59
+ stroke='#21FA90'
60
+ strokeWidth={3}
61
+ strokeLinecap='round'
62
+ strokeLinejoin='round'
63
+ />
64
+ <circle
65
+ cx={9.25738}
66
+ cy={31.4793}
67
+ r={5.68047}
68
+ stroke='#21FA90'
69
+ strokeWidth={3}
70
+ />
71
+ <circle
72
+ cx={29.139}
73
+ cy={8.75738}
74
+ r={5.68047}
75
+ stroke='#21FA90'
76
+ strokeWidth={3}
77
+ />
78
+ <circle
79
+ cx={58.9615}
80
+ cy={11.5977}
81
+ r={5.68047}
82
+ stroke='#21FA90'
83
+ strokeWidth={3}
84
+ />
85
+ <circle
86
+ cx={71.7426}
87
+ cy={40.0001}
88
+ r={5.68047}
89
+ stroke='#21FA90'
90
+ strokeWidth={3}
91
+ />
92
+ </svg>
93
+ )
94
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ export default function AppEmptyIcon () {
3
+ return (
4
+ <svg
5
+ width={32}
6
+ height={33}
7
+ viewBox='0 0 32 33'
8
+ fill='none'
9
+ xmlns='http://www.w3.org/2000/svg'
10
+ >
11
+ <path
12
+ d='M12 6.75317H5C4.44772 6.75317 4 7.20089 4 7.75317V21.1132C4 21.6655 4.44772 22.1132 5 22.1132H27C27.5523 22.1132 28 21.6655 28 21.1132V7.75317C28 7.20089 27.5523 6.75317 27 6.75317H20'
13
+ stroke='#00283D'
14
+ strokeWidth={2}
15
+ strokeLinecap='round'
16
+ />
17
+ <rect
18
+ x={12}
19
+ y={22.1133}
20
+ width={8}
21
+ height={3.84}
22
+ stroke='#00283D'
23
+ strokeWidth={2}
24
+ />
25
+ <path
26
+ d='M8 26.9534C8 26.4011 8.44772 25.9534 9 25.9534H23C23.5523 25.9534 24 26.4011 24 26.9534V28.8334H8V26.9534Z'
27
+ stroke='#00283D'
28
+ strokeWidth={2}
29
+ />
30
+ <path
31
+ d='M16 4.83325L17.7961 10.14H23.6085L18.9062 13.4198L20.7023 18.7265L16 15.4468L11.2977 18.7265L13.0938 13.4198L8.39155 10.14H14.2039L16 4.83325Z'
32
+ stroke='#00283D'
33
+ strokeWidth={2}
34
+ strokeLinejoin='round'
35
+ />
36
+ </svg>
37
+ )
38
+ }
@@ -0,0 +1,69 @@
1
+ import * as React from 'react'
2
+ import styles from './Icons.module.css'
3
+ const PuzzleDynamicIcon = ({ color = 'green', size = 'normal', tip = '' }) => {
4
+ const className = `${styles.noShrinkForFlex} ` + styles[`${color}`]
5
+ let dimension = 40
6
+ switch (size) {
7
+ case 'small':
8
+ dimension = 24
9
+ break
10
+ default:
11
+ break
12
+ }
13
+ return (
14
+ <svg
15
+ width={dimension}
16
+ height={dimension}
17
+ viewBox='0 0 24 25'
18
+ fill='none'
19
+ xmlns='http://www.w3.org/2000/svg'
20
+ className={className}
21
+ >
22
+ <rect
23
+ x={3}
24
+ y={3.5}
25
+ width={6}
26
+ height={7.55245}
27
+ rx={1}
28
+ stroke='none'
29
+ strokeWidth={1.5}
30
+ />
31
+ <path
32
+ d='M12 3.5L16.5 7.25L12 11V3.5Z'
33
+ stroke='none'
34
+ strokeWidth={1.5}
35
+ strokeLinecap='round'
36
+ strokeLinejoin='round'
37
+ />
38
+ <rect
39
+ x={21}
40
+ y={21.5}
41
+ width={6}
42
+ height={7.55245}
43
+ rx={1}
44
+ transform='rotate(-180 21 21.5)'
45
+ stroke='none'
46
+ stroke-width={1.5}
47
+ />
48
+ <rect
49
+ x={12}
50
+ y={21.5}
51
+ width={9}
52
+ height={7.55245}
53
+ rx={1}
54
+ transform='rotate(-180 12 21.5)'
55
+ stroke='#21FA90'
56
+ stroke-width={1.5}
57
+ />
58
+ <path
59
+ d='M16.5 9.5V11L21 7.25L16.5 3.5V5'
60
+ stroke='none'
61
+ strokeWidth={1.5}
62
+ strokeLinecap='round'
63
+ strokeLinejoin='round'
64
+ />
65
+ </svg>
66
+ )
67
+ }
68
+
69
+ export default PuzzleDynamicIcon
@@ -1,10 +1,13 @@
1
1
  import ApiIcon from './ApiIcon'
2
2
  import ApiIconClosed from './ApiIconClosed'
3
3
  import ApiEmptyIcon from './ApiEmptyIcon'
4
+ import AppIcon from './AppIcon'
5
+ import AppEmptyIcon from './AppEmptyIcon'
4
6
  import CloseModalIcon from './CloseModalIcon'
5
7
  import RoundCloseIcon from './RoundCloseIcon'
6
8
  import RoundCloseHoverIcon from './RoundCloseHoverIcon'
7
9
  import MetricsIcon from './MetricsIcon'
10
+ import PuzzleDynamicIcon from './PuzzleDynamicIcon'
8
11
  import PuzzleIcon from './PuzzleIcon'
9
12
  import PullRequestIcon from './PullRequestIcon'
10
13
 
@@ -12,10 +15,13 @@ export default {
12
15
  ApiIcon,
13
16
  ApiIconClosed,
14
17
  ApiEmptyIcon,
18
+ AppIcon,
19
+ AppEmptyIcon,
15
20
  CloseModalIcon,
16
21
  RoundCloseIcon,
17
22
  RoundCloseHoverIcon,
18
23
  MetricsIcon,
24
+ PuzzleDynamicIcon,
19
25
  PuzzleIcon,
20
26
  PullRequestIcon
21
27
  }
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
  import { useState } from 'react'
3
- import SideBar from '../components/SideBar'
3
+ import Sidebar from '../components/Sidebar'
4
4
  import BorderedBox from '../components/BorderedBox'
5
5
 
6
6
  const divStyle = {
@@ -11,8 +11,8 @@ const divStyle = {
11
11
  }
12
12
 
13
13
  export default {
14
- title: 'Platformatic/SideBar',
15
- component: SideBar,
14
+ title: 'Platformatic/Sidebar',
15
+ component: Sidebar,
16
16
  decorators: [
17
17
  (Story) => (
18
18
  <div style={divStyle}>
@@ -23,17 +23,18 @@ export default {
23
23
  ]
24
24
  }
25
25
 
26
- const Template = (args) => <SideBar {...args} />
26
+ const Template = (args) => <Sidebar {...args} />
27
27
 
28
- export const EmptySideBar = Template.bind({})
28
+ export const EmptySidebar = Template.bind({})
29
29
 
30
- EmptySideBar.args = {
31
- title: 'SideBar bar empty',
30
+ EmptySidebar.args = {
31
+ title: 'Sidebar bar empty',
32
32
  addTitle: 'Create',
33
- onClickAdd: () => alert('clicked on add EmptySideBar')
33
+ onClickAdd: () => alert('clicked on add EmptySidebar'),
34
+ onClickSettings: () => alert('settings')
34
35
  }
35
36
 
36
- const FullSideBarTemplate = (args) => {
37
+ const FullSidebarTemplate = (args) => {
37
38
  const [items, setItems] = useState(['a very very very very very long title 1', 'Title number 2'])
38
39
  function onClickAdd () {
39
40
  const tmpItem = items.map(item => item)
@@ -42,14 +43,15 @@ const FullSideBarTemplate = (args) => {
42
43
  }
43
44
 
44
45
  return (
45
- <SideBar items={items} onClickAdd={() => onClickAdd()} {...args} />
46
+ <Sidebar items={items} onClickAdd={() => onClickAdd()} {...args} />
46
47
  )
47
48
  }
48
49
 
49
- export const FullSideBar = FullSideBarTemplate.bind({})
50
+ export const FullSidebar = FullSidebarTemplate.bind({})
50
51
 
51
- FullSideBar.args = {
52
- title: 'SideBar bar Full',
52
+ FullSidebar.args = {
53
+ title: 'Sidebar bar Full',
53
54
  addTitle: 'Create',
54
- onClickItemSelected: (index) => alert('selected: ' + index)
55
+ onClickItemSelected: (index) => alert('selected: ' + index),
56
+ onClickSettings: () => alert('settings')
55
57
  }
@@ -1,6 +1,8 @@
1
1
  'use strict'
2
2
  import React, { useState } from 'react'
3
3
  import Input from '../../components/forms/Input'
4
+ import { faAdd, faCheckCircle } from '@fortawesome/free-solid-svg-icons'
5
+
4
6
  export default {
5
7
  title: 'Platformatic/Forms/Input',
6
8
  component: Input
@@ -54,3 +56,13 @@ ValuedAndAlertChange.args = {
54
56
  name: 'test',
55
57
  placeholder: 'Platformatic'
56
58
  }
59
+
60
+ export const IconBeforeAndAfter = Template.bind({})
61
+
62
+ IconBeforeAndAfter.args = {
63
+ name: 'test',
64
+ placeholder: 'Platformatic',
65
+ beforeInputIcon: faAdd,
66
+ afterInputIcon: faCheckCircle,
67
+ afterInputIconColor: 'error-red'
68
+ }