Skip to content

Commit 7f1d4bf

Browse files
authored
Merge pull request #21 from peelar/refactor/looks-to-layouts
refactor: looks to layouts
2 parents a640345 + 946af21 commit 7f1d4bf

55 files changed

Lines changed: 3572 additions & 975 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Get pnpm version from package.json
22+
id: pnpm-version
23+
run: |
24+
PNPM_VERSION=$(node -p "require('./package.json').packageManager?.replace('pnpm@', '') || ''")
25+
echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: ${{ steps.pnpm-version.outputs.version }}
31+
32+
- name: Get pnpm store directory
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36+
37+
- name: Setup pnpm cache
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ env.STORE_PATH }}
41+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pnpm-store-
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Typecheck
49+
run: pnpm typecheck
50+
51+
- name: Run domain tests
52+
run: pnpm test:domain
53+
54+
- name: Run UI tests
55+
run: pnpm test:ui
56+
57+
- name: Install Playwright browsers
58+
run: pnpm exec playwright install --with-deps chromium
59+
60+
- name: Run E2E tests
61+
run: pnpm test:e2e
62+

app/page.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CoverPreview } from "@/components/cover-preview";
55
import { DragOverlay } from "@/components/drag-overlay";
66
import { MobileActions } from "@/components/mobile-actions";
77
import { PlaygroundWorkspace } from "@/components/playground-workspace";
8-
import { LookSelector } from "@/components/look-selector";
8+
import { LayoutSelector } from "@/components/layout-selector";
99
import { LayoutConfigPanel } from "@/components/layout-config";
1010
import { usePlaygroundController } from "@/hooks/use-playground-controller";
1111
import { cn } from "@/utils";
@@ -49,7 +49,6 @@ export default function PlaygroundPage() {
4949
shouldShowAspectLock,
5050
isAspectLocked,
5151
canvas,
52-
handleVariantChange,
5352
toggleCanvasMode,
5453
handleExport,
5554
handleFileProcess,
@@ -93,15 +92,14 @@ export default function PlaygroundPage() {
9392
{/* Left: Content Column (Looks Rail + Preview) */}
9493
<div className="flex min-h-0 flex-1 flex-col">
9594
<div className="bg-muted/20 pl-4 sm:pl-8">
96-
<LookSelector />
95+
<LayoutSelector />
9796
</div>
9897

9998
<div className="border-b border-border pl-4 sm:pl-12" />
10099

101100
<div className="flex-1 overflow-auto px-4 pb-12 sm:px-8 sm:pb-10">
102101
<PlaygroundWorkspace
103102
isMobile={isMobile}
104-
onVariantChange={handleVariantChange}
105103
shouldShowAspectLock={shouldShowAspectLock}
106104
isAspectLocked={isAspectLocked}
107105
onToggleAspect={toggleCanvasMode}

components/cover-preview.tsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { useAtomValue } from "jotai";
44
import { cn } from "@/utils";
5-
import { canvasAtom, currentLookAtom } from "@/hooks/atoms/derived";
6-
import { getLookComponent } from "@/components/looks/registry";
5+
import { canvasAtom, currentLayoutAtom } from "@/hooks/atoms/derived";
6+
import { getLayoutComponent } from "@/components/layouts/registry";
77

88
interface CoverPreviewProps {
99
className?: string;
@@ -12,10 +12,10 @@ interface CoverPreviewProps {
1212
}
1313

1414
export function CoverPreview({ className, onUploadAsset, isStatic = false }: CoverPreviewProps) {
15-
const look = useAtomValue(currentLookAtom);
15+
const layout = useAtomValue(currentLayoutAtom);
1616
const canvasDimensions = useAtomValue(canvasAtom);
1717

18-
if (!look) {
18+
if (!layout) {
1919
return (
2020
<div
2121
className={cn(
@@ -30,25 +30,12 @@ export function CoverPreview({ className, onUploadAsset, isStatic = false }: Cov
3030
);
3131
}
3232

33-
const LookComponent = getLookComponent(look.id);
34-
35-
if (!LookComponent) {
36-
return (
37-
<div
38-
className={cn(
39-
"flex items-center justify-center bg-white",
40-
isStatic ? "" : "rounded-lg",
41-
className,
42-
)}
43-
style={{ aspectRatio: "1280 / 720" }}
44-
>
45-
<span className="text-sm text-slate-500">Component not found</span>
46-
</div>
47-
);
48-
}
33+
// getLayoutComponent throws an error if component is not found
34+
// This ensures we catch missing component registrations immediately
35+
const LayoutComponent = getLayoutComponent(layout.id);
4936

5037
// Code snippet look should not have fixed aspect ratio
51-
const useFluidLayout = look.id === "code-snippet";
38+
const useFluidLayout = layout.id === "code-snippet";
5239

5340
return (
5441
<div
@@ -61,7 +48,7 @@ export function CoverPreview({ className, onUploadAsset, isStatic = false }: Cov
6148
}
6249
}
6350
>
64-
<LookComponent onUploadAsset={onUploadAsset} isStatic={isStatic} />
51+
<LayoutComponent onUploadAsset={onUploadAsset} isStatic={isStatic} />
6552
</div>
6653
);
6754
}

components/gradient-picker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function GradientPicker({ onChangeAction }: GradientPickerProps) {
9494
config.background ?? ({ type: "gradient", value: "custom" } as BackgroundConfig);
9595
const colorPalette = screenshotAsset?.colorPalette;
9696
const hasScreenshot = Boolean(config.assets?.screenshot);
97-
const isCodeSnippet = config.lookId === "code-snippet";
97+
const isCodeSnippet = config.layoutId === "code-snippet";
9898

9999
// Generate multi-stop gradients from screenshot colors
100100
// Code snippets should never use screenshot-derived gradients

components/layout-config.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Asset } from "@/domain/asset/types";
66
import { UploadCloud, X } from "lucide-react";
77
import { cn } from "@/utils";
88
import { configAtom } from "@/hooks/atoms";
9-
import { lookCapabilitiesAtom, screenshotAssetAtom, logoAssetAtom } from "@/hooks/atoms/derived";
9+
import { layoutCapabilitiesAtom, screenshotAssetAtom, logoAssetAtom } from "@/hooks/atoms/derived";
1010
import {
1111
Accordion,
1212
AccordionContent,
@@ -17,7 +17,7 @@ import { useSidebarState } from "@/hooks/use-sidebar-state";
1717
import { ScreenshotSection } from "@/components/sidebar-sections/screenshot-section";
1818
import { LogoSection } from "@/components/sidebar-sections/logo-section";
1919
import { BackgroundSection } from "@/components/sidebar-sections/background-section";
20-
import { LookSection } from "@/components/sidebar-sections/look-section";
20+
import { LayoutSection } from "@/components/sidebar-sections/layout-section";
2121
import { EffectsSection } from "@/components/sidebar-sections/effects-section";
2222
import { CodeSection } from "@/components/sidebar-sections/code-section";
2323

@@ -29,12 +29,12 @@ export const LayoutConfigPanel = ({ onUploadAsset }: LayoutConfigProps) => {
2929
const config = useAtomValue(configAtom);
3030
const screenshotAsset = useAtomValue(screenshotAssetAtom);
3131
const logoAsset = useAtomValue(logoAssetAtom);
32-
const lookCapabilities = useAtomValue(lookCapabilitiesAtom);
32+
const lookCapabilities = useAtomValue(layoutCapabilitiesAtom);
3333

3434
const { expandedSection, expandSection } = useSidebarState();
3535

3636
const showLogoSection = lookCapabilities?.logo !== "hidden";
37-
const showCodeSection = config.lookId === "code-snippet";
37+
const showCodeSection = config.layoutId === "code-snippet";
3838
const showTextSection = !showCodeSection;
3939

4040
// Initialize default expansion based on state
@@ -73,7 +73,7 @@ export const LayoutConfigPanel = ({ onUploadAsset }: LayoutConfigProps) => {
7373
</div>
7474
</AccordionTrigger>
7575
<AccordionContent className="px-4 pb-4">
76-
<LookSection />
76+
<LayoutSection />
7777
</AccordionContent>
7878
</AccordionItem>
7979
)}

0 commit comments

Comments
 (0)