Skip to content

Commit 7e65254

Browse files
committed
Adds disabled status to SearchBarV2
Signed-off-by: Leonardo Rossi <[email protected]>
1 parent 1e0fe98 commit 7e65254

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/components/SearchBarV2.jsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ function SearchBarV2 ({
1414
dataAttrName = '',
1515
dataAttrValue = '',
1616
inputTextClassName = '',
17-
paddingClass = ''
17+
paddingClass = '',
18+
disabled = false
1819
}) {
1920
const inputRef = useRef()
2021
const baseClassName = `${styles.container} ${paddingClass || styles.defaultPaddingClass} ` + commonStyles[`background-color-${backgroundColor}`]
2122
const [wrapperClassName, setWrapperClassName] = useState(normalClassName())
22-
const inputClassName = `${styles.input} ${inputTextClassName} `
23+
const inputClassName = `${styles.input} ${inputTextClassName} ${disabled ? styles.disabled : ''} `
2324
const [isOnFocus, setIsOnFocus] = useState(false)
2425
const [showClear, setShowClear] = useState(false)
2526
const dataProps = {}
@@ -70,7 +71,16 @@ function SearchBarV2 ({
7071
return (
7172
<div className={wrapperClassName} {...dataProps}>
7273
<PlatformaticIcon iconName='LensIcon' color={color} disabled={!isOnFocus} size={SMALL} onClick={handleSearch} />
73-
<input type='text' placeholder={placeholder} className={inputClassName} ref={inputRef} onChange={handleChange} onFocus={onFocus} onBlur={onBlur} />
74+
<input
75+
type='text'
76+
placeholder={placeholder}
77+
className={inputClassName}
78+
ref={inputRef}
79+
onChange={handleChange}
80+
onFocus={onFocus}
81+
onBlur={onBlur}
82+
disabled={disabled}
83+
/>
7484
{showClear && (
7585
<div className={styles.clearContainer}>
7686
<PlatformaticIcon iconName='CircleCloseIcon' color={color} size={SMALL} onClick={handleClear} />

src/components/SearchBarV2.module.css

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
@apply px-2 py-1.5 md:px-3 md:py-[8.5px];
2929
}
3030

31+
.disabled::placeholder {
32+
@apply text-white/30;
33+
}

src/stories/SearchBarV2.stories.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const Template = (args) => {
1111
)
1212
}
1313
export const Standard = Template.bind({})
14-
1514
Standard.args = {
1615
onChange: (value) => {
1716
console.log('Current search: ' + value)
@@ -20,3 +19,9 @@ Standard.args = {
2019
alert('Query value: ' + value)
2120
}
2221
}
22+
23+
export const Disabled = Template.bind({})
24+
Disabled.args = {
25+
disabled: true,
26+
placeholder: 'Disabled'
27+
}

0 commit comments

Comments
 (0)