8000 wip by mattallty · Pull Request #341 · upstart-gg/upstart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wip #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

wip #341

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"useSingleVarDeclarator": "off"
},
"a11y": {
"useKeyWithClickEvents": "off"
"useKeyWithClickEvents": "off",
"noLabelWithoutControl": "off",
"useSemanticElements": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"packageManager": "pnpm@10.8.0",
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@biomejs/biome": "1.9.4",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.8",
"@vitest/ui": "2.1.9",
Expand Down
1 change: 1 addition & 0 deletions packages/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/base/reset.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/components/navbar.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/components/button.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/components/card.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/utilities/join.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/utilities/typography.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daisyui@5/utilities/radius.css" />
Expand Down
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"typescript": "^5.8.3",
"vite": "5.4.10",
"vite-plugin-bundlesize": "0.2.0",
"vite-plugin-devtools-json": "0.2.0",
"vite-plugin-dts": "4.5.4",
"vite-plugin-inspect": "0.8.7"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { sectionSchema } from "@upstart.gg/sdk/shared/bricks";
import { getSchemaObjectDefaults } from "@upstart.gg/sdk/shared/utils/schema";
import { useCallback, useMemo } from "react";
import { merge } from "lodash-es";
import { useAttributes, usePreviewMode } from "~/editor/hooks/use-editor";
import { useAttributes, useDraft, useDraftHelpers, usePreviewMode } from "~/editor/hooks/use-editor";
import { getNavItemsFromManifest, type SchemaFilter } from "./json-form/form-utils";
import type { AttributesSchema } from "@upstart.gg/sdk/shared/attributes";
import type { Attributes, AttributesSchema } from "@upstart.gg/sdk/shared/attributes";

type AttributesSettingsViewProps = {
attributesSchema: AttributesSchema;
Expand All @@ -20,6 +20,7 @@ export default function AttributesSettingsView({
}: AttributesSettingsViewProps) {
const previewMode = usePreviewMode();
const attr = useAttributes();
const draft = useDraft();
const filter: SchemaFilter = (prop) => {
return (
(typeof prop.metadata?.["ui:responsive"] === "undefined" ||
Expand All @@ -38,8 +39,10 @@ export default function AttributesSettingsView({
return merge({}, defProps, attr ?? {});
}, [attr, attributesSchema]);

const Record<string, unknown>, propertyChangedPath: string) => {
console.log("onChange", data, propertyChangedPath);
// biome-ignore lint/correctness/useExhaustiveDependencies: draft.updateAttributes is a stable function
const Record<string, unknown>, propertyChanged: string) => {
console.log("changed attr %o", data);
draft.updateAttributes(data as Attributes);
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useDraftHelpers, useGetBrick, usePreviewMode } from "~/editor/hooks/use
import { defaultProps } from "@upstart.gg/sdk/shared/bricks/manifests/all-manifests";
import { getNavItemsFromManifest, type SchemaFilter } from "./json-form/form-utils";
import { tx } from "@upstart.gg/style-system/twind";
import { useLocalStorage } from "usehooks-ts";

type BrickSettingsViewProps = {
brick: Brick;
Expand All @@ -18,6 +19,7 @@ type BrickSettingsViewProps = {
export default function BrickSettingsView({ brick, group }: BrickSettingsViewProps) {
const { updateBrickProps } = useDraftHelpers();
const manifest = useBrickManifest(brick.type);
const [showAdvanced, setShowAdvanced] = useLocalStorage("upstart:editor:show-advanced", false);
const previewMode = usePreviewMode();
const getBrickInfo = useGetBrick();
const brickInfo = getBrickInfo(brick.id);
Expand All @@ -26,7 +28,8 @@ export default function BrickSettingsView({ brick, group }: BrickSettingsViewPro
(typeof prop.metadata?.["ui:responsive"] === "undefined" ||
prop.metadata?.["ui:responsive"] === true ||
prop.metadata?.["ui:responsive"] === previewMode) &&
(!prop.metadata?.category || prop.metadata?.category === "settings")
(!prop.metadata?.category || prop.metadata?.category === "settings") &&
(!prop["ui:advanced"] || showAdvanced)
/* &&
(!group || !prop.metadata?.group || (prop.metadata?.group && key === group))*/
);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/editor/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ContextMenuWrapper = ({ children }: ComponentProps<"div">) => {
const target = e.target as HTMLElement | null;
const isBrick = target?.matches("[data-brick]");
const isBrickChild = target?.closest("[data-brick]");
const brickElement = (isBrick ? target : isBrickChild ?? null) as HTMLElement | null;
const brickElement = (isBrick ? target : (isBrickChild ?? null)) as HTMLElement | null;

if (brickElement) {
const brickId = brickElement.getAttribute("id");
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/editor/components/EditablePage.tsx
CEB7
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export default function EditablePage({ showIntro }: EditablePageProps) {
// updateDragOverGhostStyle(null);

if (position) {
console.debug("New brick dropped at", position, section);
const bricksDefaults = defaultProps[brickType];

// @ts-igneore
Expand All @@ -122,6 +121,8 @@ export default function EditablePage({ showIntro }: EditablePageProps) {
: null;
const hoveredBrickManifest = hoveredBrick ? manifests[hoveredBrick.type] : null;

console.debug("New brick dropped at", { position, section, hoveredBrick });

// Add the new brick to the store
// Specify the parent if we dropped on a container
draft.addBrick(
Expand All @@ -130,6 +131,8 @@ export default function EditablePage({ showIntro }: EditablePageProps) {
hoveredBrick && hoveredBrickManifest?.isContainer ? hoveredBrick.id : null,
);

console.log("New brick added", newBrick, section.id);

if (previewMode === "desktop") {
startTransition(() => {
draft.adjustMobileLayout();
Expand Down
32 changes: 28 additions & 4 deletions packages/components/src/editor/components/EditableSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export default function EditableSection({ section }: EditableSectionProps) {
</EditableBrickWrapper>
);
})}

{bricks.length === 0 && (
<div className="absolute h-40 text-center inset-2 rounded bg-gray-100 flex justify-center items-center text-base text-black/50 font-medium">
This is a section.
<br />
Drag bricks here to stack them inside.
</div>
)}
</section>
);
}
Expand Down Expand Up @@ -188,7 +196,9 @@ function SectionOptionsButtons({ section }: { section: SectionType }) {
"bg-white/70 backdrop-blur-md transition-opacity duration-500 group-hover/section:opacity-80 flex",
)}
>
<div className={tx(btnCls, "cursor-default flex-col items-start justify-center gap-0")}>
<div
className={tx(btnCls, "cursor-pointer flex-col items-start justify-center gap-0 hover:text-black")}
>
<div className="text-xs font-light leading-[0.9] ">Section</div>
<div className="text-sm font-semibold -mt-1.5">{section.label ?? `${section.order + 1}`}</div>
</div>
Expand Down Expand Up @@ -221,7 +231,11 @@ function SectionOptionsButtons({ section }: { section: SectionType }) {
F438 </Tooltip>
)}
<DropdownMenu.Root modal={false} >
<DropdownMenu.Trigger>
<DropdownMenu.Trigger
=> {
e.stopPropagation();
}}
>
<button type="button" className={tx(btnCls)}>
<TbDots className="w-6 h-6" />
</button>
Expand All @@ -246,12 +260,22 @@ function SectionOptionsButtons({ section }: { section: SectionType }) {
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Group>
<DropdownMenu.Item
=> {
e.stopPropagation();
draftHelpers.createEmptySection(section.id);
}}
>
<div className="flex items-center justify-start gap-2">
<span>Create new section below</span>
</div>
</DropdownMenu.Item>
<DropdownMenu.Item => draftHelpers.duplicateSection(section.id)}>
<div className="flex items-center justify-start gap-2">
<span>Duplicate</span>
</div>
</DropdownMenu.Item>
<DropdownMenu.Item
{/* <DropdownMenu.Item
=> {
setSelectedSectionId(section.id);
setPanel("inspector");
Expand All @@ -260,7 +284,7 @@ function SectionOptionsButtons({ section }: { section: SectionType }) {
<div className="flex items-center justify-start gap-2">
<span>Settings</span>
</div>
</DropdownMenu.Item>
</DropdownMenu.Item> */}
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Item
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/editor/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default function NavBar() {

return (
<nav
role="navigation"
className={tx(
`z-[9999] h-full gap-1 px-4 flex text-xl w-full items-center transition-opacity duration-300
text-black/70 dark:text-dark-200 bg-white`,
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/editor/components/PageHierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import type { Brick, Section } from "@upstart.gg/sdk/shared/bricks";
import { manifests } from "@upstart.gg/sdk/bricks/manifests/all-manifests";
import { tx } from "@upstart.gg/style-system/twind";
import { PanelBlockTitle } from "./PanelBlockTitle";
import { useEffect, useState } from "react";

export default function PageHierarchy({ brick: selectedBrick }: { brick?: Brick; section: Section }) {
const { setSelectedBrickId, setSelectedSectionId } = useEditorHelpers();
const sections = useSections();
const currentSectionId = useSelectedSectionId();
const [hoverElement, setHoverElement] = useState<{ type: string; id: string }>();

useEffect(() => {
console.log("hoverElement changed", hoverElement);
}, [hoverElement]);

function mapBricks(bricks: Brick[], level = 0) {
return bricks.map((brick) => {
Expand All @@ -30,6 +36,8 @@ export default function PageHierarchy({ brick: selectedBrick }: { brick?: Brick;
console.log("clicking on brick %s", brick.id);
setSelectedBrickId(brick.id);
}}
=> setHoverElement({ type: "brick", id: brick.id })}
=> setHoverElement(undefined)}
>
<div className="flex items-center justify-between group transition-all">
<span className="inline-flex items-center gap-1.5">
Expand Down
9 changes: 0 additions & 9 deletions packages/components/src/editor/components/PanelAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@ import { ScrollablePanelTab } from "./ScrollablePanelTab";
import { tx, css } from "@upstart.gg/style-system/twind";
import FormNavigator from "./json-form/FormNavigator";
import AttributesSettingsView from "./AttributesSettingsView";
import { TObject } from "@sinclair/typebox";

export default function SettingsForm() {
const draft = useDraft();
const attributes = useAttributes();
const attrSchema = useAttributesSchema();
const [shouldRender, setShouldRender] = useState(false);
const [currentTab, setCurrentTab] = useState("page-settings");

// biome-ignore lint/correctness/useExhaustiveDependencies: draft.updateAttributes is a stable function
const Record<string, unknown>, propertyChanged: string) => {
console.log("changed attr %o", data);
draft.updateAttributes(data as Attributes);
}, []);

const filteredAttrSchema = useMemo(() => {
const filteredSchema = {
...attrSchema,
Expand Down
Loading
Loading
0