@platformatic/ui-components 0.1.102 → 0.1.103
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/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import styles from './LogoDropDown.module.css'
|
|
|
5
5
|
import PlatformaticIcon from './PlatformaticIcon'
|
|
6
6
|
import { MAIN_DARK_BLUE, SMALL, WHITE } from './constants'
|
|
7
7
|
import Logo from './Logo'
|
|
8
|
-
function LogoDropDown ({ itemSelected, items, width, height }) {
|
|
8
|
+
function LogoDropDown ({ itemSelected, items, width, height, onClickItemSelected }) {
|
|
9
9
|
const [open, setOpen] = useState(false)
|
|
10
10
|
|
|
11
11
|
function handleOpen () {
|
|
@@ -13,7 +13,7 @@ function LogoDropDown ({ itemSelected, items, width, height }) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function getItemsSelected () {
|
|
16
|
-
return items.find(item => item.id === itemSelected)?.name
|
|
16
|
+
return items.find(item => item.id === itemSelected)?.name || '...'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function onClick (callback) {
|
|
@@ -27,10 +27,15 @@ function LogoDropDown ({ itemSelected, items, width, height }) {
|
|
|
27
27
|
<div className={styles.logoContainer}>
|
|
28
28
|
<Logo width={width} height={height} color={WHITE} fillColor={MAIN_DARK_BLUE} />
|
|
29
29
|
</div>
|
|
30
|
-
<div className={styles.selectorContainer} style={{ left: width / 2, paddingLeft: width / 3 }}
|
|
31
|
-
<p className={styles.header}
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
<div className={styles.selectorContainer} style={{ left: width / 2, paddingLeft: width / 3 }}>
|
|
31
|
+
<p className={styles.header} onClick={() => onClickItemSelected()}>
|
|
32
|
+
<span className={styles.itemSelected}>{getItemsSelected()}</span>
|
|
33
|
+
</p>
|
|
34
|
+
{items.length > 1 && (
|
|
35
|
+
<div>
|
|
36
|
+
{!open && <PlatformaticIcon iconName='ArrowDownIcon' color={MAIN_DARK_BLUE} onClick={() => handleOpen()} />}
|
|
37
|
+
{open && <PlatformaticIcon iconName='ArrowUpIcon' color={MAIN_DARK_BLUE} onClick={() => handleOpen()} />}
|
|
38
|
+
</div>)}
|
|
34
39
|
</div>
|
|
35
40
|
</div>
|
|
36
41
|
{open && (
|
|
@@ -70,13 +75,18 @@ LogoDropDown.propTypes = {
|
|
|
70
75
|
id: PropTypes.string.isRequired,
|
|
71
76
|
name: PropTypes.string,
|
|
72
77
|
handleClick: PropTypes.func
|
|
73
|
-
}))
|
|
78
|
+
})),
|
|
79
|
+
/**
|
|
80
|
+
* onClickItemSelected
|
|
81
|
+
*/
|
|
82
|
+
onClickItemSelected: PropTypes.func
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
LogoDropDown.defaultProps = {
|
|
77
86
|
width: 71,
|
|
78
87
|
height: 56,
|
|
79
88
|
itemSelected: '',
|
|
80
|
-
items: []
|
|
89
|
+
items: [],
|
|
90
|
+
onClickItemSelected: () => {}
|
|
81
91
|
}
|
|
82
92
|
export default LogoDropDown
|
|
@@ -11,10 +11,13 @@
|
|
|
11
11
|
@apply relative z-10;
|
|
12
12
|
}
|
|
13
13
|
.selectorContainer {
|
|
14
|
-
@apply absolute top-[50%] translate-y-[-50%] flex items-center gap-x-1 bg-white p-0.5 pr-3 rounded-full mt-[0.5px] cursor-pointer;
|
|
14
|
+
@apply absolute top-[50%] translate-y-[-50%] flex items-center justify-between gap-x-1 bg-white p-0.5 pr-3 rounded-full mt-[0.5px] cursor-pointer min-w-[228px] max-w-[228px];
|
|
15
15
|
}
|
|
16
16
|
.header {
|
|
17
|
-
@apply flex items-center hover:cursor-pointer
|
|
17
|
+
@apply flex items-center hover:cursor-pointer text-main-dark-blue pl-4 w-[170px];
|
|
18
|
+
}
|
|
19
|
+
.itemSelected {
|
|
20
|
+
@apply text-ellipsis overflow-x-hidden whitespace-nowrap;
|
|
18
21
|
}
|
|
19
22
|
.picture {
|
|
20
23
|
@apply border border-transparent rounded-full mr-2;
|
|
@@ -15,15 +15,24 @@ const Template = ({ items }) => {
|
|
|
15
15
|
}
|
|
16
16
|
return (
|
|
17
17
|
<div>
|
|
18
|
-
<LogoDropDown items={getItems()} itemSelected={selected} />
|
|
18
|
+
<LogoDropDown items={getItems()} itemSelected={selected} onClickItemSelected={() => alert(`id selected ${selected}`)} />
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
21
|
)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const
|
|
24
|
+
export const SingleItem = Template.bind({})
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
SingleItem.args = {
|
|
27
|
+
items: [{
|
|
28
|
+
id: '1',
|
|
29
|
+
name: 'Single-item'
|
|
30
|
+
}]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const MultipleItem = Template.bind({})
|
|
34
|
+
|
|
35
|
+
MultipleItem.args = {
|
|
27
36
|
items: [{
|
|
28
37
|
id: '1',
|
|
29
38
|
name: 'Organization-name-1'
|