From 1caec2e8d1b1a5399243ee6859662a88940594c6 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Fri, 24 May 2024 08:12:07 -0700 Subject: [PATCH 1/3] reorganizing --- apps/new/widget/Index.jsx | 12 +- apps/new/widget/app/view.jsx | 104 ------------------ apps/new/widget/components/project/card.jsx | 12 +- apps/new/widget/components/project/list.jsx | 12 +- apps/new/widget/{components => }/css.jsx | 3 + .../new/widget/{Icons/Icons.jsx => icons.jsx} | 0 apps/new/widget/{ => page}/home/Build.jsx | 0 .../widget/{ => page}/home/BuildSomething.jsx | 0 apps/new/widget/{ => page}/home/CTA.jsx | 0 apps/new/widget/{ => page}/home/Cards.jsx | 0 apps/new/widget/{ => page}/home/Hero.jsx | 49 ++------- .../widget/{ => page}/home/MovingHeader.jsx | 0 .../{ => page}/home/hero/ScrollingText.jsx | 0 .../widget/{ => page}/home/hero/Vertical.jsx | 0 .../widget/page/{home.jsx => home/index.jsx} | 10 +- .../page/{projects.jsx => projects/List.jsx} | 61 +++++----- .../{build.jsx => page/projects/index.jsx} | 10 +- apps/new/widget/utils.js | 46 ++++++++ 18 files changed, 112 insertions(+), 207 deletions(-) delete mode 100644 apps/new/widget/app/view.jsx rename apps/new/widget/{components => }/css.jsx (99%) rename apps/new/widget/{Icons/Icons.jsx => icons.jsx} (100%) rename apps/new/widget/{ => page}/home/Build.jsx (100%) rename apps/new/widget/{ => page}/home/BuildSomething.jsx (100%) rename apps/new/widget/{ => page}/home/CTA.jsx (100%) rename apps/new/widget/{ => page}/home/Cards.jsx (100%) rename apps/new/widget/{ => page}/home/Hero.jsx (85%) rename apps/new/widget/{ => page}/home/MovingHeader.jsx (100%) rename apps/new/widget/{ => page}/home/hero/ScrollingText.jsx (100%) rename apps/new/widget/{ => page}/home/hero/Vertical.jsx (100%) rename apps/new/widget/page/{home.jsx => home/index.jsx} (56%) rename apps/new/widget/page/{projects.jsx => projects/List.jsx} (88%) rename apps/new/widget/{build.jsx => page/projects/index.jsx} (92%) create mode 100644 apps/new/widget/utils.js diff --git a/apps/new/widget/Index.jsx b/apps/new/widget/Index.jsx index 9cb5f95d..d7c4e67f 100644 --- a/apps/new/widget/Index.jsx +++ b/apps/new/widget/Index.jsx @@ -1,4 +1,4 @@ -const { CSS } = VM.require("${config_account}/widget/components.css") || { +const { CSS } = VM.require("${config_account}/widget/css") || { CSS: () => <>, }; @@ -22,18 +22,18 @@ const config = { param: "page", routes: { home: { - path: "${config_account}/widget/page.home", + path: "${config_account}/widget/page.home.index", blockHeight: "final", init: { name: "Home", }, default: true, }, - build: { - path: "${config_account}/widget/build", + projects: { + path: "${config_account}/widget/page.projects.index", blockHeight: "final", init: { - name: "Build", + name: "Projects", }, }, }, @@ -43,7 +43,7 @@ const config = { return ( diff --git a/apps/new/widget/app/view.jsx b/apps/new/widget/app/view.jsx deleted file mode 100644 index 41f2f98c..00000000 --- a/apps/new/widget/app/view.jsx +++ /dev/null @@ -1,104 +0,0 @@ -const { Router } = VM.require("${alias_old}/widget/Router") || { - Router: () => <>, -}; - -const { config, ...passProps } = props; - -if (!config) { - // TODO: get from settings (or default) - config = { - router: { - param: "page", - routes: { - home: { - default: true, - path: "efiz.near/widget/Tree", - blockHeight: "final", - init: { - name: "Home", - }, - }, - }, - }, - blocks: { - Header: () => <>, // customize your header - Footer: () => <>, // customize your footer - }, - }; -} else { - // config may be a VM require string - if (typeof config !== "object") { - config = VM.require(config) || {}; - } -} - -if (!config) { - return ( -

- unable to load config:{" "} - {typeof config === object ? JSON.stringify(config) : config} -

- ); -} - -const { Layout } = VM.require( - config.layout?.src ?? "${alias_devs}/widget/Layout", -) || { Layout: () => <> }; - -// While something like Theme should be in the parent... -const CSS = styled.div` - .container { - border: 1px solid red; - } - - .button { - } - - .input { - } - - .layout { - border: 4px solid var(--main-color); - } - - .header { - border: 1px solid blue; - } - - .content { - } - - .footer { - } -`; - -const Container = styled.div` - display: flex; - height: 100%; - - .main { - min-height: 100vh; - } -`; - -const Content = styled.div` - width: 100%; - height: 100%; - background: var(--bg-1, #000); -`; - -// const Template = config.Template ?? (({children}) => <>{children}); -return ( - - - - - - - - - -); diff --git a/apps/new/widget/components/project/card.jsx b/apps/new/widget/components/project/card.jsx index 23e0aafa..925714d5 100644 --- a/apps/new/widget/components/project/card.jsx +++ b/apps/new/widget/components/project/card.jsx @@ -3,7 +3,7 @@ const { Avatar, Button } = VM.require("${alias_old}/widget/components") || { Button: () => <>, }; -const { href } = VM.require("${alias_old}/widget/lib.url") || { +const { href } = VM.require("${alias_devs}/widget/lib.url") || { href: () => {}, }; @@ -13,7 +13,7 @@ const { ProfileImages } = VM.require( ProfileImages: () => <>, }; -const Card = styled.div` +const GridCard = styled.div` border-radius: 16px; background: var(--bg-2, #23242b); @@ -94,7 +94,7 @@ const Tag = styled.div` } `; -const ProjectCard = ({ project, type }) => { +const ProjectCard = ({ data, variant }) => { const { accountId, description, @@ -103,7 +103,7 @@ const ProjectCard = ({ project, type }) => { collaborators, metadata, projectID, - } = project; + } = data; const profile = Social.getr(`${projectAccountId}/profile`); @@ -119,7 +119,7 @@ const ProjectCard = ({ project, type }) => { })} style={{ textDecoration: "none", display: "flex", flexGrow: "1" }} > - + { - + ); }; diff --git a/apps/new/widget/components/project/list.jsx b/apps/new/widget/components/project/list.jsx index 8ca7bb58..43e6e40d 100644 --- a/apps/new/widget/components/project/list.jsx +++ b/apps/new/widget/components/project/list.jsx @@ -3,7 +3,7 @@ const { Avatar, Button } = VM.require("${alias_old}/widget/components") || { Button: () => <>, }; -const { href } = VM.require("${alias_old}/widget/lib.url") || { +const { href } = VM.require("${alias_devs}/widget/lib.url") || { href: () => {}, }; @@ -13,7 +13,7 @@ const { ProfileImages } = VM.require( ProfileImages: () => <>, }; -const Card = styled.div` +const ListCard = styled.div` border-radius: 16px; background: var(--bg-2, #23242b); @@ -95,7 +95,7 @@ const Tag = styled.div` } `; -const ProjectList = ({ project, type }) => { +const ProjectList = ({ data, type }) => { const { accountId, projectAccountId, @@ -103,7 +103,7 @@ const ProjectList = ({ project, type }) => { collaborators, metadata, projectID, - } = project; + } = data; const profile = Social.getr(`${projectAccountId}/profile`); @@ -119,7 +119,7 @@ const ProjectList = ({ project, type }) => { })} style={{ textDecoration: "none", display: "flex", flexGrow: "1" }} > - +
{
- + ); }; diff --git a/apps/new/widget/components/css.jsx b/apps/new/widget/css.jsx similarity index 99% rename from apps/new/widget/components/css.jsx rename to apps/new/widget/css.jsx index 3e14603d..fe0a59a6 100644 --- a/apps/new/widget/components/css.jsx +++ b/apps/new/widget/css.jsx @@ -1,4 +1,7 @@ const CSS = styled.div` + + min-height: 100vh; + @font-face { font-family: "Poppins"; font-weight: 100; diff --git a/apps/new/widget/Icons/Icons.jsx b/apps/new/widget/icons.jsx similarity index 100% rename from apps/new/widget/Icons/Icons.jsx rename to apps/new/widget/icons.jsx diff --git a/apps/new/widget/home/Build.jsx b/apps/new/widget/page/home/Build.jsx similarity index 100% rename from apps/new/widget/home/Build.jsx rename to apps/new/widget/page/home/Build.jsx diff --git a/apps/new/widget/home/BuildSomething.jsx b/apps/new/widget/page/home/BuildSomething.jsx similarity index 100% rename from apps/new/widget/home/BuildSomething.jsx rename to apps/new/widget/page/home/BuildSomething.jsx diff --git a/apps/new/widget/home/CTA.jsx b/apps/new/widget/page/home/CTA.jsx similarity index 100% rename from apps/new/widget/home/CTA.jsx rename to apps/new/widget/page/home/CTA.jsx diff --git a/apps/new/widget/home/Cards.jsx b/apps/new/widget/page/home/Cards.jsx similarity index 100% rename from apps/new/widget/home/Cards.jsx rename to apps/new/widget/page/home/Cards.jsx diff --git a/apps/new/widget/home/Hero.jsx b/apps/new/widget/page/home/Hero.jsx similarity index 85% rename from apps/new/widget/home/Hero.jsx rename to apps/new/widget/page/home/Hero.jsx index 7a27ba18..46adbaef 100644 --- a/apps/new/widget/home/Hero.jsx +++ b/apps/new/widget/page/home/Hero.jsx @@ -2,44 +2,9 @@ const { Button } = VM.require("${alias_old}/widget/components") || { Button: () => <>, }; -const BuilderHat = () => ( - - - - - - -); +const { BuilderHat } = VM.require("${alias_new}/widget/icons") || { + BuilderHat: () => <>, +} const HeroContainer = styled.div` display: flex; @@ -306,7 +271,7 @@ const Hero = () => {
Let's Build - +
Designed to support builders in a multi-chain ecosystem. @@ -360,7 +325,7 @@ const Hero = () => {
{ }} /> <>, }; -const { Build } = VM.require("${config_account}/widget/home.Build") || { +const { Build } = VM.require("${config_account}/widget/page.home.Build") || { Build: () => <>, }; -const { Cards } = VM.require("${config_account}/widget/home.Cards") || { +const { Cards } = VM.require("${config_account}/widget/page.home.Cards") || { Cards: () => <>, }; const { BuildSomething } = VM.require( - "${config_account}/widget/home.BuildSomething", + "${config_account}/widget/page.home.BuildSomething", ) || { BuildSomething: () => <>, }; -const { CTA } = VM.require("${config_account}/widget/home.CTA") || { +const { CTA } = VM.require("${config_account}/widget/page.home.CTA") || { CTA: () => <>, }; diff --git a/apps/new/widget/page/projects.jsx b/apps/new/widget/page/projects/List.jsx similarity index 88% rename from apps/new/widget/page/projects.jsx rename to apps/new/widget/page/projects/List.jsx index 615bbf35..ecfe8f26 100644 --- a/apps/new/widget/page/projects.jsx +++ b/apps/new/widget/page/projects/List.jsx @@ -19,22 +19,21 @@ const type = props.type || "project"; const flattenObject = (obj) => { let paths = []; - try { - Object.keys(obj).forEach((key) => { - const projects = Object.keys(obj?.[key]?.[app]?.[type] ?? {}); - projects.map((path) => { - if (!path || !path.includes("_")) { - return; - } - const convertedStr = path.replace(/_/g, "/"); - paths.push(convertedStr); - }); + Object.keys(obj).forEach((key) => { + const projects = Object.keys(obj?.[key]?.[app]?.[type] ?? {}); + (projects || []).map((path) => { + if (!path || !path.includes("_")) { + return; + } + const convertedStr = path.replace(/_/g, "/"); + paths.push(convertedStr); }); - } catch (e) {} + }); return paths; }; -const fetchProjects = () => { +/** This may be moved to a separate, common SDK */ +const fetchThings = () => { const keys = Social.keys(`*/${app}/${type}/*`, "final", { order: "desc", subscribe: true, @@ -61,7 +60,7 @@ const fetchProjects = () => { return projects; }; -const data = fetchProjects(); +const data = fetchThings({ app: "${alias_old}", type: "project" }); if (!data) { return "Loading..."; @@ -70,7 +69,7 @@ if (!data) { const processData = useCallback( (data) => { const accounts = Object.entries(data ?? {}); - const allProjects = accounts + const allProjects = (accounts || []) .map((account) => { const accountId = account[0]; return Object.entries(account?.[1]?.[type] ?? {}).map((kv) => { @@ -194,7 +193,7 @@ const filteredProjects = useMemo(() => { }, [filters, projects]); const tagFilters = useMemo(() => { - let tags = projects.map((project) => project.tags).flat(); + let tags = (projects || []).map((project) => project.tags).flat(); tags = [...new Set(tags)]; return tags; }, [projects]); @@ -350,24 +349,24 @@ return (
- {view === "grid" ? ( - - {filteredProjects.length === 0 && ( -

No Projects Found

+ {filteredProjects && filteredProjects.length > 0 ? ( + <> + {view === "grid" ? ( + + {filteredProjects.map((project) => ( + + ))} + + ) : ( +
+ {filteredProjects.map((project) => ( + + ))} +
)} - {filteredProjects.map((project) => ( - - ))} -
+ ) : ( -
- {filteredProjects.length === 0 && ( -

No Projects Found

- )} - {filteredProjects.map((project) => ( - - ))} -
+

No Projects Found

)} ); diff --git a/apps/new/widget/build.jsx b/apps/new/widget/page/projects/index.jsx similarity index 92% rename from apps/new/widget/build.jsx rename to apps/new/widget/page/projects/index.jsx index fc29bd6b..f79fb804 100644 --- a/apps/new/widget/build.jsx +++ b/apps/new/widget/page/projects/index.jsx @@ -1,8 +1,5 @@ const config = { - theme: { - "--color": "white", - color: "var(--color)", - }, + theme: {}, layout: { src: "${alias_devs}/widget/Layout", props: { @@ -17,7 +14,7 @@ const config = { src="${config_account}/widget/components.sidebar" props={{ routes: config.router.routes, - currentRoute: "/builddao.near/widget/Index?page=build", + currentRoute: "/${config_account}/widget/Index?page=projects", ...props, }} /> @@ -28,7 +25,6 @@ const config = { param: "tab", routes: { projects: { - label: "BUILD", init: { name: "Projects", icon: "bi bi-gear", @@ -42,7 +38,7 @@ const config = { }, }, allProjects: { - path: "${config_account}/widget/page.projects", + path: "${config_account}/widget/page.projects.List", blockHeight: "final", init: { name: "All Projects", diff --git a/apps/new/widget/utils.js b/apps/new/widget/utils.js new file mode 100644 index 00000000..f42e0986 --- /dev/null +++ b/apps/new/widget/utils.js @@ -0,0 +1,46 @@ +/** This may be moved to a separate, common SDK */ +const fetchThings = ({ app, type, options }) => { + const keys = Social.keys( + `*/${app}/${type}/*`, + "final", + options || { + order: "desc", + }, + ); + + let flattenedKeys = flattenObject(keys); + const things = Social.get(flattenedKeys, "final"); + // check if things is singular (since we have to update the return format for parsing) + const isSingular = flattenedKeys.length === 1; + if (isSingular) { + const [_app, _type, _id] = flattenedKeys?.[0]?.split("/").slice(0, 3); + return { + [_app]: { + [_type]: { + [_id]: things, + }, + }, + }; + } + return things; +}; + +const flattenObject = (obj, app, type) => { + let paths = []; + + try { + Object.keys(obj).forEach((key) => { + const items = Object.keys(obj?.[key]?.[app]?.[type] ?? {}); + items.map((path) => { + if (!path || !path.includes("_")) { + return; + } + const convertedStr = path.replace(/_/g, "/"); + paths.push(convertedStr); + }); + }); + } catch (e) {} + return paths; +}; + +return { flattenObject, fetchThings }; From 964a57c4c3d4b39f8aeddeec964c4813152c47e0 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Fri, 24 May 2024 08:20:55 -0700 Subject: [PATCH 2/3] formatting --- apps/new/widget/Index.jsx | 5 +-- apps/new/widget/css.jsx | 1 - apps/new/widget/page/home/Hero.jsx | 2 +- apps/new/widget/page/projects/List.jsx | 7 ++-- apps/new/widget/utils.js | 46 -------------------------- 5 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 apps/new/widget/utils.js diff --git a/apps/new/widget/Index.jsx b/apps/new/widget/Index.jsx index d7c4e67f..d3b2e29a 100644 --- a/apps/new/widget/Index.jsx +++ b/apps/new/widget/Index.jsx @@ -42,9 +42,6 @@ const config = { return ( - + ); diff --git a/apps/new/widget/css.jsx b/apps/new/widget/css.jsx index fe0a59a6..cfbc9c63 100644 --- a/apps/new/widget/css.jsx +++ b/apps/new/widget/css.jsx @@ -1,5 +1,4 @@ const CSS = styled.div` - min-height: 100vh; @font-face { diff --git a/apps/new/widget/page/home/Hero.jsx b/apps/new/widget/page/home/Hero.jsx index 46adbaef..ddb95322 100644 --- a/apps/new/widget/page/home/Hero.jsx +++ b/apps/new/widget/page/home/Hero.jsx @@ -4,7 +4,7 @@ const { Button } = VM.require("${alias_old}/widget/components") || { const { BuilderHat } = VM.require("${alias_new}/widget/icons") || { BuilderHat: () => <>, -} +}; const HeroContainer = styled.div` display: flex; diff --git a/apps/new/widget/page/projects/List.jsx b/apps/new/widget/page/projects/List.jsx index ecfe8f26..239a7574 100644 --- a/apps/new/widget/page/projects/List.jsx +++ b/apps/new/widget/page/projects/List.jsx @@ -231,7 +231,8 @@ const Subheading = styled.h3` margin: 0; `; -const view = Storage.get("projectsView") ?? "grid"; +const view = Storage.get("${config_account}:projects-view") ?? "grid"; +const setView = (v) => Storage.set("${config_account}:projects-view", v); return ( Storage.set("projectsView", "grid")} + onClick={() => setView("grid")} > @@ -341,7 +342,7 @@ return ( type="icon" className="rounded-2" variant={view === "list" ? "primary" : null} - onClick={() => Storage.set("projectsView", "list")} + onClick={() => setView("list")} > diff --git a/apps/new/widget/utils.js b/apps/new/widget/utils.js deleted file mode 100644 index f42e0986..00000000 --- a/apps/new/widget/utils.js +++ /dev/null @@ -1,46 +0,0 @@ -/** This may be moved to a separate, common SDK */ -const fetchThings = ({ app, type, options }) => { - const keys = Social.keys( - `*/${app}/${type}/*`, - "final", - options || { - order: "desc", - }, - ); - - let flattenedKeys = flattenObject(keys); - const things = Social.get(flattenedKeys, "final"); - // check if things is singular (since we have to update the return format for parsing) - const isSingular = flattenedKeys.length === 1; - if (isSingular) { - const [_app, _type, _id] = flattenedKeys?.[0]?.split("/").slice(0, 3); - return { - [_app]: { - [_type]: { - [_id]: things, - }, - }, - }; - } - return things; -}; - -const flattenObject = (obj, app, type) => { - let paths = []; - - try { - Object.keys(obj).forEach((key) => { - const items = Object.keys(obj?.[key]?.[app]?.[type] ?? {}); - items.map((path) => { - if (!path || !path.includes("_")) { - return; - } - const convertedStr = path.replace(/_/g, "/"); - paths.push(convertedStr); - }); - }); - } catch (e) {} - return paths; -}; - -return { flattenObject, fetchThings }; From cf91a49b6f33bc91df38998228b192efdf4cda99 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Fri, 24 May 2024 08:40:47 -0700 Subject: [PATCH 3/3] adds label --- apps/new/widget/page/projects/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/new/widget/page/projects/index.jsx b/apps/new/widget/page/projects/index.jsx index f79fb804..616d005a 100644 --- a/apps/new/widget/page/projects/index.jsx +++ b/apps/new/widget/page/projects/index.jsx @@ -25,6 +25,7 @@ const config = { param: "tab", routes: { projects: { + label: "BUILD", init: { name: "Projects", icon: "bi bi-gear",