Skip to content

Commit

Permalink
feat(ui): adjust more of the ui/ux
Browse files Browse the repository at this point in the history
  • Loading branch information
prostarz committed Jan 3, 2025
1 parent 485d7e1 commit aa6494d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 17 deletions.
42 changes: 42 additions & 0 deletions src/components/inputWithIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { cn } from "@/lib";
import React, { forwardRef, InputHTMLAttributes } from "react";
import { Input } from "./ui/input";

interface Props extends InputHTMLAttributes<HTMLInputElement> {
startIcon?: React.ReactElement;
endIcon?: React.ReactElement;
divClassName?: string;
}

export const InputWithIcon = forwardRef<HTMLInputElement, Props>(
({ className, type, startIcon, endIcon, divClassName, ...props }, ref) => {
const StartIcon = startIcon;
const EndIcon = endIcon;

return (
<div className={cn("relative w-full", divClassName)}>
{StartIcon && (
<div className="absolute left-1.5 top-1/2 transform -translate-y-1/2 *:size-4 text-muted-foreground">
{startIcon}
</div>
)}

<Input
type={type}
className={cn({
"pl-8": startIcon,
"pr-8": endIcon,
})}
ref={ref}
{...props}
/>

{EndIcon && (
<div className="absolute transform -translate-y-1/2 right-3 top-1/2 *:size-4 text-muted-foreground">
{endIcon}
</div>
)}
</div>
);
}
);
2 changes: 1 addition & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const buttonVariants = cva(
variant: {
default: "bg-muted text-secondary-foreground hover:bg-muted/50",
active:
"bg-primary/40 text-secondary-foreground hover:bg-primary/60 border-2 border-primary",
"bg-primary/80 text-secondary-foreground hover:bg-primary/90 border-2 border-primary",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
success: "bg-green-700 text-secondary-foreground hover:bg-green-700/90",
Expand Down
8 changes: 4 additions & 4 deletions src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("animate-pulse rounded-md bg-primary/10", className)}
className={cn("animate-pulse rounded-md bg-secondary/10", className)}
{...props}
/>
)
);
}

export { Skeleton }
export { Skeleton };
7 changes: 4 additions & 3 deletions src/features/search/components/search.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Input } from "@/components/ui/input";
import { PopoverContent } from "@/components/ui/popover";
import { useLanguageContext } from "@/contexts/I18N";

import { ShipWheel } from "lucide-react";
import { InputWithIcon } from "@/components/inputWithIcon";
import { SearchIcon, ShipWheel } from "lucide-react";
import { useState } from "react";
import useSearch from "../hooks/useSearch";
import SearchCard from "./card";
Expand All @@ -20,11 +20,12 @@ const Search = ({
<PopoverContent side="right" className="p-0 mt-10 w-96">
<div className="grid gap-4">
<div className="w-full px-4 pt-4">
<Input
<InputWithIcon
placeholder={t("search_placeholder")}
className="w-full"
onChange={(e) => setSearchTerm(e.target.value)}
value={searchTerm}
startIcon={<SearchIcon />}
/>
</div>

Expand Down
4 changes: 3 additions & 1 deletion src/features/settings/components/tabs/container.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PropsWithChildren } from "react";

const SettingsContainer = ({ children }: PropsWithChildren) => {
return <div className="flex flex-col gap-4 p-4 px-7">{children}</div>;
return (
<div className="relative flex flex-col gap-4 p-4 px-7">{children}</div>
);
};

export default SettingsContainer;
20 changes: 13 additions & 7 deletions src/features/settings/components/tabs/plugins/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { InputWithIcon } from "@/components/inputWithIcon";
import { Button } from "@/components/ui/button";
import { Dialog, DialogTrigger } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { useLanguageContext } from "@/contexts/I18N";
import { Plus } from "lucide-react";
import { Filter, Plus, SearchIcon } from "lucide-react";
import { useEffect, useState } from "react";
import { SettingsSection } from "../../section";
import SettingTitle from "../../title";
Expand All @@ -34,7 +34,7 @@ const PluginSettings = () => {
}, []);

return (
<div>
<div className="relative w-full h-[calc(100vh-3rem)]">
<SettingTitle>{t("settings.titles.plugins")}</SettingTitle>

<SettingsContainer>
Expand All @@ -43,24 +43,26 @@ const PluginSettings = () => {
<div className="flex items-center justify-between">
<div className="flex w-full gap-4">
{/* Search Input */}
<Input
className="w-1/2"
<InputWithIcon
divClassName="w-1/3"
placeholder={t("what_plugin_are_you_looking_for")}
type="text"
value={search}
onChange={(e) => setSearch(e.target.value)}
startIcon={<SearchIcon />}
/>

{/* Add Plugin Button */}
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger>
<Tooltip>
<TooltipTrigger>
<Button variant="ghost" size="icon">
<Button className="gap-2">
<Plus />
{t("install_plugin")}
</Button>
</TooltipTrigger>
<TooltipContent>{t("add_local_plugin")}</TooltipContent>
<TooltipContent>{t("install_plugin")}</TooltipContent>
</Tooltip>
</DialogTrigger>
<AddPluginModal setOpen={setOpen} open={open} />
Expand Down Expand Up @@ -90,6 +92,10 @@ const PluginSettings = () => {
/>
</SettingsSection>
</SettingsContainer>

<div className="absolute p-3 rounded-full bottom-5 right-5 bg-muted">
<Filter size={24} />
</div>
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/translations/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@
"steam_id": "Steam ID",
"wine_prefix_folder": "Wine Prefix Folder",
"the_path_to_your_wine_prefix_folder": "The path to your wine prefix folder",
"import_from_igdb": "Import From IGDB"
"import_from_igdb": "Import From IGDB",
"install_plugin": "Install Plugin"
}

0 comments on commit aa6494d

Please sign in to comment.