Skip to content

Commit ecc3cb7

Browse files
Merge pull request #313 from dd3tech/fix/adjustment-multiselect-component
Fix: Small adjustments were made to single select and multi select components
2 parents cefee7d + d5ce082 commit ecc3cb7

6 files changed

Lines changed: 38 additions & 10 deletions

File tree

src/components/Badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Badge = ({ value, variant = 'default' }: IBadge) => {
3535
'rounded-full text-xs font-medium px-1 text-white',
3636
badgeColor
3737
)}
38-
style={{ height: 24, width: 24 }}
38+
style={{ height: 24, width: 24, minWidth: 24, minHeight: 24 }}
3939
>
4040
{value}
4141
</Flex>

src/components/Form/MultiSelect.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function MultiSelect({
228228
<span>{labelAll || 'All'}</span>
229229
</li>
230230
{options.map((option) => (
231-
<li key={option.value} className="flex items-center mb-1">
231+
<li key={option.value} className="flex items-center my-2">
232232
<input
233233
type="checkbox"
234234
checked={selectedOptions.some(
@@ -247,15 +247,17 @@ function MultiSelect({
247247
</ul>
248248
</div>
249249

250-
<Flex justifyContent="around" className="border-t py-2">
250+
<Flex justifyContent="between" className="border-t pt-3 pb-2">
251251
<Button
252+
className="w-full"
252253
variant="ghost"
253254
size="small"
254255
onClick={buttonClear?.onClick || handleClear}
255256
>
256257
{buttonClear?.label}
257258
</Button>
258259
<Button
260+
className="w-full"
259261
size="small"
260262
onClick={onSubmit}
261263
paddingX="6"

src/components/Form/SingleSelect.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ function SingleSelect({
130130

131131
useEffect(() => {
132132
if (!value) return
133-
const selected = optionsList.find((option) => option.value === value)
134-
setSelectedOption(selected ?? null)
135133
setOptions(
136134
optionsList.map((option) =>
137135
option.value === value ? { ...option, selected: true } : option
@@ -155,11 +153,11 @@ function SingleSelect({
155153
<div className="relative">
156154
<input
157155
{...otherProps}
158-
value={selectedOption?.label ?? optionsList?.[0]?.label}
156+
value={selectedOption?.label ?? label}
159157
className={composeClasses(
160158
'outline-none w-full font-medium bg-transparent truncate text-sm'
161159
)}
162-
placeholder=""
160+
placeholder="skjfafkhad"
163161
readOnly
164162
style={{
165163
cursor: 'inherit',

src/components/TableV2/base/Accordion.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react'
22
import { composeClasses } from 'lib/classes'
33
import ChevronUpIcon from '@heroicons/react/outline/ChevronUpIcon'
4+
import Tooltip from 'components/Tooltip'
45

56
export interface AccordionProps {
67
/**
@@ -13,9 +14,13 @@ export interface AccordionProps {
1314
* 0 is the position of the first column
1415
*/
1516
iconPosition?: number
17+
/**
18+
* Tooltip text
19+
*/
20+
tooltip?: string
1621
}
1722

18-
const Accordion = ({ children, iconPosition = 0 }: AccordionProps) => {
23+
const Accordion = ({ children, iconPosition = 0, tooltip }: AccordionProps) => {
1924
const [toggle, setToggle] = useState(false)
2025

2126
const onClick = () => {
@@ -29,7 +34,19 @@ const Accordion = ({ children, iconPosition = 0 }: AccordionProps) => {
2934
(cell, index) => {
3035
if (index === iconPosition) {
3136
return React.cloneElement(cell, {
32-
children: (
37+
children: tooltip ? (
38+
<Tooltip content={tooltip}>
39+
<div className="flex items-center">
40+
{cell.props.children}
41+
<ChevronUpIcon
42+
className={composeClasses(
43+
'h-4 w-4 duration-300 ease-in ml-3',
44+
!toggle && 'transform rotate-180'
45+
)}
46+
/>
47+
</div>
48+
</Tooltip>
49+
) : (
3350
<div className="flex items-center">
3451
{cell.props.children}
3552
<ChevronUpIcon

src/components/TableV2/base/TableCell.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export interface CellProps
9191
* Show a shadow when cell is sticky left
9292
*/
9393
leftStickyShadow?: boolean
94+
/**
95+
* Is accordion
96+
*/
97+
isAccordion?: boolean
9498
}
9599

96100
const Cell = ({
@@ -113,6 +117,7 @@ const Cell = ({
113117
cellColor,
114118
variant = 'default',
115119
children,
120+
isAccordion,
116121
to,
117122
...props
118123
}: CellProps) => {
@@ -194,6 +199,7 @@ const Cell = ({
194199
/>
195200
) : isSimpleChildren ? (
196201
<CellText
202+
isAccordion={isAccordion}
197203
type={type}
198204
align={align}
199205
defaultValue={defaultValue}

src/components/TableV2/base/TableCellText.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export interface CellTextProps
2929
* Show default value
3030
*/
3131
showDefaultValue?: boolean
32+
/**
33+
* Is accordion
34+
*/
35+
isAccordion?: boolean
3236
}
3337

3438
const CellText = ({
@@ -38,6 +42,7 @@ const CellText = ({
3842
showDefaultValue,
3943
children,
4044
to,
45+
isAccordion,
4146
...props
4247
}: CellTextProps) => {
4348
const getTextAlignment = () => {
@@ -80,7 +85,7 @@ const CellText = ({
8085
getTextAlignment()
8186
)}
8287
onClick={(e) => {
83-
e.stopPropagation()
88+
!isAccordion && e.stopPropagation()
8489
to?.()
8590
}}
8691
>

0 commit comments

Comments
 (0)