Skip to content

Commit

Permalink
Autocomplete support for size
Browse files Browse the repository at this point in the history
  • Loading branch information
fraincs committed Apr 30, 2024
1 parent 16b5874 commit 04900c0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-badgers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@orbit-ui/transition-components": patch
---

Fixed a typing issue when using a size on Autocomplete
29 changes: 29 additions & 0 deletions packages/components/src/autocomplete/docs/Autocomplete.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,35 @@ An autocomplete trigger can have an icon.
</Story>
</Preview>

### Size

An autocomplete trigger can have different sizes.

<Preview>
<Story name="size">
<Inline alignY="center">
<Autocomplete placeholder="Planets" aria-label="Planets" size="sm">
<Item key="earth">Earth</Item>
<Item key="jupiter">Jupiter</Item>
<Item key="mars">Mars</Item>
<Item key="mercury">Mercury</Item>
<Item key="neptune">Neptune</Item>
<Item key="saturn">Saturn</Item>
<Item key="uranus">Uranus</Item>
</Autocomplete>
<Autocomplete placeholder="Planets" aria-label="Planets" size="md">
<Item key="earth">Earth</Item>
<Item key="jupiter">Jupiter</Item>
<Item key="mars">Mars</Item>
<Item key="mercury">Mercury</Item>
<Item key="neptune">Neptune</Item>
<Item key="saturn">Saturn</Item>
<Item key="uranus">Uranus</Item>
</Autocomplete>
</Inline>
</Story>
</Preview>

### Disabled

<Preview>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/autocomplete/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export interface InnerAutocompleteProps extends PopupProps, Omit<AbstractInputPr
* Additional props to render on the menu of options.
*/
overlayProps?: Partial<OverlayProps>;
/**
* An autocomplete trigger can vary in size.
*/
size?: ResponsiveProp<"sm" | "md">;
/**
* A controlled autocomplete value.
*/
Expand Down Expand Up @@ -131,6 +135,7 @@ export function InnerAutocomplete(props: InnerAutocompleteProps) {
placeholder,
readOnly,
required,
size,
validationState,
value: valueProp,
wrapperProps,
Expand Down Expand Up @@ -419,6 +424,7 @@ export function InnerAutocomplete(props: InnerAutocompleteProps) {
readOnly,
ref: triggerRef,
role: "combobox",
size,
type: "text",
validationState,
value: queryRef.current,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ export const DefaultValueNotMatching: AutocompleteStory = {
)
};

export const Size: AutocompleteStory = {
storyName: "size",
render: () => (
<Autocomplete size="sm" placeholder="Select a planet" aria-label="Planets">
<Item key="earth">Earth</Item>
<Item key="mars">Mars</Item>
<Item key="saturn">Saturn</Item>
</Autocomplete>
)
};

export const TriggerIcon: AutocompleteStory = {
storyName: "trigger icon",
Expand Down

0 comments on commit 04900c0

Please sign in to comment.