Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dropdown font sizes and add "no results" for autocompletes #177

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/css/src/formElements/autocomplete/autocomplete.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
display: flex;
align-items: center;
font-family: 'Open sans';
font-size: 1em;
border: 0;
background-color: #fff;
width: 100%;
Expand Down Expand Up @@ -177,6 +178,12 @@
color: var(--mdPrimaryColor);
}

.md-autocomplete__dropdown-no-results {
padding: 0.9em;
background-color: #fff;
font-style: italic;
}

/* Open state */
.md-autocomplete--open .md-autocomplete__input {
border-left: 2px solid var(--mdPrimaryColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
align-items: center;
font-family: 'Open sans';
border: 0;
font-size: 1em;
background-color: #fff;
width: 100%;
text-align: left;
Expand Down Expand Up @@ -194,6 +195,12 @@
color: var(--mdPrimaryColor);
}

.md-multiautocomplete__dropdown-no-results {
padding: 0.9em;
background-color: #fff;
font-style: italic;
}

.md-multiautocomplete__chips {
display: flex;
margin-top: 0.7em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
display: flex;
align-items: center;
font-family: 'Open sans';
font-size: 1em;
border: 0;
background-color: #fff;
text-align: left;
Expand Down
1 change: 1 addition & 0 deletions packages/css/src/formElements/select/select.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
font-family: 'Open sans';
border: 0;
background-color: #fff;
font-size: 1em;
width: 100%;
text-align: left;
padding: 0.9em;
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/formElements/MdAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface MdAutocompleteProps extends React.InputHTMLAttributes<HTMLInput
value?: string;
errorText?: string;
prefixIcon?: React.ReactNode;
noResultsText?: string;
dropdownHeight?: number;
/**
* v3.0.0: Replaces previous 'amountOfElementsShown'-prop
Expand Down Expand Up @@ -60,6 +61,7 @@ const MdAutocomplete = React.forwardRef<HTMLInputElement, MdAutocompleteProps>(
dropdownHeight,
numberOfElementsShown = null,
className,
noResultsText = 'Ingen resultat funnet',
onSelectOption,
...otherProps
},
Expand Down Expand Up @@ -265,6 +267,9 @@ const MdAutocomplete = React.forwardRef<HTMLInputElement, MdAutocompleteProps>(
</button>
);
})}
{displayedOptionsSliced.length === 0 && (
<div className="md-autocomplete__dropdown-no-results">{noResultsText}</div>
)}
</div>
)}
</MdClickOutsideWrapper>
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/formElements/MdMultiAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface MdMultiAutocompleteProps extends React.InputHTMLAttributes<HTML
showChips?: boolean;
closeOnSelect?: boolean;
prefixIcon?: React.ReactNode;
noResultsText?: string;
dropdownHeight?: number;
/**
* v3.0.0: Replaces previous 'amountOfElementsShown'-prop.
Expand Down Expand Up @@ -57,6 +58,7 @@ const MdMultiAutocomplete = React.forwardRef<HTMLInputElement, MdMultiAutocomple
dropdownHeight,
numberOfElementsShown = null,
className,
noResultsText = 'Ingen resultater funnet',
onSelectOption,
...otherProps
},
Expand Down Expand Up @@ -289,6 +291,9 @@ const MdMultiAutocomplete = React.forwardRef<HTMLInputElement, MdMultiAutocomple
</div>
);
})}
{displayedOptionsSliced.length === 0 && (
<div className="md-multiautocomplete__dropdown-no-results">{noResultsText}</div>
)}
</div>
)}
</MdClickOutsideWrapper>
Expand Down