Skip to content

Commit

Permalink
Merge pull request #15 from KryptXBSA/new-ui
Browse files Browse the repository at this point in the history
New UI
  • Loading branch information
KryptXBSA authored Dec 24, 2024
2 parents b199f27 + ced76ed commit 8b3b3ad
Show file tree
Hide file tree
Showing 92 changed files with 1,578 additions and 1,667 deletions.
14 changes: 7 additions & 7 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"privatePackages": {
"version": true,
"tag": true
Expand Down
5 changes: 5 additions & 0 deletions .changeset/neat-icons-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"web": minor
---

New UI
2 changes: 1 addition & 1 deletion apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
3 changes: 3 additions & 0 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
typescript: {
ignoreBuildErrors: true,
},
};

export default nextConfig;
57 changes: 33 additions & 24 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,60 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@dnd-kit/core": "6.0.8",
"@dnd-kit/modifiers": "6.0.1",
"@dnd-kit/sortable": "7.0.2",
"@dnd-kit/utilities": "3.2.1",
"@hookform/resolvers": "^3.9.1",
"@nanostores/persistent": "^0.10.2",
"@nanostores/react": "^0.8.2",
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.1",
"@radix-ui/react-toast": "^1.2.2",
"@nanostores/react": "^0.8.4",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-checkbox": "^1.1.3",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-popover": "^1.1.4",
"@radix-ui/react-radio-group": "^1.2.2",
"@radix-ui/react-scroll-area": "^1.2.2",
"@radix-ui/react-select": "^2.1.4",
"@radix-ui/react-separator": "^1.1.1",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.2",
"@radix-ui/react-toast": "^1.2.4",
"@vercel/analytics": "^1.4.1",
"class-variance-authority": "^0.7.1",
"classnames": "^2.5.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
"date-fns": "^4.1.0",
"formbuilder-core": "workspace:*",
"handlebars": "^4.7.8",
"immer": "^10.1.1",
"json-schema-to-zod": "^2.4.1",
"json-schema-to-zod": "^2.5.0",
"lucide-react": "0.462.0",
"nanostores": "^0.11.3",
"next": "^15.0.3",
"next-themes": "^0.4.3",
"next": "15.1.2",
"next-themes": "^0.4.4",
"ramda": "^0.30.1",
"react": "^18.3.1",
"react-day-picker": "^9.4.0",
"react-day-picker": "8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.2",
"react-icons": "^5.3.0",
"react-hook-form": "^7.54.1",
"react-icons": "^5.4.0",
"sharp": "^0.33.5",
"swapy": "^0.4.2",
"tailwind-merge": "^2.5.5",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
"zod": "^3.24.1"
},
"devDependencies": {
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/ramda": "^0.30.2",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2"
}
}
51 changes: 51 additions & 0 deletions apps/web/src/app/builder/_components/AddNewFieldArrows.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Button } from "@/components/ui/button";
import { addItem } from "@/state/state";
import {
ArrowBigUpDash,
ArrowBigDownDash,
ArrowBigLeftDash,
ArrowBigRightDash,
} from "lucide-react";

export function AddNewFieldArrows({ id }: { id: string }) {
return (
<div className="flex h-[53px] w-[380px] items-center justify-between">
<Button
className="h-full w-[20%] rounded-lg rounded-r-none border-2 border-r-0"
variant="outline"
size="icon"
onClick={() => addItem(id, "left")}
>
<ArrowBigLeftDash className="h-5 w-5" />
</Button>
<div className="flex h-full w-full flex-col justify-between">
<Button
variant="outline"
className="h-full w-full rounded-none border-t-2 border-b-0"
size="icon"
onClick={() => addItem(id, "up")}
>
<ArrowBigUpDash className="h-5 w-5" />
</Button>
<Button
variant="outline"
className="h-full w-full rounded-none border-b-2"
size="icon"
onClick={() => addItem(id, "down")}
>
<ArrowBigDownDash className="h-5 w-5" />
</Button>
</div>
<Button
variant="outline"
className="h-full w-[20%] rounded-lg rounded-l-none border-2 border-l-0"
size="icon"
onClick={() => addItem(id, "right")}
>
<ArrowBigRightDash className="h-5 w-5" />
{/* TODO: This is only shown at dev */}
{id}
</Button>
</div>
);
}
40 changes: 40 additions & 0 deletions apps/web/src/app/builder/_components/CustomSensor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { MouseEvent, KeyboardEvent } from 'react'
import {
MouseSensor as LibMouseSensor,
KeyboardSensor as LibKeyboardSensor
} from '@dnd-kit/core'

export class MouseSensor extends LibMouseSensor {
static activators = [
{
eventName: 'onMouseDown' as const,
handler: ({ nativeEvent: event }: MouseEvent) => {
return shouldHandleEvent(event.target as HTMLElement)
}
}
]
}

// export class KeyboardSensor extends LibKeyboardSensor {
// static activators = [
// {
// eventName: 'onKeyDown' as const,
// handler: ({ nativeEvent: event }: KeyboardEvent<Element>) => {
// return shouldHandleEvent(event.target as HTMLElement)
// }
// }
// ]
// }

function shouldHandleEvent(element: HTMLElement | null) {
let cur = element

while (cur) {
if (cur.dataset?.noDnd) {
return false
}
cur = cur.parentElement
}

return true
}
54 changes: 54 additions & 0 deletions apps/web/src/app/builder/_components/FormFieldContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { Settings, Trash } from "lucide-react";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { cn } from "@/lib/utils";
import { useState } from "react";
import { removeItem } from "@/state/state";

export function FormFieldContent({ id }: { id: string }) {
const [isOpen, setIsOpen] = useState(false);

return (
<Accordion id={id} className="z-50 h-full" type="single" collapsible>
<AccordionItem value="item-1">
<div className={cn("flex justify-between gap-2 p-2", { "border-b-2": isOpen })}>
<Badge variant={"outline"} className="font-semibold">
Task
</Badge>
<div className="flex justify-between gap-2">
<Button
onClick={()=>removeItem(id)}
data-no-dnd={true}
variant={"ghost"}
className="-ml-2 h-auto p-1 text-secondary-foreground/50 hover:bg-red-500"
>
<Trash />
</Button>
<AccordionTrigger asChild className="flex justify-between">
<Button
data-no-dnd={true}
variant={"ghost"}
className="-ml-2 h-auto p-1 text-secondary-foreground/50"
onClick={() => {
setIsOpen(!isOpen);
console.log(id);
}}
>
<Settings />
</Button>
</AccordionTrigger>
</div>
</div>
<AccordionContent className="px-3 py-4">
Yes. It adheres to the WAI-ARIA design pattern.
</AccordionContent>
</AccordionItem>
</Accordion>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"use client"

import * as React from "react"
import { Check, ChevronsUpDown } from "lucide-react"

import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
import type { FormFramework } from "formbuilder-core"
import { useAppState } from "@/state/state";

const frameworks: { value: FormFramework; label: string }[] = [
{
value: "next",
label: "Next.js",
},
{
value: "react",
label: "React",
},
{
value: "svelte",
label: "Svelte",
},
{
value: "vue",
label: "Vue",
},
{
value: "solid",
label: "Solid",
},
{
value: "astro",
label: "Astro",
},
]

export function FrameworkCombobox() {
const { currentForm, updateFormFramework } = useAppState();
const [open, setOpen] = React.useState(false)
const [value, setValue] = React.useState(currentForm.framework)

// React.useEffect(() => {
// setValue(currentForm.framework);
// }, [currentForm]);

return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
// biome-ignore lint/a11y/useSemanticElements: <explanation>
role="combobox"
aria-expanded={open}
className="w-[200px] justify-between"
>
{value
? frameworks.find((framework) => framework.value === value)?.label
: "Select framework..."}
<ChevronsUpDown className="opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput placeholder="Search framework..." className="h-9" />
<CommandList>
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
{frameworks.map((framework) => (
<CommandItem
key={framework.value}
value={framework.value}
onSelect={(currentValue) => {
setValue(currentValue === value ? "" : currentValue)
updateFormFramework(currentValue)
setOpen(false)
}}
>
{framework.label}
<Check
className={cn(
"ml-auto",
value === framework.value ? "opacity-100" : "opacity-0"
)}
/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
)
}
Loading

0 comments on commit 8b3b3ad

Please sign in to comment.