jbilcke-hf HF staff commited on
Commit
c51d86a
β€’
1 Parent(s): fcdbd7f
src/app/engine/presets.ts CHANGED
@@ -406,7 +406,9 @@ export const presets: Record<string, Preset> = {
406
 
407
  export type PresetName = keyof typeof presets
408
 
409
- export const defaultPreset: PresetName = "random"
 
 
410
 
411
  export const getPreset = (preset?: PresetName): Preset => presets[preset || defaultPreset] || presets[defaultPreset]
412
 
 
406
 
407
  export type PresetName = keyof typeof presets
408
 
409
+ export const defaultPreset: PresetName = "american_comic_90"
410
+
411
+ export const nonRandomPresets = Object.keys(presets).filter(p => p !== "random")
412
 
413
  export const getPreset = (preset?: PresetName): Preset => presets[preset || defaultPreset] || presets[defaultPreset]
414
 
src/app/interface/top-menu/index.tsx CHANGED
@@ -13,12 +13,12 @@ import {
13
  } from "@/components/ui/select"
14
  import { Label } from "@/components/ui/label"
15
  import { cn } from "@/lib/utils"
16
- import { FontName, defaultFont, fontList, fonts } from "@/lib/fonts"
17
  import { Input } from "@/components/ui/input"
18
- import { PresetName, defaultPreset, getPreset, getRandomPreset, presets } from "@/app/engine/presets"
19
  import { useStore } from "@/app/store"
20
  import { Button } from "@/components/ui/button"
21
- import { LayoutName, allLayoutLabels, allLayouts, defaultLayout } from "@/app/layouts"
22
 
23
  import layoutPreview0 from "../../../../public/layouts/layout0.jpg"
24
  import layoutPreview1 from "../../../../public/layouts/layout1.jpg"
@@ -56,7 +56,7 @@ export function TopMenu() {
56
  const requestedPreset = (searchParams.get('preset') as PresetName) || defaultPreset
57
  const requestedFont = (searchParams.get('font') as FontName) || defaultFont
58
  const requestedPrompt = (searchParams.get('prompt') as string) || ""
59
- const requestedLayout = (searchParams.get('prompt') as LayoutName) || defaultLayout
60
 
61
  const [draftPrompt, setDraftPrompt] = useState(requestedPrompt)
62
  const [draftPreset, setDraftPreset] = useState<PresetName>(requestedPreset)
@@ -106,8 +106,8 @@ export function TopMenu() {
106
  <SelectValue className="text-xs md:text-sm" placeholder="Style" />
107
  </SelectTrigger>
108
  <SelectContent>
109
- {Object.entries(presets).map(([key, preset]) =>
110
- <SelectItem key={key} value={key}>{preset.label}</SelectItem>
111
  )}
112
  </SelectContent>
113
  </Select>
@@ -128,7 +128,7 @@ export function TopMenu() {
128
  <SelectValue className="text-xs md:text-sm" placeholder="Layout" />
129
  </SelectTrigger>
130
  <SelectContent>
131
- {Object.keys(allLayouts).map(key =>
132
  <SelectItem key={key} value={key} className="w-full">
133
  <div className="space-x-6 flex flex-row items-center justify-between font-mono">
134
  <div className="flex">{
 
13
  } from "@/components/ui/select"
14
  import { Label } from "@/components/ui/label"
15
  import { cn } from "@/lib/utils"
16
+ import { FontName, defaultFont } from "@/lib/fonts"
17
  import { Input } from "@/components/ui/input"
18
+ import { PresetName, defaultPreset, nonRandomPresets, presets } from "@/app/engine/presets"
19
  import { useStore } from "@/app/store"
20
  import { Button } from "@/components/ui/button"
21
+ import { LayoutName, allLayoutLabels, defaultLayout, nonRandomLayouts } from "@/app/layouts"
22
 
23
  import layoutPreview0 from "../../../../public/layouts/layout0.jpg"
24
  import layoutPreview1 from "../../../../public/layouts/layout1.jpg"
 
56
  const requestedPreset = (searchParams.get('preset') as PresetName) || defaultPreset
57
  const requestedFont = (searchParams.get('font') as FontName) || defaultFont
58
  const requestedPrompt = (searchParams.get('prompt') as string) || ""
59
+ const requestedLayout = (searchParams.get('layout') as LayoutName) || defaultLayout
60
 
61
  const [draftPrompt, setDraftPrompt] = useState(requestedPrompt)
62
  const [draftPreset, setDraftPreset] = useState<PresetName>(requestedPreset)
 
106
  <SelectValue className="text-xs md:text-sm" placeholder="Style" />
107
  </SelectTrigger>
108
  <SelectContent>
109
+ {nonRandomPresets.map(key =>
110
+ <SelectItem key={key} value={key}>{presets[key].label}</SelectItem>
111
  )}
112
  </SelectContent>
113
  </Select>
 
128
  <SelectValue className="text-xs md:text-sm" placeholder="Layout" />
129
  </SelectTrigger>
130
  <SelectContent>
131
+ {nonRandomLayouts.map(key =>
132
  <SelectItem key={key} value={key} className="w-full">
133
  <div className="space-x-6 flex flex-row items-center justify-between font-mono">
134
  <div className="flex">{
src/app/layouts/index.tsx CHANGED
@@ -271,7 +271,7 @@ export const allLayoutLabels = {
271
 
272
  export type LayoutName = keyof typeof allLayouts
273
 
274
- export const defaultLayout: LayoutName = "random"
275
 
276
  export type LayoutCategory = "square" | "fluid"
277
 
 
271
 
272
  export type LayoutName = keyof typeof allLayouts
273
 
274
+ export const defaultLayout: LayoutName = "Layout1"
275
 
276
  export type LayoutCategory = "square" | "fluid"
277
 
src/app/main.tsx CHANGED
@@ -5,7 +5,6 @@ import { useEffect, useState, useTransition } from "react"
5
  import { cn } from "@/lib/utils"
6
  import { TopMenu } from "./interface/top-menu"
7
  import { fonts } from "@/lib/fonts"
8
- import { getRandomLayoutName } from "./layouts"
9
  import { useStore } from "./store"
10
  import { Zoom } from "./interface/zoom"
11
  import { getStory } from "./queries/getStory"
 
5
  import { cn } from "@/lib/utils"
6
  import { TopMenu } from "./interface/top-menu"
7
  import { fonts } from "@/lib/fonts"
 
8
  import { useStore } from "./store"
9
  import { Zoom } from "./interface/zoom"
10
  import { getStory } from "./queries/getStory"
src/app/store/index.ts CHANGED
@@ -3,8 +3,8 @@
3
  import { create } from "zustand"
4
 
5
  import { FontName } from "@/lib/fonts"
6
- import { Preset, PresetName, getPreset, getRandomPreset } from "@/app/engine/presets"
7
- import { LayoutName, getRandomLayoutName, getRandomLayoutNames } from "../layouts"
8
  import html2canvas from "html2canvas"
9
 
10
  export const useStore = create<{
@@ -42,13 +42,13 @@ export const useStore = create<{
42
  }>((set, get) => ({
43
  prompt: "",
44
  font: "actionman",
45
- preset: getRandomPreset(),
46
  nbFrames: 1,
47
  panels: [],
48
  captions: [],
49
  showCaptions: false,
50
- layout: "random",
51
- layouts: getRandomLayoutNames(),
52
  zoomLevel: 60,
53
  page: undefined as unknown as HTMLDivElement,
54
  isGeneratingStory: false,
 
3
  import { create } from "zustand"
4
 
5
  import { FontName } from "@/lib/fonts"
6
+ import { Preset, PresetName, defaultPreset, getPreset, getRandomPreset } from "@/app/engine/presets"
7
+ import { LayoutName, defaultLayout, getRandomLayoutName, getRandomLayoutNames } from "../layouts"
8
  import html2canvas from "html2canvas"
9
 
10
  export const useStore = create<{
 
42
  }>((set, get) => ({
43
  prompt: "",
44
  font: "actionman",
45
+ preset: getPreset(defaultPreset),
46
  nbFrames: 1,
47
  panels: [],
48
  captions: [],
49
  showCaptions: false,
50
+ layout: defaultLayout,
51
+ layouts: [defaultLayout, defaultLayout],
52
  zoomLevel: 60,
53
  page: undefined as unknown as HTMLDivElement,
54
  isGeneratingStory: false,