Skip to content

Commit 5b88785

Browse files
fix(ui): remove transition-opacity from page icon hover reveal (#191) (#196)
* fix(ui): remove transition-opacity from page icon hover reveal (#191) Co-authored-by: Ona <no-reply@ona.com> * fix: [ci-fix] make page-images bucket migration idempotent The staging job runs `supabase db reset --linked` which drops the public schema but not the storage schema. The INSERT INTO storage.buckets and CREATE POLICY statements failed on re-runs because the objects already existed. Added ON CONFLICT DO NOTHING for the bucket insert and wrapped policies in DO blocks with duplicate_object exception handlers. Co-authored-by: Ona <no-reply@ona.com> --------- Co-authored-by: Ona <no-reply@ona.com>
1 parent 5df0ce5 commit 5b88785

3 files changed

Lines changed: 51 additions & 14 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, it, expect } from "vitest";
2+
import { readFileSync } from "fs";
3+
import { join } from "path";
4+
5+
/**
6+
* Regression test for issue #191: the "Add icon" hover-reveal button
7+
* must not use transition-opacity. Design spec requires instant hover states.
8+
*/
9+
describe("page-icon design spec compliance", () => {
10+
const source = readFileSync(join(__dirname, "page-icon.tsx"), "utf-8");
11+
12+
it("hover-reveal wrapper does not use transition classes", () => {
13+
// Design spec: "Hover states: no transition (instant)."
14+
// The opacity-0 → opacity-100 hover reveal must be instant.
15+
const lines = source.split("\n");
16+
const hoverRevealLines = lines.filter(
17+
(line) =>
18+
line.includes("opacity-0") &&
19+
line.includes("group-hover")
20+
);
21+
22+
for (const line of hoverRevealLines) {
23+
expect(line).not.toContain("transition-opacity");
24+
expect(line).not.toMatch(/duration-\d+/);
25+
}
26+
});
27+
});

src/components/page-icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function PageIcon({ pageId, initialIcon }: PageIconProps) {
6666
}
6767

6868
return (
69-
<div className="mb-1 opacity-0 group-hover/page-header:opacity-100 transition-opacity">
69+
<div className="mb-1 opacity-0 group-hover/page-header:opacity-100">
7070
<EmojiPicker
7171
open={open}
7272
onOpenChange={setOpen}

supabase/migrations/20260417165531_create_page_images_bucket.sql

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,32 @@ VALUES (
88
true,
99
5242880, -- 5 MB
1010
ARRAY['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/svg+xml']
11-
);
11+
)
12+
ON CONFLICT (id) DO NOTHING;
1213

1314
-- Authenticated users can upload images
14-
CREATE POLICY "Authenticated users can upload page images"
15-
ON storage.objects FOR INSERT
16-
TO authenticated
17-
WITH CHECK (bucket_id = 'page-images');
15+
DO $$ BEGIN
16+
CREATE POLICY "Authenticated users can upload page images"
17+
ON storage.objects FOR INSERT
18+
TO authenticated
19+
WITH CHECK (bucket_id = 'page-images');
20+
EXCEPTION WHEN duplicate_object THEN NULL;
21+
END $$;
1822

1923
-- Anyone can view uploaded images (public bucket)
20-
CREATE POLICY "Public read access for page images"
21-
ON storage.objects FOR SELECT
22-
TO public
23-
USING (bucket_id = 'page-images');
24+
DO $$ BEGIN
25+
CREATE POLICY "Public read access for page images"
26+
ON storage.objects FOR SELECT
27+
TO public
28+
USING (bucket_id = 'page-images');
29+
EXCEPTION WHEN duplicate_object THEN NULL;
30+
END $$;
2431

2532
-- Image owners can delete their uploads
26-
CREATE POLICY "Users can delete own page images"
27-
ON storage.objects FOR DELETE
28-
TO authenticated
29-
USING (bucket_id = 'page-images' AND (storage.foldername(name))[1] = 'uploads' AND auth.uid() = owner);
33+
DO $$ BEGIN
34+
CREATE POLICY "Users can delete own page images"
35+
ON storage.objects FOR DELETE
36+
TO authenticated
37+
USING (bucket_id = 'page-images' AND (storage.foldername(name))[1] = 'uploads' AND auth.uid() = owner);
38+
EXCEPTION WHEN duplicate_object THEN NULL;
39+
END $$;

0 commit comments

Comments
 (0)