Skip to content

Commit bc8a880

Browse files
committed
progress bar format and lint
1 parent 5743e75 commit bc8a880

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

next.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ import type { NextConfig } from "next";
33
const nextConfig: NextConfig = {
44
/* config options here */
55
reactCompiler: true,
6+
async headers() {
7+
return [
8+
{
9+
source: "/(.*)",
10+
headers: [
11+
{
12+
key: "Cross-Origin-Opener-Policy",
13+
value: "same-origin",
14+
},
15+
{
16+
key: "Cross-Origin-Embedder-Policy",
17+
value: "require-corp",
18+
},
19+
],
20+
},
21+
];
22+
},
623
};
724

825
export default nextConfig;

src/components/BackgroundRemoverApp.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { Button } from "@cloudflare/kumo/components/button";
4+
import { Meter } from "@cloudflare/kumo/components/meter";
45
import { cva } from "class-variance-authority";
56
import Image from "next/image";
67
import { useState } from "react";
@@ -23,15 +24,6 @@ const previewContainerStyles = cva([
2324
"bg-[repeating-conic-gradient(#80808020_0%_25%,transparent_0%_50%)]",
2425
"bg-size-[20px_20px]",
2526
]);
26-
const progressBarContainerStyles = cva([
27-
"w-full bg-(--surface-tint) rounded-full h-2 mb-2",
28-
]);
29-
const progressBarStyles = cva([
30-
"bg-(--accent) h-2 rounded-full transition-[width] duration-300",
31-
]);
32-
const progressTextStyles = cva([
33-
"text-[0.85rem] text-(--foreground-muted) text-center",
34-
]);
3527

3628
export default function BackgroundRemoverApp() {
3729
const [imageData, setImageData] = useState<ImageData | null>(null);
@@ -71,6 +63,8 @@ export default function BackgroundRemoverApp() {
7163
const { removeBackground } = await import("@imgly/background-removal");
7264

7365
const blob = await removeBackground(imageData.src, {
66+
model: "isnet",
67+
device: "gpu",
7468
progress: (key, current, total) => {
7569
setProgress({ key, current, total });
7670
},
@@ -150,15 +144,14 @@ export default function BackgroundRemoverApp() {
150144

151145
{isProcessing && progress && (
152146
<div className="mb-4">
153-
<div className={progressBarContainerStyles()}>
154-
<div
155-
className={progressBarStyles()}
156-
style={{ width: `${progressPercent}%` }}
157-
/>
158-
</div>
159-
<p className={progressTextStyles()}>
160-
{progress.key}{progressPercent}%
161-
</p>
147+
<Meter
148+
label={
149+
progress.key.includes("fetch")
150+
? "Fetching model…"
151+
: "Removing background…"
152+
}
153+
value={progressPercent}
154+
/>
162155
</div>
163156
)}
164157

0 commit comments

Comments
 (0)