-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add rollup-v2 support for EtherPortal deposit form.
- Loading branch information
1 parent
e356742
commit 658a6fd
Showing
13 changed files
with
1,093 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { | ||
AutocompleteProps, | ||
Combobox, | ||
InputBase, | ||
Stack, | ||
Text, | ||
useCombobox, | ||
} from "@mantine/core"; | ||
import { useUncontrolled } from "@mantine/hooks"; | ||
import { FC } from "react"; | ||
import { Application } from "./commons/interfaces"; | ||
|
||
export interface ApplicationAutocompleteProps extends AutocompleteProps { | ||
onApplicationSelected: (app: Application) => void; | ||
applications: Application[]; | ||
} | ||
|
||
const ApplicationAutocomplete: FC<ApplicationAutocompleteProps> = (props) => { | ||
const { | ||
applications, | ||
onApplicationSelected, | ||
value, | ||
defaultValue, | ||
onChange, | ||
...rest | ||
} = props; | ||
const combobox = useCombobox(); | ||
const [_value, setValue] = useUncontrolled({ | ||
value, | ||
defaultValue, | ||
finalValue: "", | ||
onChange, | ||
}); | ||
|
||
const options = applications.map((app) => ( | ||
<Combobox.Option | ||
value={app.address} | ||
onClick={() => { | ||
onApplicationSelected(app); | ||
}} | ||
key={`${app.address}-${app.rollupVersion}`} | ||
> | ||
<Stack | ||
gap={0} | ||
style={{ | ||
borderInlineStart: | ||
".3px solid var(--mantine-primary-color-filled)", | ||
}} | ||
px="xs" | ||
> | ||
<Text size="sm">{app.address}</Text> | ||
<Text size="xs" c="dimmed"> | ||
Rollup {app.rollupVersion} | ||
</Text> | ||
</Stack> | ||
</Combobox.Option> | ||
)); | ||
|
||
return ( | ||
<Combobox | ||
onOptionSubmit={(optVal) => { | ||
setValue(optVal); | ||
combobox.closeDropdown(); | ||
}} | ||
store={combobox} | ||
> | ||
<Combobox.Target> | ||
<InputBase | ||
{...rest} | ||
value={_value} | ||
onBlur={(evt) => { | ||
combobox.closeDropdown(); | ||
rest.onBlur?.(evt); | ||
}} | ||
onFocus={(evt) => { | ||
combobox.openDropdown(); | ||
rest.onFocus?.(evt); | ||
}} | ||
onChange={(evt) => { | ||
setValue(evt.currentTarget.value); | ||
combobox.openDropdown(); | ||
combobox.updateSelectedOptionIndex(); | ||
}} | ||
/> | ||
</Combobox.Target> | ||
|
||
<Combobox.Dropdown | ||
mah="calc(13.75rem * var(--mantine-scale))" | ||
style={{ overflow: "scroll" }} | ||
> | ||
<Combobox.Options> | ||
{options.length === 0 ? ( | ||
<Combobox.Empty>No Applications found!</Combobox.Empty> | ||
) : ( | ||
options | ||
)} | ||
</Combobox.Options> | ||
</Combobox.Dropdown> | ||
</Combobox> | ||
); | ||
}; | ||
|
||
export default ApplicationAutocomplete; |
Oops, something went wrong.