Skip to content

Commit 4809fc6

Browse files
finalsetp: sanitize for release; update home layout;
1 parent a9f41f5 commit 4809fc6

14 files changed

Lines changed: 118 additions & 130 deletions

File tree

editor/components/home/cards/base-home-scene-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const ThumbnailArea = styled.div`
7979

8080
const SceneCardPreviewThumbnail = styled.div`
8181
height: 101px;
82+
background-color: #c1c1c1;
8283
position: relative;
8384
align-self: stretch;
8485
`;
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React from "react";
2-
import { RecentDesignCard } from "./recent-design-card";
32
import moment from "moment";
43
import router from "next/router";
54
import { formToCodeUrl } from "../../../url";
5+
import { FileCard } from "./card-variant-file";
66

77
const _id =
88
"https://www.figma.com/file/x7RRK6RwWtZuNakmbMLTVH/examples?node-id=1%3A120";
99
const defaultdemodesign = {
10-
id: _id,
10+
type: "file" as "file",
11+
key: "x7RRK6RwWtZuNakmbMLTVH",
1112
name: "WNV Main screen",
1213
provider: "figma",
13-
addedAt: moment().toDate(),
14+
lastUsed: moment().toDate(),
1415
lastUpdatedAt: moment().toDate(),
15-
previewUrl:
16+
thumbnailUrl:
1617
"https://example-project-manifest.s3.us-west-1.amazonaws.com/app-wnv/cover.png",
1718
};
1819

@@ -25,7 +26,7 @@ export function BuiltinDemoFileCard() {
2526
};
2627
return (
2728
<>
28-
<RecentDesignCard key={_id} onclick={onclick} data={defaultdemodesign} />
29+
<FileCard key={_id} onClick={onclick} data={defaultdemodesign} />
2930
</>
3031
);
3132
}
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
import { useRouter } from "next/router";
22
import React from "react";
3-
import { RecentDesignCard } from "./recent-design-card";
3+
import { FileCard } from "./card-variant-file";
44

55
const _id = "--new--";
66
const importnewdesingcarddata = {
7-
id: _id,
7+
type: "file" as "file",
8+
key: _id,
89
name: "New Design",
9-
addedAt: new Date(),
10-
provider: "unknown",
11-
previewUrl:
10+
thumbnailUrl:
1211
"https://example-project-manifest.s3.us-west-1.amazonaws.com/app-new/cover.png",
1312
};
1413

1514
export function ImportNewDesignCard() {
1615
const router = useRouter();
1716
const onclick = () => {
18-
router.push("/import");
17+
// router.push("/import");
18+
router.push("https://grida.co");
1919
};
2020

2121
return (
2222
<>
23-
<RecentDesignCard
24-
key={_id}
25-
onclick={onclick}
26-
data={importnewdesingcarddata}
27-
/>
23+
<FileCard key={_id} onClick={onclick} data={importnewdesingcarddata} />
2824
</>
2925
);
3026
}

editor/components/home/cards/card-variant-file.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import { useRouter } from "next/router";
22
import React, { useEffect } from "react";
3+
import { LastUsedFileDisplay } from "repository/workspace-repository";
34
import { BaseHomeSceneCard } from "./base-home-scene-card";
45

56
export function FileCard({
67
label,
78
data,
9+
onClick,
810
}: {
9-
label: string;
1011
data: {
12+
type: "file";
13+
lastUsed?: Date;
1114
key: string;
15+
name: string;
1216
thumbnailUrl: string;
1317
};
18+
label?: string;
19+
onClick?: () => void;
1420
}) {
1521
const router = useRouter();
16-
1722
return (
1823
<BaseHomeSceneCard
19-
onClick={() => {
20-
router.push(`/files/[key]`, `/files/${data.key}`);
21-
}}
22-
label={label}
24+
onClick={
25+
onClick ??
26+
(() => {
27+
router.push(`/files/[key]`, `/files/${data.key}`);
28+
})
29+
}
30+
label={label ?? data.name}
2331
thumbnail={data.thumbnailUrl}
2432
/>
2533
);

editor/components/home/cards/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from "./recent-design-card";
21
export * from "./builtin-demo-file-card";
32
export * from "./builtin-import-new-design-card";
43

editor/components/home/cards/recent-design-card.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

editor/components/home/home-side-bar-tree.tsx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ const preset_pages: PresetPage[] = [
3131
path: "/#files",
3232
depth: 1,
3333
},
34-
{
35-
id: "/#scenes",
36-
name: "Scenes",
37-
path: "/#scenes",
38-
depth: 1,
39-
},
40-
{
41-
id: "/#components",
42-
name: "Components",
43-
path: "/#components",
44-
depth: 1,
45-
},
34+
// {
35+
// id: "/#scenes",
36+
// name: "Scenes",
37+
// path: "/#scenes",
38+
// depth: 1,
39+
// },
40+
// {
41+
// id: "/#components",
42+
// name: "Components",
43+
// path: "/#components",
44+
// depth: 1,
45+
// },
4646
],
4747
},
4848
{
@@ -51,34 +51,40 @@ const preset_pages: PresetPage[] = [
5151
path: "/files",
5252
depth: 0,
5353
},
54-
{
55-
id: "/components",
56-
name: "Components",
57-
path: "/components",
58-
depth: 0,
59-
},
60-
{
61-
id: "/integrations",
62-
name: "Import / Sync",
63-
path: "/integrations",
64-
depth: 0,
65-
},
54+
// {
55+
// id: "/components",
56+
// name: "Components",
57+
// path: "/components",
58+
// depth: 0,
59+
// },
60+
// {
61+
// id: "/integrations",
62+
// name: "Import / Sync",
63+
// path: "/integrations",
64+
// depth: 0,
65+
// },
6666
{
6767
id: "help",
6868
name: "Help",
6969
path: "",
7070
depth: 0,
7171
children: [
7272
{
73-
id: "/docs",
73+
id: "bug-report",
7474
name: "Bug report",
7575
path: "https://github.com/gridaco/designto-code/issues/new",
7676
depth: 1,
7777
},
7878
{
79-
id: "/docs",
79+
id: "Github",
80+
name: "Github",
81+
path: "https://github.com/gridaco/designto-code/",
82+
depth: 1,
83+
},
84+
{
85+
id: "docs",
8086
name: "Docs",
81-
path: "/docs",
87+
path: "https://github.com/gridaco/designto-code/tree/main/docs",
8288
depth: 1,
8389
},
8490
],

editor/repository/workspace-repository/index.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
1-
import { FigmaFilesStore } from "store/fimga-file-store/figma-file-store";
1+
import {
2+
FigmaFilesStore,
3+
FileResponseRecord,
4+
} from "store/fimga-file-store/figma-file-store";
5+
6+
export type LastUsedFileDisplay = FileResponseRecord & { type: "file" } & {
7+
lastUsed: Date;
8+
};
9+
export type LastusedDisplayType = LastUsedFileDisplay;
210

311
export class WorkspaceRepository {
412
constructor() {}
513

614
async getRecents({ count = 4 }: { count?: number }) {
7-
const fetches = [];
8-
fetches.push(this.getRecentFiles());
9-
fetches.push(this.getRecentScenes());
10-
fetches.push(this.getRecentComponents());
15+
const fetches: LastusedDisplayType[] = [];
16+
const files = (await this.getFiles()).map(
17+
(f) =>
18+
<LastusedDisplayType>{
19+
...f,
20+
type: "file",
21+
}
22+
);
23+
fetches.push(...files);
24+
// fetches.push(this.getRecentScenes());
25+
// fetches.push(this.getRecentComponents());
1126

1227
const allRecents = await Promise.all(fetches);
13-
const recents = allRecents.sort((r) => r.lastUsed).slice(0, count);
28+
const recents = allRecents
29+
.sort((r, r2) => (r2.lastUsed > r.lastUsed ? 1 : -1))
30+
.slice(0, count);
31+
1432
return recents;
1533
}
1634

17-
async getFiles(): Promise<any[]> {
35+
async getFiles() {
1836
return FigmaFilesStore.all();
19-
return [
20-
"JRD2EdsbBlWgib8NzTXIGo",
21-
"HSozKEVWhh8saZa2vr1Nxd",
22-
"Gaznaw1QHppxvs9UkqNOb0",
23-
"Y0Gh77AqBoHH7dG1GtK3xF",
24-
"iypAHagtcSp3Osfo2a7EDz",
25-
"x7RRK6RwWtZuNakmbMLTVH",
26-
].map((id) => {
27-
return {
28-
id: id,
29-
file: id,
30-
name: id,
31-
lastUsed: new Date("2021-01-01"),
32-
};
33-
});
34-
}
35-
36-
async getRecentFiles() {
37-
return this.getFiles();
3837
}
3938

4039
async getRecentScenes() {

editor/scaffolds/home-dashboard/home-dashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export function HomeDashboard() {
2323

2424
repository.getFiles().then(setFiles);
2525

26-
repository.getRecentScenes().then(setScenes);
26+
// repository.getRecentScenes().then(setScenes);
2727

28-
repository.getRecentComponents().then(setComponents);
28+
// repository.getRecentComponents().then(setComponents);
2929
}, []);
3030

3131
return (

editor/scaffolds/home-dashboard/recent-design-card-list.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
import styled from "@emotion/styled";
22
import router from "next/router";
33
import React, { useEffect, useState } from "react";
4-
import { WorkspaceRepository } from "repository";
4+
import { LastusedDisplayType } from "repository";
55
import {
66
BuiltinDemoFileCard,
7+
Cards,
78
ImportNewDesignCard,
8-
RecentDesignCard,
99
} from "components/home/cards";
1010

11-
export function RecentDesignCardList({ recents }: { recents: any[] }) {
11+
export function RecentDesignCardList({
12+
recents,
13+
}: {
14+
recents: LastusedDisplayType[];
15+
}) {
1216
const oncardclick = (id: string, d) => {
1317
console.log("click", id);
1418
router.push(`/to-code/${id}`); // fixme id is not a param
1519
};
1620

17-
const also_show_demo = recents.length <= 2;
21+
const also_show_demo = false; // recents.length <= 2; // DISABLED
1822

1923
return (
2024
<ListWrap>
2125
<ImportNewDesignCard />
2226
{also_show_demo && <BuiltinDemoFileCard />}
2327
{recents.map((recentDesign) => {
24-
return (
25-
<RecentDesignCard
26-
key={recentDesign.id}
27-
data={recentDesign}
28-
onclick={oncardclick}
29-
/>
30-
);
28+
switch (recentDesign.type) {
29+
case "file": {
30+
return <Cards.File key={recentDesign.key} data={recentDesign} />;
31+
}
32+
}
3133
})}
3234
</ListWrap>
3335
);

0 commit comments

Comments
 (0)