Skip to content

Commit

Permalink
feat: ✨ Add funcionality to editor bottom bar controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoannis Sánchez Soto committed Nov 16, 2024
1 parent ba8ea63 commit 1b5a2ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
33 changes: 25 additions & 8 deletions components/editor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @next/next/no-img-element */
"use client"

import { FormEvent, useEffect, useState } from "react"
import { FormEvent, useEffect, useRef, useState } from "react"
import Image from "next/image"
import { Config, removeBackground } from "@imgly/background-removal"
import { sendGAEvent } from "@next/third-parties/google"
Expand Down Expand Up @@ -42,6 +42,7 @@ import ImageSettings from "./settings/ImageSettings"
import { ThemeToggle } from "./theme-toggle"

export const Editor = () => {
const editor = useRef<InfiniteViewer>(null)
const [show, setShow] = useState(false)

const [files, setFiles] = useState<File[] | null>([])
Expand Down Expand Up @@ -177,6 +178,7 @@ export const Editor = () => {
return (
<>
<InfiniteViewer
ref={editor}
className="viewer my-2 h-screen w-screen"
margin={0}
threshold={0}
Expand Down Expand Up @@ -288,19 +290,34 @@ export const Editor = () => {
<Download></Download>
</Button>

<Button size={"icon"} variant={"ghost"}>
<Settings></Settings>
</Button>

<Button size={"icon"} variant={"ghost"}>
<Button
onClick={() =>
editor.current?.setZoom(editor.current.getZoom() + 0.2)
}
size={"icon"}
variant={"ghost"}
>
<ZoomIn></ZoomIn>
</Button>

<Button size={"icon"} variant={"ghost"}>
<Button
onClick={() =>
editor.current?.setZoom(editor.current.getZoom() - 0.2)
}
size={"icon"}
variant={"ghost"}
>
<ZoomOut></ZoomOut>
</Button>

<Button size={"icon"} variant={"ghost"}>
<Button
onClick={() => {
editor.current?.setZoom(1)
editor.current?.scrollCenter()
}}
size={"icon"}
variant={"ghost"}
>
<ScanEye></ScanEye>
</Button>

Expand Down
12 changes: 5 additions & 7 deletions components/settings/ImageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function ImageSettings({
return (
<div className="flex flex-col gap-4">
{/* Name */}
<div>
<div className="flex flex-col gap-2">
<label className="text-sm font-medium">Image Name</label>
<Input
disabled
Expand All @@ -40,7 +40,7 @@ export default function ImageSettings({
</div>

{/* Remove */}
<div>
<div className="flex flex-col gap-2">
<label className="flex items-center text-sm font-medium">
Remove
<Tooltip>
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function ImageSettings({
</div>

{/* Model */}
<div>
<div className="flex flex-col gap-2">
<label className="flex items-center text-sm font-medium">
Model
<Tooltip>
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function ImageSettings({
</div>

{/* Quality */}
<div>
<div className="flex flex-col gap-2">
<label className="flex items-center text-sm font-medium">
Quality
<Tooltip>
Expand All @@ -138,7 +138,7 @@ export default function ImageSettings({
</div>

{/* Format */}
<div>
<div className="flex flex-col gap-2">
<label className="flex items-center text-sm font-medium">
Format
<Tooltip>
Expand All @@ -164,8 +164,6 @@ export default function ImageSettings({
</SelectContent>
</Select>
</div>

<Button onClick={() => console.log(settings)}>Save Settings</Button>
</div>
)
}

0 comments on commit 1b5a2ad

Please sign in to comment.