Skip to content

2022.11 W45 Release #186

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

Merged
merged 60 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5f404cc
share icons
softmarshmallow Oct 26, 2022
df46aff
add editor-home
softmarshmallow Oct 26, 2022
8f9069e
state updates with editor-home
softmarshmallow Oct 26, 2022
be63335
fix state node query
softmarshmallow Oct 26, 2022
b39d8cb
add image view canvas
softmarshmallow Oct 27, 2022
239aa9b
update refs
softmarshmallow Oct 27, 2022
5566177
fix index db ssr warning
softmarshmallow Oct 27, 2022
49dfe93
add figma image service and provider
softmarshmallow Oct 27, 2022
e0213e9
use figma image service on static image preview
softmarshmallow Oct 27, 2022
3a92616
.
softmarshmallow Oct 27, 2022
3aba7f0
add debouncer - wip
softmarshmallow Oct 28, 2022
525c694
add conversations view - wip
softmarshmallow Oct 28, 2022
61452d6
add figma comment store & hook
softmarshmallow Oct 29, 2022
94b02d6
fix sorting & nesting
softmarshmallow Oct 29, 2022
d19c7a6
add threads / inspect tab
softmarshmallow Oct 29, 2022
f654ec7
add comment reply function
softmarshmallow Oct 29, 2022
8ddb566
add hover menu, delete, copy link action
softmarshmallow Oct 29, 2022
a5bf101
add editor-home filter by name
softmarshmallow Oct 29, 2022
198229c
move d2c webworker
softmarshmallow Oct 29, 2022
21dd405
sanitize
softmarshmallow Oct 29, 2022
cd4d0fe
m.f.
softmarshmallow Oct 29, 2022
74f9f6d
fix worker
softmarshmallow Oct 29, 2022
936f83f
add monaco editor to have fold comments onload
softmarshmallow Oct 29, 2022
3dda988
add loading state to section-code
softmarshmallow Nov 1, 2022
6f11792
wip - cleanup figma auth
softmarshmallow Nov 1, 2022
e3e3ff8
update usage of auth state
softmarshmallow Nov 1, 2022
7490524
update title on loading
softmarshmallow Nov 1, 2022
6d9c3d2
add component section to editor-home
softmarshmallow Nov 1, 2022
ea21ebc
update state management hierarchy & warmup with authentication provider
softmarshmallow Nov 1, 2022
879f5ee
add comment reactions
softmarshmallow Nov 1, 2022
3ca3e1c
add figma meta store & optimzied home files loading speed
softmarshmallow Nov 1, 2022
396f195
update lastused on every repo fetch
softmarshmallow Nov 1, 2022
fba0560
fix image service to handle debounced queue
softmarshmallow Nov 1, 2022
aa1a12f
update loading view
softmarshmallow Nov 1, 2022
c431520
fix filter
softmarshmallow Nov 1, 2022
1a243b2
update background tasks queue indicator
softmarshmallow Nov 2, 2022
6dd5fd3
update comment store with index
softmarshmallow Nov 2, 2022
3600202
disable delete on non authorized comment
softmarshmallow Nov 2, 2022
94b799b
fix build
softmarshmallow Nov 2, 2022
da70a29
update indexed store clear with index
softmarshmallow Nov 2, 2022
3f286da
clean
softmarshmallow Nov 2, 2022
0bd3b96
add comment mode & cursor
softmarshmallow Nov 2, 2022
c56a3c0
color chip & gradient chip
softmarshmallow Nov 2, 2022
1a72e69
fix assets section image fetching
softmarshmallow Nov 2, 2022
8d5ca06
disable appbar
softmarshmallow Nov 2, 2022
cf23c92
bump react to 18.2.0, fix type build issues
softmarshmallow Nov 2, 2022
c2058a0
clean
softmarshmallow Nov 3, 2022
c12fc7d
fix db up
softmarshmallow Nov 3, 2022
f56dc0d
update view states
softmarshmallow Nov 3, 2022
3f010bc
fix appbar style
softmarshmallow Nov 3, 2022
fb25b92
worker initialization handling with event bus
softmarshmallow Nov 3, 2022
dd61f94
optimize css fro ssr
softmarshmallow Nov 3, 2022
7d0fffe
disable canvas sizing
softmarshmallow Nov 3, 2022
0d7a8cf
update home layout
softmarshmallow Nov 3, 2022
bdf2e06
update text container word break
softmarshmallow Nov 3, 2022
5527f1f
update spacing guide readability
softmarshmallow Nov 3, 2022
ad01aae
update Home -> Dashboard
softmarshmallow Nov 3, 2022
6c224aa
Merge pull request #184 from gridaco/editor/inspector
softmarshmallow Nov 3, 2022
3832a91
add queue bumper
softmarshmallow Nov 4, 2022
f2c9255
fix db
softmarshmallow Nov 4, 2022
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import { useGesture } from "@use-gesture/react";
import type {
Handler,
Expand Down Expand Up @@ -39,24 +39,28 @@ export function CanvasEventTarget({
onDrag,
onDragStart,
onDragEnd,
cursor,
children,
}: {
onZoomToFit?: () => void;
onPanning: OnPanningHandler;
onPanningStart: OnPanningHandler;
onPanningEnd: OnPanningHandler;
onZooming: OnZoomingHandler;
onZoomingStart: OnZoomingHandler;
onZoomingEnd: OnZoomingHandler;
onPointerMove: OnPointerMoveHandler;
onPointerMoveStart: OnPointerMoveHandler;
onPointerMoveEnd: OnPointerMoveHandler;
onPointerDown: OnPointerDownHandler;
onDrag: OnDragHandler;
onDragStart: OnDragHandler;
onDragEnd: OnDragHandler;
children?: React.ReactNode;
}) {
}: React.PropsWithChildren<
{
onZoomToFit?: () => void;
onPanning: OnPanningHandler;
onPanningStart: OnPanningHandler;
onPanningEnd: OnPanningHandler;
onZooming: OnZoomingHandler;
onZoomingStart: OnZoomingHandler;
onZoomingEnd: OnZoomingHandler;
onPointerMove: OnPointerMoveHandler;
onPointerMoveStart: OnPointerMoveHandler;
onPointerMoveEnd: OnPointerMoveHandler;
onPointerDown: OnPointerDownHandler;
onDrag: OnDragHandler;
onDragStart: OnDragHandler;
onDragEnd: OnDragHandler;
} & {
cursor?: React.CSSProperties["cursor"];
}
>) {
const interactionEventTargetRef = useRef();

const [isSpacebarPressed, setIsSpacebarPressed] = useState(false);
Expand Down Expand Up @@ -210,7 +214,7 @@ export function CanvasEventTarget({
inset: 0,
overflow: "hidden",
touchAction: "none",
cursor: isSpacebarPressed ? "grab" : "default",
cursor: isSpacebarPressed ? "grab" : cursor,
userSelect: "none",
WebkitUserSelect: "none",
}}
Expand Down
43 changes: 27 additions & 16 deletions editor-packages/editor-canvas/canvas/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ interface GroupingOptions {
disabled?: boolean;
}

interface CanvasCursorOptions {
cursor?: React.CSSProperties["cursor"];
}

const default_canvas_preferences: CanvsPreferences = {
can_highlight_selected_layer: false,
marquee: {
Expand All @@ -91,6 +95,18 @@ const default_canvas_preferences: CanvsPreferences = {
},
};

type CanvasProps = CanvasCursorOptions & {
viewbound: Box;
onSelectNode?: (...node: ReflectSceneNode[]) => void;
onMoveNodeStart?: (...node: string[]) => void;
onMoveNode?: (delta: XY, ...node: string[]) => void;
onMoveNodeEnd?: (delta: XY, ...node: string[]) => void;
onClearSelection?: () => void;
} & CanvasCustomRenderers &
CanvasState & {
config?: CanvsPreferences;
};

interface HovringNode {
node: ReflectSceneNode;
reason: "frame-title" | "raycast" | "external";
Expand All @@ -113,18 +129,9 @@ export function Canvas({
readonly = true,
config = default_canvas_preferences,
backgroundColor,
cursor,
...props
}: {
viewbound: Box;
onSelectNode?: (...node: ReflectSceneNode[]) => void;
onMoveNodeStart?: (...node: string[]) => void;
onMoveNode?: (delta: XY, ...node: string[]) => void;
onMoveNodeEnd?: (delta: XY, ...node: string[]) => void;
onClearSelection?: () => void;
} & CanvasCustomRenderers &
CanvasState & {
config?: CanvsPreferences;
}) {
}: CanvasProps) {
useEffect(() => {
if (transformIntitialized) {
return;
Expand Down Expand Up @@ -430,8 +437,9 @@ export function Canvas({
<>
<ContextMenuProvider>
<Container
width={viewbound[2] - viewbound[0]}
height={viewbound[3] - viewbound[1]}
// todo: viewbound not accurate.
// width={viewbound[2] - viewbound[0]}
// height={viewbound[3] - viewbound[1]}
>
<CanvasEventTarget
onPanning={onPanning}
Expand Down Expand Up @@ -462,6 +470,7 @@ export function Canvas({
onDragStart={onDragStart}
onDrag={onDrag}
onDragEnd={onDragEnd}
cursor={cursor}
>
<HudSurface
offset={nonscaled_offset}
Expand Down Expand Up @@ -505,10 +514,12 @@ export function Canvas({
);
}

const Container = styled.div<{ width: number; height: number }>`
width: ${(p) => p.width}px;
height: ${(p) => p.height}px;
const Container = styled.div`
min-width: 240px;
min-height: 240px;
`;
/* width: ${(p) => p.width}px; */
/* height: ${(p) => p.height}px; */

/**
* 1. container positioning guide (static per selection)
Expand Down
4 changes: 2 additions & 2 deletions editor-packages/editor-canvas/hud/hud-surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ function PositionGuides({
}) {
return (
<>
{guides.map((guide) => {
return <PositionGuide a={guide.a} b={guide.b} zoom={zoom} />;
{guides.map((guide, i) => {
return <PositionGuide key={i} a={guide.a} b={guide.b} zoom={zoom} />;
})}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ function SpacingMeterLabel({
return (
<MeterLabel
label={(Math.round(length * 10) / 10).toString()}
background={"orange"}
background={"darkorange"}
x={tx}
y={ty}
weight={"bolder"}
margin={4}
anchor={__label_anchor_map[side]}
zoom={zoom}
Expand Down Expand Up @@ -173,7 +174,7 @@ function GuideLine({
direction,
length,
width,
color = "orange",
color = "darkorange",
dashed,
}: GuideLineProps) {
const tl = length * zoom;
Expand Down Expand Up @@ -230,7 +231,7 @@ function SpacingGuideLine({
length={length}
direction={rotation}
width={1}
color={"orange"}
color={"darkorange"}
/>
);
}
Expand All @@ -257,7 +258,7 @@ function AuxiliaryLine({
direction={rotation}
width={1}
dashed
color={"orange"}
color={"darkorange"}
/>
);
}
51 changes: 27 additions & 24 deletions editor-packages/editor-canvas/overlay/handle.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import React, { forwardRef } from "react";
import * as k from "./k";

export const Handle = forwardRef(function ({
color,
anchor,
box,
outlineWidth = 1,
outlineColor = "transparent",
size = 4,
borderRadius = 0,
cursor,
readonly,
}: {
color: string;
/**
* the width of the outline
*/
outlineWidth?: number;
outlineColor?: string;
size: number;
anchor: "nw" | "ne" | "sw" | "se";
box: [number, number, number, number];
borderRadius?: React.CSSProperties["borderRadius"];
cursor?: React.CSSProperties["cursor"];
readonly?: boolean;
}) {
export const Handle = forwardRef(function (
{
color,
anchor,
box,
outlineWidth = 1,
outlineColor = "transparent",
size = 4,
borderRadius = 0,
cursor,
readonly,
}: {
color: string;
/**
* the width of the outline
*/
outlineWidth?: number;
outlineColor?: string;
size: number;
anchor: "nw" | "ne" | "sw" | "se";
box: [number, number, number, number];
borderRadius?: React.CSSProperties["borderRadius"];
cursor?: React.CSSProperties["cursor"];
readonly?: boolean;
},
ref
) {
let dx = 0;
let dy = 0;
switch (anchor) {
Expand Down
4 changes: 3 additions & 1 deletion editor-packages/editor-canvas/overlay/meter-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export function MeterLabel({
zoom,
margin = 0,
zIndex = k.Z_INDEX_GUIDE_LABEL,
weight = 500,
}: {
x: number;
y: number;
weight?: React.CSSProperties["fontWeight"];
background?: React.CSSProperties["background"];
label: string;
anchor: "w" | "n" | "s" | "e";
Expand Down Expand Up @@ -98,7 +100,7 @@ export function MeterLabel({
color: "white",
fontSize: font_size,
fontFamily: "Inter, sans-serif",
fontWeight: 500,
fontWeight: weight,
textAlign: "center",
zIndex: zIndex,
}}
Expand Down
2 changes: 2 additions & 0 deletions editor-packages/editor-figma-file/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./stores";
export * from "./repository";
4 changes: 4 additions & 0 deletions editor-packages/editor-figma-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@editor/figma-file",
"version": "0.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetch } from "@design-sdk/figma-remote";
import { FileResponse } from "@design-sdk/figma-remote-types";
import { FigmaFileStore, FileResponseRecord } from "@editor/figma-file-store";
import { FigmaFileStore, FigmaFileMetaStore } from "./stores";
import type { FileResponseRecord } from "./stores";

export type TFetchFileForApp = (
| fetch.FetchFileGeneratorReturnType
Expand All @@ -20,23 +20,29 @@ export class FigmaDesignRepository {
) {}

static async fetchCachedFile(fileId: string) {
const metastore = new FigmaFileMetaStore();
const store = new FigmaFileStore(fileId);
const existing = await store.get();
if (existing) {
// everytime the file is consumed consider it as used, we upsert the file so that the lastUsed can be updated.
metastore.upsert(existing.key, existing);
return { ...existing, __initial: false } as TFetchFileForApp;
} else {
throw new Error("file not found");
}
}

async *fetchFile(fileId: string) {
const store = new FigmaFileStore(fileId);
async *fetchFile(filekey: string) {
const metastore = new FigmaFileMetaStore();
const store = new FigmaFileStore(filekey);
const existing = await store.get();
if (existing) {
// everytime the file is consumed consider it as used, we upsert the file so that the lastUsed can be updated.
metastore.upsert(existing.key, existing);
yield { ...existing, __initial: false } as TFetchFileForApp;
}

const _iter = fetch.fetchFile({ file: fileId, auth: this.auth });
const _iter = fetch.fetchFile({ file: filekey, auth: this.auth });
let next: IteratorResult<fetch.FetchFileGeneratorReturnType>;
while ((next = await _iter.next()).done === false) {
switch (next.value.__response_type) {
Expand All @@ -48,6 +54,7 @@ export class FigmaDesignRepository {
__type: "file-fetched-for-app",
} as TFetchFileForApp;
store.upsert(next.value);
metastore.upsert(filekey, next.value);
}
break;
case "roots":
Expand All @@ -58,6 +65,7 @@ export class FigmaDesignRepository {
__type: "file-fetched-for-app",
} as TFetchFileForApp;
store.upsert(next.value);
metastore.upsert(filekey, next.value);
}
break;
case "whole":
Expand All @@ -67,6 +75,7 @@ export class FigmaDesignRepository {
__type: "file-fetched-for-app",
} as TFetchFileForApp;
store.upsert(next.value);
metastore.upsert(filekey, next.value);
break;
}
}
Expand Down
Loading