Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: placeholder to select element (#9905)
Browse files Browse the repository at this point in the history
  • Loading branch information
bojangabric authored Jan 13, 2024
1 parent eaa367c commit efbe58a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/Tabs.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Select from "@components/form/Select";
import { classNames } from "@services/utils/classNames";

export default function Tabs({ tabs, setTabs, selectedTab }) {
export default function Tabs({ tabs, setTabs, selectedTab, placeholder }) {
return (
<div>
<div className="sm:hidden">
{tabs.length > 1 && (
<Select
name="tabs"
value={selectedTab?.name}
placeholder={placeholder}
onChange={(e) =>
setTabs(tabs.find((tab) => tab.name === e.currentTarget.value))
}
Expand Down
8 changes: 7 additions & 1 deletion components/form/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { classNames } from "@services/utils/classNames";
import Label from "./Label";

export default function Select({
value,
value = "",
onChange,
options = [],
label,
name,
className,
placeholder,
...restProps
}) {
return (
Expand All @@ -27,6 +28,11 @@ export default function Select({
)}
{...restProps}
>
{placeholder && (
<option value="" disabled>
{placeholder}
</option>
)}
{options.map((option) => (
<option
className="checked:text-secondary-high checked:font-bold dark:checked:text-secondary-low-high"
Expand Down
9 changes: 8 additions & 1 deletion components/navbar/SubNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ export default function SubNav({ tabs }) {
});
};

return <Tabs tabs={tabs} setTabs={changeTab} selectedTab={selectedTab} />;
return (
<Tabs
tabs={tabs}
setTabs={changeTab}
selectedTab={selectedTab}
placeholder="Choose a category"
/>
);
}

0 comments on commit efbe58a

Please sign in to comment.