Skip to content

Commit 26c3917

Browse files
committed
Feature MUI example of search bar
1 parent 8ae1e53 commit 26c3917

File tree

2 files changed

+34
-67
lines changed

2 files changed

+34
-67
lines changed

stories/MuiSearchInput.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

stories/SearchBar.stories.tsx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React, { useState } from "react";
22
import { SearchBar } from "../dist/SearchBar";
33
import { sectionName } from "./sectionName";
44
import { getStoryFactory } from "./getStory";
5-
import { MuiSearchInput } from "./MuiSearchInput";
5+
import Autocomplete from "@mui/material/Autocomplete";
6+
import { cx } from "../dist/tools/cx";
67

78
const { meta, getStory } = getStoryFactory({
89
sectionName,
@@ -143,17 +144,7 @@ function Root(){
143144
export const WithMuiAutocomplete = getStory(
144145
{
145146
"renderInput": ({ className, id, placeholder, type }) => (
146-
<MuiSearchInput
147-
className={className}
148-
id={id}
149-
placeholder={placeholder}
150-
type={type}
151-
value=""
152-
onChange={() => {
153-
/**/
154-
}}
155-
results={[]}
156-
/>
147+
<MuiSearchInput className={className} id={id} placeholder={placeholder} type={type} />
157148
)
158149
},
159150
{
@@ -214,8 +205,37 @@ function MySearchInput(props: MySearchInputProps) {
214205
)}
215206
/>
216207
\`\`\`
217-
218-
219208
`
220209
}
221210
);
211+
212+
export type MuiSearchInputProps = {
213+
className: string;
214+
id: string;
215+
placeholder: string;
216+
type: "search";
217+
};
218+
219+
const options = ["Option 1", "Option 2"];
220+
221+
export function MuiSearchInput(props: MuiSearchInputProps) {
222+
const { className, id, placeholder, type } = props;
223+
224+
return (
225+
<Autocomplete
226+
style={{ "width": "100%" }}
227+
id={id}
228+
options={options}
229+
renderInput={params => (
230+
<div ref={params.InputProps.ref}>
231+
<input
232+
{...params.inputProps}
233+
className={cx(params.inputProps.className, className)}
234+
placeholder={placeholder}
235+
type={type}
236+
/>
237+
</div>
238+
)}
239+
/>
240+
);
241+
}

0 commit comments

Comments
 (0)