@@ -511,236 +414,63 @@ const avatarComponent = useMemo(() => {
);
}, [context.accountId]);
-// for drafts
-const [showDraftsModal, setShowDraftsModal] = useState(false);
-const [draftEditMode, setDraftEditMode] = useState(false);
-const [checkedDrafts, setCheckDrafts] = useState([]);
-
-// handle deletion of drafts
-const handleDraftDelete = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
- const newDrafts = drafts.filter((draft, i) => !checkedDrafts.includes(i));
- Storage.privateSet("savedDrafts", JSON.stringify(newDrafts));
- setCheckDrafts([]);
-};
-
-// handle draft save
-const onSaveDraft = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts) || [];
- drafts.push(postContent);
- Storage.privateSet("savedDrafts", JSON.stringify(drafts));
-};
-
-const DraftLabel = styled.span`
- display: inline-flex;
- padding: 12px;
- align-items: center;
- gap: 8px;
-
- color: #fff;
- font-size: 16px;
- font-style: normal;
- font-weight: 400;
- line-height: 170%; /* 27.2px */
-`;
-
-const DraftItem = ({ draft, checked, isEdit }) => {
- return (
-
- );
-};
-
-const RenderDrafts = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
-
- const handleDraftSelect = (draft) => {
- textareaInputHandler(draft);
- setPostUUID(generateUID());
- setShowDraftsModal(false);
- setView("editor");
- };
-
- return (
-
- );
-};
-
-const EditDrafts = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
-
- const handleDraftSelect = (draftIndex) => {
- if (checkedDrafts.includes(draftIndex)) {
- setCheckDrafts(checkedDrafts.filter((draft) => draft !== draftIndex));
- } else {
- setCheckDrafts([...checkedDrafts, draftIndex]);
- }
- };
-
- return (
-
- {drafts.map((draft, i) => (
-
handleDraftSelect(i)}>
-
+ {avatarComponent}
+
+ {view === "editor" ? (
+
+ {
+ setPostContent(v);
+ Storage.privateSet(draftKey, v || "");
+ },
+ }}
+ />
+
+ ) : (
+
+
-
- ))}
- {drafts.length === 0 && No drafts saved
}
+
+ )}
- );
-};
-return (
-
-
setShowDraftsModal(!showDraftsModal)}
- variant="outline"
- className="align-self-stretch mb-3"
- >
- Continue Drafts
-
-
setShowDraftsModal(!showDraftsModal)}
- editButton={
- draftEditMode ? (
-
-
-
-
- setDraftEditMode(!draftEditMode)}
- >
- Done
-
-
- ) : (
- setDraftEditMode(!draftEditMode)}
- >
- Edit
-
- )
- }
- children={{draftEditMode ? : }
}
- />
-
-
- {avatarComponent}
-
- Save Draft
-
-
-
+
+ setView(view === "editor" ? "preview" : "editor")}
+ style={{ fontSize: 14 }}
+ >
{view === "editor" ? (
-
- {
- textareaInputHandler(content);
- },
- embedCss: MarkdownEditor,
- }}
- />
- {autocompleteEnabled && showAccountAutocomplete && (
- setShowAccountAutocomplete(false),
- }}
- />
- )}
-
+ <>
+ Preview
+ >
) : (
-
-
- {state.image.cid && (
-
- )}
-
- )}
-
-
-
- {view === "editor" && (
-
+ <>
+ Edit
+ >
)}
- setView(view === "editor" ? "preview" : "editor")}
- style={{ fontSize: 14 }}
- >
- {view === "editor" ? (
- <>
- Preview
- >
- ) : (
- <>
- Edit
- >
- )}
-
-
- postToCustomFeed({ feed: props.feed, text: postContent, labels })
- }
- >
- Post {props.feed.name}
-
-
-
-
+
+
+ postToCustomFeed({ feed: props.feed, text: postContent, labels })
+ }
+ >
+ Post {props.feed.name}
+
+
+
);
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index b73c4264..38499bad 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -33,11 +33,7 @@ function Pagination({
function Post(props) {
return (
-
}
- props={{ ...props }}
- />
+
);
}
diff --git a/apps/builddao/widget/components/AccountAutocomplete.jsx b/apps/builddao/widget/components/AccountAutocomplete.jsx
deleted file mode 100644
index 5823f397..00000000
--- a/apps/builddao/widget/components/AccountAutocomplete.jsx
+++ /dev/null
@@ -1,147 +0,0 @@
-if (!context.accountId || !props.term) return <>>;
-
-let results = [];
-const filterAccounts = props.filterAccounts ?? []; // hide certain accounts from the list
-const profilesData = Social.get("*/profile/name", "final") || {};
-const followingData = Social.get(
- `${context.accountId}/graph/follow/**`,
- "final"
-);
-if (!profilesData) return <>>;
-const profiles = Object.entries(profilesData);
-const term = (props.term || "").replace(/\W/g, "").toLowerCase();
-const limit = 5;
-
-for (let i = 0; i < profiles.length; i++) {
- let score = 0;
- const accountId = profiles[i][0];
- const accountIdSearch = profiles[i][0].replace(/\W/g, "").toLowerCase();
- const nameSearch = (profiles[i][1]?.profile?.name || "")
- .replace(/\W/g, "")
- .toLowerCase();
- const accountIdSearchIndex = accountIdSearch.indexOf(term);
- const nameSearchIndex = nameSearch.indexOf(term);
-
- if (accountIdSearchIndex > -1 || nameSearchIndex > -1) {
- score += 10;
-
- if (accountIdSearchIndex === 0) {
- score += 10;
- }
- if (nameSearchIndex === 0) {
- score += 10;
- }
- if (followingData[accountId] === "") {
- score += 30;
- }
-
- results.push({
- accountId,
- score
- });
- }
-}
-
-results.sort((a, b) => b.score - a.score);
-results = results.slice(0, limit);
-if (filterAccounts?.length > 0) {
- results = results.filter((item) => !filterAccounts?.includes(item.accountId));
-}
-
-function onResultClick(id) {
- props.onSelect && props.onSelect(id);
-}
-
-const Wrapper = styled.div`
- position: relative;
-
- &::before {
- content: "";
- display: block;
- position: absolute;
- right: 0;
- width: 6px;
- height: 100%;
- z-index: 10;
- }
-`;
-
-const Scroller = styled.div`
- position: relative;
- display: flex;
- padding: 6px;
- gap: 6px;
- overflow: auto;
- scroll-behavior: smooth;
- align-items: center;
- scrollbar-width: none;
- -ms-overflow-style: none;
- &::-webkit-scrollbar {
- display: none;
- }
-
- > * {
- max-width: 175px;
- flex-grow: 0;
- flex-shrink: 0;
-
- button {
- border: 1px solid #eceef0;
- background: #fff !important;
- border-radius: 6px;
- padding: 3px 6px;
- transition: all 200ms;
-
- &:focus,
- &:hover {
- border-color: #687076;
- }
- }
- }
-`;
-
-const CloseButton = styled.button`
- background: none;
- border: none;
- display: block;
- padding: 12px;
- color white;
- transition: all 200ms;
-
- &:hover {
- transform:scale(1.2);
- }
-`;
-
-const ProfileCardWrapper = styled.div`
- opacity: 0.8;
-`;
-
-if (results.length === 0) return <>>;
-
-return (
-
-
-
-
-
-
- {results.map((result) => {
- return (
-
-
-
- );
- })}
-
-
-);
diff --git a/apps/builddao/widget/components/Checkbox.jsx b/apps/builddao/widget/components/Checkbox.jsx
index 1f3bed49..27387079 100644
--- a/apps/builddao/widget/components/Checkbox.jsx
+++ b/apps/builddao/widget/components/Checkbox.jsx
@@ -7,8 +7,6 @@ const CheckboxLabel = styled.label`
padding: 12px;
align-items: center;
gap: 8px;
- cursor: pointer;
- max-width: 100%;
color: #fff;
font-size: 16px;
@@ -17,20 +15,20 @@ const CheckboxLabel = styled.label`
line-height: 170%; /* 27.2px */
`;
-function Checkbox({ className, value, onChange, label }) {
+function Checkbox({ value, onChange, label }) {
return (
-
+
{value ? (
-
+
) : (
-
+
)}
- {label}
+ {label}
);
}
-return { Checkbox };
+return { Checkbox };
\ No newline at end of file
diff --git a/apps/builddao/widget/components/MarkdownEditorIframe.jsx b/apps/builddao/widget/components/MarkdownEditorIframe.jsx
deleted file mode 100644
index ffb2e26b..00000000
--- a/apps/builddao/widget/components/MarkdownEditorIframe.jsx
+++ /dev/null
@@ -1,64 +0,0 @@
-const data = props.data ?? "# Hello World\n\n";
-const embedCss = props.embedCss || "";
-
-const code = `
-
-
-
-
-
-
-
-
-
-
-`;
-return (
-
-);
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index c029e3b7..db7409fe 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -22,7 +22,7 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242b;
+ background: #23242B;
border-radius: 16px;
color: white;
`;
@@ -36,14 +36,14 @@ const NoButton = styled.button`
`;
const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
`;
const Icon = styled.i`
- font-size: 24px;
+ font-size: 24px;
`;
function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
@@ -72,4 +72,4 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
);
}
-return { Modal };
+return { Modal };
\ No newline at end of file
diff --git a/apps/builddao/widget/components/modals/DraftModal.jsx b/apps/builddao/widget/components/modals/DraftModal.jsx
deleted file mode 100644
index 825338a6..00000000
--- a/apps/builddao/widget/components/modals/DraftModal.jsx
+++ /dev/null
@@ -1,89 +0,0 @@
-const { Button } = VM.require("buildhub.near/widget/components.Button");
-
-const toggle = props.toggle ??
Open Modal ;
-
-const Overlay = styled.div`
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- display: grid;
- place-items: center;
- overflow-y: auto;
- z-index: 1000;
- width: 100vw;
- height: 100vh;
- background: rgba(11, 12, 20, 0.5);
-`;
-
-const Content = styled.div`
- min-width: 500px;
- max-width: 1000px;
- padding: 24px;
- outline: none !important;
- background: #23242b;
- border-radius: 16px;
- color: white;
-
- @media screen and (max-width: 768px) {
- max-width: 90%;
- min-width: 50%;
- width: 100%;
- }
-`;
-
-const NoButton = styled.button`
- background: transparent;
- border: none;
- padding: 0;
- margin: 0;
- box-shadow: none;
-`;
-
-const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
-`;
-
-const Icon = styled.i`
- font-size: 24px;
-`;
-
-function DraftModal({
- children,
- open,
- onOpenChange,
- toggle,
- toggleContainerProps,
- editButton,
-}) {
- return (
-
-
- {toggle}
-
-
-
-
-
-
-
-
- Drafts
-
-
- {editButton}
-
- {children}
-
-
-
-
-
- );
-}
-
-return { DraftModal };
From b925adfaca67e8449701f0244530bd447816dabc Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 24 Jan 2024 22:20:31 +0500
Subject: [PATCH 015/132] Replace old Feed with General Feed
---
apps/builddao/widget/Feed.jsx | 321 ++++++------------
apps/builddao/widget/GeneralFeed.jsx | 112 ------
apps/builddao/widget/components/Post.jsx | 1 +
.../widget/components/post/Content.jsx | 2 +-
apps/builddao/widget/config.jsx | 12 +-
apps/builddao/widget/page/feed.jsx | 52 +--
6 files changed, 114 insertions(+), 386 deletions(-)
delete mode 100644 apps/builddao/widget/GeneralFeed.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 6113ad5d..78847859 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -1,233 +1,114 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed");
-const { ButtonLink } = VM.require("buildhub.near/widget/components.ButtonLink");
-
-ButtonLink || (ButtonLink = () => <>>);
-Feed = Feed || (() => <>>); // ensure it's defined or set to a default component
+const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
+const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
+ Post: () => <>>,
+ ButtonLink: () => <>>,
+};
-const { type, hashtag } = props;
-type = hashtag;
-hashtag = type;
+const daoName = props.daoName || "Build DAO";
+const feedLink = props.feedLink || "https://nearbuilders.org/feed";
+const daoTag = props.daoTag || "build";
-const tab = props.tab || "resolutions";
+const feeds = props.feeds || {};
-if (!tab) {
+if (!feeds) {
return "";
}
-const { Post } = VM.require("buildhub.near/widget/components");
-Post = Post || (() => <>>);
-
-function formatDate(date) {
- const options = { year: "numeric", month: "short", day: "numeric" };
- return date.toLocaleDateString("en-US", options);
+const tab = props.tab || Object.keys(feeds)[0];
+if (Object.keys(feeds).includes(props.hashtag)) {
+ tab = props.hashtag;
}
-
-const feeds = {
- resolutions: {
- label: "Resolutions",
- icon: "bi-calendar3",
- name: "resolution",
- hashtag: "nearyearresolutions2024",
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed))
-
-**🌟 REFLECTIONS ON THE PAST YEAR:**
-- [Reflection 1 from the past year]
-- [Reflection 2 from the past year]
-
-**🎯 NEW YEAR'S RESOLUTIONS:**
-- [Resolution 1]
-- [Resolution 2]
-
-**📊 MEASURING SUCCESS:**
-- [Metric 1 for Success]
-- [Metric 2 for Success]
-`,
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=update))
-
-**✅ DONE**
-- [what'd you do]
-- [link proof]
-
-**⏩ NEXT**
-- [what's next?]
-- [what are you thinking about?]
-
-**🛑 BLOCKERS**
-- [what's blocking you?]
-- [how can someone help?]
-`,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=documentation))
-
-**WHAT IS _____?**
-- [context]
-- [why is it important?]
-
-**EXAMPLE**
-- [how can this be demonstrated?]
-- [what is the expected outcome?]
-
-**USAGE**
-- [where is it used?]
-- [how to use it]
-`,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=question))
-
-[what are you thinking about?]
-[why are you asking?]
-`,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=answer))
-
-[please restate the question you are answering]
-
-[your answer]
-
-[link to relevant docs, examples, or resources]
-`,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=opportunity))
-
-[what is the opportunity?]
-
-[explain the motivation or reason]
-
-`,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: ``,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- template: `## TASK TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=task))
-
-**What needs to be done?**
-- [Describe the task or action steps]
-
-**Context or additional information:**
-- [Provide any context or details]
-`,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- },
-};
-
-const [activeFeed, setActiveFeed] = useState(tab || "resolutions");
+const [activeFeed, setActiveFeed] = useState(tab);
return (
- {
- const data = feeds[route];
- return (
-
-
- {data.label}
-
- );
- }),
- mainContent: (
- <>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
+ <>
+ {
+ const data = feeds[route];
+ return (
+
+
+ {data.label}
+
+ );
+ }),
+ mainContent: (
+ <>
+ {context.accountId ? (
+ activeFeed !== "bookmarks" ? (
+
+ ) : (
+
+ )
+ ) : (
- ) : (
-
- )
- ) : (
-
- )}
- {activeFeed !== "bookmarks" && (
- (
-
- )}
- />
- )}
- >
- ),
- }}
- />
+ // fix this
+ // {
+ // action: "hashtag",
+ // key: daoTag, // build
+ // options: {
+ // limit: 10,
+ // order: "desc",
+ // },
+ // cacheOptions: {
+ // ignoreCache: true,
+ // },
+ // required: true,
+ // },
+ ]}
+ Item={(p) => (
+
+ )}
+ />
+ )}
+ >
+ ),
+ }}
+ />
+ >
);
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
deleted file mode 100644
index 942755e8..00000000
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ /dev/null
@@ -1,112 +0,0 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
-const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
- Post: () => <>>,
- ButtonLink: () => <>>,
-};
-
-const daoName = props.daoName || "Build DAO";
-const feedLink = props.feedLink || "https://nearbuilders.org/feed";
-const daoTag = props.daoTag || "build";
-
-const feeds = props.feeds || {};
-
-if (!feeds) {
- return "";
-}
-
-const tab = props.tab || Object.keys(feeds)[0];
-if (Object.keys(feeds).includes(props.hashtag)) {
- tab = props.hashtag;
-}
-const [activeFeed, setActiveFeed] = useState(tab);
-
-return (
- <>
- {
- const data = feeds[route];
- return (
-
-
- {data.label}
-
- );
- }),
- mainContent: (
- <>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
-
- ) : (
-
- )
- ) : (
-
- )}
- {activeFeed !== "bookmarks" && (
- (
-
- )}
- />
- )}
- >
- ),
- }}
- />
- >
-);
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index bf8b7fd9..863cd43b 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -266,6 +266,7 @@ const contentWidget = (
raw,
truncateContent: props.truncateContent,
noEmbed: props.noEmbed,
+ currentPath: props.currentPath,
}}
/>
diff --git a/apps/builddao/widget/components/post/Content.jsx b/apps/builddao/widget/components/post/Content.jsx
index cc7f49a0..5d18cc8d 100644
--- a/apps/builddao/widget/components/post/Content.jsx
+++ b/apps/builddao/widget/components/post/Content.jsx
@@ -59,7 +59,7 @@ const [onHashtag] = useState(() => (hashtag) => (
className="d-inline-flex"
style={{ color: "var(--bs-link-color)" }}
>
- #{hashtag}
+ #{hashtag}
));
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 6b57fa9b..d91fddf8 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -182,16 +182,14 @@ return {
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
- init: {
- icon: "bi bi-globe",
- },
- },
- generalFeed: {
- path: "buildhub.near/widget/GeneralFeed",
- blockHeight: "final",
init: {
icon: "bi bi-globe",
feeds: feeds,
+ daoName: "Build DAO",
+ feedLink: "https://nearbuilders.org/feed",
+ daoTag: "build",
+ pagePath: "/?page=feed",
+ //hashtag: "something"
},
},
inspect: {
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 53cc3566..f4b8ab32 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,49 +1,9 @@
-const { Feed } = VM.require("devs.near/widget/Feed") || {
- // this is being pulled from local apps/bos-blocks/widget/Feed
- Feed: () => Feed loading...
,
-};
-
-// would a provider pattern be helpful here?
-// const { items } = props;
-
-const [activeItem, setActiveItem] = useState(null);
-
-function Sidebar() {
- return ( // minimal styling, classnames from Theme
- setActiveItem}>
-
sidebar
-
- );
-}
-
-// can we take influence from the pattern in buildhub.near/widget/app?
-
return (
- <>
-
- {JSON.stringify(p)}
}
+
+
- >
+
);
From 14c4f02880683d49ad525c8374c7ec1fe6556c04 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 01:47:16 +0500
Subject: [PATCH 016/132] Change sidebar to navbar
---
apps/builddao/widget/app.jsx | 14 ++-
apps/builddao/widget/config.jsx | 3 +-
apps/builddao/widget/page/home.jsx | 2 +-
apps/builddao/widget/template/layout.jsx | 103 +++++++++++++++++++++++
4 files changed, 111 insertions(+), 11 deletions(-)
create mode 100644 apps/builddao/widget/template/layout.jsx
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 5c2f5b60..05e13412 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -2,10 +2,10 @@ const { page, layout, loading, ...passProps } = props;
const { routes, theme } = VM.require("buildhub.near/widget/config") ?? {
routes: {},
- theme: "background-color: red;"
+ theme: "background-color: red;",
};
-const { AppLayout } = VM.require("every.near/widget/layout") || {
+const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
AppLayout: () => <>Layout loading...>,
};
@@ -16,9 +16,7 @@ const Root = styled.div`
color: inherit;
}
- ${theme}
-
- // can come from config
+ ${theme}// can come from config
`;
const [activeRoute, setActiveRoute] = useState(page);
@@ -27,7 +25,8 @@ useEffect(() => {
setActiveRoute(page);
}, [page]);
-function Router({ active, routes }) { // this may be converted to a module at devs.near/widget/Router
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
const routeParts = active.split(".");
let currentRoute = routes;
@@ -60,13 +59,12 @@ function Router({ active, routes }) { // this may be converted to a module at de
const Container = styled.div`
display: flex;
- height: 100vh;
+ height: 100%;
`;
const Content = styled.div`
width: 100%;
height: 100%;
- overflow: scroll;
`;
return (
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index d91fddf8..a94fc53c 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -176,14 +176,13 @@ return {
blockHeight: "final",
init: {
name: "Home",
- icon: "bi bi-house",
},
},
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
init: {
- icon: "bi bi-globe",
+ name: "Feed",
feeds: feeds,
daoName: "Build DAO",
feedLink: "https://nearbuilders.org/feed",
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index c61d8eb7..a74adcab 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -1 +1 @@
-return home
;
+return ;
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
new file mode 100644
index 00000000..ff43b84a
--- /dev/null
+++ b/apps/builddao/widget/template/layout.jsx
@@ -0,0 +1,103 @@
+const { Button } = VM.require("buildhub.near/widget/components");
+
+const Container = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ height: 100%;
+ // margin-top: calc(-1 * var(--body-top-padding));
+`;
+
+const ContentContainer = styled.div`
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+`;
+
+const Navbar = styled.div`
+ width: 64px;
+
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ padding: 24px;
+ width: 100%;
+
+ border: 2px outset #3c3d43;
+ background-color: #0b0c14;
+`;
+
+const ButtonGroup = styled.div`
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 8px;
+`;
+
+const { NavLink } = props || {
+ NavLink: ({ to, children }) => (
+
+ {children}
+
+ ),
+};
+
+const AppHeader = ({ page, routes }) => (
+
+
+ {routes &&
+ (Object.keys(routes) || []).map((k) => {
+ const route = routes[k];
+ if (route.hide) {
+ return null;
+ }
+ return (
+
+
+ {route.init.icon && }
+ {route.init.name}
+
+
+ );
+ })}
+
+ {routes && (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )}
+
+);
+
+const Footer = (props) => {
+ return <>>;
+};
+
+// Define the new component that follows the AppLayout pattern
+function AppLayout({ routes, page, children }) {
+ return (
+ <>
+
+
+ {children}
+
+
+ >
+ );
+}
+
+return { AppLayout };
From e3d049aa430532d5180327844f54144b3716b579 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:21:39 +0500
Subject: [PATCH 017/132] refactor and style changes
---
apps/builddao/widget/Feed.jsx | 30 +--
apps/builddao/widget/Proposals.jsx | 1 +
apps/builddao/widget/app.jsx | 16 +-
.../builddao/widget/components/ButtonLink.jsx | 2 +-
apps/builddao/widget/config.jsx | 189 +-----------------
apps/builddao/widget/config/feed.jsx | 148 ++++++++++++++
apps/builddao/widget/config/theme.jsx | 33 +++
apps/builddao/widget/page/feed.jsx | 19 +-
apps/builddao/widget/page/proposal.jsx | 8 +
apps/builddao/widget/template/layout.jsx | 3 +-
10 files changed, 237 insertions(+), 212 deletions(-)
create mode 100644 apps/builddao/widget/Proposals.jsx
create mode 100644 apps/builddao/widget/config/feed.jsx
create mode 100644 apps/builddao/widget/config/theme.jsx
create mode 100644 apps/builddao/widget/page/proposal.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 78847859..930d6334 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -39,6 +39,7 @@ return (
fontSize: "14px",
textDecoration: "none",
cursor: "pointer",
+ padding: "8px 12px",
}}
>
@@ -48,26 +49,27 @@ return (
}),
mainContent: (
<>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
-
- ) : (
-
- )
+ {feeds[activeFeed].hideCompose ? null : context.accountId ? (
+
) : (
)}
- {activeFeed !== "bookmarks" && (
+ {feeds[activeFeed].customWidget ? (
+
+ ) : (
Proposals ;
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 05e13412..e4200242 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,8 +1,11 @@
const { page, layout, loading, ...passProps } = props;
-const { routes, theme } = VM.require("buildhub.near/widget/config") ?? {
+const { routes } = VM.require("buildhub.near/widget/config") ?? {
routes: {},
- theme: "background-color: red;",
+};
+
+const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+ theme: {},
};
const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
@@ -12,10 +15,6 @@ const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
if (!page) page = Object.keys(routes)[0] || "home";
const Root = styled.div`
- a {
- color: inherit;
- }
-
${theme}// can come from config
`;
@@ -49,10 +48,7 @@ function Router({ active, routes }) {
return (
-
+
);
}
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index f9a3978c..11283685 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -41,7 +41,7 @@ const StyledLink = styled.a`
default:
return "var(--button-default-color, #CDD0D5)";
}
- }} !important;
+ }};
border: ${(props) =>
props.variant === "outline"
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index a94fc53c..34290fbb 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -1,173 +1,3 @@
-function formatDate(date) {
- const options = { year: "numeric", month: "short", day: "numeric" };
- return date.toLocaleDateString("en-US", options);
-}
-
-const theme = `
- --stroke-color: rgba(255, 255, 255, 0.2);
- --bg-1: #0b0c14;
- --bg-1-hover: #17181c;
- --bg-1-hover-transparent: rgba(23, 24, 28, 0);
- --bg-2: ##23242b;
- --label-color: #fff;
- --font-color: #fff;
- --font-muted-color: #cdd0d5;
- --black: #000;
- --system-red: #fd2a5c;
- --yellow: #ffaf51;
-
- --compose-bg: #23242b;
-
- --post-bg: #0b0c14;
- --post-bg-hover: #17181c;
- --post-bg-transparent: rgba(23, 24, 28, 0);
-
- --button-primary-bg: #ffaf51;
- --button-outline-bg: transparent;
- --button-default-bg: #23242b;
-
- --button-primary-color: #000;
- --button-outline-color: #fff;
- --button-default-color: #cdd0d5;
-
- --button-primary-hover-bg: #e49b48;
- --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
- --button-default-hover-bg: #17181c;
-`;
-
-const feeds = {
- resolutions: {
- label: "Resolutions",
- icon: "bi-calendar3",
- name: "resolution",
- hashtag: "nearyearresolutions2024",
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
- (posted via [${daoName} Gateway](${feedLink}))
-
- **🌟 REFLECTIONS ON THE PAST YEAR:**
- - [Reflection 1 from the past year]
- - [Reflection 2 from the past year]
-
- **🎯 NEW YEAR'S RESOLUTIONS:**
- - [Resolution 1]
- - [Resolution 2]
-
- **📊 MEASURING SUCCESS:**
- - [Metric 1 for Success]
- - [Metric 2 for Success]
- `,
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
- (posted via [${daoName} Gateway](${feedLink}?tab=update))
-
- **✅ DONE**
- - [what'd you do]
- - [link proof]
-
- **⏩ NEXT**
- - [what's next?]
- - [what are you thinking about?]
-
- **🛑 BLOCKERS**
- - [what's blocking you?]
- - [how can someone help?]
- `,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
-
- **WHAT IS _____?**
- - [context]
- - [why is it important?]
-
- **EXAMPLE**
- - [how can this be demonstrated?]
- - [what is the expected outcome?]
-
- **USAGE**
- - [where is it used?]
- - [how to use it]
- `,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
- (posted via [${daoName} Gateway](${feedLink}?tab=question))
-
- [what are you thinking about?]
- [why are you asking?]
- `,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
- (posted via [${daoName} Gateway](${feedLink}?tab=answer))
-
- [please restate the question you are answering]
-
- [your answer]
-
- [link to relevant docs, examples, or resources]
- `,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
-
- [what is the opportunity?]
-
- [explain the motivation or reason]
-
- `,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: ``,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- template: `## TASK TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=task))
-
- **What needs to be done?**
- - [Describe the task or action steps]
-
- **Context or additional information:**
- - [Provide any context or details]
- `,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- },
-};
-
return {
type: "app",
routes: {
@@ -183,23 +13,14 @@ return {
blockHeight: "final",
init: {
name: "Feed",
- feeds: feeds,
- daoName: "Build DAO",
- feedLink: "https://nearbuilders.org/feed",
- daoTag: "build",
- pagePath: "/?page=feed",
- //hashtag: "something"
},
},
- inspect: {
- path: "mob.near/widget/WidgetSource",
+ proposal: {
+ path: "buildhub.near/widget/page.proposal",
blockHeight: "final",
- hide: true,
- },
- notifications: {
- path: "mob.near/widget/NotificationFeed",
- blockHeight: "final",
- hide: true,
+ init: {
+ name: "Proposal",
+ },
},
},
theme: theme,
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
new file mode 100644
index 00000000..e6f8a3c8
--- /dev/null
+++ b/apps/builddao/widget/config/feed.jsx
@@ -0,0 +1,148 @@
+function formatDate(date) {
+ const options = { year: "numeric", month: "short", day: "numeric" };
+ return date.toLocaleDateString("en-US", options);
+}
+
+const feeds = {
+ resolutions: {
+ label: "Resolutions",
+ icon: "bi-calendar3",
+ name: "resolution",
+ hashtag: "nearyearresolutions2024",
+ template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
+ (posted via [${daoName} Gateway](${feedLink}))
+
+ **🌟 REFLECTIONS ON THE PAST YEAR:**
+ - [Reflection 1 from the past year]
+ - [Reflection 2 from the past year]
+
+ **🎯 NEW YEAR'S RESOLUTIONS:**
+ - [Resolution 1]
+ - [Resolution 2]
+
+ **📊 MEASURING SUCCESS:**
+ - [Metric 1 for Success]
+ - [Metric 2 for Success]
+ `,
+ },
+ updates: {
+ label: "Updates",
+ icon: "bi-bell",
+ name: "update",
+ hashtag: "update",
+ template: `### BUILDER UPDATE: ${formatDate(new Date())}
+ (posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+ **✅ DONE**
+ - [what'd you do]
+ - [link proof]
+
+ **⏩ NEXT**
+ - [what's next?]
+ - [what are you thinking about?]
+
+ **🛑 BLOCKERS**
+ - [what's blocking you?]
+ - [how can someone help?]
+ `,
+ },
+ documentation: {
+ label: "Documentation",
+ icon: "bi-book",
+ name: "documentation",
+ hashtag: "documentation",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+ **WHAT IS _____?**
+ - [context]
+ - [why is it important?]
+
+ **EXAMPLE**
+ - [how can this be demonstrated?]
+ - [what is the expected outcome?]
+
+ **USAGE**
+ - [where is it used?]
+ - [how to use it]
+ `,
+ },
+ question: {
+ label: "Question",
+ icon: "bi-question-lg",
+ name: "question",
+ hashtag: "question",
+ template: `## what is your question?
+ (posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+ [what are you thinking about?]
+ [why are you asking?]
+ `,
+ },
+ answer: {
+ label: "Answer",
+ icon: "bi-journal-code",
+ name: "answer",
+ hashtag: "answer",
+ template: `## Share an answer
+ (posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+ [please restate the question you are answering]
+
+ [your answer]
+
+ [link to relevant docs, examples, or resources]
+ `,
+ },
+ opportunity: {
+ label: "Opportunity",
+ icon: "bi-briefcase",
+ name: "opportunity",
+ hashtag: "opportunity",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+ [what is the opportunity?]
+
+ [explain the motivation or reason]
+
+ `,
+ },
+ idea: {
+ label: "Idea",
+ icon: "bi-lightbulb",
+ name: "idea",
+ hashtag: "idea",
+ template: ``,
+ },
+ task: {
+ label: "Task",
+ icon: "bi-check-lg",
+ name: "task",
+ template: `## TASK TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+ **What needs to be done?**
+ - [Describe the task or action steps]
+
+ **Context or additional information:**
+ - [Provide any context or details]
+ `,
+ },
+ bookmarks: {
+ label: "Bookmarks",
+ icon: "bi-bookmark",
+ name: "bookmark",
+ hideCompose: true,
+ customWidget: "buildhub.near/widget/Bookmarks",
+ },
+ proposals: {
+ label: "Proposals",
+ icon: "bi-file-earmark-text",
+ name: "proposal",
+ hideCompose: true,
+ customWidget: "buildhub.near/widget/Proposals",
+ },
+};
+
+return { type: config, feeds: feeds };
diff --git a/apps/builddao/widget/config/theme.jsx b/apps/builddao/widget/config/theme.jsx
new file mode 100644
index 00000000..b3253beb
--- /dev/null
+++ b/apps/builddao/widget/config/theme.jsx
@@ -0,0 +1,33 @@
+const theme = `
+ --stroke-color: rgba(255, 255, 255, 0.2);
+ --bg-1: #0b0c14;
+ --bg-1-hover: #17181c;
+ --bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --bg-2: ##23242b;
+ --label-color: #fff;
+ --font-color: #fff;
+ --font-muted-color: #cdd0d5;
+ --black: #000;
+ --system-red: #fd2a5c;
+ --yellow: #ffaf51;
+
+ --compose-bg: #23242b;
+
+ --post-bg: #0b0c14;
+ --post-bg-hover: #17181c;
+ --post-bg-transparent: rgba(23, 24, 28, 0);
+
+ --button-primary-bg: #ffaf51;
+ --button-outline-bg: transparent;
+ --button-default-bg: #23242b;
+
+ --button-primary-color: #000;
+ --button-outline-color: #fff;
+ --button-default-color: #cdd0d5;
+
+ --button-primary-hover-bg: #e49b48;
+ --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
+ --button-default-hover-bg: #17181c;
+`;
+
+return { type: "theme", theme: theme };
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index f4b8ab32..910b11ab 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,9 +1,26 @@
+const { feeds } = VM.require("buildhub.near/widget/config.feed");
+
+console.log(feeds);
+
+if (!feeds) {
+ return "...";
+}
+
+const defaultProps = {
+ feeds: feeds,
+ daoName: "Build DAO",
+ feedLink: "https://nearbuilders.org/feed",
+ daoTag: "build",
+ pagePath: "/?page=feed",
+ //hashtag: "something"
+};
+
return (
);
diff --git a/apps/builddao/widget/page/proposal.jsx b/apps/builddao/widget/page/proposal.jsx
new file mode 100644
index 00000000..b3529c33
--- /dev/null
+++ b/apps/builddao/widget/page/proposal.jsx
@@ -0,0 +1,8 @@
+return (
+
+
+
+);
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
index ff43b84a..9e7ba415 100644
--- a/apps/builddao/widget/template/layout.jsx
+++ b/apps/builddao/widget/template/layout.jsx
@@ -26,7 +26,6 @@ const Navbar = styled.div`
padding: 24px;
width: 100%;
- border: 2px outset #3c3d43;
background-color: #0b0c14;
`;
@@ -46,7 +45,7 @@ const { NavLink } = props || {
};
const AppHeader = ({ page, routes }) => (
-
+
{routes &&
(Object.keys(routes) || []).map((k) => {
From 6a6d08e2a4ce7f04bdfabe9b44faaea7da5a9094 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:26:55 +0500
Subject: [PATCH 018/132] Style updates to match figma
---
apps/builddao/widget/Feed.jsx | 3 ++-
apps/builddao/widget/config/theme.jsx | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 930d6334..46626a13 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -40,10 +40,11 @@ return (
textDecoration: "none",
cursor: "pointer",
padding: "8px 12px",
+ gap: "10px",
}}
>
- {data.label}
+ {data.label}
);
}),
diff --git a/apps/builddao/widget/config/theme.jsx b/apps/builddao/widget/config/theme.jsx
index b3253beb..4a24853c 100644
--- a/apps/builddao/widget/config/theme.jsx
+++ b/apps/builddao/widget/config/theme.jsx
@@ -22,7 +22,7 @@ const theme = `
--button-default-bg: #23242b;
--button-primary-color: #000;
- --button-outline-color: #fff;
+ --button-outline-color: #cdd0d5;
--button-default-color: #cdd0d5;
--button-primary-hover-bg: #e49b48;
From ac1025b6629ac809f975efce62f18bb098dc004d Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:41:11 +0500
Subject: [PATCH 019/132] Fix navbar variant
---
apps/builddao/widget/template/layout.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
index 9e7ba415..201bf9a3 100644
--- a/apps/builddao/widget/template/layout.jsx
+++ b/apps/builddao/widget/template/layout.jsx
@@ -55,7 +55,7 @@ const AppHeader = ({ page, routes }) => (
}
return (
-
+
{route.init.icon && }
{route.init.name}
From a7e57f75c0ab07816dfe69ae02ed3db96eaa1aea Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:44:41 +0500
Subject: [PATCH 020/132] Fix task feed
---
apps/builddao/widget/config/feed.jsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index e6f8a3c8..08ce4cca 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -119,6 +119,7 @@ const feeds = {
label: "Task",
icon: "bi-check-lg",
name: "task",
+ hashtag: "task",
template: `## TASK TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=task))
From e9e7fdfabcc122dd06a4de2b83241f296e1cc5ba Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:53:15 +0500
Subject: [PATCH 021/132] fix feed templates
---
apps/builddao/widget/config/feed.jsx | 147 ++++++++++++++-------------
1 file changed, 79 insertions(+), 68 deletions(-)
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 08ce4cca..c8dc2dc0 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -3,6 +3,9 @@ function formatDate(date) {
return date.toLocaleDateString("en-US", options);
}
+const daoName = "Build DAO";
+const feedLink = "https://nearbuilders.org/feed";
+
const feeds = {
resolutions: {
label: "Resolutions",
@@ -10,20 +13,20 @@ const feeds = {
name: "resolution",
hashtag: "nearyearresolutions2024",
template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
- (posted via [${daoName} Gateway](${feedLink}))
+(posted via [${daoName} Gateway](${feedLink}))
- **🌟 REFLECTIONS ON THE PAST YEAR:**
- - [Reflection 1 from the past year]
- - [Reflection 2 from the past year]
+**🌟 REFLECTIONS ON THE PAST YEAR:**
+- [Reflection 1 from the past year]
+- [Reflection 2 from the past year]
- **🎯 NEW YEAR'S RESOLUTIONS:**
- - [Resolution 1]
- - [Resolution 2]
+**🎯 NEW YEAR'S RESOLUTIONS:**
+- [Resolution 1]
+- [Resolution 2]
- **📊 MEASURING SUCCESS:**
- - [Metric 1 for Success]
- - [Metric 2 for Success]
- `,
+**📊 MEASURING SUCCESS:**
+- [Metric 1 for Success]
+- [Metric 2 for Success]
+`,
},
updates: {
label: "Updates",
@@ -31,20 +34,20 @@ const feeds = {
name: "update",
hashtag: "update",
template: `### BUILDER UPDATE: ${formatDate(new Date())}
- (posted via [${daoName} Gateway](${feedLink}?tab=update))
-
- **✅ DONE**
- - [what'd you do]
- - [link proof]
-
- **⏩ NEXT**
- - [what's next?]
- - [what are you thinking about?]
-
- **🛑 BLOCKERS**
- - [what's blocking you?]
- - [how can someone help?]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+**✅ DONE**
+- [what'd you do]
+- [link proof]
+
+**⏩ NEXT**
+- [what's next?]
+- [what are you thinking about?]
+
+**🛑 BLOCKERS**
+- [what's blocking you?]
+- [how can someone help?]
+`,
},
documentation: {
label: "Documentation",
@@ -52,20 +55,20 @@ const feeds = {
name: "documentation",
hashtag: "documentation",
template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
-
- **WHAT IS _____?**
- - [context]
- - [why is it important?]
-
- **EXAMPLE**
- - [how can this be demonstrated?]
- - [what is the expected outcome?]
-
- **USAGE**
- - [where is it used?]
- - [how to use it]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+**WHAT IS _____?**
+- [context]
+- [why is it important?]
+
+**EXAMPLE**
+- [how can this be demonstrated?]
+- [what is the expected outcome?]
+
+**USAGE**
+- [where is it used?]
+- [how to use it]
+`,
},
question: {
label: "Question",
@@ -73,11 +76,11 @@ const feeds = {
name: "question",
hashtag: "question",
template: `## what is your question?
- (posted via [${daoName} Gateway](${feedLink}?tab=question))
-
- [what are you thinking about?]
- [why are you asking?]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+[what are you thinking about?]
+[why are you asking?]
+`,
},
answer: {
label: "Answer",
@@ -85,14 +88,14 @@ const feeds = {
name: "answer",
hashtag: "answer",
template: `## Share an answer
- (posted via [${daoName} Gateway](${feedLink}?tab=answer))
-
- [please restate the question you are answering]
-
- [your answer]
-
- [link to relevant docs, examples, or resources]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+[please restate the question you are answering]
+
+[your answer]
+
+[link to relevant docs, examples, or resources]
+`,
},
opportunity: {
label: "Opportunity",
@@ -100,20 +103,28 @@ const feeds = {
name: "opportunity",
hashtag: "opportunity",
template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
-
- [what is the opportunity?]
-
- [explain the motivation or reason]
-
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+[what is the opportunity?]
+
+[explain the motivation or reason]
+
+`,
},
idea: {
label: "Idea",
icon: "bi-lightbulb",
name: "idea",
hashtag: "idea",
- template: ``,
+ template: `## IDEA TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=idea))
+
+**What idea are you proposing?**
+- [Describe the idea]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
},
task: {
label: "Task",
@@ -121,14 +132,14 @@ const feeds = {
name: "task",
hashtag: "task",
template: `## TASK TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=task))
-
- **What needs to be done?**
- - [Describe the task or action steps]
-
- **Context or additional information:**
- - [Provide any context or details]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+**What needs to be done?**
+- [Describe the task or action steps]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
},
bookmarks: {
label: "Bookmarks",
From e4994dbaa21e081dc9cb6cbcf2b975f9a67ba06e Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 22:41:14 +0500
Subject: [PATCH 022/132] Add request feed with custom propose action
---
apps/builddao/widget/Feed.jsx | 1 +
apps/builddao/widget/Post.jsx | 372 -----------------------
apps/builddao/widget/Post/Header.jsx | 169 ----------
apps/builddao/widget/components/Post.jsx | 2 +
apps/builddao/widget/components/User.jsx | 14 +
apps/builddao/widget/config/feed.jsx | 37 ++-
6 files changed, 47 insertions(+), 548 deletions(-)
delete mode 100644 apps/builddao/widget/Post.jsx
delete mode 100644 apps/builddao/widget/Post/Header.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 46626a13..e602ddfe 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -105,6 +105,7 @@ return (
blockHeight={p.blockHeight}
noBorder={true}
currentPath={`${props.pagePath}`}
+ customActions={feeds[activeFeed].customActions}
/>
)}
/>
diff --git a/apps/builddao/widget/Post.jsx b/apps/builddao/widget/Post.jsx
deleted file mode 100644
index 94901be7..00000000
--- a/apps/builddao/widget/Post.jsx
+++ /dev/null
@@ -1,372 +0,0 @@
-const accountId = props.accountId;
-if (!accountId) {
- return "No accountId";
-}
-const blockHeight =
- props.blockHeight === "now" ? "now" : parseInt(props.blockHeight);
-const pinned = !!props.pinned;
-const hideMenu = !!props.hideMenu;
-const hideButtons = !!props.hideButtons;
-const content =
- props.content ??
- JSON.parse(Social.get(`${accountId}/post/main`, blockHeight) ?? "null");
-const subscribe = !!props.subscribe;
-const raw = !!props.raw;
-const groupId = props.groupId ?? content.groupId;
-const indexKey = props.indexKey;
-const permissions = props.permissions;
-const fullPostLink = props.fullPostLink;
-const postPage = props.postPage ?? "mob.near/widget/MainPage.N.Post.Page";
-
-const notifyAccountId = accountId;
-const item = {
- type: "social",
- path: `${accountId}/post/main`,
- blockHeight,
-};
-
-const link =
- props.link ??
- props.fullPostLink ??
- `/${postPage}?accountId=${accountId}&blockHeight=${blockHeight}`;
-
-const StyledPost = styled.div`
- margin-bottom: 1rem;
- .post {
- border-radius: 16px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
- color: #b6b6b8;
- padding: 24px !important;
- background-color: #0b0c14;
- transition: all 300ms;
-
- &:hover {
- background-color: #171929 !important;
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgb(23, 25, 41, 0),
- rgb(23, 25, 41, 1) 25%
- ) !important;
- }
- }
-
- .post-header {
- span,
- .text-muted {
- color: #fff !important;
- }
- }
-
- .buttons {
- border-top: 1px solid #3c3d43;
- padding: 0.5rem;
- }
-
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgb(11, 12, 20, 0),
- rgb(11, 12, 20, 1) 25%
- ) !important;
- }
- }
-
- .dropdown-menu {
- background-color: #0b0c14 !important;
- color: #fff !important;
-
- li.dropdown-item {
- color: #fff !important;
- &:hover {
- a {
- color: #0b0c14 !important;
- }
- }
- }
-
- .link-dark,
- .dropdown-item {
- color: #fff !important;
-
- &:hover {
- color: #0b0c14 !important;
-
- span {
- color: #0b0c14 !important;
- }
- }
- }
- }
-
- textarea {
- color: #b6b6b8 !important;
- }
-`;
-
-const Wrapper = styled.div`
- margin: 0 -12px;
- line-height: normal;
-
- .post {
- position: relative;
- padding: 12px;
- padding-bottom: 4px;
- display: flex;
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- font-size: 16px !important;
- }
- @media (max-width: 767px) {
- font-size: 15px !important;
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- font-size: 15px !important;
- }
- }
-
- h1,
- h2,
- h3,
- h4,
- h5,
- h6,
- strong,
- b {
- font-weight: 500 !important;
- }
- ol,
- ul,
- dl {
- margin-bottom: 0.5rem;
- white-space: inherit;
- }
- p {
- margin-bottom: 0.5rem;
- }
- hr {
- display: none;
- }
- img {
- border-radius: var(--bs-border-radius-lg);
- max-height: 40em;
- }
- th {
- min-width: 5em;
- }
-
- .table > :not(caption) > * > * {
- padding: 0.3rem;
- }
-
- &:hover {
- background-color: rgba(0, 0, 0, 0.03);
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgba(0, 0, 0, 0),
- rgba(247.35, 247.35, 247.35, 1) 25%
- );
- }
- }
-
- .post-header {
- margin: 4px 0;
- }
- }
-
- .post:not(:last-child):before {
- content: "";
- position: absolute;
- left: 30px;
- top: 56px;
- bottom: 0;
- width: 2px;
- background-color: #ddd;
- z-index: -1;
- }
-
- .post:not(:first-child):after {
- content: "";
- position: absolute;
- left: 30px;
- top: 0;
- width: 2px;
- height: 8px;
- background-color: #ddd;
- z-index: -1;
- }
-
- .left {
- margin-right: 12px;
- min-width: 40px;
- width: 40px;
- overflow: hidden;
- }
- .right {
- margin-top: -4px;
- flex-grow: 1;
- min-width: 0;
- }
-
- .buttons-placeholder {
- padding-bottom: 10px;
- }
-
- .buttons {
- margin-top: 10px;
- margin-bottom: 6px;
- column-gap: 4px;
- color: #888;
- }
-
- .reposted {
- padding-top: 30px;
- }
-`;
-
-const contentWidget = (
-
- }
- src="mob.near/widget/MainPage.N.Post.Content"
- props={{
- content,
- raw,
- truncateContent: props.truncateContent,
- noEmbed: props.noEmbed,
- }}
- />
-);
-
-return (
-
-
-
-
-
}
- src="/*__@appAccount__*//widget/Post.Header"
- props={{
- accountId,
- blockHeight,
- pinned,
- hideMenu,
- link,
- postType: "post",
- flagItem: item,
- }}
- />
- {fullPostLink ? (
-
- {contentWidget}
-
- ) : (
- contentWidget
- )}
- {props.customButtons ? (
- props.customButtons
- ) : !pinned && !hideButtons && blockHeight !== "now" ? (
-
- State.update({ showReply: !state.showReply }),
- }}
- />
-
-
-
-
- ) : (
-
- )}
-
-
- {state.showReply && (
-
- State.update({ showReply: false }),
- }}
- />
-
- )}
- {props.customComments
- ? props.customComments
- : !props.hideComments && (
-
-
-
- )}
-
-
-);
diff --git a/apps/builddao/widget/Post/Header.jsx b/apps/builddao/widget/Post/Header.jsx
deleted file mode 100644
index d08ddf0b..00000000
--- a/apps/builddao/widget/Post/Header.jsx
+++ /dev/null
@@ -1,169 +0,0 @@
-const accountId = props.accountId;
-const blockHeight = props.blockHeight;
-const pinned = !!props.pinned;
-const hideMenu = !!props.hideMenu;
-const name = Social.get(`${accountId}/profile/name`);
-
-const postType = props.postType ?? "post";
-const link = props.link;
-const isPremium = !!props.isPremium;
-
-const Overlay = (props) => (
-
-
-
-);
-
-const DotsSvg = (
-
-
-
-);
-
-const Button = styled.div`
- line-height: 20px;
- min-height: 20px;
- display: inline-flex;
- align-items: center;
- justify-content: left;
- background: inherit;
- color: #6c757d;
- font-size: 16px;
- .icon {
- position: relative;
- &:before {
- margin: -8px;
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- border-radius: 50%;
- }
- }
-
- &:not([disabled]) {
- cursor: pointer;
- }
-
- &:not([disabled]):hover {
- opacity: 1 !important;
- color: DeepSkyBlue;
-
- .icon:before {
- background: rgba(0, 191, 255, 0.1);
- }
- }
-`;
-
-return (
-
-
-
-
-
-
-
-
- {name && (
-
- {name}
-
- )}
-
-
-
-
-
-
- {!pinned && (
-
- {blockHeight === "now" ? (
- "now"
- ) : (
-
-
-
- )}
-
- )}
-
-
-
-
- {pinned && (
-
-
-
- )}
- {!pinned && !hideMenu && blockHeight !== "now" && (
-
-
- {DotsSvg}
-
-
-
- )}
-
-);
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 863cd43b..f5df7f23 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -237,6 +237,7 @@ const groupId = props.groupId ?? content.groupId;
const indexKey = props.indexKey;
const permissions = props.permissions;
const fullPostLink = props.fullPostLink;
+const customActions = props.customActions;
const notifyAccountId = accountId;
const item = {
@@ -308,6 +309,7 @@ return (
link={link}
postType={"post"}
flagItem={item}
+ customActions={customActions}
/>
{fullPostLink ? (
(
)}
+ {customActions.length > 0 &&
+ customActions.map((action) => (
+
+ action.onClick(flagItem)}
+ className="btn btn-outline-dark dropdown-item"
+ >
+ {" "}
+ {action.label}
+
+
+ ))}
)}
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index c8dc2dc0..df0d398c 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -139,6 +139,36 @@ const feeds = {
**Context or additional information:**
- [Provide any context or details]
+`,
+ },
+ request: {
+ label: "Request",
+ icon: "bi-file-earmark-text",
+ name: "request",
+ hashtag: "request",
+ template: `## REQUEST TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=request))
+
+**What are you requesting?**
+- [Describe the request]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
+ customActions: [
+ {
+ label: "Propose",
+ icon: "bi-file-earmark-text",
+ onClick: (post) => console.log("propose", post),
+ },
+ ],
+ },
+ feedback: {
+ label: "Feedback",
+ icon: "bi-chat-left-text",
+ name: "feedback",
+ hashtag: "feedback",
+ template: `## TITLE
`,
},
bookmarks: {
@@ -148,13 +178,6 @@ const feeds = {
hideCompose: true,
customWidget: "buildhub.near/widget/Bookmarks",
},
- proposals: {
- label: "Proposals",
- icon: "bi-file-earmark-text",
- name: "proposal",
- hideCompose: true,
- customWidget: "buildhub.near/widget/Proposals",
- },
};
return { type: config, feeds: feeds };
From 83378e2898201cd83b9dc10ddb53b497bca371e0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:11:53 +0500
Subject: [PATCH 023/132] Add Proposal Modal and Text method
---
apps/builddao/widget/components.jsx | 2 +
apps/builddao/widget/components/Modal.jsx | 40 ++-
apps/builddao/widget/components/Post.jsx | 248 ++++++++-------
apps/builddao/widget/components/User.jsx | 38 ++-
.../widget/components/modals/ProposeModal.jsx | 283 ++++++++++++++++++
apps/builddao/widget/config/feed.jsx | 12 +-
apps/builddao/widget/fetch/daos.jsx | 21 ++
apps/builddao/widget/test.jsx | 266 ++++++++++++++++
8 files changed, 759 insertions(+), 151 deletions(-)
create mode 100644 apps/builddao/widget/components/modals/ProposeModal.jsx
create mode 100644 apps/builddao/widget/fetch/daos.jsx
create mode 100644 apps/builddao/widget/test.jsx
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index 191845e0..f01cde64 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -12,6 +12,7 @@ const { TextBox } = VM.require("buildhub.near/widget/components.TextBox");
const { TextEditor } = VM.require("buildhub.near/widget/components.TextEditor");
const { Checkbox } = VM.require("buildhub.near/widget/components.Checkbox");
const { Avatar } = VM.require("buildhub.near/widget/components.Avatar");
+const { Modal } = VM.require("buildhub.near/widget/components.Modal");
function Pagination({
totalPages,
@@ -50,6 +51,7 @@ return {
Pagination,
Post,
ProgressState,
+ Modal,
Step,
InputField,
UploadField,
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index db7409fe..f3d7a2ae 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -22,7 +22,7 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242B;
+ background: #23242b;
border-radius: 16px;
color: white;
`;
@@ -36,17 +36,24 @@ const NoButton = styled.button`
`;
const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
`;
const Icon = styled.i`
- font-size: 24px;
+ font-size: 24px;
`;
-function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
+function Modal({
+ children,
+ title,
+ open,
+ onOpenChange,
+ toggle,
+ toggleContainerProps,
+}) {
return (
@@ -56,13 +63,16 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
-
-
-
-
-
-
-
+
+
{title}
+
+
+
+
+
+
+
+
{children}
@@ -72,4 +82,4 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
);
}
-return { Modal };
\ No newline at end of file
+return { Modal };
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index f5df7f23..d92cc13e 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -1,6 +1,7 @@
-const { User } = VM.require("buildhub.near/widget/components");
+const { User, Button } = VM.require("buildhub.near/widget/components");
User = User || (() => <>>);
+Button = Button || (() => <>>);
const StyledPost = styled.div`
margin-bottom: 1rem;
@@ -287,127 +288,144 @@ const contentWidget = (
>
);
+const [showModal, setShowModal] = useState(false);
+const toggleModal = () => {
+ setShowModal(!showModal);
+};
+
return (
-
-
-
-
-
- {fullPostLink ? (
-
- {contentWidget}
-
- ) : (
- contentWidget
- )}
- {props.customButtons ? (
- props.customButtons
- ) : !pinned && !hideButtons && blockHeight !== "now" ? (
-
-
State.update({ showReply: !state.showReply }),
- }}
- />
-
+ <>
+
+
+
+
+
+
+ {fullPostLink ? (
+
+ {contentWidget}
+
+ ) : (
+ contentWidget
+ )}
+ {props.customButtons ? (
+ props.customButtons
+ ) : !pinned && !hideButtons && blockHeight !== "now" ? (
+
+ State.update({ showReply: !state.showReply }),
+ }}
+ />
+
+
+
+
-
-
-
-
-
- ) : (
-
- )}
-
-
- {state.showReply && (
-
- State.update({ showReply: false }),
- }}
- />
+
+
+
+ ) : (
+
+ )}
+
- )}
- {props.customComments
- ? props.customComments
- : !props.hideComments && (
-
-
-
- )}
-
-
+ {state.showReply && (
+
+ State.update({ showReply: false }),
+ }}
+ />
+
+ )}
+ {props.customComments
+ ? props.customComments
+ : !props.hideComments && (
+
+
+
+ )}
+
+
+ >
);
diff --git a/apps/builddao/widget/components/User.jsx b/apps/builddao/widget/components/User.jsx
index 9fd83aa8..7930170e 100644
--- a/apps/builddao/widget/components/User.jsx
+++ b/apps/builddao/widget/components/User.jsx
@@ -87,13 +87,15 @@ const accountId = props.accountId;
const blockHeight = props.blockHeight;
const pinned = !!props.pinned;
const hideMenu = !!props.hideMenu;
-const name = Social.get(`${accountId}/profile/name`);
+const name = props.name || Social.get(`${accountId}/profile/name`);
const postType = props.postType ?? "post";
const link = props.link;
const isPremium = !!props.isPremium;
const flagItem = props.flagItem;
const customActions = props.customActions ?? [];
+const showTime = props.showTime ?? true;
+const toggleModal = props.toggleModal;
const Overlay = (props) => (
{accountId}
-
- {blockHeight === "now" ? (
- "now"
- ) : (
-
-
-
- )}
-
+ {showTime && (
+
+ {blockHeight === "now" ? (
+ "now"
+ ) : (
+
+
+
+ )}
+
+ )}
{pinned && (
@@ -184,7 +188,11 @@ return (
customActions.map((action) => (
action.onClick(flagItem)}
+ onClick={() =>
+ action.type === "modal"
+ ? action.onClick(toggleModal)
+ : action.onClick(flagItem)
+ }
className="btn btn-outline-dark dropdown-item"
>
{" "}
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
new file mode 100644
index 00000000..38219b6a
--- /dev/null
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -0,0 +1,283 @@
+const { daos } = VM.require("buildhub.near/widget/fetch.daos");
+const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
+
+const [selectedDAO, setSelectedDAO] = useState("testdao.near");
+const [daoName, setDAOName] = useState("Select DAO");
+const [selectedOption, setSelectedOption] = useState("");
+const [text, setText] = useState("");
+
+const options = daos.map((dao) => dao.contract_id);
+
+useEffect(() => {
+ if (selectedDAO === "testdao.near") return;
+
+ const name = Social.get(`${selectedDAO}/profile/name`);
+ setDAOName(name);
+}, [selectedDAO]);
+
+const [editorKey, setEditorKey] = useState(0);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+
+const StyledTypeahead = styled.div`
+ input,
+ input:focus,
+ .rbt-input-hint {
+ background: #23242b;
+ color: #fff;
+
+ &::placeholder {
+ color: #fff;
+ opacity: 1; /* Firefox */
+ }
+ }
+
+ .rbt-menu,
+ .dropdown-item {
+ background: #23242b;
+ color: #fff;
+ }
+`;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+const showModal = props.showModal;
+const toggleModal = props.toggleModal;
+const toggle = props.toggle;
+
+return (
+
+
+
+
+ setSelectedDAO(v)}
+ placeholder="Search DAO Contract ID"
+ defaultSelected={
+ selectedDAO !== "testdao.near" ? selectedDAO : undefined
+ }
+ />
+
+
+ {selectedDAO !== "testdao.near" && (
+ <>
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+
Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
+ >
+ )}
+
+);
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index df0d398c..a6b6158c 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -149,17 +149,17 @@ const feeds = {
template: `## REQUEST TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=request))
-**What are you requesting?**
-- [Describe the request]
+#### Description
+[Detailed description of what the proposal is about.]
-**Context or additional information:**
-- [Provide any context or details]
-`,
+#### Why This Proposal?
+[Explanation of why this proposal is necessary or beneficial.]`,
customActions: [
{
label: "Propose",
icon: "bi-file-earmark-text",
- onClick: (post) => console.log("propose", post),
+ type: "modal",
+ onClick: (modalToggle) => modalToggle(),
},
],
},
diff --git a/apps/builddao/widget/fetch/daos.jsx b/apps/builddao/widget/fetch/daos.jsx
new file mode 100644
index 00000000..a424940f
--- /dev/null
+++ b/apps/builddao/widget/fetch/daos.jsx
@@ -0,0 +1,21 @@
+let daos;
+
+const apikey = "c5d70a09-5740-489d-8c3b-36fbc3d40bff";
+
+const forgeUrl = (apiUrl, params) =>
+ apiUrl +
+ Object.keys(params)
+ .sort()
+ .reduce((paramString, p) => paramString + `${p}=${params[p]}&`, "?");
+
+daos = fetch(forgeUrl(`https://api.pikespeak.ai/daos/all`, {}), {
+ mode: "cors",
+ headers: {
+ "x-api-key": apikey,
+ "cache-control": "max-age=86400", // 1 day
+ },
+});
+if (daos === null) return "";
+daos = daos?.body;
+
+return { type: "daos", daos };
diff --git a/apps/builddao/widget/test.jsx b/apps/builddao/widget/test.jsx
new file mode 100644
index 00000000..4121f32a
--- /dev/null
+++ b/apps/builddao/widget/test.jsx
@@ -0,0 +1,266 @@
+const { item } = props.item;
+
+const { daos } = VM.require("buildhub.near/widget/fetch.daos");
+const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
+
+const [showModal, setShowModal] = useState(false);
+const [selectedDAO, setSelectedDAO] = useState("testdao.near");
+const [daoName, setDAOName] = useState("Select DAO");
+const [selectedOption, setSelectedOption] = useState("");
+const [text, setText] = useState("");
+
+const toggleModal = () => {
+ setShowModal(!showModal);
+};
+
+const toggle = props.toggle ?? (
+
+ Open Modal
+
+);
+
+const options = daos.map((dao) => dao.contract_id);
+
+useEffect(() => {
+ if (selectedDAO === "testdao.near") return;
+
+ const name = Social.get(`${selectedDAO}/profile/name`);
+ setDAOName(name);
+}, [selectedDAO]);
+
+const StyledTypeahead = styled.div`
+ input,
+ input:focus,
+ .rbt-input-hint {
+ background: #23242b;
+ color: #fff;
+
+ &::placeholder {
+ color: #fff;
+ opacity: 1; /* Firefox */
+ }
+ }
+
+ .rbt-menu,
+ .dropdown-item {
+ background: #23242b;
+ color: #fff;
+ }
+`;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+
+
+ setSelectedDAO(v)}
+ placeholder="Search DAO Contract ID"
+ defaultSelected={
+ selectedDAO !== "testdao.near" ? selectedDAO : undefined
+ }
+ />
+
+
+ {selectedDAO !== "testdao.near" && (
+ <>
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
+ >
+ )}
+
+);
From 558680c00d30e1e5b9e303d1881039c9db23003e Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:13:54 +0500
Subject: [PATCH 024/132] Don't render modal for other post types
---
apps/builddao/widget/Feed.jsx | 1 +
apps/builddao/widget/components/Post.jsx | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index e602ddfe..5c572ec9 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -106,6 +106,7 @@ return (
noBorder={true}
currentPath={`${props.pagePath}`}
customActions={feeds[activeFeed].customActions}
+ feedType={feed.name}
/>
)}
/>
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index d92cc13e..4683c5fe 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -295,14 +295,16 @@ const toggleModal = () => {
return (
<>
-
+ {props.feedType === "request" && (
+
+ )}
Date: Sat, 27 Jan 2024 01:18:52 +0500
Subject: [PATCH 025/132] Fix feed type prop
---
apps/builddao/widget/Feed.jsx | 2 +-
.../widget/components/modals/ProposeModal.jsx | 136 +++++++++---------
2 files changed, 67 insertions(+), 71 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 5c572ec9..6aa1386f 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -106,7 +106,7 @@ return (
noBorder={true}
currentPath={`${props.pagePath}`}
customActions={feeds[activeFeed].customActions}
- feedType={feed.name}
+ feedType={feeds[activeFeed].name}
/>
)}
/>
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
index 38219b6a..5f835191 100644
--- a/apps/builddao/widget/components/modals/ProposeModal.jsx
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -1,16 +1,16 @@
const { daos } = VM.require("buildhub.near/widget/fetch.daos");
const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
-const [selectedDAO, setSelectedDAO] = useState("testdao.near");
-const [daoName, setDAOName] = useState("Select DAO");
+const [selectedDAO, setSelectedDAO] = useState(
+ props.daoId || "build.sputnik-dao.near"
+);
+const [daoName, setDAOName] = useState("");
const [selectedOption, setSelectedOption] = useState("");
const [text, setText] = useState("");
const options = daos.map((dao) => dao.contract_id);
useEffect(() => {
- if (selectedDAO === "testdao.near") return;
-
const name = Social.get(`${selectedDAO}/profile/name`);
setDAOName(name);
}, [selectedDAO]);
@@ -212,72 +212,68 @@ return (
/>
- {selectedDAO !== "testdao.near" && (
- <>
-
-
Proposal Type
-
setSelectedOption(e.target.value)}
- selected={selectedOption}
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+ Proposal Description
+
- Open this select menu
- Text
- Transfer
- Function Call
- Add Member To Role
- Remove Member From Role
-
-
-
-
- {selectedOption === "text" && (
- <>
-
Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
-
-
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: "Vote",
- },
- })
- }
- >
- Next
-
-
- >
- )}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
-
- >
- )}
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
);
From d11f96e90d4aba2cd18fb2f1020cdd4b040d8e08 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:27:59 +0500
Subject: [PATCH 026/132] Fix default prop in propose modal
---
apps/builddao/widget/components/modals/ProposeModal.jsx | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
index 5f835191..bff94117 100644
--- a/apps/builddao/widget/components/modals/ProposeModal.jsx
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -203,12 +203,11 @@ return (
setSelectedDAO(v)}
placeholder="Search DAO Contract ID"
- defaultSelected={
- selectedDAO !== "testdao.near" ? selectedDAO : undefined
- }
+ defaultSelected={[selectedDAO]}
/>
From f7456ce45838ee0bda089b5c98795bab7289f5a6 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 04:43:44 +0500
Subject: [PATCH 027/132] Complete proposal modal
---
apps/builddao/widget/components/Button.jsx | 17 +-
apps/builddao/widget/components/Modal.jsx | 14 +-
apps/builddao/widget/components/Post.jsx | 2 +-
.../widget/components/modals/ProposeModal.jsx | 269 ++++++------------
.../components/modals/propose/AddMember.jsx | 62 ++++
.../modals/propose/FunctionCall.jsx | 257 +++++++++++++++++
.../modals/propose/RemoveMember.jsx | 66 +++++
.../widget/components/modals/propose/Text.jsx | 179 ++++++++++++
.../components/modals/propose/Transfer.jsx | 234 +++++++++++++++
apps/builddao/widget/page/feed.jsx | 2 +-
apps/builddao/widget/test.jsx | 266 -----------------
11 files changed, 908 insertions(+), 460 deletions(-)
create mode 100644 apps/builddao/widget/components/modals/propose/AddMember.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/FunctionCall.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/RemoveMember.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/Text.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/Transfer.jsx
delete mode 100644 apps/builddao/widget/test.jsx
diff --git a/apps/builddao/widget/components/Button.jsx b/apps/builddao/widget/components/Button.jsx
index 830c76ff..5958ea6e 100644
--- a/apps/builddao/widget/components/Button.jsx
+++ b/apps/builddao/widget/components/Button.jsx
@@ -61,12 +61,27 @@ const StyledButton = styled.button`
}
}};
}
+
+ &:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
`;
-function Button({ id, children, variant, type, onClick, className, style }) {
+function Button({
+ id,
+ disabled,
+ children,
+ variant,
+ type,
+ onClick,
+ className,
+ style,
+}) {
return (
+
{toggle}
-
+
-
+
{title}
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 4683c5fe..126a1aeb 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -305,7 +305,7 @@ return (
}}
/>
)}
-
+
dao.contract_id);
+
+const { Modal, Button, User } = VM.require(
+ "buildhub.near/widget/components"
+) || {
+ Modal: () => <>>,
+ Button: () => <>>,
+ User: () => <>>,
+};
+
+const showModal = props.showModal;
+const toggleModal = props.toggleModal;
+const toggle = props.toggle;
+if (!showModal) {
+ return "";
+}
const [selectedDAO, setSelectedDAO] = useState(
props.daoId || "build.sputnik-dao.near"
);
const [daoName, setDAOName] = useState("");
const [selectedOption, setSelectedOption] = useState("");
-const [text, setText] = useState("");
-
-const options = daos.map((dao) => dao.contract_id);
useEffect(() => {
const name = Social.get(`${selectedDAO}/profile/name`);
setDAOName(name);
}, [selectedDAO]);
-const [editorKey, setEditorKey] = useState(0);
-const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
-
-useEffect(() => {
- const { path, blockHeight } = props.item;
- setText(`[EMBED](${path}@${blockHeight})`);
- setEditorKey((editorKey) => editorKey + 1);
-}, [props.item]);
+const policy = Near.view(selectedDAO, "get_policy") || { roles: [] };
+const roles = policy.roles.map((item) => item.name) || [];
const StyledTypeahead = styled.div`
input,
@@ -35,6 +44,7 @@ const StyledTypeahead = styled.div`
color: #fff;
opacity: 1; /* Firefox */
}
+ border: 1px solid #434950;
}
.rbt-menu,
@@ -44,146 +54,13 @@ const StyledTypeahead = styled.div`
}
`;
-const MarkdownEditor = `
- html {
- background: #23242b;
- }
-
- * {
- border: none !important;
- }
-
- .rc-md-editor {
- background: #4f5055;
- border-top: 1px solid #4f5055 !important;
- border-radius: 8px;
- }
-
- .editor-container {
- background: #4f5055;
- }
-
- .drop-wrap {
- top: -110px !important;
- border-radius: 0.5rem !important;
- }
-
- .header-list {
- display: flex;
- align-items: center;
- }
-
- textarea {
- background: #23242b !important;
- color: #fff !important;
-
- font-family: sans-serif !important;
- font-size: 1rem;
-
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-navigation {
- background: #23242b !important;
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-bottom: 0 !important;
- border-radius: 8px 8px 0 0;
-
- i {
- color: #cdd0d5;
- }
- }
-
- .editor-container {
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-editor .editor-container .sec-md .input {
- overflow-y: auto;
- padding: 8px !important;
- line-height: normal;
- border-radius: 0 0 8px 8px;
- }
-`;
-
-const TextareaWrapper = styled.div`
- display: grid;
- vertical-align: top;
- align-items: center;
- position: relative;
- align-items: stretch;
- width: 100%;
-
- textarea {
- display: flex;
- align-items: center;
- transition: all 0.3s ease;
- }
-
- textarea::placeholder {
- padding-top: 4px;
- font-size: 20px;
- }
-
- textarea:focus::placeholder {
- font-size: inherit;
- padding-top: 0px;
- }
-
- &::after,
- textarea,
- iframe {
- width: 100%;
- min-width: 1em;
- height: unset;
- min-height: 3em;
- font: inherit;
- margin: 0;
- resize: none;
- background: none;
- appearance: none;
- border: 0px solid #eee;
- grid-area: 1 / 1;
- overflow: hidden;
- outline: none;
- }
-
- iframe {
- padding: 0;
- }
-
- textarea:focus,
- textarea:not(:empty) {
- border-bottom: 1px solid #eee;
- min-height: 5em;
- }
-
- &::after {
- content: attr(data-value) " ";
- visibility: hidden;
- white-space: pre-wrap;
- }
- &.markdown-editor::after {
- padding-top: 66px;
- font-family: monospace;
- font-size: 14px;
- }
-`;
-
-const showModal = props.showModal;
-const toggleModal = props.toggleModal;
-const toggle = props.toggle;
-
return (
@@ -202,10 +79,15 @@ return (
+ DAO Contract ID
setSelectedDAO(v)}
+ onChange={(v) => {
+ if (options.includes(v[0])) {
+ setSelectedDAO(v[0]);
+ }
+ }}
placeholder="Search DAO Contract ID"
defaultSelected={[selectedDAO]}
/>
@@ -218,9 +100,8 @@ return (
id="proposal-type"
data-bs-theme="dark"
class="form-select"
- aria-label="Default select example"
onChange={(e) => setSelectedOption(e.target.value)}
- selected={selectedOption}
+ value={selectedOption}
>
Open this select menu
Text
@@ -234,45 +115,59 @@ return (
{selectedOption === "text" && (
<>
-
Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
-
-
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: "Vote",
- },
- })
- }
- >
- Next
-
-
+
+ >
+ )}
+ {selectedOption === "transfer" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "functionCall" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "addMember" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "removeMember" && (
+ <>
+
>
)}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
);
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
new file mode 100644
index 00000000..a8f95e33
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -0,0 +1,62 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [accountId, setAccountId] = useState("");
+const [role, setRole] = useState("");
+const roles = props.roles;
+const selectedDAO = props.selectedDAO;
+
+return (
+
+
+ Account ID
+ setAccountId(e.target.value)}
+ />
+
+
+
+ Role
+ setRole(e.target.value)}
+ selected={role}
+ >
+ Select a role
+ {roles.length > 0 &&
+ roles.map((role) => {role} )}
+
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: "Potential member",
+ kind: {
+ AddMemberToRole: {
+ member_id: accountId,
+ role: role,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
new file mode 100644
index 00000000..efb5932d
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -0,0 +1,257 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [contract, setContract] = useState("");
+const [method, setMethod] = useState("");
+const [args, setArgs] = useState("{}");
+const [gas, setGas] = useState(50000000000000);
+const [deposit, useDeposit] = useState(0);
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDao = props.selectedDao;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+ Contract
+ setContract(e.target.value)}
+ className="form-control"
+ />
+
+
+ Method
+ setMethod(e.target.value)}
+ className="form-control"
+ />
+
+
+ Arguments (JSON)
+
+
+ Gas
+ setGas(e.target.value)}
+ className="form-control"
+ />
+
+
+ Deposit
+ setDeposit(e.target.value)}
+ className="form-control"
+ />
+
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: {
+ FunctionCall: {
+ reciever_id: contract,
+ actions: [
+ {
+ method_name: method,
+ args: args,
+ deposit: deposit,
+ gas: gas,
+ },
+ ],
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
new file mode 100644
index 00000000..a9490e50
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -0,0 +1,66 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [accountId, setAccountId] = useState("");
+const [role, setRole] = useState("");
+const roles = props.roles;
+const selectedDAO = props.selectedDAO;
+
+return (
+
+
+ Account ID
+ setAccountId(e.target.value)}
+ />
+
+
+
+ Role
+ setRole(e.target.value)}
+ selected={role}
+ >
+ Select a role
+ {roles.length > 0 &&
+ roles.map((role) => (
+
+ {role}
+
+ ))}
+
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: "Potential member",
+ kind: {
+ RemoveMemberFromRole: {
+ member_id: accountId,
+ role: role,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
new file mode 100644
index 00000000..95ee37d4
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -0,0 +1,179 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDAO = props.selectedDAO;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
new file mode 100644
index 00000000..4e184e9d
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -0,0 +1,234 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [recipient, setRecipient] = useState("");
+const [token, setToken] = useState("");
+const [amount, setAmount] = useState(0);
+const [description, setDescription] = useState("");
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDao = props.selectedDao;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+ Recipient
+ setRecipient(e.target.value)}
+ />
+
+
+ Token
+ setToken(e.target.value)}
+ >
+ Select a token
+ NEAR
+ ETH
+ USDC
+ USDT
+ AURORA
+
+
+
+ Amount
+ setAmount(e.target.value)}
+ />
+
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: {
+ Transfer: {
+ token_id: token,
+ reciever_id: recipient,
+ amount: amount,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 910b11ab..676b8d88 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,4 +1,4 @@
-const { feeds } = VM.require("buildhub.near/widget/config.feed");
+const { feeds } = VM.require("buildhub.near/widget/config.feed") || {};
console.log(feeds);
diff --git a/apps/builddao/widget/test.jsx b/apps/builddao/widget/test.jsx
deleted file mode 100644
index 4121f32a..00000000
--- a/apps/builddao/widget/test.jsx
+++ /dev/null
@@ -1,266 +0,0 @@
-const { item } = props.item;
-
-const { daos } = VM.require("buildhub.near/widget/fetch.daos");
-const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
-
-const [showModal, setShowModal] = useState(false);
-const [selectedDAO, setSelectedDAO] = useState("testdao.near");
-const [daoName, setDAOName] = useState("Select DAO");
-const [selectedOption, setSelectedOption] = useState("");
-const [text, setText] = useState("");
-
-const toggleModal = () => {
- setShowModal(!showModal);
-};
-
-const toggle = props.toggle ?? (
-
- Open Modal
-
-);
-
-const options = daos.map((dao) => dao.contract_id);
-
-useEffect(() => {
- if (selectedDAO === "testdao.near") return;
-
- const name = Social.get(`${selectedDAO}/profile/name`);
- setDAOName(name);
-}, [selectedDAO]);
-
-const StyledTypeahead = styled.div`
- input,
- input:focus,
- .rbt-input-hint {
- background: #23242b;
- color: #fff;
-
- &::placeholder {
- color: #fff;
- opacity: 1; /* Firefox */
- }
- }
-
- .rbt-menu,
- .dropdown-item {
- background: #23242b;
- color: #fff;
- }
-`;
-
-const MarkdownEditor = `
- html {
- background: #23242b;
- }
-
- * {
- border: none !important;
- }
-
- .rc-md-editor {
- background: #4f5055;
- border-top: 1px solid #4f5055 !important;
- border-radius: 8px;
- }
-
- .editor-container {
- background: #4f5055;
- }
-
- .drop-wrap {
- top: -110px !important;
- border-radius: 0.5rem !important;
- }
-
- .header-list {
- display: flex;
- align-items: center;
- }
-
- textarea {
- background: #23242b !important;
- color: #fff !important;
-
- font-family: sans-serif !important;
- font-size: 1rem;
-
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-navigation {
- background: #23242b !important;
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-bottom: 0 !important;
- border-radius: 8px 8px 0 0;
-
- i {
- color: #cdd0d5;
- }
- }
-
- .editor-container {
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-editor .editor-container .sec-md .input {
- overflow-y: auto;
- padding: 8px !important;
- line-height: normal;
- border-radius: 0 0 8px 8px;
- }
-`;
-
-const TextareaWrapper = styled.div`
- display: grid;
- vertical-align: top;
- align-items: center;
- position: relative;
- align-items: stretch;
- width: 100%;
-
- textarea {
- display: flex;
- align-items: center;
- transition: all 0.3s ease;
- }
-
- textarea::placeholder {
- padding-top: 4px;
- font-size: 20px;
- }
-
- textarea:focus::placeholder {
- font-size: inherit;
- padding-top: 0px;
- }
-
- &::after,
- textarea,
- iframe {
- width: 100%;
- min-width: 1em;
- height: unset;
- min-height: 3em;
- font: inherit;
- margin: 0;
- resize: none;
- background: none;
- appearance: none;
- border: 0px solid #eee;
- grid-area: 1 / 1;
- overflow: hidden;
- outline: none;
- }
-
- iframe {
- padding: 0;
- }
-
- textarea:focus,
- textarea:not(:empty) {
- border-bottom: 1px solid #eee;
- min-height: 5em;
- }
-
- &::after {
- content: attr(data-value) " ";
- visibility: hidden;
- white-space: pre-wrap;
- }
- &.markdown-editor::after {
- padding-top: 66px;
- font-family: monospace;
- font-size: 14px;
- }
-`;
-
-return (
-
-
-
-
- setSelectedDAO(v)}
- placeholder="Search DAO Contract ID"
- defaultSelected={
- selectedDAO !== "testdao.near" ? selectedDAO : undefined
- }
- />
-
-
- {selectedDAO !== "testdao.near" && (
- <>
-
- Proposal Type
- setSelectedOption(e.target.value)}
- selected={selectedOption}
- >
- Open this select menu
- Text
- Transfer
- Function Call
- Add Member To Role
- Remove Member From Role
-
-
-
-
- {selectedOption === "text" && (
- <>
- Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
- >
- )}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
-
- >
- )}
-
-);
From 4d23351e6814be29ccd4b2c71db76e1f8637b508 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Sat, 27 Jan 2024 19:27:21 -0500
Subject: [PATCH 028/132] review comments
---
apps/builddao/widget/Bookmarks.jsx | 5 +++++
apps/builddao/widget/components/Text/P.jsx | 7 +++++++
apps/builddao/widget/config/feed.jsx | 14 ++++++++++++--
apps/builddao/widget/fetch/daos.jsx | 3 +++
apps/builddao/widget/page/feed.jsx | 12 ++++++------
5 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/Bookmarks.jsx b/apps/builddao/widget/Bookmarks.jsx
index 04a0ff56..bf9c147b 100644
--- a/apps/builddao/widget/Bookmarks.jsx
+++ b/apps/builddao/widget/Bookmarks.jsx
@@ -1,3 +1,8 @@
+/**
+ * This could be generalized for items in the graph,
+ * Social adapter (getr(`${accountId}/graph/${item}`, "final")
+ */
+
const { Post } = VM.require("buildhub.near/widget/components") || (() => <>>);
const accountId = props.accountId ?? context.accountId;
diff --git a/apps/builddao/widget/components/Text/P.jsx b/apps/builddao/widget/components/Text/P.jsx
index 3d7d73d7..ddc61beb 100644
--- a/apps/builddao/widget/components/Text/P.jsx
+++ b/apps/builddao/widget/components/Text/P.jsx
@@ -1,3 +1,10 @@
+/**
+ * We need to
+ */
+
+// We're going to save a list to create.near, just for creating things and list
+
+// create thing, list
const StyledParagraph = styled.p`
font-family: "Aekonik", sans-serif;
font-weight: 500;
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index a6b6158c..8a30edae 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -8,10 +8,19 @@ const feedLink = "https://nearbuilders.org/feed";
const feeds = {
resolutions: {
+ // metadata
+ name: "resolution",
+
+ // start sidebar
label: "Resolutions",
icon: "bi-calendar3",
- name: "resolution",
+ // end sidebar
+ // start compose
hashtag: "nearyearresolutions2024",
+
+ // better way to provide a template? reference to document -- maybe rename "initialText" or more general, "defaultProps"
+ // this could be moved to metadata, maybe daoName and feedLink = source: { label, href }, "context", or reference to other thing
+ // I like if it came from context cuz then unconfigurable unless from a forked VM
template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
(posted via [${daoName} Gateway](${feedLink}))
@@ -27,6 +36,7 @@ const feeds = {
- [Metric 1 for Success]
- [Metric 2 for Success]
`,
+ // end compose
},
updates: {
label: "Updates",
@@ -180,4 +190,4 @@ const feeds = {
},
};
-return { type: config, feeds: feeds };
+return { type: "feed", feeds: feeds };
diff --git a/apps/builddao/widget/fetch/daos.jsx b/apps/builddao/widget/fetch/daos.jsx
index a424940f..623e3c92 100644
--- a/apps/builddao/widget/fetch/daos.jsx
+++ b/apps/builddao/widget/fetch/daos.jsx
@@ -1,3 +1,6 @@
+/**
+ * This would be nice to be in the DAO SDK
+ */
let daos;
const apikey = "c5d70a09-5740-489d-8c3b-36fbc3d40bff";
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 676b8d88..a15974fd 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,4 +1,4 @@
-const { feeds } = VM.require("buildhub.near/widget/config.feed") || {};
+const { feeds } = VM.require("buildhub.near/widget/config.feed") || {}; // this is the thing, which works better as a module if it needs to be provided with context
console.log(feeds);
@@ -8,17 +8,17 @@ if (!feeds) {
const defaultProps = {
feeds: feeds,
- daoName: "Build DAO",
- feedLink: "https://nearbuilders.org/feed",
- daoTag: "build",
- pagePath: "/?page=feed",
+ daoName: "Build DAO", // I think we could take this out, not specific to feeds
+ feedLink: "https://nearbuilders.org/feed", // this is good idea, could be used for the "share post" button
+ daoTag: "build", // maybe we can make this an array of "required hashtags"
+ pagePath: "/?page=feed", // great idea, @mattb.near RoutesManager
//hashtag: "something"
};
return (
From beafd2a366aa3106cc9a1f85aebd244911224bc8 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sun, 28 Jan 2024 10:16:20 +0500
Subject: [PATCH 029/132] Make custom adapter for items in graph
---
apps/builddao/widget/Feed.jsx | 2 +-
.../{Bookmarks.jsx => adapters/item.jsx} | 29 ++++++-------
apps/builddao/widget/components/Avatar.jsx | 41 +++++++++----------
apps/builddao/widget/config/feed.jsx | 17 +++++++-
4 files changed, 49 insertions(+), 40 deletions(-)
rename apps/builddao/widget/{Bookmarks.jsx => adapters/item.jsx} (69%)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 6aa1386f..e26ab588 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -68,7 +68,7 @@ return (
{feeds[activeFeed].customWidget ? (
) : (
<>>);
-
const accountId = props.accountId ?? context.accountId;
+const item = props.item;
+const renderItem = props.renderItem;
+
+if (!item) {
+ return No item prop passed
;
+}
-const bookmarks = Social.getr(`${accountId}/graph/bookmark`, "final", {
+const items = Social.getr(`${accountId}/graph/${item}`, "final", {
withBlockHeight: true,
});
const StorageKey = "order";
const order = Storage.privateGet(StorageKey);
const apps = useMemo(() => {
- if (bookmarks === null || order === null) {
+ if (items === null || order === null) {
return [];
}
const starredApps = new Map();
@@ -33,7 +37,7 @@ const apps = useMemo(() => {
});
};
- buildSrc(bookmarks ?? {}, [], starredApps);
+ buildSrc(items ?? {}, [], starredApps);
let apps = [...starredApps.entries()];
apps.sort((a, b) => b[1] - a[1]);
apps = apps.map((a) => a[0]);
@@ -43,7 +47,7 @@ const apps = useMemo(() => {
Object.fromEntries(apps.map((a, i) => [a, i + 1]))
);
return apps;
-}, [bookmarks, order]);
+}, [items, order]);
let transformedArray = apps.map((item) => {
let splitParts = item.split("/");
@@ -60,16 +64,9 @@ let filteredArray = transformedArray.filter(
return (
<>
- {(filteredArray ?? []).map((item) => (
-
- ))}
+ {(filteredArray ?? []).map((item) => renderItem(item))}
{filteredArray.length === 0 && (
- No Bookmarks Yet!
+ No items!
)}
>
);
diff --git a/apps/builddao/widget/components/Avatar.jsx b/apps/builddao/widget/components/Avatar.jsx
index 536eb972..94f7afb3 100644
--- a/apps/builddao/widget/components/Avatar.jsx
+++ b/apps/builddao/widget/components/Avatar.jsx
@@ -1,35 +1,32 @@
-
function Avatar(props) {
const accountId = props.accountId ?? context.accountId;
const ImageWrapper = styled.div`
- img {
- width: ${(props) =>
- props.variant === "mobile" ? "40px" : "52px"} !important;
- height: ${(props) =>
- props.variant === "mobile" ? "40px" : "52px"} !important;
- flex-shrink: 0 !important;
- border-radius: 100px !important;
- background: lightgray 50% / cover no-repeat !important;
- }
+ img {
+ width: ${(props) =>
+ props.variant === "mobile" ? "40px" : "52px"} !important;
+ height: ${(props) =>
+ props.variant === "mobile" ? "40px" : "52px"} !important;
+ flex-shrink: 0 !important;
+ border-radius: 100px !important;
+ }
- .profile-image {
- width: auto !important;
- height: auto !important;
- }
+ .profile-image {
+ width: auto !important;
+ height: auto !important;
+ }
- @media screen and (max-width: 768px) {
- ${(props) =>
- !props.variant &&
- `
+ @media screen and (max-width: 768px) {
+ ${(props) =>
+ !props.variant &&
+ `
img {
width: 40px !important;
height: 40px !important;
}
`}
- }
-`;
-
+ }
+ `;
return (
@@ -38,4 +35,4 @@ function Avatar(props) {
);
}
-return { Avatar };
\ No newline at end of file
+return { Avatar };
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 8a30edae..64125cfe 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -1,3 +1,5 @@
+const { Post } = VM.require("buildhub.near/widget/components") || (() => <>>);
+
function formatDate(date) {
const options = { year: "numeric", month: "short", day: "numeric" };
return date.toLocaleDateString("en-US", options);
@@ -186,7 +188,20 @@ const feeds = {
icon: "bi-bookmark",
name: "bookmark",
hideCompose: true,
- customWidget: "buildhub.near/widget/Bookmarks",
+ customWidget: "buildhub.near/widget/adapters.item",
+ customProps: {
+ item: "bookmark",
+ renderItem: (item) => {
+ return (
+
+ );
+ },
+ },
},
};
From 0b8c958a6a66915501be12a4b7534650e8496de8 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Sun, 28 Jan 2024 22:44:12 +0530
Subject: [PATCH 030/132] added proposal list and notification support
---
apps/builddao/widget/Proposals.jsx | 256 +++++-
.../widget/components/ProposalCard.jsx | 745 ++++++++++++++++++
2 files changed, 1000 insertions(+), 1 deletion(-)
create mode 100644 apps/builddao/widget/components/ProposalCard.jsx
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index b7fd38aa..0ad5aa1e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -1 +1,255 @@
-return Proposals
;
+const { Button } = VM.require("buildhub.near/widget/components.Button") || {
+ Button: <>>
+};
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+
+if (!DaoSDK) {
+ return <>>;
+}
+const resPerPage = 10;
+const daoId = props.daoId ?? "build.sputnik-dao.near";
+const proposalId = props.proposalId ?? null;
+const sdk = DaoSDK(daoId);
+const [currentPage, setCurrentPage] = useState(0);
+const accountId = context.accountId;
+
+const [showProposalModal, setShowModal] = useState(false);
+const lastProposalId = sdk.getLastProposalId();
+const proposals = proposalId
+ ? [
+ sdk.getProposalById({
+ proposalId
+ })
+ ] || []
+ : sdk.getProposals({
+ offset:
+ currentPage === 0
+ ? lastProposalId - resPerPage
+ : lastProposalId - currentPage * resPerPage,
+ limit: resPerPage
+ }) || [];
+
+const Container = styled.div`
+ .ndc-card {
+ border: none;
+ background-color: #23242b;
+ color: white !important;
+ padding: 2rem;
+ }
+`;
+
+const handleVote = ({ action, proposalId, proposer }) => {
+ let args = {};
+ args["id"] = JSON.parse(proposalId);
+ args["action"] = action;
+ const customAction = action.replace("Vote", "");
+ const notification = {
+ [accountId]: {
+ index: {
+ notify: JSON.stringify([
+ {
+ key: proposer,
+ value: {
+ message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
+ params: {
+ daoId: daoId,
+ proposalId: proposalId
+ },
+ type: "custom",
+ widget: "buildhub.near/widget/Proposals"
+ }
+ }
+ ])
+ }
+ }
+ };
+ Near.call([
+ {
+ contractName: daoId,
+ methodName: "act_proposal",
+ args: args,
+ gas: 200000000000000
+ },
+ {
+ contractName: "social.near",
+ methodName: "set",
+ args: { data: notification },
+ deposit: Big(JSON.stringify(notification).length * 16).mul(
+ Big(10).pow(20)
+ )
+ }
+ ]);
+};
+
+const policy = sdk.getPolicy();
+const proposalKinds = sdk.proposalKinds;
+const actions = sdk.voteActions;
+const userRoles = [];
+if (Array.isArray(policy.roles)) {
+ for (const role of policy.roles) {
+ if (role.kind === "Everyone") {
+ userRoles.push(role);
+ continue;
+ }
+ if (!role.kind.Group) continue;
+ if (accountId && role.kind.Group && role.kind.Group.includes(accountId)) {
+ userRoles.push(role);
+ }
+ }
+}
+
+const proposalPeriod = policy.proposal_period;
+console.log(policy);
+
+const ProposalsComponent = () => {
+ return (
+
+ {Array.isArray(proposals) ? (
+ proposals.map((item) => {
+ const kindName =
+ typeof item.kind === "string"
+ ? item.kind
+ : Object.keys(item.kind)[0];
+
+ const comments = Social.index("comment", {
+ type: "dao_proposal_comment",
+ path: `${daoId}/proposal/main`,
+ proposal_id: item.id + "-beta"
+ });
+ const permissionKind = proposalKinds[kindName];
+ let totalVotesNeeded = 0;
+ const isAllowedToVote = [
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteApprove
+ }),
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteReject
+ }),
+
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteRemove
+ })
+ ];
+
+ policy.roles.forEach((role) => {
+ const isRoleAllowedToVote =
+ role.permissions.includes(
+ `${proposalKinds[kindName]}:VoteApprove`
+ ) ||
+ role.permissions.includes(
+ `${proposalKinds[kindName]}:VoteReject`
+ ) ||
+ role.permissions.includes(`${proposalKinds[kindName]}:*`) ||
+ role.permissions.includes(`*:VoteApprove`) ||
+ role.permissions.includes(`*:VoteReject`) ||
+ role.permissions.includes("*:*");
+ if (isRoleAllowedToVote) {
+ const threshold = (role.vote_policy &&
+ role.vote_policy[proposalKinds[kindName]]?.threshold) ||
+ policy["default_vote_policy"]?.threshold || [0, 0];
+ const eligibleVoters = role.kind.Group
+ ? role.kind.Group.length
+ : 0;
+
+ // Apply the threshold
+ if (eligibleVoters === 0) {
+ return;
+ }
+
+ const votesNeeded =
+ Math.floor((threshold[0] / threshold[1]) * eligibleVoters) + 1;
+ console.log(item.id, "votesNeeded", votesNeeded);
+ totalVotesNeeded += votesNeeded;
+ }
+ });
+
+ let totalVotes = {
+ yes: 0,
+ no: 0,
+ spam: 0,
+ total: 0
+ };
+ for (const vote of Object.values(item.votes)) {
+ if (vote === "Approve") {
+ totalVotes.yes++;
+ } else if (vote === "Reject") {
+ totalVotes.no++;
+ } else if (vote === "Spam") {
+ totalVotes.spam++;
+ }
+ }
+ totalVotes.total = totalVotes.yes + totalVotes.no + totalVotes.spam;
+
+ let expirationTime = Big(item.submission_time).add(
+ Big(proposalPeriod)
+ );
+
+ return (
+
+ );
+ })
+ ) : (
+ <>>
+ )}
+
+ );
+};
+
+return (
+
+ setShowModal(!showProposalModal)
+ }}
+ />
+
+
Proposals
+ setShowModal(true)}>
+ Create Proposal
+
+
+
+ {!proposalId && (
+
+ 0,
+ hasNext: proposals?.[0].id !== resPerPage,
+ onPrev: () => {
+ setCurrentPage(currentPage - 1);
+ },
+ onNext: () => {
+ setCurrentPage(currentPage + 1);
+ }
+ }}
+ />
+
+ )}
+
+);
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
new file mode 100644
index 00000000..4ea759d2
--- /dev/null
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -0,0 +1,745 @@
+const {
+ id,
+ typeName,
+ proposer,
+ description,
+ kind,
+ status,
+ totalVotesNeeded,
+ totalVotes,
+ submission_time,
+ votes,
+ expirationTime
+} = props.proposalData;
+const { daoId, isAllowedToVote, handleVote, comments, proposalData } = props;
+const accountId = context.accountId;
+
+function checkVotes(value) {
+ return votes[accountId] === value;
+}
+
+const Wrapper = styled.div`
+ margin: 16px auto;
+ border-radius: 16px;
+ padding: 24px;
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+ min-height: 500px;
+ width: 100%;
+ border: 1px solid #fff;
+
+ b {
+ font-weight: 600;
+ }
+
+ .grey-bg {
+ background: rgba(255, 255, 255, 0.1) !important;
+ }
+
+ .light-grey-text {
+ color: rgba(176, 176, 176, 1) !important;
+ }
+
+ .text-muted {
+ color: rgba(176, 176, 176, 1) !important;
+ }
+
+ a {
+ background: rgba(255, 255, 255, 0.1) !important;
+ color: white !important;
+ }
+
+ .social_url {
+ background: rgba(255, 255, 255, 0.1) !important;
+ color: white !important;
+ }
+
+ .btn-primary {
+ background-color: #ffaf51 !important;
+ color: black !important;
+ }
+
+ ul {
+ background-color: #23242b;
+ }
+
+ .Approve {
+ background: none !important;
+ .vote {
+ color: #38c793 !important;
+ }
+ }
+
+ .Reject {
+ background: none !important;
+ .vote {
+ color: #bf2c37 !important;
+ }
+ }
+
+ .Remove {
+ background: none !important;
+ .vote {
+ color: #73692d !important;
+ }
+ }
+
+ .success {
+ border: 1px solid rgba(56, 199, 147, 0.2) !important;
+ background: rgba(56, 199, 147, 0.1) !important;
+ color: #38c793 !important;
+ }
+
+ .primary {
+ border: 1px solid rgba(255, 175, 81, 0.2) !important;
+ background: rgba(255, 175, 81, 0.2) !important;
+ color: #ffaf51 !important;
+ }
+
+ .info {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ // TODO
+ .danger {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ .black {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ .word-wrap {
+ word-wrap: break-word;
+ }
+
+ ${({ status }) =>
+ status === "Approved" &&
+ `
+ border-color: #82E299;
+ `}
+
+ ${({ status }) =>
+ status === "In Progress" &&
+ `
+ border-color: #fff;
+ `}
+
+ ${({ status }) =>
+ (status === "Failed" || status === "Rejected") &&
+ `
+ border-color: #C23F38;
+ `}
+
+ .text-sm {
+ font-size: 14px;
+ }
+
+ .counter-text {
+ font-size: 14px;
+ margin-right: 5px;
+ border-width: 2px;
+ animation-duration: 8s;
+ }
+
+ .text-center {
+ text-align: center;
+ }
+
+ .info_section {
+ border-right: 1px solid #dee2e6;
+ padding-right: 15px;
+ margin: 10px 15px 10px 0;
+
+ &.no-border {
+ border: 0;
+ }
+
+ @media (max-width: 768px) {
+ border: 0;
+ }
+ }
+`;
+
+const cls = (c) => c.join(" ");
+
+const YouVotedBadge = () => {
+ return (
+
+ );
+};
+
+function renderPermission({ isAllowedToVote }) {
+ return (
+
+ {isAllowedToVote
+ ? "You are allowed to vote on this proposal"
+ : "You are not allowed to vote on this proposal"}
+
+ );
+}
+
+const execProposal = ({ daoId, id }) =>
+ Near.call(daoId, "execute", { id }, 50000000000000);
+
+function renderHeader({ typeName, id, status }) {
+ let statusicon;
+ let statustext;
+ let statusvariant;
+
+ switch (status) {
+ case "Approved":
+ case "Accepted":
+ statusicon = "bi bi-check-circle";
+ statustext = status;
+ statusvariant = "success";
+ break;
+ case "Executed":
+ statusicon = "bi bi-play-fill";
+ statustext = status;
+ statusvariant = "success";
+ break;
+ case "InProgress":
+ statusicon = "spinner-border spinner-border-sm";
+ statustext = "In Progress";
+ statusvariant = "primary";
+ break;
+ case "Expired":
+ statusicon = "bi bi-clock";
+ statustext = status;
+ statusvariant = "black";
+ break;
+ case "Failed":
+ statusicon = "bi bi-x-circle";
+ statustext = status;
+ statusvariant = "black";
+ break;
+ case "Rejected":
+ statusicon = "bi bi-ban";
+ statustext = status;
+ statusvariant = "danger";
+ break;
+ }
+
+ return (
+
+
+
+
{typeName}
+
+
+
+
+
+
+ {statustext}
+ >
+ ),
+ variant: `${statusvariant} round`,
+ size: "lg"
+ }}
+ />
+
+ {status === "InProgress" &&
+ parseInt(Big(expirationTime).div(1000000)) > Date.now() && (
+
+
+
+ ),
+ variant: `info round`,
+ size: "lg"
+ }}
+ />
+ )}
+
+
+
+ );
+}
+
+function renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+}) {
+ return (
+
+
+
+
+
+
+
+ {submission_time && (
+
+
Submitted at
+
+
+ {new Date(
+ parseInt(Big(submission_time).div(1000000))
+ ).toLocaleString()}
+
+
+
+ )}
+
+
+
Expired at
+
+
+ {new Date(
+ parseInt(Big(expirationTime).div(1000000))
+ ).toLocaleString()}
+
+
+
+
+
+
Required Votes
+
+ {totalVotesNeeded}
+
+
+
+
+ );
+}
+
+function renderVoteButtons({
+ totalVotes,
+ status,
+ isAllowedToVote,
+ handleVote
+}) {
+ const finished = status !== "InProgress";
+ const VoteButton = styled.button`
+ width: 100%;
+ border-radius: 15px;
+ border: 1px solid transparent;
+ padding: 0 20px;
+ line-height: 45px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ position: relative;
+ overflow: hidden;
+ color: rgb(var(--vote-button-color));
+ background-color: rgba(255, 255, 255, 0.10);
+ --vote-button-bg: 130, 226, 153;
+ --vote-button-color: 255, 255, 255;
+
+ &.no {
+ --vote-button-bg: 194, 63, 56;
+ }
+
+ &.no > div:last-child {
+ transition: all 0.4s ease-in-out;
+ }
+ ${({ finished, percentage, disabled }) => {
+ if (finished) {
+ if (percentage > 80) {
+ return `
+ &.no > div:last-child {
+ color: rgb(var(--vote-button-color)) !important;
+ }
+ `;
+ }
+ } else if (!disabled) {
+ return `
+ &:hover.no > div:last-child {
+ color: rgb(var(--vote-button-color)) !important;
+ }
+ `;
+ }
+ }}}
+
+ &.spam {
+ --vote-button-bg: 245, 197, 24;
+ }
+
+ &.abstain {
+ --vote-button-bg: 169, 169, 169;
+ }
+
+ &:before {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ border-radius: 12px;
+ transition: all 0.4s ease-in-out;
+ z-index: 0;
+ background-color: rgb(var(--vote-button-bg));
+ ${({ percentage }) => `
+ min-width: ${percentage && percentage > 5 ? `${percentage}%` : "5px"};
+ `}
+ }
+
+ &:after {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ border-radius: 12px;
+ transition: all 0.4s ease-in-out;
+ z-index: 1;
+ background-color: var(--vote-button-bg);
+
+ min-width: ${({ percentage }) =>
+ percentage && percentage > 5 ? `${percentage}%` : "5px"};
+
+ ${({ finished, wins }) =>
+ finished &&
+ wins &&
+ `
+ display: none;
+ `}
+ }
+
+ ${({ disabled }) =>
+ !disabled &&
+ `
+ &:hover {
+ &:before {
+ min-width: 100%;
+ }
+ }
+ `}
+
+ & > div {
+ z-index: 2;
+ }
+
+ & > div:last-child span {
+ display: block;
+ font-size: 15px;
+ font-weight: 600;
+ line-height: 1.4;
+
+ &:last-child {
+ font-size: 12px;
+ font-weight: 400;
+ }
+ }
+ `;
+
+ const getPercentage = (vote) => {
+ const percentage = Math.round((vote / totalVotesNeeded) * 100);
+ return percentage || 0;
+ };
+
+ const percentages = {
+ yes: getPercentage(totalVotes.yes),
+ no: getPercentage(totalVotes.no),
+ spam: getPercentage(totalVotes.spam),
+ abstain: getPercentage(totalVotes.abstain)
+ };
+
+ const wins = {
+ yes: status === "Approved",
+ no: status === "Rejected",
+ spam: status === "Failed" || status === "Spam"
+ };
+
+ const voted = {
+ yes: checkVotes("Approve"),
+ no: checkVotes("Reject"),
+ spam: checkVotes("Remove")
+ };
+
+ const alreadyVoted = voted.yes || voted.no || voted.spam || voted.abstain;
+
+ const VotePercentage = ({ vote }) => (
+
+
+ {percentages[vote]}
+
+
+
+ {totalVotes[vote]} {totalVotes[vote] === 1 ? "Vote" : "Votes"}
+
+
+ );
+
+ return (
+
+
+ {voted.yes &&
}
+
handleVote("VoteApprove")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[0]}
+ >
+
+ {wins.yes && (
+
+
+
+ )}
+ Approve
+
+
+
+
+
+ {voted.no &&
}
+
handleVote("VoteReject")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[1]}
+ >
+
+ {wins.no && (
+
+
+
+ )}
+ Reject
+
+
+
+
+
+
+ {voted.spam &&
}
+
handleVote("VoteRemove")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[2]}
+ >
+
+ Spam
+
+
+
+
+
+ );
+}
+
+function renderFooter({ totalVotes, votes, comments, daoId, proposal }) {
+ const items = [
+ {
+ title: "Comments",
+ icon: "bi bi-chat-left-text",
+ count: comments.length || 0,
+ widget: "Common.Modals.Comments",
+ props: {
+ daoId,
+ proposal,
+ commentsCount: comments.length,
+ item: {
+ type: "dao_proposal_comment",
+ path: `${daoId}/proposal/main`,
+ proposal_id: proposal.id + "-beta"
+ }
+ }
+ },
+ {
+ title: "Voters",
+ icon: "bi bi-people",
+ count: totalVotes.total,
+ widget: "Common.Modals.Voters",
+ props: {
+ daoId,
+ votes,
+ totalVotes,
+ proposalId: proposal.id,
+ votersCount: totalVotes.total
+ }
+ },
+ {
+ title: "Share",
+ icon: "bi bi-share",
+ widget: "Common.Modals.Share",
+ props: {
+ url: `https://near.org/buildhub.near/widget/Proposals?daoId=${daoId}&proposalId=${
+ proposalData.id
+ }${props.dev ? "&dev=true" : ""}`,
+ text: "Explore this new proposal from our DAO! Your support and feedback are essential as we work towards a decentralized future. Review the details and join the discussion here:"
+ }
+ }
+ ];
+
+ if (proposal.typeName !== "Text") {
+ items.push({
+ title: "More details",
+ icon: "bi bi-three-dots",
+ widget: "Common.Modals.ProposalArguments",
+ props: {
+ daoId,
+ proposal,
+ showCard: true
+ }
+ });
+ }
+
+ const renderModal = (item, index) => {
+ return (
+
+ ),
+ toggle: (
+
+
+ {item.count && {item.count} }
+ {item.title}
+
+ ),
+ toggleContainerProps: {
+ className: "flex-fill"
+ }
+ }}
+ />
+ );
+ };
+
+ return (
+
+ {items.map(renderModal)}
+
+ );
+}
+
+const voted = {
+ yes: checkVotes("Approve"),
+ no: checkVotes("Reject"),
+ spam: checkVotes("Remove"),
+ abstain: checkVotes("Abstain")
+};
+
+const alreadyVoted = voted.yes || voted.no || voted.spam;
+
+const canVote =
+ isAllowedToVote.every((v) => v) && status === "In Progress" && !alreadyVoted;
+
+return (
+
+ {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
+ {renderHeader({ typeName, id, daoId, status })}
+ {renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+ })}
+ {renderVoteButtons({
+ totalVotes,
+ status,
+ votes,
+ accountId,
+ isAllowedToVote,
+ handleVote: (action) => {
+ return handleVote({
+ action,
+ proposalId: id,
+ proposer
+ });
+ }
+ })}
+ {renderFooter({
+ totalVotes,
+ votes,
+ comments,
+ daoId,
+ proposal: proposalData
+ })}
+
+);
From 26a64e9a219f80d43afe395b8a7fafe546f56b06 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Mon, 29 Jan 2024 08:24:21 +0500
Subject: [PATCH 031/132] Rename ProposeModal.jsx to CreateProposal.jsx
---
apps/builddao/widget/components/Post.jsx | 2 +-
.../components/modals/{ProposeModal.jsx => CreateProposal.jsx} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename apps/builddao/widget/components/modals/{ProposeModal.jsx => CreateProposal.jsx} (100%)
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 126a1aeb..7166bcad 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -297,7 +297,7 @@ return (
<>
{props.feedType === "request" && (
Date: Mon, 29 Jan 2024 08:27:35 +0500
Subject: [PATCH 032/132] Add Proposal description for Add and Remove Member
options of proposal
---
.../components/modals/propose/AddMember.jsx | 160 +++++++++++++++++-
.../modals/propose/RemoveMember.jsx | 160 +++++++++++++++++-
2 files changed, 318 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index a8f95e33..9b89e91c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -6,6 +6,144 @@ const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
return (
@@ -36,6 +174,26 @@ return (
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
Near.call(selectedDAO, "add_proposal", {
proposal: {
- description: "Potential member",
+ description: text,
kind: {
AddMemberToRole: {
member_id: accountId,
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
index a9490e50..3b502c15 100644
--- a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -6,6 +6,144 @@ const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
return (
@@ -40,6 +178,26 @@ return (
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
Near.call(selectedDAO, "add_proposal", {
proposal: {
- description: "Potential member",
+ description: text,
kind: {
RemoveMemberFromRole: {
member_id: accountId,
From 26bc2f672a756051fd12b0a38b13933b6466cc25 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Mon, 29 Jan 2024 09:04:33 +0500
Subject: [PATCH 033/132] Add Validations
---
.../components/modals/CreateProposal.jsx | 10 ++++-
.../components/modals/propose/AddMember.jsx | 27 ++++++++++++--
.../modals/propose/FunctionCall.jsx | 8 +++-
.../modals/propose/RemoveMember.jsx | 27 ++++++++++++--
.../components/modals/propose/Transfer.jsx | 37 +++++++++++++++++--
5 files changed, 93 insertions(+), 16 deletions(-)
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 57f22cb3..822a96ab 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -37,7 +37,7 @@ const StyledTypeahead = styled.div`
input,
input:focus,
.rbt-input-hint {
- background: #23242b;
+ background: #212529;
color: #fff;
&::placeholder {
@@ -47,9 +47,13 @@ const StyledTypeahead = styled.div`
border: 1px solid #434950;
}
+ .rbt-input-hint {
+ color: rgba(255, 255, 255, 0.2) !important;
+ }
+
.rbt-menu,
.dropdown-item {
- background: #23242b;
+ background: #212529;
color: #fff;
}
`;
@@ -153,6 +157,7 @@ return (
props={{
roles: roles,
selectedDAO: selectedDAO,
+ item: props.item,
}}
/>
>
@@ -164,6 +169,7 @@ return (
props={{
roles: roles,
selectedDAO: selectedDAO,
+ item: props.item,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 9b89e91c..818b3f0c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -14,6 +14,16 @@ useEffect(() => {
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const [validatedAddresss, setValidatedAddresss] = useState(true);
+
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(accountId) || accountId === "") {
+ setValidatedAddresss(true);
+ } else {
+ setValidatedAddresss(false);
+ }
+});
const MarkdownEditor = `
html {
@@ -147,7 +157,9 @@ const TextareaWrapper = styled.div`
return (
- Account ID
+
+ Account ID*
+
setAccountId(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
-
Role
+
+ Role*
+
setRole(e.target.value)}
selected={role}
>
- Select a role
+ Select a role
{roles.length > 0 &&
roles.map((role) => {role} )}
@@ -198,7 +217,7 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index efb5932d..8b653cfa 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -149,7 +149,9 @@ const TextareaWrapper = styled.div`
return (
- Contract
+
+ Contract*
+
-
Method
+
+ Method*
+
{
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const [validatedAddresss, setValidatedAddresss] = useState(true);
+
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(accountId) || accountId === "") {
+ setValidatedAddresss(true);
+ } else {
+ setValidatedAddresss(false);
+ }
+});
const MarkdownEditor = `
html {
@@ -147,7 +157,9 @@ const TextareaWrapper = styled.div`
return (
- Account ID
+
+ Account ID*
+
setAccountId(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
-
Role
+
+ Role*
+
setRole(e.target.value)}
selected={role}
>
- Select a role
+ Select a role
{roles.length > 0 &&
roles.map((role) => (
@@ -202,7 +221,7 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index 4e184e9d..07cfc31c 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -5,6 +5,7 @@ const [recipient, setRecipient] = useState("");
const [token, setToken] = useState("");
const [amount, setAmount] = useState(0);
const [description, setDescription] = useState("");
+const [validatedAddresss, setValidatedAddress] = useState(true);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -16,6 +17,22 @@ useEffect(() => {
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
const selectedDao = props.selectedDao;
+// handle checking
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(recipient) || recipient === "") {
+ setValidatedAddress(true);
+ } else {
+ setValidatedAddress(false);
+ }
+}, [recipient]);
+
+useEffect(() => {
+ if (amount < 0) {
+ setAmount(0);
+ }
+}, [amount]);
+
const MarkdownEditor = `
html {
background: #23242b;
@@ -148,18 +165,28 @@ const TextareaWrapper = styled.div`
return (
- Recipient
+
+ Recipient*
+
setRecipient(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
- Token
+
+ Token*
+
setToken(e.target.value)}
>
- Select a token
+ Select a token
NEAR
ETH
USDC
@@ -177,7 +204,9 @@ return (
-
Amount
+
+ Amount*
+
Date: Mon, 29 Jan 2024 16:34:50 +0530
Subject: [PATCH 034/132] minor css updates
---
apps/builddao/widget/components/ProposalCard.jsx | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index 4ea759d2..52719412 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -103,17 +103,16 @@ const Wrapper = styled.div`
color: #51b6ff !important;
}
- // TODO
.danger {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid rgba(253, 42, 92, 0.1);
+ background: rgba(253, 42, 92, 0.1);
+ color: #fd2a5c !important;
}
.black {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ background: rgba(255, 255, 255, 0.1);
+ color: #fff !important;
}
.word-wrap {
From 6ddb2dad6ee6b8217df311fea924d1c64d35d514 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:38:55 +0530
Subject: [PATCH 035/132] minor fixes
---
.prettierrc.json | 6 ++++++
apps/builddao/widget/Proposals.jsx | 2 +-
.../components/modals/propose/AddMember.jsx | 13 ++++++++-----
.../components/modals/propose/FunctionCall.jsx | 17 ++++++++++-------
.../components/modals/propose/RemoveMember.jsx | 13 ++++++++-----
.../widget/components/modals/propose/Text.jsx | 9 ++++++---
.../components/modals/propose/Transfer.jsx | 13 ++++++++-----
7 files changed, 47 insertions(+), 26 deletions(-)
create mode 100644 .prettierrc.json
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 00000000..daa2aef0
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,6 @@
+{
+ "trailingComma": "none",
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": false
+}
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 0ad5aa1e..8d6923cc 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -219,7 +219,7 @@ const ProposalsComponent = () => {
return (
setShowModal(!showProposalModal)
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 818b3f0c..266926df 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -9,6 +9,9 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -207,7 +210,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -225,10 +228,10 @@ return (
kind: {
AddMemberToRole: {
member_id: accountId,
- role: role,
- },
- },
- },
+ role: role
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 8b653cfa..2d661c87 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -10,6 +10,9 @@ const [deposit, useDeposit] = useState(0);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -223,7 +226,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -245,12 +248,12 @@ return (
method_name: method,
args: args,
deposit: deposit,
- gas: gas,
- },
- ],
- },
- },
- },
+ gas: gas
+ }
+ ]
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
index 798ccc3a..c8134e27 100644
--- a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -9,6 +9,9 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -211,7 +214,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -229,10 +232,10 @@ return (
kind: {
RemoveMemberFromRole: {
member_id: accountId,
- role: role,
- },
- },
- },
+ role: role
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
index 95ee37d4..29633005 100644
--- a/apps/builddao/widget/components/modals/propose/Text.jsx
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -4,6 +4,9 @@ const { Button } =
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -155,7 +158,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -167,8 +170,8 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
description: text,
- kind: "Vote",
- },
+ kind: "Vote"
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index 07cfc31c..b132e97e 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -10,6 +10,9 @@ const [validatedAddresss, setValidatedAddress] = useState(true);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -231,7 +234,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -249,10 +252,10 @@ return (
Transfer: {
token_id: token,
reciever_id: recipient,
- amount: amount,
- },
- },
- },
+ amount: amount
+ }
+ }
+ }
})
}
>
From 8a3810b5e38f922a31c22e1f38e942a7075a1ae8 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:42:18 +0530
Subject: [PATCH 036/132] remove prettier
---
.prettierrc.json | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 .prettierrc.json
diff --git a/.prettierrc.json b/.prettierrc.json
deleted file mode 100644
index daa2aef0..00000000
--- a/.prettierrc.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "trailingComma": "none",
- "tabWidth": 2,
- "semi": true,
- "singleQuote": false
-}
From c020c1ecd3965d83bf87f19682d9e1cdf51a398a Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:43:43 +0530
Subject: [PATCH 037/132] remove logs
---
apps/builddao/widget/Proposals.jsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 8d6923cc..666fa85e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -99,7 +99,6 @@ if (Array.isArray(policy.roles)) {
}
const proposalPeriod = policy.proposal_period;
-console.log(policy);
const ProposalsComponent = () => {
return (
From 298662b7cf1c8e97b87457135247da918d113355 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 23:46:09 +0530
Subject: [PATCH 038/132] add theme support
---
apps/builddao/widget/Proposals.jsx | 215 ++++++++----------
apps/builddao/widget/components.jsx | 4 +-
.../builddao/widget/components/Pagination.jsx | 82 ++++---
.../widget/components/ProposalCard.jsx | 192 +++++++++-------
4 files changed, 252 insertions(+), 241 deletions(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 666fa85e..238d89a9 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -29,19 +29,44 @@ const proposals = proposalId
limit: resPerPage
}) || [];
+const PaginationThemeContainer = props.PaginationThemeContainer;
+
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --primary-bg-color: #23242b;
+ --secondary-bg-color: #ffffff1a;
+ --primary-border-color: #fff;
+ --primary-text-color: #ffffff;
+ --secondary-text-color: #b0b0b0;
+ --primary-btn-bg-color: #ffaf51;
+ --primary-btn-text-color: #000;
+ --approve-bg-color: #82e299;
+ --reject-bg-color: #c23f38;
+ --spam-bg-color: #f5c518;
+ --vote-button-color: #ffffff;
+ --success-badge-bg-color: #38c7931a;
+ --success-badge-text-color: #38c793;
+ --primary-badge-bg-color: #ffaf5133;
+ --primary-badge-text-color: #ffaf51;
+ --info-badge-bg-color: #51b6ff33;
+ --info-badge-text-color: #51b6ff;
+ --danger-badge-bg-color: #fd2a5c1a;
+ --danger-badge-text-color: #fd2a5c;
+ --black-badge-bg-color: #ffffff1a;
+ --black-badge-text-color: #fff;
+ `;
+
const Container = styled.div`
.ndc-card {
border: none;
- background-color: #23242b;
- color: white !important;
+ background-color: var(--primary-bg-color);
+ color: var(--primary-text-color) !important;
padding: 2rem;
}
`;
const handleVote = ({ action, proposalId, proposer }) => {
- let args = {};
- args["id"] = JSON.parse(proposalId);
- args["action"] = action;
const customAction = action.replace("Vote", "");
const notification = {
[accountId]: {
@@ -63,22 +88,23 @@ const handleVote = ({ action, proposalId, proposer }) => {
}
}
};
- Near.call([
- {
- contractName: daoId,
- methodName: "act_proposal",
- args: args,
- gas: 200000000000000
- },
- {
- contractName: "social.near",
- methodName: "set",
- args: { data: notification },
- deposit: Big(JSON.stringify(notification).length * 16).mul(
- Big(10).pow(20)
- )
- }
- ]);
+
+ sdk.actProposal({
+ proposalId,
+ action,
+ deposit: "",
+ gas: 200000000000000,
+ additionalCalls: [
+ {
+ contractName: "social.near",
+ methodName: "set",
+ args: { data: notification },
+ deposit: Big(JSON.stringify(notification).length * 16).mul(
+ Big(10).pow(20)
+ )
+ }
+ ]
+ });
};
const policy = sdk.getPolicy();
@@ -110,84 +136,34 @@ const ProposalsComponent = () => {
? item.kind
: Object.keys(item.kind)[0];
- const comments = Social.index("comment", {
- type: "dao_proposal_comment",
- path: `${daoId}/proposal/main`,
- proposal_id: item.id + "-beta"
- });
- const permissionKind = proposalKinds[kindName];
- let totalVotesNeeded = 0;
+ const comments = sdk.getCommentsByProposalId({ proposalId: item.id });
+
const isAllowedToVote = [
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteApprove
}),
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteReject
}),
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteRemove
})
];
- policy.roles.forEach((role) => {
- const isRoleAllowedToVote =
- role.permissions.includes(
- `${proposalKinds[kindName]}:VoteApprove`
- ) ||
- role.permissions.includes(
- `${proposalKinds[kindName]}:VoteReject`
- ) ||
- role.permissions.includes(`${proposalKinds[kindName]}:*`) ||
- role.permissions.includes(`*:VoteApprove`) ||
- role.permissions.includes(`*:VoteReject`) ||
- role.permissions.includes("*:*");
- if (isRoleAllowedToVote) {
- const threshold = (role.vote_policy &&
- role.vote_policy[proposalKinds[kindName]]?.threshold) ||
- policy["default_vote_policy"]?.threshold || [0, 0];
- const eligibleVoters = role.kind.Group
- ? role.kind.Group.length
- : 0;
-
- // Apply the threshold
- if (eligibleVoters === 0) {
- return;
- }
-
- const votesNeeded =
- Math.floor((threshold[0] / threshold[1]) * eligibleVoters) + 1;
- console.log(item.id, "votesNeeded", votesNeeded);
- totalVotesNeeded += votesNeeded;
- }
+ const { thresholdVoteCount } = getVotersAndThresholdForProposalKind({
+ kindName
+ });
+ const totalVotes = calculateVoteCountByType({ votes: item.votes });
+ let expirationTime = sdk.getProposalExpirationTime({
+ submissionTime: item.submission_time
});
-
- let totalVotes = {
- yes: 0,
- no: 0,
- spam: 0,
- total: 0
- };
- for (const vote of Object.values(item.votes)) {
- if (vote === "Approve") {
- totalVotes.yes++;
- } else if (vote === "Reject") {
- totalVotes.no++;
- } else if (vote === "Spam") {
- totalVotes.spam++;
- }
- }
- totalVotes.total = totalVotes.yes + totalVotes.no + totalVotes.spam;
-
- let expirationTime = Big(item.submission_time).add(
- Big(proposalPeriod)
- );
return (
{
proposalData: {
...item,
typeName: kindName.replace(/([A-Z])/g, " $1").trim(),
- totalVotesNeeded,
- totalVotes,
+ totalVotesNeeded: thresholdVoteCount,
+ totalVotes: {
+ ...totalVotes,
+ yes: totalVotes.approve,
+ no: totalVotes.reject
+ },
expirationTime
},
daoId: daoId,
@@ -216,39 +196,38 @@ const ProposalsComponent = () => {
};
return (
-
- setShowModal(!showProposalModal)
- }}
- />
-
-
Proposals
- setShowModal(true)}>
- Create Proposal
-
-
-
- {!proposalId && (
-
-
0,
- hasNext: proposals?.[0].id !== resPerPage,
- onPrev: () => {
- setCurrentPage(currentPage - 1);
- },
- onNext: () => {
- setCurrentPage(currentPage + 1);
- }
- }}
- />
+
+
+ setShowModal(!showProposalModal)
+ }}
+ />
+
+
Proposals
+ setShowModal(true)}>
+ Create Proposal
+
- )}
-
+
+ {!proposalId && (
+
+ setCurrentPage(v),
+ selectedPage: currentPage,
+ ThemeContainer: PaginationThemeContainer
+ }}
+ />
+
+ )}
+
+
);
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index f01cde64..d3cf4b9f 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -19,6 +19,7 @@ function Pagination({
maxVisiblePages,
onPageClick,
selectedPage,
+ ThemeContainer
}) {
return (
);
@@ -59,5 +61,5 @@ return {
TextEditor,
Checkbox,
Avatar,
- User,
+ User
};
diff --git a/apps/builddao/widget/components/Pagination.jsx b/apps/builddao/widget/components/Pagination.jsx
index 5e39fb73..8e0a109e 100644
--- a/apps/builddao/widget/components/Pagination.jsx
+++ b/apps/builddao/widget/components/Pagination.jsx
@@ -4,9 +4,18 @@ const onPageClick = props.onPageClick
? props.onPageClick
: () => console.log("clicked");
const pagesToShow = Math.min(totalPages, maxVisiblePages);
-const [selectedPage, setSelectedPage] = useState(props.selectedPage ?? 11);
+const selectedPage = props.selectedPage === 0 ? 1 : props.selectedPage;
const totalPageSets = Math.ceil(totalPages / maxVisiblePages);
-const [currentPageSet, setCurrentPageSet] = useState(totalPageSets);
+const [currentPageSet, setCurrentPageSet] = useState(1);
+
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --font-color: #fff;
+ --bg-color: none;
+ --selected-bg-color: #23242b;
+ --arrow-stroke-color: #ffffff1a;
+ `;
const Pagination = styled.div`
display: flex;
@@ -21,9 +30,10 @@ const Pagination = styled.div`
align-items: center;
gap: 10px;
border-radius: 8px;
- color: var(--font-color, #fff);
+ color: var(--font-color);
transition: all 300ms;
cursor: pointer;
+ background-color: var(--bg-color);
/* Other/Button_text */
font-size: 14px;
@@ -33,11 +43,11 @@ const Pagination = styled.div`
&.selected,
&:hover {
- background-color: var(--bg-1, #23242b);
+ background-color: var(--selected-bg-color);
}
&.arrow {
- border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ border: 1px solid var(--arrow-stroke-color);
}
&.disabled {
@@ -64,34 +74,36 @@ const getPageNumber = (index) =>
(currentPageSet - 1) * maxVisiblePages + index + 1;
return (
-
- handleArrowClick("left")}
- >
-
-
- {Array.from({ length: pagesToShow }).map((_, index) => {
- const pageNumber = getPageNumber(index);
- return (
- handlePageClick(pageNumber)}
- >
- {pageNumber}
-
- );
- })}
- handleArrowClick("right")}
- >
-
-
-
+
+
+ handleArrowClick("left")}
+ >
+
+
+ {Array.from({ length: pagesToShow }).map((_, index) => {
+ const pageNumber = getPageNumber(index);
+ return (
+ handlePageClick(pageNumber)}
+ >
+ {pageNumber}
+
+ );
+ })}
+ handleArrowClick("right")}
+ >
+
+
+
+
);
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index 52719412..a2fe30bf 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -14,6 +14,32 @@ const {
const { daoId, isAllowedToVote, handleVote, comments, proposalData } = props;
const accountId = context.accountId;
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --primary-bg-color: #23242b;
+ --secondary-bg-color: #ffffff1a;
+ --primary-border-color: #fff;
+ --primary-text-color: #ffffff;
+ --secondary-text-color: #b0b0b0;
+ --primary-btn-bg-color: #ffaf51;
+ --primary-btn-text-color: #000;
+ --approve-bg-color: #82e299;
+ --reject-bg-color: #c23f38;
+ --spam-bg-color: #f5c518;
+ --vote-button-color: #ffffff;
+ --success-badge-bg-color: #38c7931a;
+ --success-badge-text-color: #38c793;
+ --primary-badge-bg-color: #ffaf5133;
+ --primary-badge-text-color: #ffaf51;
+ --info-badge-bg-color: #51b6ff33;
+ --info-badge-text-color: #51b6ff;
+ --danger-badge-bg-color: #fd2a5c1a;
+ --danger-badge-text-color: #fd2a5c;
+ --black-badge-bg-color: #ffffff1a;
+ --black-badge-text-color: #fff;
+ `;
+
function checkVotes(value) {
return votes[accountId] === value;
}
@@ -27,41 +53,37 @@ const Wrapper = styled.div`
gap: 24px;
min-height: 500px;
width: 100%;
- border: 1px solid #fff;
+ border: 1px solid var(--primary-border-color);
b {
font-weight: 600;
}
- .grey-bg {
- background: rgba(255, 255, 255, 0.1) !important;
- }
-
- .light-grey-text {
- color: rgba(176, 176, 176, 1) !important;
+ .secondary-bg {
+ background: var(--secondary-bg-color) !important;
}
- .text-muted {
- color: rgba(176, 176, 176, 1) !important;
+ .secondary-text {
+ color: var(--secondary-text-color) !important;
}
a {
- background: rgba(255, 255, 255, 0.1) !important;
- color: white !important;
+ background: var(--secondary-bg-color) !important;
+ color: var(--primary-text-color) !important;
}
.social_url {
- background: rgba(255, 255, 255, 0.1) !important;
- color: white !important;
+ background: var(--secondary-bg-color) !important;
}
.btn-primary {
- background-color: #ffaf51 !important;
- color: black !important;
+ background-color: var(--primary-btn-bg-color) !important;
+ color: var(--primary-btn-text-color) !important;
+ border: none;
}
ul {
- background-color: #23242b;
+ background-color: var(--primary-bg-color);
}
.Approve {
@@ -86,33 +108,33 @@ const Wrapper = styled.div`
}
.success {
- border: 1px solid rgba(56, 199, 147, 0.2) !important;
- background: rgba(56, 199, 147, 0.1) !important;
- color: #38c793 !important;
+ border: 1px solid var(--success-badge-bg-color) !important;
+ background: var(--success-badge-bg-color) !important;
+ color: var(--success-badge-text-color) !important;
}
.primary {
- border: 1px solid rgba(255, 175, 81, 0.2) !important;
- background: rgba(255, 175, 81, 0.2) !important;
- color: #ffaf51 !important;
+ border: 1px solid var(--primary-badge-bg-color) !important;
+ background: var(--primary-badge-bg-color) !important;
+ color: var(--primary-badge-text-color) !important;
}
.info {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid var(--info-badge-bg-color) !important;
+ background: var(--info-badge-bg-color) !important;
+ color: var(--info-badge-text-color) !important;
}
.danger {
- border: 1px solid rgba(253, 42, 92, 0.1);
- background: rgba(253, 42, 92, 0.1);
- color: #fd2a5c !important;
+ border: 1px solid var(--danger-badge-bg-color) !important;
+ background: var(--danger-badge-bg-color) !important;
+ color: var(--danger-badge-text-color) !important;
}
.black {
- border: 1px solid rgba(255, 255, 255, 0.1);
- background: rgba(255, 255, 255, 0.1);
- color: #fff !important;
+ border: 1px solid var(--black-badge-bg-color) !important;
+ background: var(--black-badge-bg-color) !important;
+ color: var(--black-badge-text-color) !important;
}
.word-wrap {
@@ -122,7 +144,7 @@ const Wrapper = styled.div`
${({ status }) =>
status === "Approved" &&
`
- border-color: #82E299;
+ border-color: var(--approve-bg-color);
`}
${({ status }) =>
@@ -134,7 +156,7 @@ const Wrapper = styled.div`
${({ status }) =>
(status === "Failed" || status === "Rejected") &&
`
- border-color: #C23F38;
+ border-color: var(--reject-bg-color);
`}
.text-sm {
@@ -184,7 +206,7 @@ const YouVotedBadge = () => {
function renderPermission({ isAllowedToVote }) {
return (
-
+
{isAllowedToVote
? "You are allowed to vote on this proposal"
: "You are not allowed to vote on this proposal"}
@@ -246,7 +268,7 @@ function renderHeader({ typeName, id, status }) {
props={{
children: `Proposal ID #${id}`,
variant: "",
- className: "grey-bg",
+ className: "secondary-bg",
size: "lg"
}}
/>
@@ -314,7 +336,7 @@ function renderData({
Proposer
-
+
Description
-
@@ -339,7 +361,7 @@ function renderData({
Submitted at
-
+
{new Date(
parseInt(Big(submission_time).div(1000000))
).toLocaleString()}
@@ -351,7 +373,7 @@ function renderData({
Expired at
-
+
{new Date(
parseInt(Big(expirationTime).div(1000000))
).toLocaleString()}
@@ -362,7 +384,7 @@ function renderData({
Required Votes
- {totalVotesNeeded}
+ {totalVotesNeeded}
@@ -388,13 +410,11 @@ function renderVoteButtons({
align-items: center;
position: relative;
overflow: hidden;
- color: rgb(var(--vote-button-color));
- background-color: rgba(255, 255, 255, 0.10);
- --vote-button-bg: 130, 226, 153;
- --vote-button-color: 255, 255, 255;
-
+ color: var(--vote-button-color);
+ background-color: var(--secondary-bg-color);
+ --vote-button-bg: var(--approve-bg-color);
&.no {
- --vote-button-bg: 194, 63, 56;
+ --vote-button-bg: var(--reject-bg-color);
}
&.no > div:last-child {
@@ -405,27 +425,23 @@ function renderVoteButtons({
if (percentage > 80) {
return `
&.no > div:last-child {
- color: rgb(var(--vote-button-color)) !important;
+ color: var(--vote-button-color) !important;
}
`;
}
} else if (!disabled) {
return `
&:hover.no > div:last-child {
- color: rgb(var(--vote-button-color)) !important;
+ color: var(--vote-button-color) !important;
}
`;
}
}}}
&.spam {
- --vote-button-bg: 245, 197, 24;
+ --vote-button-bg: var(--spam-bg-color);
}
- &.abstain {
- --vote-button-bg: 169, 169, 169;
- }
-
&:before {
content: "";
position: absolute;
@@ -435,7 +451,7 @@ function renderVoteButtons({
border-radius: 12px;
transition: all 0.4s ease-in-out;
z-index: 0;
- background-color: rgb(var(--vote-button-bg));
+ background-color: var(--vote-button-bg);
${({ percentage }) => `
min-width: ${percentage && percentage > 5 ? `${percentage}%` : "5px"};
`}
@@ -544,7 +560,7 @@ function renderVoteButtons({
wins={wins.yes}
myVote={voted.yes}
onClick={() => handleVote("VoteApprove")}
- disabled={alreadyVoted || finished || !isAllowedToVote[0]}
+ // disabled={alreadyVoted || finished || !isAllowedToVote[0]}
>
{wins.yes && (
@@ -673,7 +689,7 @@ function renderFooter({ totalVotes, votes, comments, daoId, proposal }) {
@@ -710,35 +726,37 @@ const canVote =
isAllowedToVote.every((v) => v) && status === "In Progress" && !alreadyVoted;
return (
-
- {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
- {renderHeader({ typeName, id, daoId, status })}
- {renderData({
- proposer,
- description,
- submission_time,
- totalVotesNeeded
- })}
- {renderVoteButtons({
- totalVotes,
- status,
- votes,
- accountId,
- isAllowedToVote,
- handleVote: (action) => {
- return handleVote({
- action,
- proposalId: id,
- proposer
- });
- }
- })}
- {renderFooter({
- totalVotes,
- votes,
- comments,
- daoId,
- proposal: proposalData
- })}
-
+
+
+ {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
+ {renderHeader({ typeName, id, daoId, status })}
+ {renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+ })}
+ {renderVoteButtons({
+ totalVotes,
+ status,
+ votes,
+ accountId,
+ isAllowedToVote,
+ handleVote: (action) => {
+ return handleVote({
+ action,
+ proposalId: id,
+ proposer
+ });
+ }
+ })}
+ {renderFooter({
+ totalVotes,
+ votes,
+ comments,
+ daoId,
+ proposal: proposalData
+ })}
+
+
);
From 95184f60a6a48e7d6ec4016223d59c87ff282351 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Tue, 30 Jan 2024 01:38:38 +0530
Subject: [PATCH 039/132] fix sdk method
---
apps/builddao/widget/Proposals.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 238d89a9..e4fccf8e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -157,10 +157,10 @@ const ProposalsComponent = () => {
})
];
- const { thresholdVoteCount } = getVotersAndThresholdForProposalKind({
+ const { thresholdVoteCount } = sdk.getVotersAndThresholdForProposalKind({
kindName
});
- const totalVotes = calculateVoteCountByType({ votes: item.votes });
+ const totalVotes = sdk.calculateVoteCountByType({ votes: item.votes });
let expirationTime = sdk.getProposalExpirationTime({
submissionTime: item.submission_time
});
From 470b64c0f1c14ed25a480a18949eab7502a26e2c Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:20:29 +0500
Subject: [PATCH 040/132] Add css variables and props for custom styling
---
apps/builddao/widget/components/Modal.jsx | 6 ++--
.../components/modals/CreateProposal.jsx | 14 ++++++++-
.../components/modals/propose/AddMember.jsx | 18 +++++++-----
.../modals/propose/FunctionCall.jsx | 29 ++++++++++---------
.../modals/propose/RemoveMember.jsx | 18 +++++++-----
.../components/modals/propose/Transfer.jsx | 20 +++++++------
6 files changed, 63 insertions(+), 42 deletions(-)
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index 65d551f5..62c857ce 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -14,7 +14,7 @@ const Overlay = styled.div`
z-index: 1000;
width: 100vw;
height: 100vh;
- background: rgba(11, 12, 20, 0.5);
+ background: var(--modal-overlay-color, rgba(11, 12, 20, 0.5));
`;
const Content = styled.div`
@@ -22,9 +22,9 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242b;
+ background: var(--modal-background-color, #23242b);
border-radius: 16px;
- color: white;
+ color: var(--modal-text-color, #fff);
@media screen and (max-width: 768px) {
width: 80%;
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 822a96ab..a32f224f 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -15,6 +15,9 @@ const { Modal, Button, User } = VM.require(
const showModal = props.showModal;
const toggleModal = props.toggleModal;
const toggle = props.toggle;
+const bootstrapTheme = props.bootstrapTheme || "dark";
+const editorCSS = props.editorCSS;
+
if (!showModal) {
return "";
}
@@ -102,7 +105,7 @@ return (
setSelectedOption(e.target.value)}
value={selectedOption}
@@ -124,6 +127,7 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
}}
/>
>
@@ -135,6 +139,8 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -146,6 +152,8 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -158,6 +166,8 @@ return (
roles: roles,
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -170,6 +180,8 @@ return (
roles: roles,
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 266926df..ae08e83c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -8,6 +8,8 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
+
+const bootstrapTheme = props.bootstrapTheme;
useEffect(() => {
if (!props.item) {
return;
@@ -167,7 +169,7 @@ return (
name="accountId"
id="accountId"
className="form-control"
- data-bs-theme="dark"
+ data-bs-theme={bootstrapTheme}
value={accountId}
onChange={(e) => setAccountId(e.target.value)}
/>
@@ -185,7 +187,7 @@ return (
setRole(e.target.value)}
selected={role}
@@ -207,10 +209,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -228,10 +230,10 @@ return (
kind: {
AddMemberToRole: {
member_id: accountId,
- role: role
- }
- }
- }
+ role: role,
+ },
+ },
+ },
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 2d661c87..7ed6ca9b 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -9,6 +9,9 @@ const [deposit, useDeposit] = useState(0);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
+
+const bootstrapTheme = props.bootstrapTheme;
+
useEffect(() => {
if (!props.item) {
return;
@@ -158,7 +161,7 @@ return (
setContract(e.target.value)}
className="form-control"
@@ -171,7 +174,7 @@ return (
setMethod(e.target.value)}
className="form-control"
@@ -182,7 +185,7 @@ return (
@@ -231,10 +233,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -252,10 +254,10 @@ return (
Transfer: {
token_id: token,
reciever_id: recipient,
- amount: amount
- }
- }
- }
+ amount: amount,
+ },
+ },
+ },
})
}
>
From 07e19082eedfd776f6852af3242f0ca2572169d3 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:22:55 +0500
Subject: [PATCH 041/132] Add missing prop to text widget
---
apps/builddao/widget/components/modals/CreateProposal.jsx | 1 +
apps/builddao/widget/components/modals/propose/Text.jsx | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index a32f224f..68b433c2 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -128,6 +128,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
index 29633005..a786f840 100644
--- a/apps/builddao/widget/components/modals/propose/Text.jsx
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -155,10 +155,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -170,8 +170,8 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
description: text,
- kind: "Vote"
- }
+ kind: "Vote",
+ },
})
}
>
From f30a018a90df6189a69c46699dfaa4dc522b72b0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:37:31 +0500
Subject: [PATCH 042/132] Add proposals widget to route
---
apps/builddao/widget/Proposals.jsx | 59 ++++++++++---------
apps/builddao/widget/config.jsx | 4 +-
.../page/{proposal.jsx => proposals.jsx} | 4 +-
3 files changed, 35 insertions(+), 32 deletions(-)
rename apps/builddao/widget/page/{proposal.jsx => proposals.jsx} (54%)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index e4fccf8e..37ba6e54 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -1,5 +1,5 @@
const { Button } = VM.require("buildhub.near/widget/components.Button") || {
- Button: <>>
+ Button: <>>,
};
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
@@ -18,15 +18,15 @@ const lastProposalId = sdk.getLastProposalId();
const proposals = proposalId
? [
sdk.getProposalById({
- proposalId
- })
+ proposalId,
+ }),
] || []
: sdk.getProposals({
offset:
currentPage === 0
? lastProposalId - resPerPage
: lastProposalId - currentPage * resPerPage,
- limit: resPerPage
+ limit: resPerPage,
}) || [];
const PaginationThemeContainer = props.PaginationThemeContainer;
@@ -78,15 +78,15 @@ const handleVote = ({ action, proposalId, proposer }) => {
message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
params: {
daoId: daoId,
- proposalId: proposalId
+ proposalId: proposalId,
},
type: "custom",
- widget: "buildhub.near/widget/Proposals"
- }
- }
- ])
- }
- }
+ widget: "buildhub.near/widget/Proposals",
+ },
+ },
+ ]),
+ },
+ },
};
sdk.actProposal({
@@ -101,9 +101,9 @@ const handleVote = ({ action, proposalId, proposer }) => {
args: { data: notification },
deposit: Big(JSON.stringify(notification).length * 16).mul(
Big(10).pow(20)
- )
- }
- ]
+ ),
+ },
+ ],
});
};
@@ -142,27 +142,30 @@ const ProposalsComponent = () => {
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteApprove
+ actionType: actions.VoteApprove,
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteReject
+ actionType: actions.VoteReject,
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteRemove
- })
+ actionType: actions.VoteRemove,
+ }),
];
- const { thresholdVoteCount } = sdk.getVotersAndThresholdForProposalKind({
- kindName
+ const { thresholdVoteCount } =
+ sdk.getVotersAndThresholdForProposalKind({
+ kindName,
+ });
+ const totalVotes = sdk.calculateVoteCountByType({
+ votes: item.votes,
});
- const totalVotes = sdk.calculateVoteCountByType({ votes: item.votes });
let expirationTime = sdk.getProposalExpirationTime({
- submissionTime: item.submission_time
+ submissionTime: item.submission_time,
});
return (
@@ -176,14 +179,14 @@ const ProposalsComponent = () => {
totalVotes: {
...totalVotes,
yes: totalVotes.approve,
- no: totalVotes.reject
+ no: totalVotes.reject,
},
- expirationTime
+ expirationTime,
},
daoId: daoId,
comments: comments,
isAllowedToVote,
- handleVote
+ handleVote,
}}
/>
);
@@ -202,11 +205,11 @@ return (
src="buildhub.near/widget/components.modals.CreateProposal"
props={{
showModal: showProposalModal,
- toggleModal: () => setShowModal(!showProposalModal)
+ toggleModal: () => setShowModal(!showProposalModal),
}}
/>
-
Proposals
+ Proposals
setShowModal(true)}>
Create Proposal
@@ -223,7 +226,7 @@ return (
totalPages: Math.round(lastProposalId / resPerPage),
onPageClick: (v) => setCurrentPage(v),
selectedPage: currentPage,
- ThemeContainer: PaginationThemeContainer
+ ThemeContainer: PaginationThemeContainer,
}}
/>
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 34290fbb..cc1f593e 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -16,10 +16,10 @@ return {
},
},
proposal: {
- path: "buildhub.near/widget/page.proposal",
+ path: "buildhub.near/widget/page.proposals",
blockHeight: "final",
init: {
- name: "Proposal",
+ name: "Proposals",
},
},
},
diff --git a/apps/builddao/widget/page/proposal.jsx b/apps/builddao/widget/page/proposals.jsx
similarity index 54%
rename from apps/builddao/widget/page/proposal.jsx
rename to apps/builddao/widget/page/proposals.jsx
index b3529c33..fc72ecaa 100644
--- a/apps/builddao/widget/page/proposal.jsx
+++ b/apps/builddao/widget/page/proposals.jsx
@@ -1,7 +1,7 @@
return (
-
+
From 514595c9e584b1002c52d95884243a1b38f5b672 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Mon, 22 Jan 2024 23:13:38 -0500
Subject: [PATCH 043/132] init
---
apps/bos-blocks/bos.config.json | 3 +
apps/bos-blocks/widget/Compose.jsx | 99 +++++++
apps/bos-blocks/widget/Feed.jsx | 89 ++++++
apps/bos-blocks/widget/Library.jsx | 270 ++++++++++++++++++
.../widget/PR/FilteredIndexFeed.jsx | 11 +
apps/bos-blocks/widget/PR/IndexFeed.jsx | 192 +++++++++++++
apps/bos-blocks/widget/PR/MergedIndexFeed.jsx | 259 +++++++++++++++++
apps/bos-blocks/widget/Router.jsx | 72 +++++
apps/builddao/widget/app.jsx | 82 ++++++
apps/builddao/widget/config.jsx | 32 +++
apps/builddao/widget/page/feed.jsx | 49 ++++
apps/builddao/widget/page/home.jsx | 1 +
src/App.js | 31 +-
src/pages/Viewer.js | 74 +++++
14 files changed, 1256 insertions(+), 8 deletions(-)
create mode 100644 apps/bos-blocks/bos.config.json
create mode 100644 apps/bos-blocks/widget/Compose.jsx
create mode 100644 apps/bos-blocks/widget/Feed.jsx
create mode 100644 apps/bos-blocks/widget/Library.jsx
create mode 100644 apps/bos-blocks/widget/PR/FilteredIndexFeed.jsx
create mode 100644 apps/bos-blocks/widget/PR/IndexFeed.jsx
create mode 100644 apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
create mode 100644 apps/bos-blocks/widget/Router.jsx
create mode 100644 apps/builddao/widget/app.jsx
create mode 100644 apps/builddao/widget/config.jsx
create mode 100644 apps/builddao/widget/page/feed.jsx
create mode 100644 apps/builddao/widget/page/home.jsx
create mode 100644 src/pages/Viewer.js
diff --git a/apps/bos-blocks/bos.config.json b/apps/bos-blocks/bos.config.json
new file mode 100644
index 00000000..25f7b186
--- /dev/null
+++ b/apps/bos-blocks/bos.config.json
@@ -0,0 +1,3 @@
+{
+ "appAccount": "devs.near"
+}
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/Compose.jsx b/apps/bos-blocks/widget/Compose.jsx
new file mode 100644
index 00000000..203c52cf
--- /dev/null
+++ b/apps/bos-blocks/widget/Compose.jsx
@@ -0,0 +1,99 @@
+if (!context.accountId) {
+ return "";
+}
+
+const index = props.index || {
+ post: JSON.stringify({
+ key: "main",
+ value: {
+ type: "md",
+ },
+ }),
+};
+
+const composeData = () => {
+ if (props.appendHashtags) {
+ state.content.text = props.appendHashtags(state.content.text);
+ }
+ const data = {
+ post: {
+ main: JSON.stringify(state.content),
+ },
+ index,
+ };
+
+ const item = {
+ type: "social",
+ path: `${context.accountId}/post/main`,
+ };
+
+ const notifications = state.extractMentionNotifications(
+ state.content.text,
+ item
+ );
+
+ if (notifications.length) {
+ data.index.notify = JSON.stringify(
+ notifications.length > 1 ? notifications : notifications[0]
+ );
+ }
+
+ const hashtags = state.extractHashtags(state.content.text);
+
+ if (hashtags.length) {
+ data.index.hashtag = JSON.stringify(
+ hashtags.map((hashtag) => ({
+ key: hashtag,
+ value: item,
+ }))
+ );
+ }
+
+ return data;
+};
+
+State.init({
+ onChange: ({ content }) => {
+ State.update({ content });
+ },
+});
+
+return (
+ <>
+
+ {
+ State.update({ extractMentionNotifications, extractHashtags });
+ },
+ composeButton: (onCompose) => (
+ {
+ onCompose();
+ }}
+ >
+ Post
+
+ ),
+ }}
+ />
+
+ {state.content && (
+
+ )}
+ >
+);
diff --git a/apps/bos-blocks/widget/Feed.jsx b/apps/bos-blocks/widget/Feed.jsx
new file mode 100644
index 00000000..f252659e
--- /dev/null
+++ b/apps/bos-blocks/widget/Feed.jsx
@@ -0,0 +1,89 @@
+const Feed = ({ index, typeWhitelist, Item, Layout, showCompose }) => {
+ Item = Item || ((props) =>
{JSON.stringify(props)}
);
+ Layout = Layout || (({ children }) => children);
+
+ const renderItem = (a, i) => {
+ if (typeWhitelist && !typeWhitelist.includes(a.value.type)) {
+ return false;
+ }
+ return (
+
+
+
+ );
+ };
+
+ const composeIndex = () => {
+ const arr = Array.isArray(index) ? index : [index];
+
+ const grouped = arr.reduce((acc, i) => {
+ if (i.action !== "repost") {
+ if (!acc[i.action]) {
+ acc[i.action] = [];
+ }
+ acc[i.action].push({ key: i.key, value: { type: "md" } });
+ }
+ return acc;
+ }, {});
+
+ Object.keys(grouped).forEach((action) => {
+ if (grouped[action].length === 1) {
+ grouped[action] = grouped[action][0];
+ }
+ grouped[action] = JSON.stringify(grouped[action]);
+ });
+
+ return grouped;
+ };
+
+ const appendHashtags = (v) => {
+ const arr = Array.isArray(index) ? index : [index];
+ const hashtags = arr
+ .filter((i) => i.action === "hashtag")
+ .map((i) => i.key);
+
+ hashtags.forEach((hashtag) => {
+ if (v.toLowerCase().includes(`#${hashtag.toLowerCase()}`)) return;
+ else v += ` #${hashtag}`;
+ });
+
+ return v;
+ };
+
+ return (
+ <>
+ {showCompose && (
+
+ )}
+ {Array.isArray(index) ? (
+
{children} ,
+ }}
+ />
+ ) : (
+ {children} ,
+ }}
+ />
+ )}
+ >
+ );
+};
+
+return { Feed };
diff --git a/apps/bos-blocks/widget/Library.jsx b/apps/bos-blocks/widget/Library.jsx
new file mode 100644
index 00000000..c164e5b9
--- /dev/null
+++ b/apps/bos-blocks/widget/Library.jsx
@@ -0,0 +1,270 @@
+/**
+ * This is just a direct copy of mob.near/widget/N.Library
+ */
+const accountId = context.accountId || "root.near";
+const authorId = "mob.near";
+
+const itemDescription =
+ 'The identifier item. It will be used as a unique identifier of the entity that receives the action. It\'s also used as a key of the action in the index.\nThe item should be an object with the following keys: `type`, `path` and optional `blockHeight`.\n- `type`: If the data is stored in the social DB, then the type is likely `"social"`, other types can be defined in the standards.\n- `path`: The path to the item. For a `"social"` type, it\'s absolute path within SocialDB, e.g. `alice.near/post/main`.\n- `blockHeight`: An optional paremeter to indicate the block when the data was stored. Since SocialDB data can be overwritten to save storage, the exact data should be referenced by the block height (e.g. for a given post). But if the latest data should be used, then `blockHeight` should be ommited.\n\nExamples of `item`:\n- `{type: "social", path: "mob.near/widget/N.Library"}`\n- `{type: "social", path: "mob.near/post/main", blockHeight: 81101335}`\n';
+
+const components = [
+ {
+ title: "Feed",
+ // category: "Profile",
+ widgetName: "Feed",
+ description:
+ "",
+ // demoProps: { accountId },
+ // requiredProps: {
+ // accountId: "The account ID of the profile",
+ // },
+ // optionalProps: {
+ // profile: "Object that holds profile information to display",
+ // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
+ // hideDescription: "Don't show description, default false",
+ // },
+ },
+ {
+ title: "Context Menu",
+ // category: "Profile",
+ widgetName: "ContextMenu",
+ description:
+ "",
+ // demoProps: { accountId, tooltip: true },
+ // requiredProps: {
+ // accountId: "The account ID of the profile",
+ // },
+ // optionalProps: {
+ // profile: "Object that holds profile information to display",
+ // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
+ // tooltip:
+ // "Display overlay tooltip when you hover over the profile, default false",
+ // },
+ },
+ {
+ title: "Router",
+ // category: "Profile",
+ widgetName: "Router",
+ description:
+ "",
+ // demoProps: { accountId, tooltip: true },
+ // requiredProps: {
+ // accountId: "The account ID of the profile",
+ // },
+ // optionalProps: {
+ // link: "Whether to make profile clickable with a link to the profile page, default true.",
+ // hideAccountId: "Don't show account ID, default false",
+ // hideName: "Don't show profile name, default false",
+ // hideImage: "Don't show profile picture, default false",
+ // hideCheckmark: "Don't show premium checkmark, default false",
+ // profile: "Object that holds profile information to display",
+ // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
+ // title:
+ // 'Optional title when you hover over the profile. Default `"${name} ${accountId}"`',
+ // tooltip:
+ // "Display overlay tooltip or title when you hover over the profile, default false. Will display a custom title if tooltip is given. If tooltip is true, the full tooltip is displayed. Default false",
+ // },
+ },
+];
+
+const renderProps = (props, optional) => {
+ return Object.entries(props || {}).map(([key, desc]) => {
+ return (
+
+
+
+ {key}
+
+
+
+
+
+
+ );
+ });
+};
+
+const renderComponent = (c, i) => {
+ const widgetSrc = `${authorId}/widget/${c.widgetName}`;
+ const embedCode = ` ` ${s}`)
+ .join("\n")}}}\n/>\n`;
+ const id = c.title.toLowerCase().replaceAll(" ", "-");
+ return (
+
+
+
+ {c.title}
+
+
{c.description}
+
Preview
+
+
+
+
Component
+
+
Props
+
+
+
+ Key
+ Description
+
+
+
+ {renderProps(c.requiredProps)}
+ {renderProps(c.optionalProps, true)}
+
+
+
Example
+
+
+ );
+};
+
+const renderMenuItem = (c, i) => {
+ const prev = i ? components[i - 1] : null;
+ const res = [];
+ if (!prev || prev.category !== c.category) {
+ res.push(
+
+ {c.category}
+
+ );
+ }
+ const id = c.title.toLowerCase().replaceAll(" ", "-");
+ res.push(
+
+ );
+ return res;
+};
+
+const Wrapper = styled.div`
+@media(min-width: 992px) {
+ .b-s {
+ border-left: 1px solid #eee;
+ }
+ .b-e {
+ border-right: 1px solid #eee;
+ }
+}
+.category:not(:first-child) {
+ margin-top: 1em;
+}
+.component {
+ padding: 0.5em 12px;
+ padding-bottom: 0;
+ margin-bottom: 3em;
+ margin: 0 -12px 3em;
+ position: relative;
+
+ &:hover {
+ background: rgba(0, 0, 0, 0.03);
+ }
+
+ .anchor {
+ position: absolute;
+ top: -70px;
+ }
+
+ table {
+ background: white;
+ }
+
+ label {
+ font-size: 20px;
+ }
+
+ .code {
+ display: inline-flex;
+ line-height: normal;
+ border-radius: 0.3em;
+ padding: 0 4px;
+ border: 1px solid #ddd;
+ background: rgba(0, 0, 0, 0.03);
+ font-family: var(--bs-font-monospace);
+ }
+ .path {
+
+ }
+ .preview {
+ background-color: white;
+ padding: 12px;
+ border: 1px solid #eee;
+ border-radius: 12px;
+ pre {
+ margin-bottom: 0;
+ }
+ }
+ .props {
+ .prop-key {
+ font-weight: 600;
+ &.optional {
+ font-weight: normal;
+ }
+ }
+ .prop-desc {
+ p {
+ margin-bottom: 0;
+ }
+ }
+ }
+ .embed-code {
+ position: relative;
+
+ .embed-copy {
+ position: absolute;
+ top: 18px;
+ right: 10px;
+ }
+ }
+}
+`;
+
+return (
+
+ Social Components Library
+
+ This library contains common social components used by near.social
+
+
+
{components.map(renderMenuItem)}
+
{components.map(renderComponent)}
+
+
+);
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/PR/FilteredIndexFeed.jsx b/apps/bos-blocks/widget/PR/FilteredIndexFeed.jsx
new file mode 100644
index 00000000..4decaa9f
--- /dev/null
+++ b/apps/bos-blocks/widget/PR/FilteredIndexFeed.jsx
@@ -0,0 +1,11 @@
+const filter = context.accountId && {
+ ignore: Social.getr(`${context.accountId}/graph/hide`),
+};
+
+return (
+
+);
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/PR/IndexFeed.jsx b/apps/bos-blocks/widget/PR/IndexFeed.jsx
new file mode 100644
index 00000000..651bc880
--- /dev/null
+++ b/apps/bos-blocks/widget/PR/IndexFeed.jsx
@@ -0,0 +1,192 @@
+const index = JSON.parse(JSON.stringify(props.index));
+if (!index) {
+ return "props.index is not defined";
+}
+
+const filter = props.filter;
+
+const renderItem =
+ props.renderItem ??
+ ((item, i) => (
+
+ #{item.blockHeight}: {JSON.stringify(item)}
+
+ ));
+const cachedRenderItem = (item, i) => {
+ const key = JSON.stringify(item);
+
+ if (!(key in state.cachedItems)) {
+ state.cachedItems[key] = renderItem(item, i);
+ State.update();
+ }
+ return state.cachedItems[key];
+};
+
+index.options = index.options || {};
+const initialRenderLimit =
+ props.initialRenderLimit ?? index.options.limit ?? 10;
+const addDisplayCount = props.nextLimit ?? initialRenderLimit;
+
+index.options.limit = Math.min(
+ Math.max(initialRenderLimit + addDisplayCount * 2, index.options.limit ?? 0),
+ 100
+);
+const reverse = !!props.reverse;
+
+const initialItems = Social.index(index.action, index.key, index.options);
+if (initialItems === null) {
+ return "";
+}
+
+const computeFetchFrom = (items, limit) => {
+ if (!items || items.length < limit) {
+ return false;
+ }
+ const blockHeight = items[items.length - 1].blockHeight;
+ return index.options.order === "desc" ? blockHeight - 1 : blockHeight + 1;
+};
+
+const mergeItems = (newItems) => {
+ const items = [
+ ...new Set([...newItems, ...state.items].map((i) => JSON.stringify(i))),
+ ].map((i) => JSON.parse(i));
+ items.sort((a, b) => a.blockHeight - b.blockHeight);
+ if (index.options.order === "desc") {
+ items.reverse();
+ }
+ return items;
+};
+
+const jInitialItems = JSON.stringify(initialItems);
+if (state.jInitialItems !== jInitialItems) {
+ const jIndex = JSON.stringify(index);
+ const nextFetchFrom = computeFetchFrom(initialItems, index.options.limit);
+ if (jIndex !== state.jIndex || nextFetchFrom !== state.initialNextFetchFrom) {
+ State.update({
+ jIndex,
+ jInitialItems,
+ items: initialItems,
+ fetchFrom: false,
+ initialNextFetchFrom: nextFetchFrom,
+ nextFetchFrom,
+ displayCount: initialRenderLimit,
+ cachedItems: {},
+ });
+ } else {
+ State.update({
+ jInitialItems,
+ items: mergeItems(initialItems),
+ });
+ }
+}
+
+if (state.fetchFrom) {
+ const limit = addDisplayCount;
+ const newItems = Social.index(
+ index.action,
+ index.key,
+ Object.assign({}, index.options, {
+ from: state.fetchFrom,
+ subscribe: undefined,
+ limit,
+ })
+ );
+ if (newItems !== null) {
+ State.update({
+ items: mergeItems(newItems),
+ fetchFrom: false,
+ nextFetchFrom: computeFetchFrom(newItems, limit),
+ });
+ }
+}
+
+const filteredItems = state.items;
+if (filter) {
+ if (filter.ignore) {
+ filteredItems = filteredItems.filter(
+ (item) => !(item.accountId in filter.ignore)
+ );
+ }
+}
+
+const maybeFetchMore = () => {
+ if (
+ filteredItems.length - state.displayCount < addDisplayCount * 2 &&
+ !state.fetchFrom &&
+ state.nextFetchFrom &&
+ state.nextFetchFrom !== state.fetchFrom
+ ) {
+ State.update({
+ fetchFrom: state.nextFetchFrom,
+ });
+ }
+};
+
+maybeFetchMore();
+
+const makeMoreItems = () => {
+ State.update({
+ displayCount: state.displayCount + addDisplayCount,
+ });
+ maybeFetchMore();
+};
+
+const loader = (
+
+
+ Loading ...
+
+);
+
+const fetchMore =
+ props.manual &&
+ !props.hideFetchMore &&
+ (state.fetchFrom && filteredItems.length < state.displayCount
+ ? loader
+ : state.displayCount < filteredItems.length && (
+
+ ));
+
+const items = filteredItems ? filteredItems.slice(0, state.displayCount) : [];
+if (reverse) {
+ items.reverse();
+}
+
+const renderedItems = items.map(cachedRenderItem);
+const Layout = props.Layout;
+
+return props.manual ? (
+ <>
+ {reverse && fetchMore}
+ {renderedItems}
+ {!reverse && fetchMore}
+ >
+) : (
+
+
+ Loading ...
+
+ }
+ >
+ {props.headerElement}
+ {Layout ? {renderedItems} : <>{renderedItems}>}
+ {props.footerElement}
+
+);
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
new file mode 100644
index 00000000..9a62accb
--- /dev/null
+++ b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
@@ -0,0 +1,259 @@
+if (!props.index) {
+ return "props.index is not defined";
+}
+const indices = JSON.parse(
+ JSON.stringify(Array.isArray(props.index) ? props.index : [props.index])
+);
+
+const filter = props.filter;
+
+const renderItem =
+ props.renderItem ??
+ ((item) => (
+
+ #{item.blockHeight}: {JSON.stringify(item)}
+
+ ));
+const cachedRenderItem = (item, i) => {
+ const key = JSON.stringify(item);
+
+ if (!(key in state.cachedItems)) {
+ state.cachedItems[key] = renderItem(item, i);
+ State.update();
+ }
+ return state.cachedItems[key];
+};
+
+const initialRenderLimit = props.initialRenderLimit ?? 10;
+const addDisplayCount = props.nextLimit ?? initialRenderLimit;
+const reverse = !!props.reverse;
+
+const computeFetchFrom = (items, limit, desc) => {
+ if (!items || items.length < limit) {
+ return false;
+ }
+ const blockHeight = items[items.length - 1].blockHeight;
+ return desc ? blockHeight - 1 : blockHeight + 1;
+};
+
+const mergeItems = (iIndex, oldItems, newItems, desc) => {
+ const index = indices[iIndex];
+ const items = [
+ ...new Set(
+ [
+ ...newItems.map((item) => ({
+ ...item,
+ action: index.action,
+ key: index.key,
+ index: iIndex,
+ })),
+ ...oldItems,
+ ].map((i) => JSON.stringify(i))
+ ),
+ ].map((i) => JSON.parse(i));
+ items.sort((a, b) => a.blockHeight - b.blockHeight);
+ if (desc) {
+ items.reverse();
+ }
+ return items;
+};
+
+const jIndices = JSON.stringify(indices);
+if (jIndices !== state.jIndices) {
+ State.update({
+ jIndices,
+ feeds: indices.map(() => ({})),
+ items: [],
+ displayCount: initialRenderLimit,
+ cachedItems: {},
+ });
+}
+
+let stateChanged = false;
+for (let iIndex = 0; iIndex < indices.length; ++iIndex) {
+ const index = indices[iIndex];
+ const feed = state.feeds[iIndex];
+ let feedChanged = false;
+ index.options = index.options || {};
+ index.options.limit = Math.min(
+ Math.max(initialRenderLimit + addDisplayCount * 2, index.options.limit),
+ 100
+ );
+ const desc = index.options.order === "desc";
+
+ const initialItems = Social.index(
+ index.action,
+ index.key,
+ index.options,
+ index.cacheOptions
+ );
+ if (initialItems === null) {
+ continue;
+ }
+
+ const jInitialItems = JSON.stringify(initialItems);
+ const nextFetchFrom = computeFetchFrom(
+ initialItems,
+ index.options.limit,
+ desc
+ );
+ if (feed.jInitialItems !== jInitialItems) {
+ feed.jInitialItems = jInitialItems;
+ feedChanged = true;
+ if (nextFetchFrom !== feed.initialNextFetchFrom) {
+ feed.fetchFrom = false;
+ feed.items = mergeItems(iIndex, [], initialItems, desc);
+ feed.initialNextFetchFrom = nextFetchFrom;
+ feed.nextFetchFrom = nextFetchFrom;
+ } else {
+ feed.items = mergeItems(iIndex, feed.items, initialItems, desc);
+ }
+ }
+
+ feed.usedCount = 0;
+
+ if (feedChanged) {
+ state.feeds[iIndex] = feed;
+ stateChanged = true;
+ }
+}
+
+// Construct merged feed and compute usage per feed.
+
+const filteredItems = [];
+while (filteredItems.length < state.displayCount) {
+ let bestItem = null;
+ for (let iIndex = 0; iIndex < indices.length; ++iIndex) {
+ const index = indices[iIndex];
+ const feed = state.feeds[iIndex];
+ const desc = index.options.order === "desc";
+ if (!feed.items) {
+ continue;
+ }
+ const item = feed.items[feed.usedCount];
+ if (!item) {
+ continue;
+ }
+ if (
+ bestItem === null ||
+ (desc
+ ? item.blockHeight > bestItem.blockHeight
+ : item.blockHeight < bestItem.blockHeight)
+ ) {
+ bestItem = item;
+ }
+ }
+ if (!bestItem) {
+ break;
+ }
+ state.feeds[bestItem.index].usedCount++;
+ if (filter) {
+ if (filter.ignore) {
+ if (bestItem.accountId in filter.ignore) {
+ continue;
+ }
+ }
+ }
+ filteredItems.push(bestItem);
+}
+
+// Fetch new items for feeds that don't have enough items.
+for (let iIndex = 0; iIndex < indices.length; ++iIndex) {
+ const index = indices[iIndex];
+ const feed = state.feeds[iIndex];
+ const desc = index.options.order === "desc";
+ let feedChanged = false;
+
+ if (
+ (feed.items.length || 0) - feed.usedCount < addDisplayCount * 2 &&
+ !feed.fetchFrom &&
+ feed.nextFetchFrom &&
+ feed.nextFetchFrom !== feed.fetchFrom
+ ) {
+ feed.fetchFrom = feed.nextFetchFrom;
+ feedChanged = true;
+ }
+
+ if (feed.fetchFrom) {
+ const limit = addDisplayCount;
+ const newItems = Social.index(
+ index.action,
+ index.key,
+ Object.assign({}, index.options, {
+ from: feed.fetchFrom,
+ subscribe: undefined,
+ limit,
+ })
+ );
+ if (newItems !== null) {
+ feed.items = mergeItems(iIndex, feed.items, newItems, desc);
+ feed.fetchFrom = false;
+ feed.nextFetchFrom = computeFetchFrom(newItems, limit, desc);
+ feedChanged = true;
+ }
+ }
+
+ if (feedChanged) {
+ state.feeds[iIndex] = feed;
+ stateChanged = true;
+ }
+}
+
+if (stateChanged) {
+ State.update();
+}
+
+const makeMoreItems = () => {
+ State.update({
+ displayCount: state.displayCount + addDisplayCount,
+ });
+};
+
+const loader = (
+
+
+ Loading ...
+
+);
+
+const fetchMore =
+ props.manual &&
+ (state.feeds.some((f) => !!f.fetchFrom) &&
+ filteredItems.length < state.displayCount
+ ? loader
+ : state.displayCount < filteredItems.length && (
+
+ ));
+
+const items = filteredItems ? filteredItems.slice(0, state.displayCount) : [];
+if (reverse) {
+ items.reverse();
+}
+
+const renderedItems = items.map(cachedRenderItem);
+const Layout = props.Layout;
+
+return props.manual ? (
+ <>
+ {reverse && fetchMore}
+ {renderedItems}
+ {!reverse && fetchMore}
+ >
+) : (
+
+ {Layout ? {renderedItems} : <>{renderedItems}>}
+
+);
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/Router.jsx b/apps/bos-blocks/widget/Router.jsx
new file mode 100644
index 00000000..c6bea38c
--- /dev/null
+++ b/apps/bos-blocks/widget/Router.jsx
@@ -0,0 +1,72 @@
+// We eventually want to merge this with what we have in buildhub.near/widget/app
+
+const routes = props.routes;
+if (!routes) {
+ routes = [];
+}
+const Navigator = props.Navigator;
+
+State.init({
+ CurrentWidget: null,
+});
+
+function init() {
+ if (!state.CurrentWidget) {
+ // TODO: check from local storage or props
+ const initialSrc = Object.values(props.routes)[0].src;
+ State.update({ CurrentWidget: initialSrc });
+ // () =>
+ }
+}
+
+init();
+
+// Function to handle navigation
+function handleNavigate(newRoute, passProps) {
+ const currentSrc = props.routes[newRoute]?.src;
+ State.update({ CurrentWidget: currentSrc, passProps });
+}
+
+// const activePage = pages.find((p) => p.active);
+
+// const navigate = (v, params) => {
+// State.update({ page: v, project: params?.project });
+// const url = Url.construct("#//*__@appAccount__*//widget/home", params);
+// Storage.set("url", url);
+// };
+
+function RouterLink({ to, children, passProps }) {
+ return (
+ handleNavigate(to, passProps)}
+ key={"link-to-" + to}
+ style={{ cursor: "pointer" }}
+ >
+ {children}
+
+ );
+}
+
+// Render the current widget or a default message if the route is not found
+return (
+
+ {/* Navigation buttons -- this should be passed to a Navigator widget */}
+
+
+
+ {/** This could already render all of the children, but just put them as display none (lazy loading) */}
+ {state.CurrentWidget ? (
+
+ ) : (
+
{JSON.stringify(state.CurrentWidget)}
+ )}
+
+);
\ No newline at end of file
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
new file mode 100644
index 00000000..5c2f5b60
--- /dev/null
+++ b/apps/builddao/widget/app.jsx
@@ -0,0 +1,82 @@
+const { page, layout, loading, ...passProps } = props;
+
+const { routes, theme } = VM.require("buildhub.near/widget/config") ?? {
+ routes: {},
+ theme: "background-color: red;"
+};
+
+const { AppLayout } = VM.require("every.near/widget/layout") || {
+ AppLayout: () => <>Layout loading...>,
+};
+
+if (!page) page = Object.keys(routes)[0] || "home";
+
+const Root = styled.div`
+ a {
+ color: inherit;
+ }
+
+ ${theme}
+
+ // can come from config
+`;
+
+const [activeRoute, setActiveRoute] = useState(page);
+
+useEffect(() => {
+ setActiveRoute(page);
+}, [page]);
+
+function Router({ active, routes }) { // this may be converted to a module at devs.near/widget/Router
+ const routeParts = active.split(".");
+
+ let currentRoute = routes;
+ let src = "";
+ let defaultProps = {};
+
+ for (let part of routeParts) {
+ if (currentRoute[part]) {
+ currentRoute = currentRoute[part];
+ src = currentRoute.path;
+
+ if (currentRoute.init) {
+ defaultProps = { ...defaultProps, ...currentRoute.init };
+ }
+ } else {
+ // Handle 404 or default case for unknown routes
+ return 404 Not Found
;
+ }
+ }
+
+ return (
+
+
+
+ );
+}
+
+const Container = styled.div`
+ display: flex;
+ height: 100vh;
+`;
+
+const Content = styled.div`
+ width: 100%;
+ height: 100%;
+ overflow: scroll;
+`;
+
+return (
+
+
+
+
+
+
+
+
+
+);
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
new file mode 100644
index 00000000..2d71b26e
--- /dev/null
+++ b/apps/builddao/widget/config.jsx
@@ -0,0 +1,32 @@
+return {
+ "type": "app",
+ "routes": {
+ "home": {
+ "path": "buildhub.near/widget/page.home",
+ "blockHeight": "final",
+ "init": {
+ "name": "Home",
+ "icon": "bi bi-house"
+ }
+ },
+ "feed": {
+ "path": "buildhub.near/widget/page.feed",
+ "blockHeight": "final",
+ "init": {
+ "icon": "bi bi-globe"
+ }
+ },
+ "inspect": {
+ "path": "mob.near/widget/WidgetSource",
+ "blockHeight": "final",
+ "hide": true
+ },
+ "notifications": {
+ "path": "mob.near/widget/NotificationFeed",
+ "blockHeight": "final",
+ "hide": true
+ }
+ },
+ "theme": "background-color: white;"
+}
+;
\ No newline at end of file
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
new file mode 100644
index 00000000..53cc3566
--- /dev/null
+++ b/apps/builddao/widget/page/feed.jsx
@@ -0,0 +1,49 @@
+const { Feed } = VM.require("devs.near/widget/Feed") || {
+ // this is being pulled from local apps/bos-blocks/widget/Feed
+ Feed: () => Feed loading...
,
+};
+
+// would a provider pattern be helpful here?
+// const { items } = props;
+
+const [activeItem, setActiveItem] = useState(null);
+
+function Sidebar() {
+ return ( // minimal styling, classnames from Theme
+ setActiveItem}>
+
sidebar
+
+ );
+}
+
+// can we take influence from the pattern in buildhub.near/widget/app?
+
+return (
+ <>
+
+ {JSON.stringify(p)}
}
+ />
+ >
+);
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
new file mode 100644
index 00000000..c61d8eb7
--- /dev/null
+++ b/apps/builddao/widget/page/home.jsx
@@ -0,0 +1 @@
+return home
;
diff --git a/src/App.js b/src/App.js
index 2f8395ff..b0f84a8a 100644
--- a/src/App.js
+++ b/src/App.js
@@ -41,6 +41,7 @@ import ProposePage from "./pages/ProposePage";
import ViewPage from "./pages/ViewPage";
import ResourcesPage from "./pages/ResourcesPage";
import LibraryPage from "./pages/LibraryPage";
+import Viewer from "./pages/Viewer";
export const refreshAllowanceObj = {};
const documentationHref = "https://docs.near.org/bos";
@@ -80,17 +81,24 @@ function App() {
bundle: false,
}),
setupNightly(),
- setupKeypom({
+ setupKeypom({
networkId: NetworkId,
- signInContractId: NetworkId == "testnet" ? "v1.social08.testnet" : "social.near",
+ signInContractId:
+ NetworkId == "testnet" ? "v1.social08.testnet" : "social.near",
trialAccountSpecs: {
- url: NetworkId == "testnet" ? "https://test.nearbuilders.org/#trial-url/ACCOUNT_ID/SECRET_KEY" : "https://nearbuilders.org/#trial-url/ACCOUNT_ID/SECRET_KEY",
- modalOptions: KEYPOM_OPTIONS(NetworkId)
+ url:
+ NetworkId == "testnet"
+ ? "https://test.nearbuilders.org/#trial-url/ACCOUNT_ID/SECRET_KEY"
+ : "https://nearbuilders.org/#trial-url/ACCOUNT_ID/SECRET_KEY",
+ modalOptions: KEYPOM_OPTIONS(NetworkId),
},
instantSignInSpecs: {
- url: NetworkId == 'testnet' ? 'https://test.nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID' : 'https://nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID',
+ url:
+ NetworkId == "testnet"
+ ? "https://test.nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID"
+ : "https://nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID",
},
- }),
+ }),
],
}),
customElements: {
@@ -102,7 +110,7 @@ function App() {
if (props.to) {
props.to =
typeof props.to === "string" &&
- isValidAttribute("a", "href", props.to)
+ isValidAttribute("a", "href", props.to)
? props.to
: "about:blank";
}
@@ -195,8 +203,15 @@ function App() {
+
+ {/* I've added the below as the isolated route for rendering the app */}
+
+
+
+
+ {/* Legacy: */}
@@ -231,4 +246,4 @@ function App() {
);
}
-export default App;
\ No newline at end of file
+export default App;
diff --git a/src/pages/Viewer.js b/src/pages/Viewer.js
new file mode 100644
index 00000000..5310c7bd
--- /dev/null
+++ b/src/pages/Viewer.js
@@ -0,0 +1,74 @@
+import { Widget } from "near-social-vm";
+import React, { useEffect, useMemo, useState } from "react";
+import { useLocation, useParams } from "react-router-dom";
+
+const SESSION_STORAGE_REDIRECT_MAP_KEY = "nearSocialVMredirectMap";
+
+function Viewer({ code }) {
+ const { path } = useParams(); // get path from url, could be socialdb path or relative to "core"
+ const location = useLocation(); // get query params from url
+ const searchParams = new URLSearchParams(location.search);
+
+ // create props from params
+ const passProps = useMemo(() => {
+ return Array.from(searchParams.entries()).reduce((props, [key, value]) => {
+ props[key] = value;
+ return props;
+ }, {});
+ }, [location]);
+
+ const src = useMemo(() => {
+ const defaultSrc = "buildhub.near/widget/app"; // default widget to load
+ const pathSrc = path || defaultSrc; // if no path, load default widget
+ return pathSrc;
+ // const lastSlashIndex = pathSrc.lastIndexOf("/", pathSrc.indexOf(".near"));
+ // return lastSlashIndex !== -1
+ // ? pathSrc.substring(lastSlashIndex + 1)
+ // : defaultSrc;
+ }, [path]);
+
+ const [redirectMap, setRedirectMap] = useState(null);
+
+ useEffect(() => {
+ const fetchRedirectMap = async () => {
+ try {
+ const localStorageFlags = JSON.parse(
+ localStorage.getItem("flags") || "{}"
+ );
+ let redirectMapData;
+
+ if (localStorageFlags.bosLoaderUrl) {
+ const response = await fetch(localStorageFlags.bosLoaderUrl);
+ const data = await response.json();
+ redirectMapData = data.components;
+ } else {
+ redirectMapData = JSON.parse(
+ sessionStorage.getItem(SESSION_STORAGE_REDIRECT_MAP_KEY) || "{}"
+ );
+ }
+ setRedirectMap(redirectMapData);
+ } catch (error) {
+ console.error("Error fetching redirect map:", error);
+ }
+ };
+ fetchRedirectMap();
+ }, []);
+
+ console.log(
+ `gateway rendering: ${src} with props: ${JSON.stringify(passProps)}`
+ );
+
+ return (
+
+ );
+}
+
+export default Viewer;
From 1cb6bb834c2d1cfa6f2049b1a0971001af6c32c8 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 24 Jan 2024 07:59:48 +0500
Subject: [PATCH 044/132] Create Modal for Drafts
---
apps/builddao/widget/Compose.jsx | 187 ++++++++++--------
apps/builddao/widget/components/Modal.jsx | 14 +-
.../widget/components/modals/DraftModal.jsx | 82 ++++++++
3 files changed, 199 insertions(+), 84 deletions(-)
create mode 100644 apps/builddao/widget/components/modals/DraftModal.jsx
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 306fa0e4..0f128c74 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -3,6 +3,10 @@ const { Avatar, Button } = VM.require("buildhub.near/widget/components") || {
Button: () => <>>,
};
+const { DraftModal } =
+ VM.require("buildhub.near/widget/components.modals.DraftModal") ||
+ (() => <>>);
+
const draftKey = props.feed.name || "draft";
const draft = Storage.privateGet(draftKey);
@@ -488,6 +492,20 @@ const LabelSelect = styled.div`
}
`;
+const [postUUID, setPostUUID] = useState(generateUID());
+const memoizedPostUUID = useMemo(() => postUUID, [postUUID]);
+
+useEffect(() => {
+ if (postContent === "") {
+ setPostUUID(generateUID());
+ }
+}, [postContent]);
+
+const setPostToTest = () => {
+ textareaInputHandler("Test");
+ setPostUUID(generateUID());
+};
+
const avatarComponent = useMemo(() => {
return (
@@ -499,90 +517,105 @@ const avatarComponent = useMemo(() => {
);
}, [context.accountId]);
+const [showDraftsModal, setShowDraftsModal] = useState(false);
+
return (
-
- {avatarComponent}
-
- {view === "editor" ? (
-
- {
- textareaInputHandler(content);
- },
- embedCss: MarkdownEditor,
- }}
- />
- {autocompleteEnabled && showAccountAutocomplete && (
+
+
setShowDraftsModal(!showDraftsModal)}
+ variant="outline"
+ className="align-self-stretch mb-3"
+ >
+ Continue Drafts
+
+
setShowDraftsModal(!showDraftsModal)}
+ children={Test
}
+ />
+
+ {avatarComponent}
+
+ {view === "editor" ? (
+
setShowAccountAutocomplete(false),
+ initialText: postContent,
+ data: { handler: handler, content: postContent },
+ onChange: (content) => {
+ textareaInputHandler(content);
+ },
+ embedCss: MarkdownEditor,
}}
/>
- )}
-
- ) : (
-
-
- {state.image.cid && (
+ {autocompleteEnabled && showAccountAutocomplete && (
+ setShowAccountAutocomplete(false),
+ }}
+ />
+ )}
+
+ ) : (
+
- )}
-
- )}
-
+ {state.image.cid && (
+
+ )}
+
+ )}
+
-
- {view === "editor" && (
-
- )}
-
setView(view === "editor" ? "preview" : "editor")}
- style={{ fontSize: 14 }}
- >
- {view === "editor" ? (
- <>
- Preview
- >
- ) : (
- <>
- Edit
- >
+
+ {view === "editor" && (
+
)}
-
-
- postToCustomFeed({ feed: props.feed, text: postContent, labels })
- }
- >
- Post {props.feed.name}
-
-
-
+ setView(view === "editor" ? "preview" : "editor")}
+ style={{ fontSize: 14 }}
+ >
+ {view === "editor" ? (
+ <>
+ Preview
+ >
+ ) : (
+ <>
+ Edit
+ >
+ )}
+
+
+ postToCustomFeed({ feed: props.feed, text: postContent, labels })
+ }
+ >
+ Post {props.feed.name}
+
+
+
+
);
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index db7409fe..c029e3b7 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -22,7 +22,7 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242B;
+ background: #23242b;
border-radius: 16px;
color: white;
`;
@@ -36,14 +36,14 @@ const NoButton = styled.button`
`;
const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
`;
const Icon = styled.i`
- font-size: 24px;
+ font-size: 24px;
`;
function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
@@ -72,4 +72,4 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
);
}
-return { Modal };
\ No newline at end of file
+return { Modal };
diff --git a/apps/builddao/widget/components/modals/DraftModal.jsx b/apps/builddao/widget/components/modals/DraftModal.jsx
new file mode 100644
index 00000000..0f0c9aab
--- /dev/null
+++ b/apps/builddao/widget/components/modals/DraftModal.jsx
@@ -0,0 +1,82 @@
+const { Button } = VM.require("buildhub.near/widget/components.Button");
+
+const toggle = props.toggle ?? Open Modal ;
+
+const Overlay = styled.div`
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ display: grid;
+ place-items: center;
+ overflow-y: auto;
+ z-index: 1000;
+ width: 100vw;
+ height: 100vh;
+ background: rgba(11, 12, 20, 0.5);
+`;
+
+const Content = styled.div`
+ min-width: 500px;
+ max-width: 1000px;
+ padding: 24px;
+ outline: none !important;
+ background: #23242b;
+ border-radius: 16px;
+ color: white;
+`;
+
+const NoButton = styled.button`
+ background: transparent;
+ border: none;
+ padding: 0;
+ margin: 0;
+ box-shadow: none;
+`;
+
+const CloseContainer = styled.div`
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
+`;
+
+const Icon = styled.i`
+ font-size: 24px;
+`;
+
+function DraftModal({
+ children,
+ open,
+ onOpenChange,
+ toggle,
+ toggleContainerProps,
+}) {
+ return (
+
+
+ {toggle}
+
+
+
+
+
+
+
+
+ Drafts
+
+
+
Edit
+
+ {children}
+
+
+
+
+
+ );
+}
+
+return { DraftModal };
From 4487f8b55aa368289906cc76d5e1ef39e5270712 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 24 Jan 2024 08:10:21 +0500
Subject: [PATCH 045/132] Save drafts
---
apps/builddao/widget/Compose.jsx | 39 ++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 0f128c74..94e33d55 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -506,6 +506,32 @@ const setPostToTest = () => {
setPostUUID(generateUID());
};
+const onSaveDraft = () => {
+ const savedDrafts = Storage.privateGet("savedDrafts") || "";
+ const drafts = JSON.parse(savedDrafts) || [];
+ drafts.push(postContent);
+ Storage.privateSet("savedDrafts", JSON.stringify(drafts));
+};
+
+const renderDrafts = () => {
+ const savedDrafts = Storage.privateGet("savedDrafts") || "";
+ const drafts = JSON.parse(savedDrafts) || [];
+
+ return (
+
+ {drafts.map((draft, i) => (
+
+ {draft}
+
+ ))}
+ {drafts.length === 0 &&
No drafts saved
}
+
+ );
+};
+
const avatarComponent = useMemo(() => {
return (
@@ -531,10 +557,19 @@ return (
setShowDraftsModal(!showDraftsModal)}
- children={Test
}
+ children={
+
+
+
+ }
/>
- {avatarComponent}
+
+ {avatarComponent}
+
+ Save Draft
+
+
{view === "editor" ? (
Date: Wed, 24 Jan 2024 10:16:49 +0500
Subject: [PATCH 046/132] Handle deletion of drafts
---
apps/builddao/widget/Compose.jsx | 140 +++++++++++++++---
apps/builddao/widget/components/Checkbox.jsx | 14 +-
.../widget/components/modals/DraftModal.jsx | 9 +-
3 files changed, 132 insertions(+), 31 deletions(-)
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 94e33d55..90dee79c 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -492,6 +492,7 @@ const LabelSelect = styled.div`
}
`;
+// To handle ifram refresh in order to trigger initialText change
const [postUUID, setPostUUID] = useState(generateUID());
const memoizedPostUUID = useMemo(() => postUUID, [postUUID]);
@@ -501,11 +502,32 @@ useEffect(() => {
}
}, [postContent]);
-const setPostToTest = () => {
- textareaInputHandler("Test");
- setPostUUID(generateUID());
+const avatarComponent = useMemo(() => {
+ return (
+
+ );
+}, [context.accountId]);
+
+// for drafts
+const [showDraftsModal, setShowDraftsModal] = useState(false);
+const [draftEditMode, setDraftEditMode] = useState(false);
+const [checkedDrafts, setCheckDrafts] = useState([]);
+
+// handle deletion of drafts
+const handleDraftDelete = () => {
+ const savedDrafts = Storage.privateGet("savedDrafts") || "";
+ const drafts = JSON.parse(savedDrafts);
+ const newDrafts = drafts.filter((draft, i) => !checkedDrafts.includes(i));
+ Storage.privateSet("savedDrafts", JSON.stringify(newDrafts));
+ setCheckDrafts([]);
};
+// handle draft save
const onSaveDraft = () => {
const savedDrafts = Storage.privateGet("savedDrafts") || "";
const drafts = JSON.parse(savedDrafts) || [];
@@ -513,37 +535,89 @@ const onSaveDraft = () => {
Storage.privateSet("savedDrafts", JSON.stringify(drafts));
};
-const renderDrafts = () => {
+const DraftLabel = styled.span`
+ display: inline-flex;
+ padding: 12px;
+ align-items: center;
+ gap: 8px;
+
+ color: #fff;
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 400;
+ line-height: 170%; /* 27.2px */
+`;
+
+const DraftItem = ({ draft, checked, isEdit }) => {
+ return (
+
+
+ {isEdit && (
+
+ )}
+ {draft}
+
+
+ );
+};
+
+const RenderDrafts = () => {
const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts) || [];
+ const drafts = JSON.parse(savedDrafts);
+
+ const handleDraftSelect = (draft) => {
+ textareaInputHandler(draft);
+ setPostUUID(generateUID());
+ setShowDraftsModal(false);
+ setView("editor");
+ };
return (
{drafts.map((draft, i) => (
-
- {draft}
+
handleDraftSelect(draft)}>
+
))}
- {drafts.length === 0 &&
No drafts saved
}
+ {drafts.length === 0 &&
No drafts saved
}
);
};
-const avatarComponent = useMemo(() => {
+const EditDrafts = () => {
+ const savedDrafts = Storage.privateGet("savedDrafts") || "";
+ const drafts = JSON.parse(savedDrafts);
+
+ const handleDraftSelect = (draftIndex) => {
+ if (checkedDrafts.includes(draftIndex)) {
+ setCheckDrafts(checkedDrafts.filter((draft) => draft !== draftIndex));
+ } else {
+ setCheckDrafts([...checkedDrafts, draftIndex]);
+ }
+ };
+
return (
-
-
-
+
+ {drafts.map((draft, i) => (
+
handleDraftSelect(i)}>
+
+
+ ))}
+ {drafts.length === 0 &&
No drafts saved
}
);
-}, [context.accountId]);
-
-const [showDraftsModal, setShowDraftsModal] = useState(false);
+};
return (
@@ -557,11 +631,29 @@ return (
setShowDraftsModal(!showDraftsModal)}
- children={
-
-
-
+ editButton={
+ draftEditMode ? (
+
+
+
+
+ setDraftEditMode(!draftEditMode)}
+ >
+ Done
+
+
+ ) : (
+ setDraftEditMode(!draftEditMode)}
+ >
+ Edit
+
+ )
}
+ children={{draftEditMode ? : }
}
/>
diff --git a/apps/builddao/widget/components/Checkbox.jsx b/apps/builddao/widget/components/Checkbox.jsx
index 27387079..1f3bed49 100644
--- a/apps/builddao/widget/components/Checkbox.jsx
+++ b/apps/builddao/widget/components/Checkbox.jsx
@@ -7,6 +7,8 @@ const CheckboxLabel = styled.label`
padding: 12px;
align-items: center;
gap: 8px;
+ cursor: pointer;
+ max-width: 100%;
color: #fff;
font-size: 16px;
@@ -15,20 +17,20 @@ const CheckboxLabel = styled.label`
line-height: 170%; /* 27.2px */
`;
-function Checkbox({ value, onChange, label }) {
+function Checkbox({ className, value, onChange, label }) {
return (
-
+
{value ? (
-
+
) : (
-
+
)}
- {label}
+ {label}
);
}
-return { Checkbox };
\ No newline at end of file
+return { Checkbox };
diff --git a/apps/builddao/widget/components/modals/DraftModal.jsx b/apps/builddao/widget/components/modals/DraftModal.jsx
index 0f0c9aab..825338a6 100644
--- a/apps/builddao/widget/components/modals/DraftModal.jsx
+++ b/apps/builddao/widget/components/modals/DraftModal.jsx
@@ -25,6 +25,12 @@ const Content = styled.div`
background: #23242b;
border-radius: 16px;
color: white;
+
+ @media screen and (max-width: 768px) {
+ max-width: 90%;
+ min-width: 50%;
+ width: 100%;
+ }
`;
const NoButton = styled.button`
@@ -52,6 +58,7 @@ function DraftModal({
onOpenChange,
toggle,
toggleContainerProps,
+ editButton,
}) {
return (
@@ -68,7 +75,7 @@ function DraftModal({
Drafts
- Edit
+ {editButton}
{children}
From b1cad45e65a65e74b9809087924cf575267c834f Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Wed, 24 Jan 2024 10:54:03 -0500
Subject: [PATCH 047/132] Revert "Add Post Drafts"
---
apps/builddao/widget/Compose.jsx | 414 +++---------------
apps/builddao/widget/components.jsx | 6 +-
.../widget/components/AccountAutocomplete.jsx | 147 -------
apps/builddao/widget/components/Checkbox.jsx | 14 +-
.../components/MarkdownEditorIframe.jsx | 64 ---
apps/builddao/widget/components/Modal.jsx | 14 +-
.../widget/components/modals/DraftModal.jsx | 89 ----
7 files changed, 86 insertions(+), 662 deletions(-)
delete mode 100644 apps/builddao/widget/components/AccountAutocomplete.jsx
delete mode 100644 apps/builddao/widget/components/MarkdownEditorIframe.jsx
delete mode 100644 apps/builddao/widget/components/modals/DraftModal.jsx
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 90dee79c..83000784 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -1,33 +1,19 @@
-const { Avatar, Button } = VM.require("buildhub.near/widget/components") || {
- Avatar: () => <>>,
- Button: () => <>>,
-};
+const { Avatar, Button } = VM.require("buildhub.near/widget/components");
-const { DraftModal } =
- VM.require("buildhub.near/widget/components.modals.DraftModal") ||
- (() => <>>);
+Avatar = Avatar || (() => <>>);
+Button = Button || (() => <>>);
const draftKey = props.feed.name || "draft";
const draft = Storage.privateGet(draftKey);
-const autocompleteEnabled = true;
-
if (draft === null) {
return "";
}
-State.init({
- image: {},
-});
-
const [view, setView] = useState("editor");
const [postContent, setPostContent] = useState("");
const [hideAdvanced, setHideAdvanced] = useState(true);
const [labels, setLabels] = useState([]);
-const [showAccountAutocomplete, setShowAccountAutocomplete] = useState(false);
-const [mentionsArray, setMentionsArray] = useState([]);
-const [mentionInput, setMentionInput] = useState(null);
-const [handler, setHandler] = useState("update");
setPostContent(draft || props.template);
@@ -37,6 +23,16 @@ function generateUID() {
return randomNumber.toString(16).padStart(8, "0");
}
+function tagsFromLabels(labels) {
+ return labels.reduce(
+ (newLabels, label) => ({
+ ...newLabels,
+ [label]: "",
+ }),
+ {}
+ );
+}
+
const extractMentions = (text) => {
const mentionRegex =
/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;
@@ -106,12 +102,6 @@ const postToCustomFeed = ({ feed, text, labels }) => {
text = checkAndAppendHashtag(text, hashtag);
});
- const content = {
- type: "md",
- image: state.image.cid ? { ipfs_cid: state.image.cid } : undefined,
- text: text,
- };
-
const data = {
// [feed.name]: {
// [postId]: {
@@ -127,7 +117,12 @@ const postToCustomFeed = ({ feed, text, labels }) => {
// },
// },
post: {
- main: JSON.stringify(content),
+ main: JSON.stringify({
+ type: "md",
+ text,
+ // tags: tagsFromLabels(labels),
+ // postType: feed.name,
+ }),
},
index: {
post: JSON.stringify({ key: "main", value: { type: "md" } }),
@@ -172,43 +167,6 @@ const postToCustomFeed = ({ feed, text, labels }) => {
});
};
-function textareaInputHandler(value) {
- const words = value.split(/\s+/);
- const allMentiones = words
- .filter((word) => word.startsWith("@"))
- .map((mention) => mention.slice(1));
- const newMentiones = allMentiones.filter(
- (item) => !mentionsArray.includes(item)
- );
- setMentionInput(newMentiones?.[0] ?? "");
- setMentionsArray(allMentiones);
- setShowAccountAutocomplete(newMentiones?.length > 0);
- setPostContent(value);
- setHandler("update");
- Storage.privateSet(draftKey, value || "");
-}
-
-function autoCompleteAccountId(id) {
- let currentIndex = 0;
- const updatedDescription = postContent.replace(
- /(?:^|\s)(@[^\s]*)/g,
- (match) => {
- if (currentIndex === mentionsArray.indexOf(mentionInput)) {
- currentIndex++;
- return ` @${id}`;
- } else {
- currentIndex++;
- return match;
- }
- }
- );
- setPostContent(updatedDescription);
- setShowAccountAutocomplete(false);
- setMentionInput(null);
- setHandler("autocompleteSelected");
- Storage.privateSet(draftKey, updatedDescription || "");
-}
-
const PostCreator = styled.div`
display: flex;
flex-direction: column;
@@ -219,51 +177,6 @@ const PostCreator = styled.div`
border-radius: 12px;
margin-bottom: 1rem;
-
- .upload-image-button {
- display: flex;
- align-items: center;
- justify-content: center;
- background: #f1f3f5;
- color: #11181c;
- border-radius: 40px;
- height: 40px;
- min-width: 40px;
- font-size: 0;
- border: none;
- cursor: pointer;
- transition: background 200ms, opacity 200ms;
-
- &::before {
- font-size: 16px;
- }
-
- &:hover,
- &:focus {
- background: #d7dbde;
- outline: none;
- }
-
- &:disabled {
- opacity: 0.5;
- pointer-events: none;
- }
-
- span {
- margin-left: 12px;
- }
- }
-
- .d-inline-block {
- display: flex !important;
- gap: 12px;
- margin: 0 !important;
-
- .overflow-hidden {
- width: 40px !important;
- height: 40px !important;
- }
- }
`;
const TextareaWrapper = styled.div`
@@ -492,16 +405,6 @@ const LabelSelect = styled.div`
}
`;
-// To handle ifram refresh in order to trigger initialText change
-const [postUUID, setPostUUID] = useState(generateUID());
-const memoizedPostUUID = useMemo(() => postUUID, [postUUID]);
-
-useEffect(() => {
- if (postContent === "") {
- setPostUUID(generateUID());
- }
-}, [postContent]);
-
const avatarComponent = useMemo(() => {
return (
@@ -513,236 +416,63 @@ const avatarComponent = useMemo(() => {
);
}, [context.accountId]);
-// for drafts
-const [showDraftsModal, setShowDraftsModal] = useState(false);
-const [draftEditMode, setDraftEditMode] = useState(false);
-const [checkedDrafts, setCheckDrafts] = useState([]);
-
-// handle deletion of drafts
-const handleDraftDelete = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
- const newDrafts = drafts.filter((draft, i) => !checkedDrafts.includes(i));
- Storage.privateSet("savedDrafts", JSON.stringify(newDrafts));
- setCheckDrafts([]);
-};
-
-// handle draft save
-const onSaveDraft = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts) || [];
- drafts.push(postContent);
- Storage.privateSet("savedDrafts", JSON.stringify(drafts));
-};
-
-const DraftLabel = styled.span`
- display: inline-flex;
- padding: 12px;
- align-items: center;
- gap: 8px;
-
- color: #fff;
- font-size: 16px;
- font-style: normal;
- font-weight: 400;
- line-height: 170%; /* 27.2px */
-`;
-
-const DraftItem = ({ draft, checked, isEdit }) => {
- return (
-
-
- {isEdit && (
-
- )}
- {draft}
-
-
- );
-};
-
-const RenderDrafts = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
-
- const handleDraftSelect = (draft) => {
- textareaInputHandler(draft);
- setPostUUID(generateUID());
- setShowDraftsModal(false);
- setView("editor");
- };
-
- return (
-
- {drafts.map((draft, i) => (
-
handleDraftSelect(draft)}>
-
-
- ))}
- {drafts.length === 0 &&
No drafts saved
}
-
- );
-};
-
-const EditDrafts = () => {
- const savedDrafts = Storage.privateGet("savedDrafts") || "";
- const drafts = JSON.parse(savedDrafts);
-
- const handleDraftSelect = (draftIndex) => {
- if (checkedDrafts.includes(draftIndex)) {
- setCheckDrafts(checkedDrafts.filter((draft) => draft !== draftIndex));
- } else {
- setCheckDrafts([...checkedDrafts, draftIndex]);
- }
- };
-
- return (
-
- {drafts.map((draft, i) => (
-
handleDraftSelect(i)}>
-
+ {avatarComponent}
+
+ {view === "editor" ? (
+
+ {
+ setPostContent(v);
+ Storage.privateSet(draftKey, v || "");
+ },
+ }}
+ />
+
+ ) : (
+
+
-
- ))}
- {drafts.length === 0 && No drafts saved
}
+
+ )}
- );
-};
-return (
-
-
setShowDraftsModal(!showDraftsModal)}
- variant="outline"
- className="align-self-stretch mb-3"
- >
- Continue Drafts
-
-
setShowDraftsModal(!showDraftsModal)}
- editButton={
- draftEditMode ? (
-
-
-
-
- setDraftEditMode(!draftEditMode)}
- >
- Done
-
-
- ) : (
- setDraftEditMode(!draftEditMode)}
- >
- Edit
-
- )
- }
- children={{draftEditMode ? : }
}
- />
-
-
- {avatarComponent}
-
- Save Draft
-
-
-
+
+ setView(view === "editor" ? "preview" : "editor")}
+ style={{ fontSize: 14 }}
+ >
{view === "editor" ? (
-
- {
- textareaInputHandler(content);
- },
- embedCss: MarkdownEditor,
- }}
- />
- {autocompleteEnabled && showAccountAutocomplete && (
- setShowAccountAutocomplete(false),
- }}
- />
- )}
-
+ <>
+ Preview
+ >
) : (
-
-
- {state.image.cid && (
-
- )}
-
- )}
-
-
-
- {view === "editor" && (
-
+ <>
+ Edit
+ >
)}
- setView(view === "editor" ? "preview" : "editor")}
- style={{ fontSize: 14 }}
- >
- {view === "editor" ? (
- <>
- Preview
- >
- ) : (
- <>
- Edit
- >
- )}
-
-
- postToCustomFeed({ feed: props.feed, text: postContent, labels })
- }
- >
- Post {props.feed.name}
-
-
-
-
+
+
+ postToCustomFeed({ feed: props.feed, text: postContent, labels })
+ }
+ >
+ Post {props.feed.name}
+
+
+
);
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index b73c4264..38499bad 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -33,11 +33,7 @@ function Pagination({
function Post(props) {
return (
-
}
- props={{ ...props }}
- />
+
);
}
diff --git a/apps/builddao/widget/components/AccountAutocomplete.jsx b/apps/builddao/widget/components/AccountAutocomplete.jsx
deleted file mode 100644
index 5823f397..00000000
--- a/apps/builddao/widget/components/AccountAutocomplete.jsx
+++ /dev/null
@@ -1,147 +0,0 @@
-if (!context.accountId || !props.term) return <>>;
-
-let results = [];
-const filterAccounts = props.filterAccounts ?? []; // hide certain accounts from the list
-const profilesData = Social.get("*/profile/name", "final") || {};
-const followingData = Social.get(
- `${context.accountId}/graph/follow/**`,
- "final"
-);
-if (!profilesData) return <>>;
-const profiles = Object.entries(profilesData);
-const term = (props.term || "").replace(/\W/g, "").toLowerCase();
-const limit = 5;
-
-for (let i = 0; i < profiles.length; i++) {
- let score = 0;
- const accountId = profiles[i][0];
- const accountIdSearch = profiles[i][0].replace(/\W/g, "").toLowerCase();
- const nameSearch = (profiles[i][1]?.profile?.name || "")
- .replace(/\W/g, "")
- .toLowerCase();
- const accountIdSearchIndex = accountIdSearch.indexOf(term);
- const nameSearchIndex = nameSearch.indexOf(term);
-
- if (accountIdSearchIndex > -1 || nameSearchIndex > -1) {
- score += 10;
-
- if (accountIdSearchIndex === 0) {
- score += 10;
- }
- if (nameSearchIndex === 0) {
- score += 10;
- }
- if (followingData[accountId] === "") {
- score += 30;
- }
-
- results.push({
- accountId,
- score
- });
- }
-}
-
-results.sort((a, b) => b.score - a.score);
-results = results.slice(0, limit);
-if (filterAccounts?.length > 0) {
- results = results.filter((item) => !filterAccounts?.includes(item.accountId));
-}
-
-function onResultClick(id) {
- props.onSelect && props.onSelect(id);
-}
-
-const Wrapper = styled.div`
- position: relative;
-
- &::before {
- content: "";
- display: block;
- position: absolute;
- right: 0;
- width: 6px;
- height: 100%;
- z-index: 10;
- }
-`;
-
-const Scroller = styled.div`
- position: relative;
- display: flex;
- padding: 6px;
- gap: 6px;
- overflow: auto;
- scroll-behavior: smooth;
- align-items: center;
- scrollbar-width: none;
- -ms-overflow-style: none;
- &::-webkit-scrollbar {
- display: none;
- }
-
- > * {
- max-width: 175px;
- flex-grow: 0;
- flex-shrink: 0;
-
- button {
- border: 1px solid #eceef0;
- background: #fff !important;
- border-radius: 6px;
- padding: 3px 6px;
- transition: all 200ms;
-
- &:focus,
- &:hover {
- border-color: #687076;
- }
- }
- }
-`;
-
-const CloseButton = styled.button`
- background: none;
- border: none;
- display: block;
- padding: 12px;
- color white;
- transition: all 200ms;
-
- &:hover {
- transform:scale(1.2);
- }
-`;
-
-const ProfileCardWrapper = styled.div`
- opacity: 0.8;
-`;
-
-if (results.length === 0) return <>>;
-
-return (
-
-
-
-
-
-
- {results.map((result) => {
- return (
-
-
-
- );
- })}
-
-
-);
diff --git a/apps/builddao/widget/components/Checkbox.jsx b/apps/builddao/widget/components/Checkbox.jsx
index 1f3bed49..27387079 100644
--- a/apps/builddao/widget/components/Checkbox.jsx
+++ b/apps/builddao/widget/components/Checkbox.jsx
@@ -7,8 +7,6 @@ const CheckboxLabel = styled.label`
padding: 12px;
align-items: center;
gap: 8px;
- cursor: pointer;
- max-width: 100%;
color: #fff;
font-size: 16px;
@@ -17,20 +15,20 @@ const CheckboxLabel = styled.label`
line-height: 170%; /* 27.2px */
`;
-function Checkbox({ className, value, onChange, label }) {
+function Checkbox({ value, onChange, label }) {
return (
-
+
{value ? (
-
+
) : (
-
+
)}
- {label}
+ {label}
);
}
-return { Checkbox };
+return { Checkbox };
\ No newline at end of file
diff --git a/apps/builddao/widget/components/MarkdownEditorIframe.jsx b/apps/builddao/widget/components/MarkdownEditorIframe.jsx
deleted file mode 100644
index 38901c46..00000000
--- a/apps/builddao/widget/components/MarkdownEditorIframe.jsx
+++ /dev/null
@@ -1,64 +0,0 @@
-const data = props.data ?? "# Hello World\n\n";
-const embedCss = props.embedCss || "";
-
-const code = `
-
-
-
-
-
-
-
-
-
-
-`;
-return (
-
-);
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index c029e3b7..db7409fe 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -22,7 +22,7 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242b;
+ background: #23242B;
border-radius: 16px;
color: white;
`;
@@ -36,14 +36,14 @@ const NoButton = styled.button`
`;
const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
`;
const Icon = styled.i`
- font-size: 24px;
+ font-size: 24px;
`;
function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
@@ -72,4 +72,4 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
);
}
-return { Modal };
+return { Modal };
\ No newline at end of file
diff --git a/apps/builddao/widget/components/modals/DraftModal.jsx b/apps/builddao/widget/components/modals/DraftModal.jsx
deleted file mode 100644
index 825338a6..00000000
--- a/apps/builddao/widget/components/modals/DraftModal.jsx
+++ /dev/null
@@ -1,89 +0,0 @@
-const { Button } = VM.require("buildhub.near/widget/components.Button");
-
-const toggle = props.toggle ??
Open Modal ;
-
-const Overlay = styled.div`
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- display: grid;
- place-items: center;
- overflow-y: auto;
- z-index: 1000;
- width: 100vw;
- height: 100vh;
- background: rgba(11, 12, 20, 0.5);
-`;
-
-const Content = styled.div`
- min-width: 500px;
- max-width: 1000px;
- padding: 24px;
- outline: none !important;
- background: #23242b;
- border-radius: 16px;
- color: white;
-
- @media screen and (max-width: 768px) {
- max-width: 90%;
- min-width: 50%;
- width: 100%;
- }
-`;
-
-const NoButton = styled.button`
- background: transparent;
- border: none;
- padding: 0;
- margin: 0;
- box-shadow: none;
-`;
-
-const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
-`;
-
-const Icon = styled.i`
- font-size: 24px;
-`;
-
-function DraftModal({
- children,
- open,
- onOpenChange,
- toggle,
- toggleContainerProps,
- editButton,
-}) {
- return (
-
-
- {toggle}
-
-
-
-
-
-
-
-
- Drafts
-
-
- {editButton}
-
- {children}
-
-
-
-
-
- );
-}
-
-return { DraftModal };
From 37bdce27e3a77991eced8521243fc9726f40a4c8 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 11:25:44 +0500
Subject: [PATCH 048/132] Use variables to color components
---
apps/builddao/widget/GeneralFeed.jsx | 30 +++++++++++++++++
apps/builddao/widget/components.jsx | 2 ++
.../components/AsideWithMainContent.jsx | 2 +-
apps/builddao/widget/components/Button.jsx | 22 +++++++------
.../builddao/widget/components/ButtonLink.jsx | 22 +++++++------
apps/builddao/widget/components/Checkbox.jsx | 4 +--
.../builddao/widget/components/InputField.jsx | 10 +++---
.../builddao/widget/components/Pagination.jsx | 6 ++--
apps/builddao/widget/components/Post.jsx | 32 +++++++++----------
.../widget/components/ProgressState.jsx | 21 ++++++------
apps/builddao/widget/components/Step.jsx | 2 +-
apps/builddao/widget/components/TextBox.jsx | 11 +++----
.../builddao/widget/components/TextEditor.jsx | 4 +--
.../widget/components/UploadField.jsx | 16 ++++++----
apps/builddao/widget/components/login-now.jsx | 2 +-
15 files changed, 112 insertions(+), 74 deletions(-)
create mode 100644 apps/builddao/widget/GeneralFeed.jsx
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
new file mode 100644
index 00000000..4bca9028
--- /dev/null
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -0,0 +1,30 @@
+const Theme = styled.div`
+ --stroke-color: rgba(255, 255, 255, 0.2);
+ --bg-1: #0b0c14;
+ --bg-2: ##23242b;
+ --bg-1-hover: #17181c;
+ --bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --label-color: #fff;
+ --font-color: #fff;
+ --font-muted-color: #cdd0d5;
+ --black: #000;
+ --system-red: #fd2a5c;
+ --yellow: #ffaf51;
+
+ --post-bg: #23242b;
+ --post-bg-transparent: rgba(23, 24, 28, 0);
+
+ --button-primary-bg: #ffaf51;
+ --button-outline-bg: transparent;
+ --button-default-bg: #23242b;
+
+ --button-primary-color: #000;
+ --button-outline-color: #fff;
+ --button-default-color: #cdd0d5;
+
+ --button-primary-hover-bg: #e49b48;
+ --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
+ --button-default-hover-bg: #17181c;
+`;
+
+return ;
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index 38499bad..191845e0 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -1,4 +1,5 @@
const { Button } = VM.require("buildhub.near/widget/components.Button");
+const { ButtonLink } = VM.require("buildhub.near/widget/components.ButtonLink");
const { ProgressState } = VM.require(
"buildhub.near/widget/components.ProgressState"
);
@@ -45,6 +46,7 @@ function User(props) {
return {
Button,
+ ButtonLink,
Pagination,
Post,
ProgressState,
diff --git a/apps/builddao/widget/components/AsideWithMainContent.jsx b/apps/builddao/widget/components/AsideWithMainContent.jsx
index c1abfd8a..66a75678 100644
--- a/apps/builddao/widget/components/AsideWithMainContent.jsx
+++ b/apps/builddao/widget/components/AsideWithMainContent.jsx
@@ -13,7 +13,7 @@ const Container = styled.div`
const AsideContainer = styled.div`
border-radius: 16px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
background: var(--bg-1, #0b0c14);
width: 100%;
diff --git a/apps/builddao/widget/components/Button.jsx b/apps/builddao/widget/components/Button.jsx
index 885bfd4d..830c76ff 100644
--- a/apps/builddao/widget/components/Button.jsx
+++ b/apps/builddao/widget/components/Button.jsx
@@ -24,38 +24,40 @@ const StyledButton = styled.button`
background: ${(props) => {
switch (props.variant) {
case "primary":
- return "#FFAF51";
+ return "var(--button-primary-bg, #FFAF51)";
case "outline":
- return "transparent";
+ return "var(--button-outline-bg, transparent)";
default:
- return "#23242B";
+ return "var(--button-default-bg, #23242B)";
}
}};
color: ${(props) => {
switch (props.variant) {
case "primary":
- return "#000";
+ return "var(--button-primary-color, #000)";
case "outline":
- return "#fff";
+ return "var(--button-outline-color, #fff)";
default:
- return "#CDD0D5";
+ return "var(--button-default-color, #CDD0D5)";
}
}};
border: ${(props) =>
- props.variant === "outline" ? "1px solid rgba(255, 255, 255, 0.20)" : ""};
+ props.variant === "outline"
+ ? "1px solid var(--stroke-color, rgba(255, 255, 255, 0.20))"
+ : ""};
/* Hover states */
&:hover {
background: ${(props) => {
switch (props.variant) {
case "primary":
- return "#e49b48";
+ return "var(--button-primary-hover-bg, #e49b48)";
case "outline":
- return "rgba(255, 255, 255, 0.20)";
+ return "var(--button-outline-hover-bg, rgba(255, 255, 255, 0.20))";
default:
- return "#17181c";
+ return "var(--button-default-hover-bg, #17181c)";
}
}};
}
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index 153e7381..11283685 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -24,38 +24,40 @@ const StyledLink = styled.a`
background: ${(props) => {
switch (props.variant) {
case "primary":
- return "#FFAF51";
+ return "var(--button-primary-bg, #FFAF51)";
case "outline":
- return "transparent";
+ return "var(--button-outline-bg, transparent)";
default:
- return "#23242B";
+ return "var(--button-default-bg, #23242B)";
}
}};
color: ${(props) => {
switch (props.variant) {
case "primary":
- return "#000";
+ return "var(--button-primary-color, #000)";
case "outline":
- return "#fff";
+ return "var(--button-outline-color, #fff)";
default:
- return "#CDD0D5";
+ return "var(--button-default-color, #CDD0D5)";
}
}};
border: ${(props) =>
- props.variant === "outline" ? "1px solid rgba(255, 255, 255, 0.20)" : ""};
+ props.variant === "outline"
+ ? "1px solid var(--stroke-color, rgba(255, 255, 255, 0.20))"
+ : ""};
/* Hover states */
&:hover {
background: ${(props) => {
switch (props.variant) {
case "primary":
- return "#e49b48";
+ return "var(--button-primary-hover-bg, #e49b48)";
case "outline":
- return "rgba(255, 255, 255, 0.20)";
+ return "var(--button-outline-hover-bg, rgba(255, 255, 255, 0.20))";
default:
- return "#17181c";
+ return "var(--button-default-hover-bg, #17181c)";
}
}};
}
diff --git a/apps/builddao/widget/components/Checkbox.jsx b/apps/builddao/widget/components/Checkbox.jsx
index 27387079..97aec9e4 100644
--- a/apps/builddao/widget/components/Checkbox.jsx
+++ b/apps/builddao/widget/components/Checkbox.jsx
@@ -8,7 +8,7 @@ const CheckboxLabel = styled.label`
align-items: center;
gap: 8px;
- color: #fff;
+ color: var(--label-color, #fff);
font-size: 16px;
font-style: normal;
font-weight: 400;
@@ -31,4 +31,4 @@ function Checkbox({ value, onChange, label }) {
);
}
-return { Checkbox };
\ No newline at end of file
+return { Checkbox };
diff --git a/apps/builddao/widget/components/InputField.jsx b/apps/builddao/widget/components/InputField.jsx
index ab6fcff0..deacecd2 100644
--- a/apps/builddao/widget/components/InputField.jsx
+++ b/apps/builddao/widget/components/InputField.jsx
@@ -6,7 +6,7 @@ const InputContainer = styled.div`
`;
const Label = styled.label`
- color: var(--White-100, #fff);
+ color: var(--label-color, #fff);
/* Body/16px */
font-size: 16px;
@@ -24,12 +24,12 @@ const Input = styled.input`
gap: 10px;
border-radius: 8px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
- background: var(--Bg-1, #0b0c14);
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ background: var(--bg-1, #0b0c14);
flex: 1 0 0;
- color: var(--White-50, #cdd0d5);
+ color: var(--font-muted-color, #cdd0d5);
/* Body/16px */
font-size: 16px;
@@ -62,4 +62,4 @@ function InputField({
);
}
-return { InputField };
\ No newline at end of file
+return { InputField };
diff --git a/apps/builddao/widget/components/Pagination.jsx b/apps/builddao/widget/components/Pagination.jsx
index 4196eb2a..5e39fb73 100644
--- a/apps/builddao/widget/components/Pagination.jsx
+++ b/apps/builddao/widget/components/Pagination.jsx
@@ -21,7 +21,7 @@ const Pagination = styled.div`
align-items: center;
gap: 10px;
border-radius: 8px;
- color: var(--White-100, #fff);
+ color: var(--font-color, #fff);
transition: all 300ms;
cursor: pointer;
@@ -33,11 +33,11 @@ const Pagination = styled.div`
&.selected,
&:hover {
- background-color: #23242b;
+ background-color: var(--bg-1, #23242b);
}
&.arrow {
- border: 1px solid rgba(255, 255, 255, 0.2);
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
}
&.disabled {
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 3c569b24..4106a19b 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -6,19 +6,19 @@ const StyledPost = styled.div`
margin-bottom: 1rem;
.post {
border-radius: 16px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
- color: #b6b6b8;
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ color: var(--font-muted-color, #b6b6b8);
padding: 24px !important;
- background-color: #23242b;
+ background-color: var(--bg-1, #23242b);
transition: all 300ms;
&:hover {
- background-color: #1c1f33 !important;
+ background-color: var(--bg-1-hover, #17181c) !important;
.expand-post {
background-image: linear-gradient(
to bottom,
- rgba(28, 31, 51, 0),
- rgba(28, 31, 51, 1) 25%
+ var(--bg-1-hover-transparent, rgba(23, 24, 28, 0)),
+ var(--bg-1-hover, #17181c) 25%
) !important;
}
}
@@ -26,7 +26,7 @@ const StyledPost = styled.div`
.post-header {
span,
.text-muted {
- color: #fff !important;
+ color: var(--font-color, #fff) !important;
}
}
@@ -38,34 +38,34 @@ const StyledPost = styled.div`
.expand-post {
background-image: linear-gradient(
to bottom,
- rgba(35, 36, 43, 0),
- rgba(35, 36, 43, 1) 25%
+ var(--post-bg, rgba(35, 36, 43, 0)),
+ var(--post-bg-transparent, rgba(35, 36, 43, 1)) 25%
) !important;
}
}
.dropdown-menu {
- background-color: #0b0c14 !important;
- color: #fff !important;
+ background-color: var(--bg-1, #0b0c14) !important;
+ color: var(--font-color, #fff) !important;
li.dropdown-item {
- color: #fff !important;
+ color: var(--font-color, #fff) !important;
&:hover {
a {
- color: #0b0c14 !important;
+ color: var(--bg-1, #0b0c14) !important;
}
}
}
.link-dark,
.dropdown-item {
- color: #fff !important;
+ color: var(--font-color, #fff) !important;
&:hover {
- color: #0b0c14 !important;
+ color: var(--bg-1, #0b0c14) !important;
span {
- color: #0b0c14 !important;
+ color: var(--bg-1, #0b0c14) !important;
}
}
}
diff --git a/apps/builddao/widget/components/ProgressState.jsx b/apps/builddao/widget/components/ProgressState.jsx
index e96fe0ba..41be6d01 100644
--- a/apps/builddao/widget/components/ProgressState.jsx
+++ b/apps/builddao/widget/components/ProgressState.jsx
@@ -1,4 +1,3 @@
-
const Progress = styled.div`
display: flex;
width: 40px;
@@ -12,13 +11,13 @@ const Progress = styled.div`
border: ${(props) => {
switch (props.status) {
case "focused":
- return "1px solid var(--Yellow, #FFAF51)";
+ return "1px solid var(--yellow, #FFAF51)";
case "error":
- return "1px solid var(--System-Red, #FD2A5C)";
+ return "1px solid var(--system-red, #FD2A5C)";
case "completed":
- return "1px solid var(--Stroke-color, rgba(255, 255, 255, 0.20))";
+ return "1px solid var(--stroke-color, rgba(255, 255, 255, 0.20))";
default:
- return "1px solid var(--Stroke-color, rgba(255, 255, 255, 0.20))";
+ return "1px solid var(--stroke-color, rgba(255, 255, 255, 0.20))";
}
}};
@@ -29,7 +28,7 @@ const Progress = styled.div`
case "error":
return "#2f101f";
case "completed":
- return "#FFAF51";
+ return "var(--yellow, #FFAF51)";
default:
return "#23242B";
}
@@ -38,13 +37,13 @@ const Progress = styled.div`
color: ${(props) => {
switch (props.status) {
case "focused":
- return "#fff";
+ return "var(--font-color, #fff)";
case "error":
- return "#FD2A5C";
+ return "var(--system-red, #FD2A5C)";
case "completed":
- return "#000";
+ return "var(--black, #000)";
default:
- return "#fff";
+ return "var(--font-color, #fff)";
}
}};
`;
@@ -66,4 +65,4 @@ function ProgressState({ children, status }) {
);
}
-return { ProgressState };
\ No newline at end of file
+return { ProgressState };
diff --git a/apps/builddao/widget/components/Step.jsx b/apps/builddao/widget/components/Step.jsx
index c4f4bcd1..0f9fceab 100644
--- a/apps/builddao/widget/components/Step.jsx
+++ b/apps/builddao/widget/components/Step.jsx
@@ -11,7 +11,7 @@ const StepContainer = styled.div`
left: 0;
right: 0;
height: 1px;
- background: #000; /* Change color as needed */
+ background: var(--black, #000); /* Change color as needed */
background-image: repeating-linear-gradient(
90deg,
#3c3d43,
diff --git a/apps/builddao/widget/components/TextBox.jsx b/apps/builddao/widget/components/TextBox.jsx
index 66113c3c..55b6e3d4 100644
--- a/apps/builddao/widget/components/TextBox.jsx
+++ b/apps/builddao/widget/components/TextBox.jsx
@@ -1,5 +1,5 @@
const Label = styled.label`
- color: var(--White-100, #fff);
+ color: var(--label-color, #fff);
/* Body/16px */
font-size: 16px;
@@ -8,7 +8,6 @@ const Label = styled.label`
line-height: 170%; /* 27.2px */
`;
-
const TextArea = styled.textarea`
display: flex;
min-height: 100px;
@@ -18,10 +17,10 @@ const TextArea = styled.textarea`
align-self: stretch;
border-radius: 8px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
- background: var(--Bg-1, #0b0c14);
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ background: var(--bg-1, #0b0c14);
- color: var(--White-50, #fff);
+ color: var(--font-color, #fff);
/* Body/16px */
font-size: 16px;
@@ -42,4 +41,4 @@ function TextBox({ label, value, onChange, placeholder, maxWidth }) {
);
}
-return { TextBox };
\ No newline at end of file
+return { TextBox };
diff --git a/apps/builddao/widget/components/TextEditor.jsx b/apps/builddao/widget/components/TextEditor.jsx
index 160ea28f..bdb999c5 100644
--- a/apps/builddao/widget/components/TextEditor.jsx
+++ b/apps/builddao/widget/components/TextEditor.jsx
@@ -137,7 +137,7 @@ function TextEditor({ value, onChange, maxWidth }) {
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: value,
- embedCss: MarkdownEditor,
+ embedCss: props.EditorCSS || MarkdownEditor,
onChange,
}}
/>
@@ -145,4 +145,4 @@ function TextEditor({ value, onChange, maxWidth }) {
);
}
-return { TextEditor };
\ No newline at end of file
+return { TextEditor };
diff --git a/apps/builddao/widget/components/UploadField.jsx b/apps/builddao/widget/components/UploadField.jsx
index 1d663954..b0f873b2 100644
--- a/apps/builddao/widget/components/UploadField.jsx
+++ b/apps/builddao/widget/components/UploadField.jsx
@@ -14,11 +14,12 @@ const UploadContainer = styled.div`
gap: 24px;
border-radius: 16px;
- border: 1px dashed var(--Stroke-color, rgba(255, 255, 255, 0.2));
- background: ${(props) => (props.background ? "#23242B" : "#0b0c14")};
+ border: 1px dashed var(--stroke-color, rgba(255, 255, 255, 0.2));
+ background: ${(props) =>
+ props.background ? "var(--bg-2, #23242B)" : "var(--bg-1, #0b0c14)"};
p {
- color: var(--White-100, #fff);
+ color: var(--font-color, #fff);
text-align: center;
/* Body/Medium-16px */
@@ -30,7 +31,7 @@ const UploadContainer = styled.div`
}
p.secondary {
- color: var(--White-50, #cdd0d5);
+ color: var(--font-muted-color, #cdd0d5);
text-align: center;
font-size: 12px;
font-style: normal;
@@ -39,7 +40,7 @@ const UploadContainer = styled.div`
}
i {
- color: white;
+ color: var(--font-color, #fff);
font-size: 2rem;
}
`;
@@ -54,7 +55,10 @@ function UploadField({ background }) {
JPEG, PNG, PDF, and MP4 formats, up to 50 MB.
-
+
Browse Files
diff --git a/apps/builddao/widget/components/login-now.jsx b/apps/builddao/widget/components/login-now.jsx
index cd5c619e..b82ba89a 100644
--- a/apps/builddao/widget/components/login-now.jsx
+++ b/apps/builddao/widget/components/login-now.jsx
@@ -1,6 +1,6 @@
const Container = styled.div`
background-color: #23242b;
- color: #ffffff;
+ color: #fff;
width: 100%;
height: 16rem;
From 6e09e7d03390b7c9cc9069ea4e3fd4c5d7753471 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 11:28:59 +0500
Subject: [PATCH 049/132] Add Feed tabs to general feed
---
apps/builddao/widget/GeneralFeed.jsx | 141 +++++++++++++++++++++++++++
1 file changed, 141 insertions(+)
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index 4bca9028..d9c89f85 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -27,4 +27,145 @@ const Theme = styled.div`
--button-default-hover-bg: #17181c;
`;
+function formatDate(date) {
+ const options = { year: "numeric", month: "short", day: "numeric" };
+ return date.toLocaleDateString("en-US", options);
+}
+
+const daoName = "Build DAO";
+const feedLink = "https://nearbuilders.org/feed";
+
+const feeds = {
+ resolutions: {
+ label: "Resolutions",
+ icon: "bi-calendar3",
+ name: "resolution",
+ hashtag: "nearyearresolutions2024",
+ template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
+ (posted via [${daoName} Gateway](${feedLink}))
+
+ **🌟 REFLECTIONS ON THE PAST YEAR:**
+ - [Reflection 1 from the past year]
+ - [Reflection 2 from the past year]
+
+ **🎯 NEW YEAR'S RESOLUTIONS:**
+ - [Resolution 1]
+ - [Resolution 2]
+
+ **📊 MEASURING SUCCESS:**
+ - [Metric 1 for Success]
+ - [Metric 2 for Success]
+ `,
+ },
+ updates: {
+ label: "Updates",
+ icon: "bi-bell",
+ name: "update",
+ hashtag: "update",
+ template: `### BUILDER UPDATE: ${formatDate(new Date())}
+ (posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+ **✅ DONE**
+ - [what'd you do]
+ - [link proof]
+
+ **⏩ NEXT**
+ - [what's next?]
+ - [what are you thinking about?]
+
+ **🛑 BLOCKERS**
+ - [what's blocking you?]
+ - [how can someone help?]
+ `,
+ },
+ documentation: {
+ label: "Documentation",
+ icon: "bi-book",
+ name: "documentation",
+ hashtag: "documentation",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+ **WHAT IS _____?**
+ - [context]
+ - [why is it important?]
+
+ **EXAMPLE**
+ - [how can this be demonstrated?]
+ - [what is the expected outcome?]
+
+ **USAGE**
+ - [where is it used?]
+ - [how to use it]
+ `,
+ },
+ question: {
+ label: "Question",
+ icon: "bi-question-lg",
+ name: "question",
+ hashtag: "question",
+ template: `## what is your question?
+ (posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+ [what are you thinking about?]
+ [why are you asking?]
+ `,
+ },
+ answer: {
+ label: "Answer",
+ icon: "bi-journal-code",
+ name: "answer",
+ hashtag: "answer",
+ template: `## Share an answer
+ (posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+ [please restate the question you are answering]
+
+ [your answer]
+
+ [link to relevant docs, examples, or resources]
+ `,
+ },
+ opportunity: {
+ label: "Opportunity",
+ icon: "bi-briefcase",
+ name: "opportunity",
+ hashtag: "opportunity",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+ [what is the opportunity?]
+
+ [explain the motivation or reason]
+
+ `,
+ },
+ idea: {
+ label: "Idea",
+ icon: "bi-lightbulb",
+ name: "idea",
+ hashtag: "idea",
+ template: ``,
+ },
+ task: {
+ label: "Task",
+ icon: "bi-check-lg",
+ name: "task",
+ template: `## TASK TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+ **What needs to be done?**
+ - [Describe the task or action steps]
+
+ **Context or additional information:**
+ - [Provide any context or details]
+ `,
+ },
+ bookmarks: {
+ label: "Bookmarks",
+ icon: "bi-bookmark",
+ name: "bookmark",
+ },
+};
+
return ;
From f1408ec5eb3d7f784ae2ee3d36447b501614b5f7 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 11:49:08 +0500
Subject: [PATCH 050/132] Make General Feed functional
---
apps/builddao/widget/Feed.jsx | 1 -
apps/builddao/widget/GeneralFeed.jsx | 87 ++++++++++++++++++-
.../components/AsideWithMainContent.jsx | 2 +-
3 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index f1c47b1a..2f50a9d4 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -164,7 +164,6 @@ const feeds = {
};
const [activeFeed, setActiveFeed] = useState(tab || "resolutions");
-const [template, setTemplate] = useState("What did you have in mind?");
return (
<>>);
+const { Post, Button } = VM.require("buildhub.near/widget/components") || {
+ Post: () => <>>,
+ Button: () => <>>,
+};
+
const Theme = styled.div`
--stroke-color: rgba(255, 255, 255, 0.2);
--bg-1: #0b0c14;
@@ -168,4 +174,83 @@ const feeds = {
},
};
-return ;
+const tab = props.tab || "resolutions";
+
+const [activeFeed, setActiveFeed] = useState(tab);
+const daoTag = "build";
+
+return (
+
+ {
+ const data = feeds[route];
+ return (
+ setActiveFeed(route)}
+ className={
+ "align-self-stretch flex-shrink-0 justify-content-start fw-medium"
+ }
+ style={{
+ fontSize: "14px",
+ }}
+ >
+
+ {data.label}
+
+ );
+ }),
+ mainContent: (
+ <>
+ {context.accountId ? (
+ activeFeed !== "bookmarks" ? (
+
+ ) : (
+
+ )
+ ) : (
+
+ )}
+ {activeFeed !== "bookmarks" && (
+ (
+
+ )}
+ />
+ )}
+ >
+ ),
+ }}
+ />
+
+);
diff --git a/apps/builddao/widget/components/AsideWithMainContent.jsx b/apps/builddao/widget/components/AsideWithMainContent.jsx
index 66a75678..c56a243c 100644
--- a/apps/builddao/widget/components/AsideWithMainContent.jsx
+++ b/apps/builddao/widget/components/AsideWithMainContent.jsx
@@ -23,7 +23,7 @@ const AsideContainer = styled.div`
align-items: flex-start;
gap: 16px;
margin-bottom: 1rem;
- height: calc(min(100vh - 64px, 100%));
+ height: max-content;
@media screen and (max-width: 768px) {
border: 0px;
From 050f7850671cd51074ef338002c57f12bc6ebbc1 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 11:59:34 +0500
Subject: [PATCH 051/132] Pass required dao tag from general feed to compose
---
apps/builddao/widget/Compose.jsx | 2 +-
apps/builddao/widget/GeneralFeed.jsx | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 83000784..4902d6f6 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -92,7 +92,7 @@ const postToCustomFeed = ({ feed, text, labels }) => {
labels = labels.map((label) => label.toLowerCase());
labels.push(feed.name.toLowerCase());
- const requiredHashtags = ["build"];
+ const requiredHashtags = props.requiredHashtags || ["build"];
if (feed.hashtag) requiredHashtags.push(feed.hashtag.toLowerCase());
requiredHashtags.push(feed.name.toLowerCase());
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index 94058b07..036473a2 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -40,6 +40,7 @@ function formatDate(date) {
const daoName = "Build DAO";
const feedLink = "https://nearbuilders.org/feed";
+const daoTag = "testDao";
const feeds = {
resolutions: {
@@ -175,9 +176,7 @@ const feeds = {
};
const tab = props.tab || "resolutions";
-
const [activeFeed, setActiveFeed] = useState(tab);
-const daoTag = "build";
return (
@@ -212,6 +211,7 @@ return (
props={{
feed: feeds[activeFeed],
template: feeds[activeFeed].template,
+ requiredHashtags: [daoTag],
}}
/>
) : (
From 6a41b1f528dd39a17ddb64b886052661ee8139f0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 12:00:38 +0500
Subject: [PATCH 052/132] Change feed name back
---
apps/builddao/widget/GeneralFeed.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index 036473a2..c77c8ac2 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -40,7 +40,7 @@ function formatDate(date) {
const daoName = "Build DAO";
const feedLink = "https://nearbuilders.org/feed";
-const daoTag = "testDao";
+const daoTag = "build";
const feeds = {
resolutions: {
From edc8a6894e1f3e8f7856f8212571168a19d9260b Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 12:30:32 +0500
Subject: [PATCH 053/132] More style improvements and link navigation
---
apps/builddao/widget/Compose.jsx | 34 ++-----------------
apps/builddao/widget/GeneralFeed.jsx | 28 ++++++++++-----
apps/builddao/widget/components/Post.jsx | 20 +++++------
.../widget/components/post/Content.jsx | 2 +-
4 files changed, 33 insertions(+), 51 deletions(-)
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 4902d6f6..98b83572 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -173,7 +173,7 @@ const PostCreator = styled.div`
gap: 1.5rem;
padding: 1rem;
- background: #23242b;
+ background: var(--compose-bg, #23242b);
border-radius: 12px;
margin-bottom: 1rem;
@@ -375,36 +375,6 @@ const MarkdownPreview = styled.div`
}
`;
-const LabelSelect = styled.div`
- label {
- color: #fff;
- }
-
- .rbt-input-multi {
- background: #23242b !important;
- color: #fff !important;
- }
-
- .rbt-token {
- background: #202020 !important;
- color: #fff !important;
- }
-
- .rbt-menu {
- background: #23242b !important;
- color: #fff !important;
-
- .dropdown-item {
- color: #fff !important;
- transition: all 300ms;
-
- &:hover {
- background: #202020;
- }
- }
- }
-`;
-
const avatarComponent = useMemo(() => {
return (
@@ -430,7 +400,7 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: postContent,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setPostContent(v);
Storage.privateSet(draftKey, v || "");
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index c77c8ac2..4d81e340 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -1,15 +1,15 @@
const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
-const { Post, Button } = VM.require("buildhub.near/widget/components") || {
+const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
Post: () => <>>,
- Button: () => <>>,
+ ButtonLink: () => <>>,
};
const Theme = styled.div`
--stroke-color: rgba(255, 255, 255, 0.2);
--bg-1: #0b0c14;
- --bg-2: ##23242b;
--bg-1-hover: #17181c;
--bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --bg-2: ##23242b;
--label-color: #fff;
--font-color: #fff;
--font-muted-color: #cdd0d5;
@@ -17,7 +17,10 @@ const Theme = styled.div`
--system-red: #fd2a5c;
--yellow: #ffaf51;
- --post-bg: #23242b;
+ --compose-bg: #23242b;
+
+ --post-bg: #0b0c14;
+ --post-bg-hover: #17181c;
--post-bg-transparent: rgba(23, 24, 28, 0);
--button-primary-bg: #ffaf51;
@@ -175,7 +178,14 @@ const feeds = {
},
};
-const tab = props.tab || "resolutions";
+if (!feeds) {
+ return "";
+}
+
+const tab = props.tab || Object.keys(feeds)[0];
+if (Object.keys(feeds).includes(props.hashtag)) {
+ tab = props.hashtag;
+}
const [activeFeed, setActiveFeed] = useState(tab);
return (
@@ -186,20 +196,22 @@ return (
sideContent: Object.keys(feeds || {}).map((route) => {
const data = feeds[route];
return (
-
setActiveFeed(route)}
+ href={`?tab=${route}`}
className={
"align-self-stretch flex-shrink-0 justify-content-start fw-medium"
}
style={{
fontSize: "14px",
+ textDecoration: "none",
+ cursor: "pointer",
}}
>
{data.label}
-
+
);
}),
mainContent: (
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 4106a19b..bf8b7fd9 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -9,16 +9,16 @@ const StyledPost = styled.div`
border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
color: var(--font-muted-color, #b6b6b8);
padding: 24px !important;
- background-color: var(--bg-1, #23242b);
+ background-color: var(--post-bg, #23242b);
transition: all 300ms;
&:hover {
- background-color: var(--bg-1-hover, #17181c) !important;
+ background-color: var(--post-bg-hover, #17181c) !important;
.expand-post {
background-image: linear-gradient(
to bottom,
- var(--bg-1-hover-transparent, rgba(23, 24, 28, 0)),
- var(--bg-1-hover, #17181c) 25%
+ var(--post-bg-hover-transparent, rgba(23, 24, 28, 0)),
+ var(--post-bg-hover, #17181c) 25%
) !important;
}
}
@@ -38,21 +38,21 @@ const StyledPost = styled.div`
.expand-post {
background-image: linear-gradient(
to bottom,
- var(--post-bg, rgba(35, 36, 43, 0)),
- var(--post-bg-transparent, rgba(35, 36, 43, 1)) 25%
+ var(--post-bg-transparent, rgba(35, 36, 43, 0)),
+ var(--post-bg, rgba(35, 36, 43, 1)) 25%
) !important;
}
}
.dropdown-menu {
- background-color: var(--bg-1, #0b0c14) !important;
+ background-color: var(--post-bg, #0b0c14) !important;
color: var(--font-color, #fff) !important;
li.dropdown-item {
color: var(--font-color, #fff) !important;
&:hover {
a {
- color: var(--bg-1, #0b0c14) !important;
+ color: var(--post-bg, #0b0c14) !important;
}
}
}
@@ -62,10 +62,10 @@ const StyledPost = styled.div`
color: var(--font-color, #fff) !important;
&:hover {
- color: var(--bg-1, #0b0c14) !important;
+ color: var(--post-bg, #0b0c14) !important;
span {
- color: var(--bg-1, #0b0c14) !important;
+ color: var(--post-bg, #0b0c14) !important;
}
}
}
diff --git a/apps/builddao/widget/components/post/Content.jsx b/apps/builddao/widget/components/post/Content.jsx
index 83039a20..cc7f49a0 100644
--- a/apps/builddao/widget/components/post/Content.jsx
+++ b/apps/builddao/widget/components/post/Content.jsx
@@ -59,7 +59,7 @@ const [onHashtag] = useState(() => (hashtag) => (
className="d-inline-flex"
style={{ color: "var(--bs-link-color)" }}
>
-
#{hashtag}
+
#{hashtag}
));
From 02a7692ed5eb6eb4fd7bf8489eb6cf095210c3a0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 20:12:54 +0500
Subject: [PATCH 054/132] Add required tag
---
apps/builddao/widget/GeneralFeed.jsx | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index 4d81e340..c5b1ea51 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -240,7 +240,19 @@ return (
index={[
{
action: "hashtag",
- key: feeds[activeFeed].hashtag,
+ key: feeds[activeFeed].hashtag, // resolution
+ options: {
+ limit: 10,
+ order: "desc",
+ },
+ cacheOptions: {
+ ignoreCache: true,
+ },
+ required: true,
+ },
+ {
+ action: "hashtag",
+ key: daoTag, // build
options: {
limit: 10,
order: "desc",
From 7af4a175458ab3fd04d9585d4ef21d083369e1bf Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 20:23:03 +0500
Subject: [PATCH 055/132] add css variables to config
---
apps/builddao/widget/config.jsx | 85 ++++++++++++++++++++++-----------
1 file changed, 58 insertions(+), 27 deletions(-)
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 2d71b26e..7d0abafb 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -1,32 +1,63 @@
+const theme = `
+ --stroke-color: rgba(255, 255, 255, 0.2);
+ --bg-1: #0b0c14;
+ --bg-1-hover: #17181c;
+ --bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --bg-2: ##23242b;
+ --label-color: #fff;
+ --font-color: #fff;
+ --font-muted-color: #cdd0d5;
+ --black: #000;
+ --system-red: #fd2a5c;
+ --yellow: #ffaf51;
+
+ --compose-bg: #23242b;
+
+ --post-bg: #0b0c14;
+ --post-bg-hover: #17181c;
+ --post-bg-transparent: rgba(23, 24, 28, 0);
+
+ --button-primary-bg: #ffaf51;
+ --button-outline-bg: transparent;
+ --button-default-bg: #23242b;
+
+ --button-primary-color: #000;
+ --button-outline-color: #fff;
+ --button-default-color: #cdd0d5;
+
+ --button-primary-hover-bg: #e49b48;
+ --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
+ --button-default-hover-bg: #17181c;
+`;
+
return {
- "type": "app",
- "routes": {
- "home": {
- "path": "buildhub.near/widget/page.home",
- "blockHeight": "final",
- "init": {
- "name": "Home",
- "icon": "bi bi-house"
- }
+ type: "app",
+ routes: {
+ home: {
+ path: "buildhub.near/widget/page.home",
+ blockHeight: "final",
+ init: {
+ name: "Home",
+ icon: "bi bi-house",
+ },
},
- "feed": {
- "path": "buildhub.near/widget/page.feed",
- "blockHeight": "final",
- "init": {
- "icon": "bi bi-globe"
- }
+ feed: {
+ path: "buildhub.near/widget/page.feed",
+ blockHeight: "final",
+ init: {
+ icon: "bi bi-globe",
+ },
},
- "inspect": {
- "path": "mob.near/widget/WidgetSource",
- "blockHeight": "final",
- "hide": true
+ inspect: {
+ path: "mob.near/widget/WidgetSource",
+ blockHeight: "final",
+ hide: true,
+ },
+ notifications: {
+ path: "mob.near/widget/NotificationFeed",
+ blockHeight: "final",
+ hide: true,
},
- "notifications": {
- "path": "mob.near/widget/NotificationFeed",
- "blockHeight": "final",
- "hide": true
- }
},
- "theme": "background-color: white;"
-}
-;
\ No newline at end of file
+ theme: theme,
+};
From eba943860bba4b2d72debaf8ec53761fa90db905 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 23 Jan 2024 20:34:59 +0500
Subject: [PATCH 056/132] Abstract theme and aside content of feed to config
---
apps/builddao/widget/GeneralFeed.jsx | 180 +-----------------
.../builddao/widget/components/ButtonLink.jsx | 2 +-
apps/builddao/widget/config.jsx | 146 ++++++++++++++
3 files changed, 153 insertions(+), 175 deletions(-)
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
index c5b1ea51..942755e8 100644
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ b/apps/builddao/widget/GeneralFeed.jsx
@@ -4,179 +4,11 @@ const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
ButtonLink: () => <>>,
};
-const Theme = styled.div`
- --stroke-color: rgba(255, 255, 255, 0.2);
- --bg-1: #0b0c14;
- --bg-1-hover: #17181c;
- --bg-1-hover-transparent: rgba(23, 24, 28, 0);
- --bg-2: ##23242b;
- --label-color: #fff;
- --font-color: #fff;
- --font-muted-color: #cdd0d5;
- --black: #000;
- --system-red: #fd2a5c;
- --yellow: #ffaf51;
+const daoName = props.daoName || "Build DAO";
+const feedLink = props.feedLink || "https://nearbuilders.org/feed";
+const daoTag = props.daoTag || "build";
- --compose-bg: #23242b;
-
- --post-bg: #0b0c14;
- --post-bg-hover: #17181c;
- --post-bg-transparent: rgba(23, 24, 28, 0);
-
- --button-primary-bg: #ffaf51;
- --button-outline-bg: transparent;
- --button-default-bg: #23242b;
-
- --button-primary-color: #000;
- --button-outline-color: #fff;
- --button-default-color: #cdd0d5;
-
- --button-primary-hover-bg: #e49b48;
- --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
- --button-default-hover-bg: #17181c;
-`;
-
-function formatDate(date) {
- const options = { year: "numeric", month: "short", day: "numeric" };
- return date.toLocaleDateString("en-US", options);
-}
-
-const daoName = "Build DAO";
-const feedLink = "https://nearbuilders.org/feed";
-const daoTag = "build";
-
-const feeds = {
- resolutions: {
- label: "Resolutions",
- icon: "bi-calendar3",
- name: "resolution",
- hashtag: "nearyearresolutions2024",
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
- (posted via [${daoName} Gateway](${feedLink}))
-
- **🌟 REFLECTIONS ON THE PAST YEAR:**
- - [Reflection 1 from the past year]
- - [Reflection 2 from the past year]
-
- **🎯 NEW YEAR'S RESOLUTIONS:**
- - [Resolution 1]
- - [Resolution 2]
-
- **📊 MEASURING SUCCESS:**
- - [Metric 1 for Success]
- - [Metric 2 for Success]
- `,
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
- (posted via [${daoName} Gateway](${feedLink}?tab=update))
-
- **✅ DONE**
- - [what'd you do]
- - [link proof]
-
- **⏩ NEXT**
- - [what's next?]
- - [what are you thinking about?]
-
- **🛑 BLOCKERS**
- - [what's blocking you?]
- - [how can someone help?]
- `,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
-
- **WHAT IS _____?**
- - [context]
- - [why is it important?]
-
- **EXAMPLE**
- - [how can this be demonstrated?]
- - [what is the expected outcome?]
-
- **USAGE**
- - [where is it used?]
- - [how to use it]
- `,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
- (posted via [${daoName} Gateway](${feedLink}?tab=question))
-
- [what are you thinking about?]
- [why are you asking?]
- `,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
- (posted via [${daoName} Gateway](${feedLink}?tab=answer))
-
- [please restate the question you are answering]
-
- [your answer]
-
- [link to relevant docs, examples, or resources]
- `,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
-
- [what is the opportunity?]
-
- [explain the motivation or reason]
-
- `,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: ``,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- template: `## TASK TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=task))
-
- **What needs to be done?**
- - [Describe the task or action steps]
-
- **Context or additional information:**
- - [Provide any context or details]
- `,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- },
-};
+const feeds = props.feeds || {};
if (!feeds) {
return "";
@@ -189,7 +21,7 @@ if (Object.keys(feeds).includes(props.hashtag)) {
const [activeFeed, setActiveFeed] = useState(tab);
return (
-
+ <>
-
+ >
);
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index 11283685..f9a3978c 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -41,7 +41,7 @@ const StyledLink = styled.a`
default:
return "var(--button-default-color, #CDD0D5)";
}
- }};
+ }} !important;
border: ${(props) =>
props.variant === "outline"
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 7d0abafb..6b57fa9b 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -1,3 +1,8 @@
+function formatDate(date) {
+ const options = { year: "numeric", month: "short", day: "numeric" };
+ return date.toLocaleDateString("en-US", options);
+}
+
const theme = `
--stroke-color: rgba(255, 255, 255, 0.2);
--bg-1: #0b0c14;
@@ -30,6 +35,139 @@ const theme = `
--button-default-hover-bg: #17181c;
`;
+const feeds = {
+ resolutions: {
+ label: "Resolutions",
+ icon: "bi-calendar3",
+ name: "resolution",
+ hashtag: "nearyearresolutions2024",
+ template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
+ (posted via [${daoName} Gateway](${feedLink}))
+
+ **🌟 REFLECTIONS ON THE PAST YEAR:**
+ - [Reflection 1 from the past year]
+ - [Reflection 2 from the past year]
+
+ **🎯 NEW YEAR'S RESOLUTIONS:**
+ - [Resolution 1]
+ - [Resolution 2]
+
+ **📊 MEASURING SUCCESS:**
+ - [Metric 1 for Success]
+ - [Metric 2 for Success]
+ `,
+ },
+ updates: {
+ label: "Updates",
+ icon: "bi-bell",
+ name: "update",
+ hashtag: "update",
+ template: `### BUILDER UPDATE: ${formatDate(new Date())}
+ (posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+ **✅ DONE**
+ - [what'd you do]
+ - [link proof]
+
+ **⏩ NEXT**
+ - [what's next?]
+ - [what are you thinking about?]
+
+ **🛑 BLOCKERS**
+ - [what's blocking you?]
+ - [how can someone help?]
+ `,
+ },
+ documentation: {
+ label: "Documentation",
+ icon: "bi-book",
+ name: "documentation",
+ hashtag: "documentation",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+ **WHAT IS _____?**
+ - [context]
+ - [why is it important?]
+
+ **EXAMPLE**
+ - [how can this be demonstrated?]
+ - [what is the expected outcome?]
+
+ **USAGE**
+ - [where is it used?]
+ - [how to use it]
+ `,
+ },
+ question: {
+ label: "Question",
+ icon: "bi-question-lg",
+ name: "question",
+ hashtag: "question",
+ template: `## what is your question?
+ (posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+ [what are you thinking about?]
+ [why are you asking?]
+ `,
+ },
+ answer: {
+ label: "Answer",
+ icon: "bi-journal-code",
+ name: "answer",
+ hashtag: "answer",
+ template: `## Share an answer
+ (posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+ [please restate the question you are answering]
+
+ [your answer]
+
+ [link to relevant docs, examples, or resources]
+ `,
+ },
+ opportunity: {
+ label: "Opportunity",
+ icon: "bi-briefcase",
+ name: "opportunity",
+ hashtag: "opportunity",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+ [what is the opportunity?]
+
+ [explain the motivation or reason]
+
+ `,
+ },
+ idea: {
+ label: "Idea",
+ icon: "bi-lightbulb",
+ name: "idea",
+ hashtag: "idea",
+ template: ``,
+ },
+ task: {
+ label: "Task",
+ icon: "bi-check-lg",
+ name: "task",
+ template: `## TASK TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+ **What needs to be done?**
+ - [Describe the task or action steps]
+
+ **Context or additional information:**
+ - [Provide any context or details]
+ `,
+ },
+ bookmarks: {
+ label: "Bookmarks",
+ icon: "bi-bookmark",
+ name: "bookmark",
+ },
+};
+
return {
type: "app",
routes: {
@@ -48,6 +186,14 @@ return {
icon: "bi bi-globe",
},
},
+ generalFeed: {
+ path: "buildhub.near/widget/GeneralFeed",
+ blockHeight: "final",
+ init: {
+ icon: "bi bi-globe",
+ feeds: feeds,
+ },
+ },
inspect: {
path: "mob.near/widget/WidgetSource",
blockHeight: "final",
From 49433fe5c102ec47a42ca73c6000b8409602de49 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 24 Jan 2024 22:20:31 +0500
Subject: [PATCH 057/132] Replace old Feed with General Feed
---
apps/builddao/widget/Feed.jsx | 329 ++++++------------
apps/builddao/widget/GeneralFeed.jsx | 112 ------
apps/builddao/widget/components/Post.jsx | 1 +
.../widget/components/post/Content.jsx | 2 +-
apps/builddao/widget/config.jsx | 12 +-
apps/builddao/widget/page/feed.jsx | 52 +--
6 files changed, 114 insertions(+), 394 deletions(-)
delete mode 100644 apps/builddao/widget/GeneralFeed.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 2f50a9d4..78847859 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -1,241 +1,114 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed");
-const { ButtonLink } = VM.require("buildhub.near/widget/components.ButtonLink");
-
-ButtonLink || (ButtonLink = () => <>>);
-Feed = Feed || (() => <>>); // ensure it's defined or set to a default component
+const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
+const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
+ Post: () => <>>,
+ ButtonLink: () => <>>,
+};
-const { type, hashtag } = props;
-type = hashtag;
-hashtag = type;
+const daoName = props.daoName || "Build DAO";
+const feedLink = props.feedLink || "https://nearbuilders.org/feed";
+const daoTag = props.daoTag || "build";
-const tab = props.tab || "resolutions";
+const feeds = props.feeds || {};
-if (!tab) {
+if (!feeds) {
return "";
}
-const { Post } = VM.require("buildhub.near/widget/components");
-Post = Post || (() => <>>);
-
-function formatDate(date) {
- const options = { year: "numeric", month: "short", day: "numeric" };
- return date.toLocaleDateString("en-US", options);
+const tab = props.tab || Object.keys(feeds)[0];
+if (Object.keys(feeds).includes(props.hashtag)) {
+ tab = props.hashtag;
}
-
-const feeds = {
- resolutions: {
- label: "Resolutions",
- icon: "bi-calendar3",
- name: "resolution",
- hashtag: "nearyearresolutions2024",
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed))
-
-**🌟 REFLECTIONS ON THE PAST YEAR:**
-- [Reflection 1 from the past year]
-- [Reflection 2 from the past year]
-
-**🎯 NEW YEAR'S RESOLUTIONS:**
-- [Resolution 1]
-- [Resolution 2]
-
-**📊 MEASURING SUCCESS:**
-- [Metric 1 for Success]
-- [Metric 2 for Success]
-`,
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=update))
-
-**✅ DONE**
-- [what'd you do]
-- [link proof]
-
-**⏩ NEXT**
-- [what's next?]
-- [what are you thinking about?]
-
-**🛑 BLOCKERS**
-- [what's blocking you?]
-- [how can someone help?]
-`,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=documentation))
-
-**WHAT IS _____?**
-- [context]
-- [why is it important?]
-
-**EXAMPLE**
-- [how can this be demonstrated?]
-- [what is the expected outcome?]
-
-**USAGE**
-- [where is it used?]
-- [how to use it]
-`,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=question))
-
-[what are you thinking about?]
-[why are you asking?]
-`,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=answer))
-
-[please restate the question you are answering]
-
-[your answer]
-
-[link to relevant docs, examples, or resources]
-`,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=opportunity))
-
-[what is the opportunity?]
-
-[explain the motivation or reason]
-
-`,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: ``,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- hashtag: "task",
- template: `## TASK TITLE
-(posted via [Build DAO Gateway](https://nearbuilders.org/feed?hashtag=task))
-
-**What needs to be done?**
-- [Describe the task or action steps]
-
-**Context or additional information:**
-- [Provide any context or details]
-`,
- },
- test: {
- label: "Test",
- icon: "bi-tools",
- name: "test",
- hashtag: "test",
- template: ``,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- },
-};
-
-const [activeFeed, setActiveFeed] = useState(tab || "resolutions");
+const [activeFeed, setActiveFeed] = useState(tab);
return (
- {
- const data = feeds[route];
- return (
-
-
- {data.label}
-
- );
- }),
- mainContent: (
- <>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
+ <>
+ {
+ const data = feeds[route];
+ return (
+
+
+ {data.label}
+
+ );
+ }),
+ mainContent: (
+ <>
+ {context.accountId ? (
+ activeFeed !== "bookmarks" ? (
+
+ ) : (
+
+ )
+ ) : (
- ) : (
-
- )
- ) : (
-
- )}
- {activeFeed !== "bookmarks" && (
- (
-
- )}
- />
- )}
- >
- ),
- }}
- />
+ // fix this
+ // {
+ // action: "hashtag",
+ // key: daoTag, // build
+ // options: {
+ // limit: 10,
+ // order: "desc",
+ // },
+ // cacheOptions: {
+ // ignoreCache: true,
+ // },
+ // required: true,
+ // },
+ ]}
+ Item={(p) => (
+
+ )}
+ />
+ )}
+ >
+ ),
+ }}
+ />
+ >
);
diff --git a/apps/builddao/widget/GeneralFeed.jsx b/apps/builddao/widget/GeneralFeed.jsx
deleted file mode 100644
index 942755e8..00000000
--- a/apps/builddao/widget/GeneralFeed.jsx
+++ /dev/null
@@ -1,112 +0,0 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
-const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
- Post: () => <>>,
- ButtonLink: () => <>>,
-};
-
-const daoName = props.daoName || "Build DAO";
-const feedLink = props.feedLink || "https://nearbuilders.org/feed";
-const daoTag = props.daoTag || "build";
-
-const feeds = props.feeds || {};
-
-if (!feeds) {
- return "";
-}
-
-const tab = props.tab || Object.keys(feeds)[0];
-if (Object.keys(feeds).includes(props.hashtag)) {
- tab = props.hashtag;
-}
-const [activeFeed, setActiveFeed] = useState(tab);
-
-return (
- <>
- {
- const data = feeds[route];
- return (
-
-
- {data.label}
-
- );
- }),
- mainContent: (
- <>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
-
- ) : (
-
- )
- ) : (
-
- )}
- {activeFeed !== "bookmarks" && (
- (
-
- )}
- />
- )}
- >
- ),
- }}
- />
- >
-);
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index bf8b7fd9..863cd43b 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -266,6 +266,7 @@ const contentWidget = (
raw,
truncateContent: props.truncateContent,
noEmbed: props.noEmbed,
+ currentPath: props.currentPath,
}}
/>
diff --git a/apps/builddao/widget/components/post/Content.jsx b/apps/builddao/widget/components/post/Content.jsx
index cc7f49a0..5d18cc8d 100644
--- a/apps/builddao/widget/components/post/Content.jsx
+++ b/apps/builddao/widget/components/post/Content.jsx
@@ -59,7 +59,7 @@ const [onHashtag] = useState(() => (hashtag) => (
className="d-inline-flex"
style={{ color: "var(--bs-link-color)" }}
>
- #{hashtag}
+ #{hashtag}
));
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 6b57fa9b..d91fddf8 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -182,16 +182,14 @@ return {
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
- init: {
- icon: "bi bi-globe",
- },
- },
- generalFeed: {
- path: "buildhub.near/widget/GeneralFeed",
- blockHeight: "final",
init: {
icon: "bi bi-globe",
feeds: feeds,
+ daoName: "Build DAO",
+ feedLink: "https://nearbuilders.org/feed",
+ daoTag: "build",
+ pagePath: "/?page=feed",
+ //hashtag: "something"
},
},
inspect: {
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 53cc3566..f4b8ab32 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,49 +1,9 @@
-const { Feed } = VM.require("devs.near/widget/Feed") || {
- // this is being pulled from local apps/bos-blocks/widget/Feed
- Feed: () => Feed loading...
,
-};
-
-// would a provider pattern be helpful here?
-// const { items } = props;
-
-const [activeItem, setActiveItem] = useState(null);
-
-function Sidebar() {
- return ( // minimal styling, classnames from Theme
- setActiveItem}>
-
sidebar
-
- );
-}
-
-// can we take influence from the pattern in buildhub.near/widget/app?
-
return (
- <>
-
- {JSON.stringify(p)}
}
+
+
- >
+
);
From f86e78756d53566e4c8d86441b1998f0b50808b2 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 01:47:16 +0500
Subject: [PATCH 058/132] Change sidebar to navbar
---
apps/builddao/widget/app.jsx | 14 ++-
apps/builddao/widget/config.jsx | 3 +-
apps/builddao/widget/page/home.jsx | 2 +-
apps/builddao/widget/template/layout.jsx | 103 +++++++++++++++++++++++
4 files changed, 111 insertions(+), 11 deletions(-)
create mode 100644 apps/builddao/widget/template/layout.jsx
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 5c2f5b60..05e13412 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -2,10 +2,10 @@ const { page, layout, loading, ...passProps } = props;
const { routes, theme } = VM.require("buildhub.near/widget/config") ?? {
routes: {},
- theme: "background-color: red;"
+ theme: "background-color: red;",
};
-const { AppLayout } = VM.require("every.near/widget/layout") || {
+const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
AppLayout: () => <>Layout loading...>,
};
@@ -16,9 +16,7 @@ const Root = styled.div`
color: inherit;
}
- ${theme}
-
- // can come from config
+ ${theme}// can come from config
`;
const [activeRoute, setActiveRoute] = useState(page);
@@ -27,7 +25,8 @@ useEffect(() => {
setActiveRoute(page);
}, [page]);
-function Router({ active, routes }) { // this may be converted to a module at devs.near/widget/Router
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
const routeParts = active.split(".");
let currentRoute = routes;
@@ -60,13 +59,12 @@ function Router({ active, routes }) { // this may be converted to a module at de
const Container = styled.div`
display: flex;
- height: 100vh;
+ height: 100%;
`;
const Content = styled.div`
width: 100%;
height: 100%;
- overflow: scroll;
`;
return (
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index d91fddf8..a94fc53c 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -176,14 +176,13 @@ return {
blockHeight: "final",
init: {
name: "Home",
- icon: "bi bi-house",
},
},
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
init: {
- icon: "bi bi-globe",
+ name: "Feed",
feeds: feeds,
daoName: "Build DAO",
feedLink: "https://nearbuilders.org/feed",
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index c61d8eb7..a74adcab 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -1 +1 @@
-return home
;
+return ;
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
new file mode 100644
index 00000000..ff43b84a
--- /dev/null
+++ b/apps/builddao/widget/template/layout.jsx
@@ -0,0 +1,103 @@
+const { Button } = VM.require("buildhub.near/widget/components");
+
+const Container = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ height: 100%;
+ // margin-top: calc(-1 * var(--body-top-padding));
+`;
+
+const ContentContainer = styled.div`
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+`;
+
+const Navbar = styled.div`
+ width: 64px;
+
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ padding: 24px;
+ width: 100%;
+
+ border: 2px outset #3c3d43;
+ background-color: #0b0c14;
+`;
+
+const ButtonGroup = styled.div`
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 8px;
+`;
+
+const { NavLink } = props || {
+ NavLink: ({ to, children }) => (
+
+ {children}
+
+ ),
+};
+
+const AppHeader = ({ page, routes }) => (
+
+
+ {routes &&
+ (Object.keys(routes) || []).map((k) => {
+ const route = routes[k];
+ if (route.hide) {
+ return null;
+ }
+ return (
+
+
+ {route.init.icon && }
+ {route.init.name}
+
+
+ );
+ })}
+
+ {routes && (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )}
+
+);
+
+const Footer = (props) => {
+ return <>>;
+};
+
+// Define the new component that follows the AppLayout pattern
+function AppLayout({ routes, page, children }) {
+ return (
+ <>
+
+
+ {children}
+
+
+ >
+ );
+}
+
+return { AppLayout };
From 160247c3e7ff15892c5fb0d35ba33738099a88e5 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:21:39 +0500
Subject: [PATCH 059/132] refactor and style changes
---
apps/builddao/widget/Feed.jsx | 30 +--
apps/builddao/widget/Proposals.jsx | 1 +
apps/builddao/widget/app.jsx | 16 +-
.../builddao/widget/components/ButtonLink.jsx | 2 +-
apps/builddao/widget/config.jsx | 189 +-----------------
apps/builddao/widget/config/feed.jsx | 148 ++++++++++++++
apps/builddao/widget/config/theme.jsx | 33 +++
apps/builddao/widget/page/feed.jsx | 19 +-
apps/builddao/widget/page/proposal.jsx | 8 +
apps/builddao/widget/template/layout.jsx | 3 +-
10 files changed, 237 insertions(+), 212 deletions(-)
create mode 100644 apps/builddao/widget/Proposals.jsx
create mode 100644 apps/builddao/widget/config/feed.jsx
create mode 100644 apps/builddao/widget/config/theme.jsx
create mode 100644 apps/builddao/widget/page/proposal.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 78847859..930d6334 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -39,6 +39,7 @@ return (
fontSize: "14px",
textDecoration: "none",
cursor: "pointer",
+ padding: "8px 12px",
}}
>
@@ -48,26 +49,27 @@ return (
}),
mainContent: (
<>
- {context.accountId ? (
- activeFeed !== "bookmarks" ? (
-
- ) : (
-
- )
+ {feeds[activeFeed].hideCompose ? null : context.accountId ? (
+
) : (
)}
- {activeFeed !== "bookmarks" && (
+ {feeds[activeFeed].customWidget ? (
+
+ ) : (
Proposals ;
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 05e13412..e4200242 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,8 +1,11 @@
const { page, layout, loading, ...passProps } = props;
-const { routes, theme } = VM.require("buildhub.near/widget/config") ?? {
+const { routes } = VM.require("buildhub.near/widget/config") ?? {
routes: {},
- theme: "background-color: red;",
+};
+
+const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+ theme: {},
};
const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
@@ -12,10 +15,6 @@ const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
if (!page) page = Object.keys(routes)[0] || "home";
const Root = styled.div`
- a {
- color: inherit;
- }
-
${theme}// can come from config
`;
@@ -49,10 +48,7 @@ function Router({ active, routes }) {
return (
-
+
);
}
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index f9a3978c..11283685 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -41,7 +41,7 @@ const StyledLink = styled.a`
default:
return "var(--button-default-color, #CDD0D5)";
}
- }} !important;
+ }};
border: ${(props) =>
props.variant === "outline"
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index a94fc53c..34290fbb 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -1,173 +1,3 @@
-function formatDate(date) {
- const options = { year: "numeric", month: "short", day: "numeric" };
- return date.toLocaleDateString("en-US", options);
-}
-
-const theme = `
- --stroke-color: rgba(255, 255, 255, 0.2);
- --bg-1: #0b0c14;
- --bg-1-hover: #17181c;
- --bg-1-hover-transparent: rgba(23, 24, 28, 0);
- --bg-2: ##23242b;
- --label-color: #fff;
- --font-color: #fff;
- --font-muted-color: #cdd0d5;
- --black: #000;
- --system-red: #fd2a5c;
- --yellow: #ffaf51;
-
- --compose-bg: #23242b;
-
- --post-bg: #0b0c14;
- --post-bg-hover: #17181c;
- --post-bg-transparent: rgba(23, 24, 28, 0);
-
- --button-primary-bg: #ffaf51;
- --button-outline-bg: transparent;
- --button-default-bg: #23242b;
-
- --button-primary-color: #000;
- --button-outline-color: #fff;
- --button-default-color: #cdd0d5;
-
- --button-primary-hover-bg: #e49b48;
- --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
- --button-default-hover-bg: #17181c;
-`;
-
-const feeds = {
- resolutions: {
- label: "Resolutions",
- icon: "bi-calendar3",
- name: "resolution",
- hashtag: "nearyearresolutions2024",
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
- (posted via [${daoName} Gateway](${feedLink}))
-
- **🌟 REFLECTIONS ON THE PAST YEAR:**
- - [Reflection 1 from the past year]
- - [Reflection 2 from the past year]
-
- **🎯 NEW YEAR'S RESOLUTIONS:**
- - [Resolution 1]
- - [Resolution 2]
-
- **📊 MEASURING SUCCESS:**
- - [Metric 1 for Success]
- - [Metric 2 for Success]
- `,
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
- (posted via [${daoName} Gateway](${feedLink}?tab=update))
-
- **✅ DONE**
- - [what'd you do]
- - [link proof]
-
- **⏩ NEXT**
- - [what's next?]
- - [what are you thinking about?]
-
- **🛑 BLOCKERS**
- - [what's blocking you?]
- - [how can someone help?]
- `,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
-
- **WHAT IS _____?**
- - [context]
- - [why is it important?]
-
- **EXAMPLE**
- - [how can this be demonstrated?]
- - [what is the expected outcome?]
-
- **USAGE**
- - [where is it used?]
- - [how to use it]
- `,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
- (posted via [${daoName} Gateway](${feedLink}?tab=question))
-
- [what are you thinking about?]
- [why are you asking?]
- `,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
- (posted via [${daoName} Gateway](${feedLink}?tab=answer))
-
- [please restate the question you are answering]
-
- [your answer]
-
- [link to relevant docs, examples, or resources]
- `,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
-
- [what is the opportunity?]
-
- [explain the motivation or reason]
-
- `,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: ``,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- template: `## TASK TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=task))
-
- **What needs to be done?**
- - [Describe the task or action steps]
-
- **Context or additional information:**
- - [Provide any context or details]
- `,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- },
-};
-
return {
type: "app",
routes: {
@@ -183,23 +13,14 @@ return {
blockHeight: "final",
init: {
name: "Feed",
- feeds: feeds,
- daoName: "Build DAO",
- feedLink: "https://nearbuilders.org/feed",
- daoTag: "build",
- pagePath: "/?page=feed",
- //hashtag: "something"
},
},
- inspect: {
- path: "mob.near/widget/WidgetSource",
+ proposal: {
+ path: "buildhub.near/widget/page.proposal",
blockHeight: "final",
- hide: true,
- },
- notifications: {
- path: "mob.near/widget/NotificationFeed",
- blockHeight: "final",
- hide: true,
+ init: {
+ name: "Proposal",
+ },
},
},
theme: theme,
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
new file mode 100644
index 00000000..e6f8a3c8
--- /dev/null
+++ b/apps/builddao/widget/config/feed.jsx
@@ -0,0 +1,148 @@
+function formatDate(date) {
+ const options = { year: "numeric", month: "short", day: "numeric" };
+ return date.toLocaleDateString("en-US", options);
+}
+
+const feeds = {
+ resolutions: {
+ label: "Resolutions",
+ icon: "bi-calendar3",
+ name: "resolution",
+ hashtag: "nearyearresolutions2024",
+ template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
+ (posted via [${daoName} Gateway](${feedLink}))
+
+ **🌟 REFLECTIONS ON THE PAST YEAR:**
+ - [Reflection 1 from the past year]
+ - [Reflection 2 from the past year]
+
+ **🎯 NEW YEAR'S RESOLUTIONS:**
+ - [Resolution 1]
+ - [Resolution 2]
+
+ **📊 MEASURING SUCCESS:**
+ - [Metric 1 for Success]
+ - [Metric 2 for Success]
+ `,
+ },
+ updates: {
+ label: "Updates",
+ icon: "bi-bell",
+ name: "update",
+ hashtag: "update",
+ template: `### BUILDER UPDATE: ${formatDate(new Date())}
+ (posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+ **✅ DONE**
+ - [what'd you do]
+ - [link proof]
+
+ **⏩ NEXT**
+ - [what's next?]
+ - [what are you thinking about?]
+
+ **🛑 BLOCKERS**
+ - [what's blocking you?]
+ - [how can someone help?]
+ `,
+ },
+ documentation: {
+ label: "Documentation",
+ icon: "bi-book",
+ name: "documentation",
+ hashtag: "documentation",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+ **WHAT IS _____?**
+ - [context]
+ - [why is it important?]
+
+ **EXAMPLE**
+ - [how can this be demonstrated?]
+ - [what is the expected outcome?]
+
+ **USAGE**
+ - [where is it used?]
+ - [how to use it]
+ `,
+ },
+ question: {
+ label: "Question",
+ icon: "bi-question-lg",
+ name: "question",
+ hashtag: "question",
+ template: `## what is your question?
+ (posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+ [what are you thinking about?]
+ [why are you asking?]
+ `,
+ },
+ answer: {
+ label: "Answer",
+ icon: "bi-journal-code",
+ name: "answer",
+ hashtag: "answer",
+ template: `## Share an answer
+ (posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+ [please restate the question you are answering]
+
+ [your answer]
+
+ [link to relevant docs, examples, or resources]
+ `,
+ },
+ opportunity: {
+ label: "Opportunity",
+ icon: "bi-briefcase",
+ name: "opportunity",
+ hashtag: "opportunity",
+ template: `## TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+ [what is the opportunity?]
+
+ [explain the motivation or reason]
+
+ `,
+ },
+ idea: {
+ label: "Idea",
+ icon: "bi-lightbulb",
+ name: "idea",
+ hashtag: "idea",
+ template: ``,
+ },
+ task: {
+ label: "Task",
+ icon: "bi-check-lg",
+ name: "task",
+ template: `## TASK TITLE
+ (posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+ **What needs to be done?**
+ - [Describe the task or action steps]
+
+ **Context or additional information:**
+ - [Provide any context or details]
+ `,
+ },
+ bookmarks: {
+ label: "Bookmarks",
+ icon: "bi-bookmark",
+ name: "bookmark",
+ hideCompose: true,
+ customWidget: "buildhub.near/widget/Bookmarks",
+ },
+ proposals: {
+ label: "Proposals",
+ icon: "bi-file-earmark-text",
+ name: "proposal",
+ hideCompose: true,
+ customWidget: "buildhub.near/widget/Proposals",
+ },
+};
+
+return { type: config, feeds: feeds };
diff --git a/apps/builddao/widget/config/theme.jsx b/apps/builddao/widget/config/theme.jsx
new file mode 100644
index 00000000..b3253beb
--- /dev/null
+++ b/apps/builddao/widget/config/theme.jsx
@@ -0,0 +1,33 @@
+const theme = `
+ --stroke-color: rgba(255, 255, 255, 0.2);
+ --bg-1: #0b0c14;
+ --bg-1-hover: #17181c;
+ --bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --bg-2: ##23242b;
+ --label-color: #fff;
+ --font-color: #fff;
+ --font-muted-color: #cdd0d5;
+ --black: #000;
+ --system-red: #fd2a5c;
+ --yellow: #ffaf51;
+
+ --compose-bg: #23242b;
+
+ --post-bg: #0b0c14;
+ --post-bg-hover: #17181c;
+ --post-bg-transparent: rgba(23, 24, 28, 0);
+
+ --button-primary-bg: #ffaf51;
+ --button-outline-bg: transparent;
+ --button-default-bg: #23242b;
+
+ --button-primary-color: #000;
+ --button-outline-color: #fff;
+ --button-default-color: #cdd0d5;
+
+ --button-primary-hover-bg: #e49b48;
+ --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
+ --button-default-hover-bg: #17181c;
+`;
+
+return { type: "theme", theme: theme };
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index f4b8ab32..910b11ab 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,9 +1,26 @@
+const { feeds } = VM.require("buildhub.near/widget/config.feed");
+
+console.log(feeds);
+
+if (!feeds) {
+ return "...";
+}
+
+const defaultProps = {
+ feeds: feeds,
+ daoName: "Build DAO",
+ feedLink: "https://nearbuilders.org/feed",
+ daoTag: "build",
+ pagePath: "/?page=feed",
+ //hashtag: "something"
+};
+
return (
);
diff --git a/apps/builddao/widget/page/proposal.jsx b/apps/builddao/widget/page/proposal.jsx
new file mode 100644
index 00000000..b3529c33
--- /dev/null
+++ b/apps/builddao/widget/page/proposal.jsx
@@ -0,0 +1,8 @@
+return (
+
+
+
+);
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
index ff43b84a..9e7ba415 100644
--- a/apps/builddao/widget/template/layout.jsx
+++ b/apps/builddao/widget/template/layout.jsx
@@ -26,7 +26,6 @@ const Navbar = styled.div`
padding: 24px;
width: 100%;
- border: 2px outset #3c3d43;
background-color: #0b0c14;
`;
@@ -46,7 +45,7 @@ const { NavLink } = props || {
};
const AppHeader = ({ page, routes }) => (
-
+
{routes &&
(Object.keys(routes) || []).map((k) => {
From 6ee3b1b4c71f0234469bb9dedd7b23831875d1a9 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:26:55 +0500
Subject: [PATCH 060/132] Style updates to match figma
---
apps/builddao/widget/Feed.jsx | 3 ++-
apps/builddao/widget/config/theme.jsx | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 930d6334..46626a13 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -40,10 +40,11 @@ return (
textDecoration: "none",
cursor: "pointer",
padding: "8px 12px",
+ gap: "10px",
}}
>
- {data.label}
+ {data.label}
);
}),
diff --git a/apps/builddao/widget/config/theme.jsx b/apps/builddao/widget/config/theme.jsx
index b3253beb..4a24853c 100644
--- a/apps/builddao/widget/config/theme.jsx
+++ b/apps/builddao/widget/config/theme.jsx
@@ -22,7 +22,7 @@ const theme = `
--button-default-bg: #23242b;
--button-primary-color: #000;
- --button-outline-color: #fff;
+ --button-outline-color: #cdd0d5;
--button-default-color: #cdd0d5;
--button-primary-hover-bg: #e49b48;
From e7f9fcac8b5ae35fa21fb386c0616caf259381fe Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:41:11 +0500
Subject: [PATCH 061/132] Fix navbar variant
---
apps/builddao/widget/template/layout.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/layout.jsx
index 9e7ba415..201bf9a3 100644
--- a/apps/builddao/widget/template/layout.jsx
+++ b/apps/builddao/widget/template/layout.jsx
@@ -55,7 +55,7 @@ const AppHeader = ({ page, routes }) => (
}
return (
-
+
{route.init.icon && }
{route.init.name}
From cba69231c25bc790480765bfd0788ca9dccef829 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:44:41 +0500
Subject: [PATCH 062/132] Fix task feed
---
apps/builddao/widget/config/feed.jsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index e6f8a3c8..08ce4cca 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -119,6 +119,7 @@ const feeds = {
label: "Task",
icon: "bi-check-lg",
name: "task",
+ hashtag: "task",
template: `## TASK TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=task))
From d33769f97a780d4bd7aad81649ae8bea74b331e5 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 03:53:15 +0500
Subject: [PATCH 063/132] fix feed templates
---
apps/builddao/widget/config/feed.jsx | 147 ++++++++++++++-------------
1 file changed, 79 insertions(+), 68 deletions(-)
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 08ce4cca..c8dc2dc0 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -3,6 +3,9 @@ function formatDate(date) {
return date.toLocaleDateString("en-US", options);
}
+const daoName = "Build DAO";
+const feedLink = "https://nearbuilders.org/feed";
+
const feeds = {
resolutions: {
label: "Resolutions",
@@ -10,20 +13,20 @@ const feeds = {
name: "resolution",
hashtag: "nearyearresolutions2024",
template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
- (posted via [${daoName} Gateway](${feedLink}))
+(posted via [${daoName} Gateway](${feedLink}))
- **🌟 REFLECTIONS ON THE PAST YEAR:**
- - [Reflection 1 from the past year]
- - [Reflection 2 from the past year]
+**🌟 REFLECTIONS ON THE PAST YEAR:**
+- [Reflection 1 from the past year]
+- [Reflection 2 from the past year]
- **🎯 NEW YEAR'S RESOLUTIONS:**
- - [Resolution 1]
- - [Resolution 2]
+**🎯 NEW YEAR'S RESOLUTIONS:**
+- [Resolution 1]
+- [Resolution 2]
- **📊 MEASURING SUCCESS:**
- - [Metric 1 for Success]
- - [Metric 2 for Success]
- `,
+**📊 MEASURING SUCCESS:**
+- [Metric 1 for Success]
+- [Metric 2 for Success]
+`,
},
updates: {
label: "Updates",
@@ -31,20 +34,20 @@ const feeds = {
name: "update",
hashtag: "update",
template: `### BUILDER UPDATE: ${formatDate(new Date())}
- (posted via [${daoName} Gateway](${feedLink}?tab=update))
-
- **✅ DONE**
- - [what'd you do]
- - [link proof]
-
- **⏩ NEXT**
- - [what's next?]
- - [what are you thinking about?]
-
- **🛑 BLOCKERS**
- - [what's blocking you?]
- - [how can someone help?]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=update))
+
+**✅ DONE**
+- [what'd you do]
+- [link proof]
+
+**⏩ NEXT**
+- [what's next?]
+- [what are you thinking about?]
+
+**🛑 BLOCKERS**
+- [what's blocking you?]
+- [how can someone help?]
+`,
},
documentation: {
label: "Documentation",
@@ -52,20 +55,20 @@ const feeds = {
name: "documentation",
hashtag: "documentation",
template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=documentation))
-
- **WHAT IS _____?**
- - [context]
- - [why is it important?]
-
- **EXAMPLE**
- - [how can this be demonstrated?]
- - [what is the expected outcome?]
-
- **USAGE**
- - [where is it used?]
- - [how to use it]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=documentation))
+
+**WHAT IS _____?**
+- [context]
+- [why is it important?]
+
+**EXAMPLE**
+- [how can this be demonstrated?]
+- [what is the expected outcome?]
+
+**USAGE**
+- [where is it used?]
+- [how to use it]
+`,
},
question: {
label: "Question",
@@ -73,11 +76,11 @@ const feeds = {
name: "question",
hashtag: "question",
template: `## what is your question?
- (posted via [${daoName} Gateway](${feedLink}?tab=question))
-
- [what are you thinking about?]
- [why are you asking?]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=question))
+
+[what are you thinking about?]
+[why are you asking?]
+`,
},
answer: {
label: "Answer",
@@ -85,14 +88,14 @@ const feeds = {
name: "answer",
hashtag: "answer",
template: `## Share an answer
- (posted via [${daoName} Gateway](${feedLink}?tab=answer))
-
- [please restate the question you are answering]
-
- [your answer]
-
- [link to relevant docs, examples, or resources]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=answer))
+
+[please restate the question you are answering]
+
+[your answer]
+
+[link to relevant docs, examples, or resources]
+`,
},
opportunity: {
label: "Opportunity",
@@ -100,20 +103,28 @@ const feeds = {
name: "opportunity",
hashtag: "opportunity",
template: `## TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
-
- [what is the opportunity?]
-
- [explain the motivation or reason]
-
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
+
+[what is the opportunity?]
+
+[explain the motivation or reason]
+
+`,
},
idea: {
label: "Idea",
icon: "bi-lightbulb",
name: "idea",
hashtag: "idea",
- template: ``,
+ template: `## IDEA TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=idea))
+
+**What idea are you proposing?**
+- [Describe the idea]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
},
task: {
label: "Task",
@@ -121,14 +132,14 @@ const feeds = {
name: "task",
hashtag: "task",
template: `## TASK TITLE
- (posted via [${daoName} Gateway](${feedLink}?tab=task))
-
- **What needs to be done?**
- - [Describe the task or action steps]
-
- **Context or additional information:**
- - [Provide any context or details]
- `,
+(posted via [${daoName} Gateway](${feedLink}?tab=task))
+
+**What needs to be done?**
+- [Describe the task or action steps]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
},
bookmarks: {
label: "Bookmarks",
From e6908afd6ffd074a224cac4b9981e1b49812e810 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Fri, 26 Jan 2024 22:41:14 +0500
Subject: [PATCH 064/132] Add request feed with custom propose action
---
apps/builddao/widget/Feed.jsx | 1 +
apps/builddao/widget/Post.jsx | 372 -----------------------
apps/builddao/widget/Post/Header.jsx | 169 ----------
apps/builddao/widget/components/Post.jsx | 2 +
apps/builddao/widget/components/User.jsx | 14 +
apps/builddao/widget/config/feed.jsx | 37 ++-
6 files changed, 47 insertions(+), 548 deletions(-)
delete mode 100644 apps/builddao/widget/Post.jsx
delete mode 100644 apps/builddao/widget/Post/Header.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 46626a13..e602ddfe 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -105,6 +105,7 @@ return (
blockHeight={p.blockHeight}
noBorder={true}
currentPath={`${props.pagePath}`}
+ customActions={feeds[activeFeed].customActions}
/>
)}
/>
diff --git a/apps/builddao/widget/Post.jsx b/apps/builddao/widget/Post.jsx
deleted file mode 100644
index 94901be7..00000000
--- a/apps/builddao/widget/Post.jsx
+++ /dev/null
@@ -1,372 +0,0 @@
-const accountId = props.accountId;
-if (!accountId) {
- return "No accountId";
-}
-const blockHeight =
- props.blockHeight === "now" ? "now" : parseInt(props.blockHeight);
-const pinned = !!props.pinned;
-const hideMenu = !!props.hideMenu;
-const hideButtons = !!props.hideButtons;
-const content =
- props.content ??
- JSON.parse(Social.get(`${accountId}/post/main`, blockHeight) ?? "null");
-const subscribe = !!props.subscribe;
-const raw = !!props.raw;
-const groupId = props.groupId ?? content.groupId;
-const indexKey = props.indexKey;
-const permissions = props.permissions;
-const fullPostLink = props.fullPostLink;
-const postPage = props.postPage ?? "mob.near/widget/MainPage.N.Post.Page";
-
-const notifyAccountId = accountId;
-const item = {
- type: "social",
- path: `${accountId}/post/main`,
- blockHeight,
-};
-
-const link =
- props.link ??
- props.fullPostLink ??
- `/${postPage}?accountId=${accountId}&blockHeight=${blockHeight}`;
-
-const StyledPost = styled.div`
- margin-bottom: 1rem;
- .post {
- border-radius: 16px;
- border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2));
- color: #b6b6b8;
- padding: 24px !important;
- background-color: #0b0c14;
- transition: all 300ms;
-
- &:hover {
- background-color: #171929 !important;
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgb(23, 25, 41, 0),
- rgb(23, 25, 41, 1) 25%
- ) !important;
- }
- }
-
- .post-header {
- span,
- .text-muted {
- color: #fff !important;
- }
- }
-
- .buttons {
- border-top: 1px solid #3c3d43;
- padding: 0.5rem;
- }
-
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgb(11, 12, 20, 0),
- rgb(11, 12, 20, 1) 25%
- ) !important;
- }
- }
-
- .dropdown-menu {
- background-color: #0b0c14 !important;
- color: #fff !important;
-
- li.dropdown-item {
- color: #fff !important;
- &:hover {
- a {
- color: #0b0c14 !important;
- }
- }
- }
-
- .link-dark,
- .dropdown-item {
- color: #fff !important;
-
- &:hover {
- color: #0b0c14 !important;
-
- span {
- color: #0b0c14 !important;
- }
- }
- }
- }
-
- textarea {
- color: #b6b6b8 !important;
- }
-`;
-
-const Wrapper = styled.div`
- margin: 0 -12px;
- line-height: normal;
-
- .post {
- position: relative;
- padding: 12px;
- padding-bottom: 4px;
- display: flex;
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- font-size: 16px !important;
- }
- @media (max-width: 767px) {
- font-size: 15px !important;
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- font-size: 15px !important;
- }
- }
-
- h1,
- h2,
- h3,
- h4,
- h5,
- h6,
- strong,
- b {
- font-weight: 500 !important;
- }
- ol,
- ul,
- dl {
- margin-bottom: 0.5rem;
- white-space: inherit;
- }
- p {
- margin-bottom: 0.5rem;
- }
- hr {
- display: none;
- }
- img {
- border-radius: var(--bs-border-radius-lg);
- max-height: 40em;
- }
- th {
- min-width: 5em;
- }
-
- .table > :not(caption) > * > * {
- padding: 0.3rem;
- }
-
- &:hover {
- background-color: rgba(0, 0, 0, 0.03);
- .expand-post {
- background-image: linear-gradient(
- to bottom,
- rgba(0, 0, 0, 0),
- rgba(247.35, 247.35, 247.35, 1) 25%
- );
- }
- }
-
- .post-header {
- margin: 4px 0;
- }
- }
-
- .post:not(:last-child):before {
- content: "";
- position: absolute;
- left: 30px;
- top: 56px;
- bottom: 0;
- width: 2px;
- background-color: #ddd;
- z-index: -1;
- }
-
- .post:not(:first-child):after {
- content: "";
- position: absolute;
- left: 30px;
- top: 0;
- width: 2px;
- height: 8px;
- background-color: #ddd;
- z-index: -1;
- }
-
- .left {
- margin-right: 12px;
- min-width: 40px;
- width: 40px;
- overflow: hidden;
- }
- .right {
- margin-top: -4px;
- flex-grow: 1;
- min-width: 0;
- }
-
- .buttons-placeholder {
- padding-bottom: 10px;
- }
-
- .buttons {
- margin-top: 10px;
- margin-bottom: 6px;
- column-gap: 4px;
- color: #888;
- }
-
- .reposted {
- padding-top: 30px;
- }
-`;
-
-const contentWidget = (
-
- }
- src="mob.near/widget/MainPage.N.Post.Content"
- props={{
- content,
- raw,
- truncateContent: props.truncateContent,
- noEmbed: props.noEmbed,
- }}
- />
-);
-
-return (
-
-
-
-
-
}
- src="/*__@appAccount__*//widget/Post.Header"
- props={{
- accountId,
- blockHeight,
- pinned,
- hideMenu,
- link,
- postType: "post",
- flagItem: item,
- }}
- />
- {fullPostLink ? (
-
- {contentWidget}
-
- ) : (
- contentWidget
- )}
- {props.customButtons ? (
- props.customButtons
- ) : !pinned && !hideButtons && blockHeight !== "now" ? (
-
- State.update({ showReply: !state.showReply }),
- }}
- />
-
-
-
-
- ) : (
-
- )}
-
-
- {state.showReply && (
-
- State.update({ showReply: false }),
- }}
- />
-
- )}
- {props.customComments
- ? props.customComments
- : !props.hideComments && (
-
-
-
- )}
-
-
-);
diff --git a/apps/builddao/widget/Post/Header.jsx b/apps/builddao/widget/Post/Header.jsx
deleted file mode 100644
index d08ddf0b..00000000
--- a/apps/builddao/widget/Post/Header.jsx
+++ /dev/null
@@ -1,169 +0,0 @@
-const accountId = props.accountId;
-const blockHeight = props.blockHeight;
-const pinned = !!props.pinned;
-const hideMenu = !!props.hideMenu;
-const name = Social.get(`${accountId}/profile/name`);
-
-const postType = props.postType ?? "post";
-const link = props.link;
-const isPremium = !!props.isPremium;
-
-const Overlay = (props) => (
-
-
-
-);
-
-const DotsSvg = (
-
-
-
-);
-
-const Button = styled.div`
- line-height: 20px;
- min-height: 20px;
- display: inline-flex;
- align-items: center;
- justify-content: left;
- background: inherit;
- color: #6c757d;
- font-size: 16px;
- .icon {
- position: relative;
- &:before {
- margin: -8px;
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- border-radius: 50%;
- }
- }
-
- &:not([disabled]) {
- cursor: pointer;
- }
-
- &:not([disabled]):hover {
- opacity: 1 !important;
- color: DeepSkyBlue;
-
- .icon:before {
- background: rgba(0, 191, 255, 0.1);
- }
- }
-`;
-
-return (
-
-
-
-
-
-
-
-
- {name && (
-
- {name}
-
- )}
-
-
-
-
-
-
- {!pinned && (
-
- {blockHeight === "now" ? (
- "now"
- ) : (
-
-
-
- )}
-
- )}
-
-
-
-
- {pinned && (
-
-
-
- )}
- {!pinned && !hideMenu && blockHeight !== "now" && (
-
-
- {DotsSvg}
-
-
-
- )}
-
-);
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 863cd43b..f5df7f23 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -237,6 +237,7 @@ const groupId = props.groupId ?? content.groupId;
const indexKey = props.indexKey;
const permissions = props.permissions;
const fullPostLink = props.fullPostLink;
+const customActions = props.customActions;
const notifyAccountId = accountId;
const item = {
@@ -308,6 +309,7 @@ return (
link={link}
postType={"post"}
flagItem={item}
+ customActions={customActions}
/>
{fullPostLink ? (
(
)}
+ {customActions.length > 0 &&
+ customActions.map((action) => (
+
+ action.onClick(flagItem)}
+ className="btn btn-outline-dark dropdown-item"
+ >
+ {" "}
+ {action.label}
+
+
+ ))}
)}
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index c8dc2dc0..df0d398c 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -139,6 +139,36 @@ const feeds = {
**Context or additional information:**
- [Provide any context or details]
+`,
+ },
+ request: {
+ label: "Request",
+ icon: "bi-file-earmark-text",
+ name: "request",
+ hashtag: "request",
+ template: `## REQUEST TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=request))
+
+**What are you requesting?**
+- [Describe the request]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
+ customActions: [
+ {
+ label: "Propose",
+ icon: "bi-file-earmark-text",
+ onClick: (post) => console.log("propose", post),
+ },
+ ],
+ },
+ feedback: {
+ label: "Feedback",
+ icon: "bi-chat-left-text",
+ name: "feedback",
+ hashtag: "feedback",
+ template: `## TITLE
`,
},
bookmarks: {
@@ -148,13 +178,6 @@ const feeds = {
hideCompose: true,
customWidget: "buildhub.near/widget/Bookmarks",
},
- proposals: {
- label: "Proposals",
- icon: "bi-file-earmark-text",
- name: "proposal",
- hideCompose: true,
- customWidget: "buildhub.near/widget/Proposals",
- },
};
return { type: config, feeds: feeds };
From 8e07649b1298e6509310b447b656a0ed62644df8 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:11:53 +0500
Subject: [PATCH 065/132] Add Proposal Modal and Text method
---
apps/builddao/widget/components.jsx | 2 +
apps/builddao/widget/components/Modal.jsx | 40 ++-
apps/builddao/widget/components/Post.jsx | 248 ++++++++-------
apps/builddao/widget/components/User.jsx | 38 ++-
.../widget/components/modals/ProposeModal.jsx | 283 ++++++++++++++++++
apps/builddao/widget/config/feed.jsx | 12 +-
apps/builddao/widget/fetch/daos.jsx | 21 ++
apps/builddao/widget/test.jsx | 266 ++++++++++++++++
8 files changed, 759 insertions(+), 151 deletions(-)
create mode 100644 apps/builddao/widget/components/modals/ProposeModal.jsx
create mode 100644 apps/builddao/widget/fetch/daos.jsx
create mode 100644 apps/builddao/widget/test.jsx
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index 191845e0..f01cde64 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -12,6 +12,7 @@ const { TextBox } = VM.require("buildhub.near/widget/components.TextBox");
const { TextEditor } = VM.require("buildhub.near/widget/components.TextEditor");
const { Checkbox } = VM.require("buildhub.near/widget/components.Checkbox");
const { Avatar } = VM.require("buildhub.near/widget/components.Avatar");
+const { Modal } = VM.require("buildhub.near/widget/components.Modal");
function Pagination({
totalPages,
@@ -50,6 +51,7 @@ return {
Pagination,
Post,
ProgressState,
+ Modal,
Step,
InputField,
UploadField,
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index db7409fe..f3d7a2ae 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -22,7 +22,7 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242B;
+ background: #23242b;
border-radius: 16px;
color: white;
`;
@@ -36,17 +36,24 @@ const NoButton = styled.button`
`;
const CloseContainer = styled.div`
- display: flex;
- justify-content: flex-end;
- width: 100%;
- padding-bottom: 24px;
+ display: flex;
+ justify-content: flex-end;
+ width: 100%;
+ padding-bottom: 24px;
`;
const Icon = styled.i`
- font-size: 24px;
+ font-size: 24px;
`;
-function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
+function Modal({
+ children,
+ title,
+ open,
+ onOpenChange,
+ toggle,
+ toggleContainerProps,
+}) {
return (
@@ -56,13 +63,16 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
-
-
-
-
-
-
-
+
+
{title}
+
+
+
+
+
+
+
+
{children}
@@ -72,4 +82,4 @@ function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
);
}
-return { Modal };
\ No newline at end of file
+return { Modal };
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index f5df7f23..d92cc13e 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -1,6 +1,7 @@
-const { User } = VM.require("buildhub.near/widget/components");
+const { User, Button } = VM.require("buildhub.near/widget/components");
User = User || (() => <>>);
+Button = Button || (() => <>>);
const StyledPost = styled.div`
margin-bottom: 1rem;
@@ -287,127 +288,144 @@ const contentWidget = (
>
);
+const [showModal, setShowModal] = useState(false);
+const toggleModal = () => {
+ setShowModal(!showModal);
+};
+
return (
-
-
-
-
-
- {fullPostLink ? (
-
- {contentWidget}
-
- ) : (
- contentWidget
- )}
- {props.customButtons ? (
- props.customButtons
- ) : !pinned && !hideButtons && blockHeight !== "now" ? (
-
-
State.update({ showReply: !state.showReply }),
- }}
- />
-
+ <>
+
+
+
+
+
+
+ {fullPostLink ? (
+
+ {contentWidget}
+
+ ) : (
+ contentWidget
+ )}
+ {props.customButtons ? (
+ props.customButtons
+ ) : !pinned && !hideButtons && blockHeight !== "now" ? (
+
+ State.update({ showReply: !state.showReply }),
+ }}
+ />
+
+
+
+
-
-
-
-
-
- ) : (
-
- )}
-
-
- {state.showReply && (
-
- State.update({ showReply: false }),
- }}
- />
+
+
+
+ ) : (
+
+ )}
+
- )}
- {props.customComments
- ? props.customComments
- : !props.hideComments && (
-
-
-
- )}
-
-
+ {state.showReply && (
+
+ State.update({ showReply: false }),
+ }}
+ />
+
+ )}
+ {props.customComments
+ ? props.customComments
+ : !props.hideComments && (
+
+
+
+ )}
+
+
+ >
);
diff --git a/apps/builddao/widget/components/User.jsx b/apps/builddao/widget/components/User.jsx
index 9fd83aa8..7930170e 100644
--- a/apps/builddao/widget/components/User.jsx
+++ b/apps/builddao/widget/components/User.jsx
@@ -87,13 +87,15 @@ const accountId = props.accountId;
const blockHeight = props.blockHeight;
const pinned = !!props.pinned;
const hideMenu = !!props.hideMenu;
-const name = Social.get(`${accountId}/profile/name`);
+const name = props.name || Social.get(`${accountId}/profile/name`);
const postType = props.postType ?? "post";
const link = props.link;
const isPremium = !!props.isPremium;
const flagItem = props.flagItem;
const customActions = props.customActions ?? [];
+const showTime = props.showTime ?? true;
+const toggleModal = props.toggleModal;
const Overlay = (props) => (
{accountId}
-
- {blockHeight === "now" ? (
- "now"
- ) : (
-
-
-
- )}
-
+ {showTime && (
+
+ {blockHeight === "now" ? (
+ "now"
+ ) : (
+
+
+
+ )}
+
+ )}
{pinned && (
@@ -184,7 +188,11 @@ return (
customActions.map((action) => (
action.onClick(flagItem)}
+ onClick={() =>
+ action.type === "modal"
+ ? action.onClick(toggleModal)
+ : action.onClick(flagItem)
+ }
className="btn btn-outline-dark dropdown-item"
>
{" "}
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
new file mode 100644
index 00000000..38219b6a
--- /dev/null
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -0,0 +1,283 @@
+const { daos } = VM.require("buildhub.near/widget/fetch.daos");
+const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
+
+const [selectedDAO, setSelectedDAO] = useState("testdao.near");
+const [daoName, setDAOName] = useState("Select DAO");
+const [selectedOption, setSelectedOption] = useState("");
+const [text, setText] = useState("");
+
+const options = daos.map((dao) => dao.contract_id);
+
+useEffect(() => {
+ if (selectedDAO === "testdao.near") return;
+
+ const name = Social.get(`${selectedDAO}/profile/name`);
+ setDAOName(name);
+}, [selectedDAO]);
+
+const [editorKey, setEditorKey] = useState(0);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+
+const StyledTypeahead = styled.div`
+ input,
+ input:focus,
+ .rbt-input-hint {
+ background: #23242b;
+ color: #fff;
+
+ &::placeholder {
+ color: #fff;
+ opacity: 1; /* Firefox */
+ }
+ }
+
+ .rbt-menu,
+ .dropdown-item {
+ background: #23242b;
+ color: #fff;
+ }
+`;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+const showModal = props.showModal;
+const toggleModal = props.toggleModal;
+const toggle = props.toggle;
+
+return (
+
+
+
+
+ setSelectedDAO(v)}
+ placeholder="Search DAO Contract ID"
+ defaultSelected={
+ selectedDAO !== "testdao.near" ? selectedDAO : undefined
+ }
+ />
+
+
+ {selectedDAO !== "testdao.near" && (
+ <>
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+
Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
+ >
+ )}
+
+);
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index df0d398c..a6b6158c 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -149,17 +149,17 @@ const feeds = {
template: `## REQUEST TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=request))
-**What are you requesting?**
-- [Describe the request]
+#### Description
+[Detailed description of what the proposal is about.]
-**Context or additional information:**
-- [Provide any context or details]
-`,
+#### Why This Proposal?
+[Explanation of why this proposal is necessary or beneficial.]`,
customActions: [
{
label: "Propose",
icon: "bi-file-earmark-text",
- onClick: (post) => console.log("propose", post),
+ type: "modal",
+ onClick: (modalToggle) => modalToggle(),
},
],
},
diff --git a/apps/builddao/widget/fetch/daos.jsx b/apps/builddao/widget/fetch/daos.jsx
new file mode 100644
index 00000000..a424940f
--- /dev/null
+++ b/apps/builddao/widget/fetch/daos.jsx
@@ -0,0 +1,21 @@
+let daos;
+
+const apikey = "c5d70a09-5740-489d-8c3b-36fbc3d40bff";
+
+const forgeUrl = (apiUrl, params) =>
+ apiUrl +
+ Object.keys(params)
+ .sort()
+ .reduce((paramString, p) => paramString + `${p}=${params[p]}&`, "?");
+
+daos = fetch(forgeUrl(`https://api.pikespeak.ai/daos/all`, {}), {
+ mode: "cors",
+ headers: {
+ "x-api-key": apikey,
+ "cache-control": "max-age=86400", // 1 day
+ },
+});
+if (daos === null) return "";
+daos = daos?.body;
+
+return { type: "daos", daos };
diff --git a/apps/builddao/widget/test.jsx b/apps/builddao/widget/test.jsx
new file mode 100644
index 00000000..4121f32a
--- /dev/null
+++ b/apps/builddao/widget/test.jsx
@@ -0,0 +1,266 @@
+const { item } = props.item;
+
+const { daos } = VM.require("buildhub.near/widget/fetch.daos");
+const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
+
+const [showModal, setShowModal] = useState(false);
+const [selectedDAO, setSelectedDAO] = useState("testdao.near");
+const [daoName, setDAOName] = useState("Select DAO");
+const [selectedOption, setSelectedOption] = useState("");
+const [text, setText] = useState("");
+
+const toggleModal = () => {
+ setShowModal(!showModal);
+};
+
+const toggle = props.toggle ?? (
+
+ Open Modal
+
+);
+
+const options = daos.map((dao) => dao.contract_id);
+
+useEffect(() => {
+ if (selectedDAO === "testdao.near") return;
+
+ const name = Social.get(`${selectedDAO}/profile/name`);
+ setDAOName(name);
+}, [selectedDAO]);
+
+const StyledTypeahead = styled.div`
+ input,
+ input:focus,
+ .rbt-input-hint {
+ background: #23242b;
+ color: #fff;
+
+ &::placeholder {
+ color: #fff;
+ opacity: 1; /* Firefox */
+ }
+ }
+
+ .rbt-menu,
+ .dropdown-item {
+ background: #23242b;
+ color: #fff;
+ }
+`;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+
+
+ setSelectedDAO(v)}
+ placeholder="Search DAO Contract ID"
+ defaultSelected={
+ selectedDAO !== "testdao.near" ? selectedDAO : undefined
+ }
+ />
+
+
+ {selectedDAO !== "testdao.near" && (
+ <>
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
+ >
+ )}
+
+);
From 84f48861d04ec26c85889d0866b2e0651b763c41 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:13:54 +0500
Subject: [PATCH 066/132] Don't render modal for other post types
---
apps/builddao/widget/Feed.jsx | 1 +
apps/builddao/widget/components/Post.jsx | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index e602ddfe..5c572ec9 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -106,6 +106,7 @@ return (
noBorder={true}
currentPath={`${props.pagePath}`}
customActions={feeds[activeFeed].customActions}
+ feedType={feed.name}
/>
)}
/>
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index d92cc13e..4683c5fe 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -295,14 +295,16 @@ const toggleModal = () => {
return (
<>
-
+ {props.feedType === "request" && (
+
+ )}
Date: Sat, 27 Jan 2024 01:18:52 +0500
Subject: [PATCH 067/132] Fix feed type prop
---
apps/builddao/widget/Feed.jsx | 2 +-
.../widget/components/modals/ProposeModal.jsx | 136 +++++++++---------
2 files changed, 67 insertions(+), 71 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 5c572ec9..6aa1386f 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -106,7 +106,7 @@ return (
noBorder={true}
currentPath={`${props.pagePath}`}
customActions={feeds[activeFeed].customActions}
- feedType={feed.name}
+ feedType={feeds[activeFeed].name}
/>
)}
/>
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
index 38219b6a..5f835191 100644
--- a/apps/builddao/widget/components/modals/ProposeModal.jsx
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -1,16 +1,16 @@
const { daos } = VM.require("buildhub.near/widget/fetch.daos");
const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
-const [selectedDAO, setSelectedDAO] = useState("testdao.near");
-const [daoName, setDAOName] = useState("Select DAO");
+const [selectedDAO, setSelectedDAO] = useState(
+ props.daoId || "build.sputnik-dao.near"
+);
+const [daoName, setDAOName] = useState("");
const [selectedOption, setSelectedOption] = useState("");
const [text, setText] = useState("");
const options = daos.map((dao) => dao.contract_id);
useEffect(() => {
- if (selectedDAO === "testdao.near") return;
-
const name = Social.get(`${selectedDAO}/profile/name`);
setDAOName(name);
}, [selectedDAO]);
@@ -212,72 +212,68 @@ return (
/>
- {selectedDAO !== "testdao.near" && (
- <>
-
-
Proposal Type
-
setSelectedOption(e.target.value)}
- selected={selectedOption}
+
+ Proposal Type
+ setSelectedOption(e.target.value)}
+ selected={selectedOption}
+ >
+ Open this select menu
+ Text
+ Transfer
+ Function Call
+ Add Member To Role
+ Remove Member From Role
+
+
+
+
+ {selectedOption === "text" && (
+ <>
+ Proposal Description
+
- Open this select menu
- Text
- Transfer
- Function Call
- Add Member To Role
- Remove Member From Role
-
-
-
-
- {selectedOption === "text" && (
- <>
-
Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
-
-
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: "Vote",
- },
- })
- }
- >
- Next
-
-
- >
- )}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
-
- >
- )}
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+ >
+ )}
+ {selectedOption === "transfer" && "transfer"}
+ {selectedOption === "functionCall" && "functionCall"}
+ {selectedOption === "addMember" && "addMember"}
+ {selectedOption === "removeMember" && "removeMember"}
+
);
From ee938779dc7f4c7f4b8b660b39adb9036502b79d Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 01:27:59 +0500
Subject: [PATCH 068/132] Fix default prop in propose modal
---
apps/builddao/widget/components/modals/ProposeModal.jsx | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/components/modals/ProposeModal.jsx b/apps/builddao/widget/components/modals/ProposeModal.jsx
index 5f835191..bff94117 100644
--- a/apps/builddao/widget/components/modals/ProposeModal.jsx
+++ b/apps/builddao/widget/components/modals/ProposeModal.jsx
@@ -203,12 +203,11 @@ return (
setSelectedDAO(v)}
placeholder="Search DAO Contract ID"
- defaultSelected={
- selectedDAO !== "testdao.near" ? selectedDAO : undefined
- }
+ defaultSelected={[selectedDAO]}
/>
From 0a2cf5a0ec694339a4bb86f489bcd71f2dcb6dbc Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sat, 27 Jan 2024 04:43:44 +0500
Subject: [PATCH 069/132] Complete proposal modal
---
apps/builddao/widget/components/Button.jsx | 17 +-
apps/builddao/widget/components/Modal.jsx | 14 +-
apps/builddao/widget/components/Post.jsx | 2 +-
.../widget/components/modals/ProposeModal.jsx | 269 ++++++------------
.../components/modals/propose/AddMember.jsx | 62 ++++
.../modals/propose/FunctionCall.jsx | 257 +++++++++++++++++
.../modals/propose/RemoveMember.jsx | 66 +++++
.../widget/components/modals/propose/Text.jsx | 179 ++++++++++++
.../components/modals/propose/Transfer.jsx | 234 +++++++++++++++
apps/builddao/widget/page/feed.jsx | 2 +-
apps/builddao/widget/test.jsx | 266 -----------------
11 files changed, 908 insertions(+), 460 deletions(-)
create mode 100644 apps/builddao/widget/components/modals/propose/AddMember.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/FunctionCall.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/RemoveMember.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/Text.jsx
create mode 100644 apps/builddao/widget/components/modals/propose/Transfer.jsx
delete mode 100644 apps/builddao/widget/test.jsx
diff --git a/apps/builddao/widget/components/Button.jsx b/apps/builddao/widget/components/Button.jsx
index 830c76ff..5958ea6e 100644
--- a/apps/builddao/widget/components/Button.jsx
+++ b/apps/builddao/widget/components/Button.jsx
@@ -61,12 +61,27 @@ const StyledButton = styled.button`
}
}};
}
+
+ &:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
`;
-function Button({ id, children, variant, type, onClick, className, style }) {
+function Button({
+ id,
+ disabled,
+ children,
+ variant,
+ type,
+ onClick,
+ className,
+ style,
+}) {
return (
+
{toggle}
-
+
-
+
{title}
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 4683c5fe..126a1aeb 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -305,7 +305,7 @@ return (
}}
/>
)}
-
+
dao.contract_id);
+
+const { Modal, Button, User } = VM.require(
+ "buildhub.near/widget/components"
+) || {
+ Modal: () => <>>,
+ Button: () => <>>,
+ User: () => <>>,
+};
+
+const showModal = props.showModal;
+const toggleModal = props.toggleModal;
+const toggle = props.toggle;
+if (!showModal) {
+ return "";
+}
const [selectedDAO, setSelectedDAO] = useState(
props.daoId || "build.sputnik-dao.near"
);
const [daoName, setDAOName] = useState("");
const [selectedOption, setSelectedOption] = useState("");
-const [text, setText] = useState("");
-
-const options = daos.map((dao) => dao.contract_id);
useEffect(() => {
const name = Social.get(`${selectedDAO}/profile/name`);
setDAOName(name);
}, [selectedDAO]);
-const [editorKey, setEditorKey] = useState(0);
-const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
-
-useEffect(() => {
- const { path, blockHeight } = props.item;
- setText(`[EMBED](${path}@${blockHeight})`);
- setEditorKey((editorKey) => editorKey + 1);
-}, [props.item]);
+const policy = Near.view(selectedDAO, "get_policy") || { roles: [] };
+const roles = policy.roles.map((item) => item.name) || [];
const StyledTypeahead = styled.div`
input,
@@ -35,6 +44,7 @@ const StyledTypeahead = styled.div`
color: #fff;
opacity: 1; /* Firefox */
}
+ border: 1px solid #434950;
}
.rbt-menu,
@@ -44,146 +54,13 @@ const StyledTypeahead = styled.div`
}
`;
-const MarkdownEditor = `
- html {
- background: #23242b;
- }
-
- * {
- border: none !important;
- }
-
- .rc-md-editor {
- background: #4f5055;
- border-top: 1px solid #4f5055 !important;
- border-radius: 8px;
- }
-
- .editor-container {
- background: #4f5055;
- }
-
- .drop-wrap {
- top: -110px !important;
- border-radius: 0.5rem !important;
- }
-
- .header-list {
- display: flex;
- align-items: center;
- }
-
- textarea {
- background: #23242b !important;
- color: #fff !important;
-
- font-family: sans-serif !important;
- font-size: 1rem;
-
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-navigation {
- background: #23242b !important;
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-bottom: 0 !important;
- border-radius: 8px 8px 0 0;
-
- i {
- color: #cdd0d5;
- }
- }
-
- .editor-container {
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-editor .editor-container .sec-md .input {
- overflow-y: auto;
- padding: 8px !important;
- line-height: normal;
- border-radius: 0 0 8px 8px;
- }
-`;
-
-const TextareaWrapper = styled.div`
- display: grid;
- vertical-align: top;
- align-items: center;
- position: relative;
- align-items: stretch;
- width: 100%;
-
- textarea {
- display: flex;
- align-items: center;
- transition: all 0.3s ease;
- }
-
- textarea::placeholder {
- padding-top: 4px;
- font-size: 20px;
- }
-
- textarea:focus::placeholder {
- font-size: inherit;
- padding-top: 0px;
- }
-
- &::after,
- textarea,
- iframe {
- width: 100%;
- min-width: 1em;
- height: unset;
- min-height: 3em;
- font: inherit;
- margin: 0;
- resize: none;
- background: none;
- appearance: none;
- border: 0px solid #eee;
- grid-area: 1 / 1;
- overflow: hidden;
- outline: none;
- }
-
- iframe {
- padding: 0;
- }
-
- textarea:focus,
- textarea:not(:empty) {
- border-bottom: 1px solid #eee;
- min-height: 5em;
- }
-
- &::after {
- content: attr(data-value) " ";
- visibility: hidden;
- white-space: pre-wrap;
- }
- &.markdown-editor::after {
- padding-top: 66px;
- font-family: monospace;
- font-size: 14px;
- }
-`;
-
-const showModal = props.showModal;
-const toggleModal = props.toggleModal;
-const toggle = props.toggle;
-
return (
@@ -202,10 +79,15 @@ return (
+ DAO Contract ID
setSelectedDAO(v)}
+ onChange={(v) => {
+ if (options.includes(v[0])) {
+ setSelectedDAO(v[0]);
+ }
+ }}
placeholder="Search DAO Contract ID"
defaultSelected={[selectedDAO]}
/>
@@ -218,9 +100,8 @@ return (
id="proposal-type"
data-bs-theme="dark"
class="form-select"
- aria-label="Default select example"
onChange={(e) => setSelectedOption(e.target.value)}
- selected={selectedOption}
+ value={selectedOption}
>
Open this select menu
Text
@@ -234,45 +115,59 @@ return (
{selectedOption === "text" && (
<>
-
Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
-
-
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: "Vote",
- },
- })
- }
- >
- Next
-
-
+
+ >
+ )}
+ {selectedOption === "transfer" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "functionCall" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "addMember" && (
+ <>
+
+ >
+ )}
+ {selectedOption === "removeMember" && (
+ <>
+
>
)}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
);
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
new file mode 100644
index 00000000..a8f95e33
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -0,0 +1,62 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [accountId, setAccountId] = useState("");
+const [role, setRole] = useState("");
+const roles = props.roles;
+const selectedDAO = props.selectedDAO;
+
+return (
+
+
+ Account ID
+ setAccountId(e.target.value)}
+ />
+
+
+
+ Role
+ setRole(e.target.value)}
+ selected={role}
+ >
+ Select a role
+ {roles.length > 0 &&
+ roles.map((role) => {role} )}
+
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: "Potential member",
+ kind: {
+ AddMemberToRole: {
+ member_id: accountId,
+ role: role,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
new file mode 100644
index 00000000..efb5932d
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -0,0 +1,257 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [contract, setContract] = useState("");
+const [method, setMethod] = useState("");
+const [args, setArgs] = useState("{}");
+const [gas, setGas] = useState(50000000000000);
+const [deposit, useDeposit] = useState(0);
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDao = props.selectedDao;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+ Contract
+ setContract(e.target.value)}
+ className="form-control"
+ />
+
+
+ Method
+ setMethod(e.target.value)}
+ className="form-control"
+ />
+
+
+ Arguments (JSON)
+
+
+ Gas
+ setGas(e.target.value)}
+ className="form-control"
+ />
+
+
+ Deposit
+ setDeposit(e.target.value)}
+ className="form-control"
+ />
+
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: {
+ FunctionCall: {
+ reciever_id: contract,
+ actions: [
+ {
+ method_name: method,
+ args: args,
+ deposit: deposit,
+ gas: gas,
+ },
+ ],
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
new file mode 100644
index 00000000..a9490e50
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -0,0 +1,66 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [accountId, setAccountId] = useState("");
+const [role, setRole] = useState("");
+const roles = props.roles;
+const selectedDAO = props.selectedDAO;
+
+return (
+
+
+ Account ID
+ setAccountId(e.target.value)}
+ />
+
+
+
+ Role
+ setRole(e.target.value)}
+ selected={role}
+ >
+ Select a role
+ {roles.length > 0 &&
+ roles.map((role) => (
+
+ {role}
+
+ ))}
+
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: "Potential member",
+ kind: {
+ RemoveMemberFromRole: {
+ member_id: accountId,
+ role: role,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
new file mode 100644
index 00000000..95ee37d4
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -0,0 +1,179 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDAO = props.selectedDAO;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: "Vote",
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
new file mode 100644
index 00000000..4e184e9d
--- /dev/null
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -0,0 +1,234 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const [recipient, setRecipient] = useState("");
+const [token, setToken] = useState("");
+const [amount, setAmount] = useState(0);
+const [description, setDescription] = useState("");
+
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const selectedDao = props.selectedDao;
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
+return (
+
+
+ Recipient
+ setRecipient(e.target.value)}
+ />
+
+
+ Token
+ setToken(e.target.value)}
+ >
+ Select a token
+ NEAR
+ ETH
+ USDC
+ USDT
+ AURORA
+
+
+
+ Amount
+ setAmount(e.target.value)}
+ />
+
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
+
+ Near.call(selectedDAO, "add_proposal", {
+ proposal: {
+ description: text,
+ kind: {
+ Transfer: {
+ token_id: token,
+ reciever_id: recipient,
+ amount: amount,
+ },
+ },
+ },
+ })
+ }
+ >
+ Next
+
+
+
+);
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 910b11ab..676b8d88 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,4 +1,4 @@
-const { feeds } = VM.require("buildhub.near/widget/config.feed");
+const { feeds } = VM.require("buildhub.near/widget/config.feed") || {};
console.log(feeds);
diff --git a/apps/builddao/widget/test.jsx b/apps/builddao/widget/test.jsx
deleted file mode 100644
index 4121f32a..00000000
--- a/apps/builddao/widget/test.jsx
+++ /dev/null
@@ -1,266 +0,0 @@
-const { item } = props.item;
-
-const { daos } = VM.require("buildhub.near/widget/fetch.daos");
-const { Modal, Button, User } = VM.require("buildhub.near/widget/components");
-
-const [showModal, setShowModal] = useState(false);
-const [selectedDAO, setSelectedDAO] = useState("testdao.near");
-const [daoName, setDAOName] = useState("Select DAO");
-const [selectedOption, setSelectedOption] = useState("");
-const [text, setText] = useState("");
-
-const toggleModal = () => {
- setShowModal(!showModal);
-};
-
-const toggle = props.toggle ?? (
-
- Open Modal
-
-);
-
-const options = daos.map((dao) => dao.contract_id);
-
-useEffect(() => {
- if (selectedDAO === "testdao.near") return;
-
- const name = Social.get(`${selectedDAO}/profile/name`);
- setDAOName(name);
-}, [selectedDAO]);
-
-const StyledTypeahead = styled.div`
- input,
- input:focus,
- .rbt-input-hint {
- background: #23242b;
- color: #fff;
-
- &::placeholder {
- color: #fff;
- opacity: 1; /* Firefox */
- }
- }
-
- .rbt-menu,
- .dropdown-item {
- background: #23242b;
- color: #fff;
- }
-`;
-
-const MarkdownEditor = `
- html {
- background: #23242b;
- }
-
- * {
- border: none !important;
- }
-
- .rc-md-editor {
- background: #4f5055;
- border-top: 1px solid #4f5055 !important;
- border-radius: 8px;
- }
-
- .editor-container {
- background: #4f5055;
- }
-
- .drop-wrap {
- top: -110px !important;
- border-radius: 0.5rem !important;
- }
-
- .header-list {
- display: flex;
- align-items: center;
- }
-
- textarea {
- background: #23242b !important;
- color: #fff !important;
-
- font-family: sans-serif !important;
- font-size: 1rem;
-
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-navigation {
- background: #23242b !important;
- border: 1px solid #4f5055 !important;
- border-top: 0 !important;
- border-bottom: 0 !important;
- border-radius: 8px 8px 0 0;
-
- i {
- color: #cdd0d5;
- }
- }
-
- .editor-container {
- border-radius: 0 0 8px 8px;
- }
-
- .rc-md-editor .editor-container .sec-md .input {
- overflow-y: auto;
- padding: 8px !important;
- line-height: normal;
- border-radius: 0 0 8px 8px;
- }
-`;
-
-const TextareaWrapper = styled.div`
- display: grid;
- vertical-align: top;
- align-items: center;
- position: relative;
- align-items: stretch;
- width: 100%;
-
- textarea {
- display: flex;
- align-items: center;
- transition: all 0.3s ease;
- }
-
- textarea::placeholder {
- padding-top: 4px;
- font-size: 20px;
- }
-
- textarea:focus::placeholder {
- font-size: inherit;
- padding-top: 0px;
- }
-
- &::after,
- textarea,
- iframe {
- width: 100%;
- min-width: 1em;
- height: unset;
- min-height: 3em;
- font: inherit;
- margin: 0;
- resize: none;
- background: none;
- appearance: none;
- border: 0px solid #eee;
- grid-area: 1 / 1;
- overflow: hidden;
- outline: none;
- }
-
- iframe {
- padding: 0;
- }
-
- textarea:focus,
- textarea:not(:empty) {
- border-bottom: 1px solid #eee;
- min-height: 5em;
- }
-
- &::after {
- content: attr(data-value) " ";
- visibility: hidden;
- white-space: pre-wrap;
- }
- &.markdown-editor::after {
- padding-top: 66px;
- font-family: monospace;
- font-size: 14px;
- }
-`;
-
-return (
-
-
-
-
- setSelectedDAO(v)}
- placeholder="Search DAO Contract ID"
- defaultSelected={
- selectedDAO !== "testdao.near" ? selectedDAO : undefined
- }
- />
-
-
- {selectedDAO !== "testdao.near" && (
- <>
-
- Proposal Type
- setSelectedOption(e.target.value)}
- selected={selectedOption}
- >
- Open this select menu
- Text
- Transfer
- Function Call
- Add Member To Role
- Remove Member From Role
-
-
-
-
- {selectedOption === "text" && (
- <>
- Proposal Description
-
- {
- setText(v);
- },
- }}
- />
-
- >
- )}
- {selectedOption === "transfer" && "transfer"}
- {selectedOption === "functionCall" && "functionCall"}
- {selectedOption === "addMember" && "addMember"}
- {selectedOption === "removeMember" && "removeMember"}
-
- >
- )}
-
-);
From f25fc4b347c434c48ed9f69fec96647c86ae060b Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Sat, 27 Jan 2024 19:27:21 -0500
Subject: [PATCH 070/132] review comments
---
apps/builddao/widget/Bookmarks.jsx | 5 +++++
apps/builddao/widget/components/Text/P.jsx | 7 +++++++
apps/builddao/widget/config/feed.jsx | 14 ++++++++++++--
apps/builddao/widget/fetch/daos.jsx | 3 +++
apps/builddao/widget/page/feed.jsx | 12 ++++++------
5 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/Bookmarks.jsx b/apps/builddao/widget/Bookmarks.jsx
index 04a0ff56..bf9c147b 100644
--- a/apps/builddao/widget/Bookmarks.jsx
+++ b/apps/builddao/widget/Bookmarks.jsx
@@ -1,3 +1,8 @@
+/**
+ * This could be generalized for items in the graph,
+ * Social adapter (getr(`${accountId}/graph/${item}`, "final")
+ */
+
const { Post } = VM.require("buildhub.near/widget/components") || (() => <>>);
const accountId = props.accountId ?? context.accountId;
diff --git a/apps/builddao/widget/components/Text/P.jsx b/apps/builddao/widget/components/Text/P.jsx
index 3d7d73d7..ddc61beb 100644
--- a/apps/builddao/widget/components/Text/P.jsx
+++ b/apps/builddao/widget/components/Text/P.jsx
@@ -1,3 +1,10 @@
+/**
+ * We need to
+ */
+
+// We're going to save a list to create.near, just for creating things and list
+
+// create thing, list
const StyledParagraph = styled.p`
font-family: "Aekonik", sans-serif;
font-weight: 500;
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index a6b6158c..8a30edae 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -8,10 +8,19 @@ const feedLink = "https://nearbuilders.org/feed";
const feeds = {
resolutions: {
+ // metadata
+ name: "resolution",
+
+ // start sidebar
label: "Resolutions",
icon: "bi-calendar3",
- name: "resolution",
+ // end sidebar
+ // start compose
hashtag: "nearyearresolutions2024",
+
+ // better way to provide a template? reference to document -- maybe rename "initialText" or more general, "defaultProps"
+ // this could be moved to metadata, maybe daoName and feedLink = source: { label, href }, "context", or reference to other thing
+ // I like if it came from context cuz then unconfigurable unless from a forked VM
template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
(posted via [${daoName} Gateway](${feedLink}))
@@ -27,6 +36,7 @@ const feeds = {
- [Metric 1 for Success]
- [Metric 2 for Success]
`,
+ // end compose
},
updates: {
label: "Updates",
@@ -180,4 +190,4 @@ const feeds = {
},
};
-return { type: config, feeds: feeds };
+return { type: "feed", feeds: feeds };
diff --git a/apps/builddao/widget/fetch/daos.jsx b/apps/builddao/widget/fetch/daos.jsx
index a424940f..623e3c92 100644
--- a/apps/builddao/widget/fetch/daos.jsx
+++ b/apps/builddao/widget/fetch/daos.jsx
@@ -1,3 +1,6 @@
+/**
+ * This would be nice to be in the DAO SDK
+ */
let daos;
const apikey = "c5d70a09-5740-489d-8c3b-36fbc3d40bff";
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index 676b8d88..a15974fd 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,4 +1,4 @@
-const { feeds } = VM.require("buildhub.near/widget/config.feed") || {};
+const { feeds } = VM.require("buildhub.near/widget/config.feed") || {}; // this is the thing, which works better as a module if it needs to be provided with context
console.log(feeds);
@@ -8,17 +8,17 @@ if (!feeds) {
const defaultProps = {
feeds: feeds,
- daoName: "Build DAO",
- feedLink: "https://nearbuilders.org/feed",
- daoTag: "build",
- pagePath: "/?page=feed",
+ daoName: "Build DAO", // I think we could take this out, not specific to feeds
+ feedLink: "https://nearbuilders.org/feed", // this is good idea, could be used for the "share post" button
+ daoTag: "build", // maybe we can make this an array of "required hashtags"
+ pagePath: "/?page=feed", // great idea, @mattb.near RoutesManager
//hashtag: "something"
};
return (
From f2a712e2d45dd3752b549a0ab38ce6eaadfb43cc Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Sun, 28 Jan 2024 10:16:20 +0500
Subject: [PATCH 071/132] Make custom adapter for items in graph
---
apps/builddao/widget/Feed.jsx | 2 +-
.../{Bookmarks.jsx => adapters/item.jsx} | 29 ++++++-------
apps/builddao/widget/components/Avatar.jsx | 41 +++++++++----------
apps/builddao/widget/config/feed.jsx | 17 +++++++-
4 files changed, 49 insertions(+), 40 deletions(-)
rename apps/builddao/widget/{Bookmarks.jsx => adapters/item.jsx} (69%)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 6aa1386f..e26ab588 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -68,7 +68,7 @@ return (
{feeds[activeFeed].customWidget ? (
) : (
<>>);
-
const accountId = props.accountId ?? context.accountId;
+const item = props.item;
+const renderItem = props.renderItem;
+
+if (!item) {
+ return No item prop passed
;
+}
-const bookmarks = Social.getr(`${accountId}/graph/bookmark`, "final", {
+const items = Social.getr(`${accountId}/graph/${item}`, "final", {
withBlockHeight: true,
});
const StorageKey = "order";
const order = Storage.privateGet(StorageKey);
const apps = useMemo(() => {
- if (bookmarks === null || order === null) {
+ if (items === null || order === null) {
return [];
}
const starredApps = new Map();
@@ -33,7 +37,7 @@ const apps = useMemo(() => {
});
};
- buildSrc(bookmarks ?? {}, [], starredApps);
+ buildSrc(items ?? {}, [], starredApps);
let apps = [...starredApps.entries()];
apps.sort((a, b) => b[1] - a[1]);
apps = apps.map((a) => a[0]);
@@ -43,7 +47,7 @@ const apps = useMemo(() => {
Object.fromEntries(apps.map((a, i) => [a, i + 1]))
);
return apps;
-}, [bookmarks, order]);
+}, [items, order]);
let transformedArray = apps.map((item) => {
let splitParts = item.split("/");
@@ -60,16 +64,9 @@ let filteredArray = transformedArray.filter(
return (
<>
- {(filteredArray ?? []).map((item) => (
-
- ))}
+ {(filteredArray ?? []).map((item) => renderItem(item))}
{filteredArray.length === 0 && (
- No Bookmarks Yet!
+ No items!
)}
>
);
diff --git a/apps/builddao/widget/components/Avatar.jsx b/apps/builddao/widget/components/Avatar.jsx
index 536eb972..94f7afb3 100644
--- a/apps/builddao/widget/components/Avatar.jsx
+++ b/apps/builddao/widget/components/Avatar.jsx
@@ -1,35 +1,32 @@
-
function Avatar(props) {
const accountId = props.accountId ?? context.accountId;
const ImageWrapper = styled.div`
- img {
- width: ${(props) =>
- props.variant === "mobile" ? "40px" : "52px"} !important;
- height: ${(props) =>
- props.variant === "mobile" ? "40px" : "52px"} !important;
- flex-shrink: 0 !important;
- border-radius: 100px !important;
- background: lightgray 50% / cover no-repeat !important;
- }
+ img {
+ width: ${(props) =>
+ props.variant === "mobile" ? "40px" : "52px"} !important;
+ height: ${(props) =>
+ props.variant === "mobile" ? "40px" : "52px"} !important;
+ flex-shrink: 0 !important;
+ border-radius: 100px !important;
+ }
- .profile-image {
- width: auto !important;
- height: auto !important;
- }
+ .profile-image {
+ width: auto !important;
+ height: auto !important;
+ }
- @media screen and (max-width: 768px) {
- ${(props) =>
- !props.variant &&
- `
+ @media screen and (max-width: 768px) {
+ ${(props) =>
+ !props.variant &&
+ `
img {
width: 40px !important;
height: 40px !important;
}
`}
- }
-`;
-
+ }
+ `;
return (
@@ -38,4 +35,4 @@ function Avatar(props) {
);
}
-return { Avatar };
\ No newline at end of file
+return { Avatar };
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 8a30edae..64125cfe 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -1,3 +1,5 @@
+const { Post } = VM.require("buildhub.near/widget/components") || (() => <>>);
+
function formatDate(date) {
const options = { year: "numeric", month: "short", day: "numeric" };
return date.toLocaleDateString("en-US", options);
@@ -186,7 +188,20 @@ const feeds = {
icon: "bi-bookmark",
name: "bookmark",
hideCompose: true,
- customWidget: "buildhub.near/widget/Bookmarks",
+ customWidget: "buildhub.near/widget/adapters.item",
+ customProps: {
+ item: "bookmark",
+ renderItem: (item) => {
+ return (
+
+ );
+ },
+ },
},
};
From f3fac00ec1c2270bea3e39025b4b71fb0276b03f Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Sun, 28 Jan 2024 22:44:12 +0530
Subject: [PATCH 072/132] added proposal list and notification support
---
apps/builddao/widget/Proposals.jsx | 256 +++++-
.../widget/components/ProposalCard.jsx | 745 ++++++++++++++++++
2 files changed, 1000 insertions(+), 1 deletion(-)
create mode 100644 apps/builddao/widget/components/ProposalCard.jsx
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index b7fd38aa..0ad5aa1e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -1 +1,255 @@
-return Proposals
;
+const { Button } = VM.require("buildhub.near/widget/components.Button") || {
+ Button: <>>
+};
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+
+if (!DaoSDK) {
+ return <>>;
+}
+const resPerPage = 10;
+const daoId = props.daoId ?? "build.sputnik-dao.near";
+const proposalId = props.proposalId ?? null;
+const sdk = DaoSDK(daoId);
+const [currentPage, setCurrentPage] = useState(0);
+const accountId = context.accountId;
+
+const [showProposalModal, setShowModal] = useState(false);
+const lastProposalId = sdk.getLastProposalId();
+const proposals = proposalId
+ ? [
+ sdk.getProposalById({
+ proposalId
+ })
+ ] || []
+ : sdk.getProposals({
+ offset:
+ currentPage === 0
+ ? lastProposalId - resPerPage
+ : lastProposalId - currentPage * resPerPage,
+ limit: resPerPage
+ }) || [];
+
+const Container = styled.div`
+ .ndc-card {
+ border: none;
+ background-color: #23242b;
+ color: white !important;
+ padding: 2rem;
+ }
+`;
+
+const handleVote = ({ action, proposalId, proposer }) => {
+ let args = {};
+ args["id"] = JSON.parse(proposalId);
+ args["action"] = action;
+ const customAction = action.replace("Vote", "");
+ const notification = {
+ [accountId]: {
+ index: {
+ notify: JSON.stringify([
+ {
+ key: proposer,
+ value: {
+ message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
+ params: {
+ daoId: daoId,
+ proposalId: proposalId
+ },
+ type: "custom",
+ widget: "buildhub.near/widget/Proposals"
+ }
+ }
+ ])
+ }
+ }
+ };
+ Near.call([
+ {
+ contractName: daoId,
+ methodName: "act_proposal",
+ args: args,
+ gas: 200000000000000
+ },
+ {
+ contractName: "social.near",
+ methodName: "set",
+ args: { data: notification },
+ deposit: Big(JSON.stringify(notification).length * 16).mul(
+ Big(10).pow(20)
+ )
+ }
+ ]);
+};
+
+const policy = sdk.getPolicy();
+const proposalKinds = sdk.proposalKinds;
+const actions = sdk.voteActions;
+const userRoles = [];
+if (Array.isArray(policy.roles)) {
+ for (const role of policy.roles) {
+ if (role.kind === "Everyone") {
+ userRoles.push(role);
+ continue;
+ }
+ if (!role.kind.Group) continue;
+ if (accountId && role.kind.Group && role.kind.Group.includes(accountId)) {
+ userRoles.push(role);
+ }
+ }
+}
+
+const proposalPeriod = policy.proposal_period;
+console.log(policy);
+
+const ProposalsComponent = () => {
+ return (
+
+ {Array.isArray(proposals) ? (
+ proposals.map((item) => {
+ const kindName =
+ typeof item.kind === "string"
+ ? item.kind
+ : Object.keys(item.kind)[0];
+
+ const comments = Social.index("comment", {
+ type: "dao_proposal_comment",
+ path: `${daoId}/proposal/main`,
+ proposal_id: item.id + "-beta"
+ });
+ const permissionKind = proposalKinds[kindName];
+ let totalVotesNeeded = 0;
+ const isAllowedToVote = [
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteApprove
+ }),
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteReject
+ }),
+
+ sdk.hasPermission({
+ accountId,
+ permissionKind,
+ actionType: actions.VoteRemove
+ })
+ ];
+
+ policy.roles.forEach((role) => {
+ const isRoleAllowedToVote =
+ role.permissions.includes(
+ `${proposalKinds[kindName]}:VoteApprove`
+ ) ||
+ role.permissions.includes(
+ `${proposalKinds[kindName]}:VoteReject`
+ ) ||
+ role.permissions.includes(`${proposalKinds[kindName]}:*`) ||
+ role.permissions.includes(`*:VoteApprove`) ||
+ role.permissions.includes(`*:VoteReject`) ||
+ role.permissions.includes("*:*");
+ if (isRoleAllowedToVote) {
+ const threshold = (role.vote_policy &&
+ role.vote_policy[proposalKinds[kindName]]?.threshold) ||
+ policy["default_vote_policy"]?.threshold || [0, 0];
+ const eligibleVoters = role.kind.Group
+ ? role.kind.Group.length
+ : 0;
+
+ // Apply the threshold
+ if (eligibleVoters === 0) {
+ return;
+ }
+
+ const votesNeeded =
+ Math.floor((threshold[0] / threshold[1]) * eligibleVoters) + 1;
+ console.log(item.id, "votesNeeded", votesNeeded);
+ totalVotesNeeded += votesNeeded;
+ }
+ });
+
+ let totalVotes = {
+ yes: 0,
+ no: 0,
+ spam: 0,
+ total: 0
+ };
+ for (const vote of Object.values(item.votes)) {
+ if (vote === "Approve") {
+ totalVotes.yes++;
+ } else if (vote === "Reject") {
+ totalVotes.no++;
+ } else if (vote === "Spam") {
+ totalVotes.spam++;
+ }
+ }
+ totalVotes.total = totalVotes.yes + totalVotes.no + totalVotes.spam;
+
+ let expirationTime = Big(item.submission_time).add(
+ Big(proposalPeriod)
+ );
+
+ return (
+
+ );
+ })
+ ) : (
+ <>>
+ )}
+
+ );
+};
+
+return (
+
+ setShowModal(!showProposalModal)
+ }}
+ />
+
+
Proposals
+ setShowModal(true)}>
+ Create Proposal
+
+
+
+ {!proposalId && (
+
+ 0,
+ hasNext: proposals?.[0].id !== resPerPage,
+ onPrev: () => {
+ setCurrentPage(currentPage - 1);
+ },
+ onNext: () => {
+ setCurrentPage(currentPage + 1);
+ }
+ }}
+ />
+
+ )}
+
+);
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
new file mode 100644
index 00000000..4ea759d2
--- /dev/null
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -0,0 +1,745 @@
+const {
+ id,
+ typeName,
+ proposer,
+ description,
+ kind,
+ status,
+ totalVotesNeeded,
+ totalVotes,
+ submission_time,
+ votes,
+ expirationTime
+} = props.proposalData;
+const { daoId, isAllowedToVote, handleVote, comments, proposalData } = props;
+const accountId = context.accountId;
+
+function checkVotes(value) {
+ return votes[accountId] === value;
+}
+
+const Wrapper = styled.div`
+ margin: 16px auto;
+ border-radius: 16px;
+ padding: 24px;
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+ min-height: 500px;
+ width: 100%;
+ border: 1px solid #fff;
+
+ b {
+ font-weight: 600;
+ }
+
+ .grey-bg {
+ background: rgba(255, 255, 255, 0.1) !important;
+ }
+
+ .light-grey-text {
+ color: rgba(176, 176, 176, 1) !important;
+ }
+
+ .text-muted {
+ color: rgba(176, 176, 176, 1) !important;
+ }
+
+ a {
+ background: rgba(255, 255, 255, 0.1) !important;
+ color: white !important;
+ }
+
+ .social_url {
+ background: rgba(255, 255, 255, 0.1) !important;
+ color: white !important;
+ }
+
+ .btn-primary {
+ background-color: #ffaf51 !important;
+ color: black !important;
+ }
+
+ ul {
+ background-color: #23242b;
+ }
+
+ .Approve {
+ background: none !important;
+ .vote {
+ color: #38c793 !important;
+ }
+ }
+
+ .Reject {
+ background: none !important;
+ .vote {
+ color: #bf2c37 !important;
+ }
+ }
+
+ .Remove {
+ background: none !important;
+ .vote {
+ color: #73692d !important;
+ }
+ }
+
+ .success {
+ border: 1px solid rgba(56, 199, 147, 0.2) !important;
+ background: rgba(56, 199, 147, 0.1) !important;
+ color: #38c793 !important;
+ }
+
+ .primary {
+ border: 1px solid rgba(255, 175, 81, 0.2) !important;
+ background: rgba(255, 175, 81, 0.2) !important;
+ color: #ffaf51 !important;
+ }
+
+ .info {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ // TODO
+ .danger {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ .black {
+ border: 1px solid rgba(81, 182, 255, 0.2) !important;
+ background: rgba(81, 182, 255, 0.2) !important;
+ color: #51b6ff !important;
+ }
+
+ .word-wrap {
+ word-wrap: break-word;
+ }
+
+ ${({ status }) =>
+ status === "Approved" &&
+ `
+ border-color: #82E299;
+ `}
+
+ ${({ status }) =>
+ status === "In Progress" &&
+ `
+ border-color: #fff;
+ `}
+
+ ${({ status }) =>
+ (status === "Failed" || status === "Rejected") &&
+ `
+ border-color: #C23F38;
+ `}
+
+ .text-sm {
+ font-size: 14px;
+ }
+
+ .counter-text {
+ font-size: 14px;
+ margin-right: 5px;
+ border-width: 2px;
+ animation-duration: 8s;
+ }
+
+ .text-center {
+ text-align: center;
+ }
+
+ .info_section {
+ border-right: 1px solid #dee2e6;
+ padding-right: 15px;
+ margin: 10px 15px 10px 0;
+
+ &.no-border {
+ border: 0;
+ }
+
+ @media (max-width: 768px) {
+ border: 0;
+ }
+ }
+`;
+
+const cls = (c) => c.join(" ");
+
+const YouVotedBadge = () => {
+ return (
+
+ );
+};
+
+function renderPermission({ isAllowedToVote }) {
+ return (
+
+ {isAllowedToVote
+ ? "You are allowed to vote on this proposal"
+ : "You are not allowed to vote on this proposal"}
+
+ );
+}
+
+const execProposal = ({ daoId, id }) =>
+ Near.call(daoId, "execute", { id }, 50000000000000);
+
+function renderHeader({ typeName, id, status }) {
+ let statusicon;
+ let statustext;
+ let statusvariant;
+
+ switch (status) {
+ case "Approved":
+ case "Accepted":
+ statusicon = "bi bi-check-circle";
+ statustext = status;
+ statusvariant = "success";
+ break;
+ case "Executed":
+ statusicon = "bi bi-play-fill";
+ statustext = status;
+ statusvariant = "success";
+ break;
+ case "InProgress":
+ statusicon = "spinner-border spinner-border-sm";
+ statustext = "In Progress";
+ statusvariant = "primary";
+ break;
+ case "Expired":
+ statusicon = "bi bi-clock";
+ statustext = status;
+ statusvariant = "black";
+ break;
+ case "Failed":
+ statusicon = "bi bi-x-circle";
+ statustext = status;
+ statusvariant = "black";
+ break;
+ case "Rejected":
+ statusicon = "bi bi-ban";
+ statustext = status;
+ statusvariant = "danger";
+ break;
+ }
+
+ return (
+
+
+
+
{typeName}
+
+
+
+
+
+
+ {statustext}
+ >
+ ),
+ variant: `${statusvariant} round`,
+ size: "lg"
+ }}
+ />
+
+ {status === "InProgress" &&
+ parseInt(Big(expirationTime).div(1000000)) > Date.now() && (
+
+
+
+ ),
+ variant: `info round`,
+ size: "lg"
+ }}
+ />
+ )}
+
+
+
+ );
+}
+
+function renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+}) {
+ return (
+
+
+
+
+
+
+
+ {submission_time && (
+
+
Submitted at
+
+
+ {new Date(
+ parseInt(Big(submission_time).div(1000000))
+ ).toLocaleString()}
+
+
+
+ )}
+
+
+
Expired at
+
+
+ {new Date(
+ parseInt(Big(expirationTime).div(1000000))
+ ).toLocaleString()}
+
+
+
+
+
+
Required Votes
+
+ {totalVotesNeeded}
+
+
+
+
+ );
+}
+
+function renderVoteButtons({
+ totalVotes,
+ status,
+ isAllowedToVote,
+ handleVote
+}) {
+ const finished = status !== "InProgress";
+ const VoteButton = styled.button`
+ width: 100%;
+ border-radius: 15px;
+ border: 1px solid transparent;
+ padding: 0 20px;
+ line-height: 45px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ position: relative;
+ overflow: hidden;
+ color: rgb(var(--vote-button-color));
+ background-color: rgba(255, 255, 255, 0.10);
+ --vote-button-bg: 130, 226, 153;
+ --vote-button-color: 255, 255, 255;
+
+ &.no {
+ --vote-button-bg: 194, 63, 56;
+ }
+
+ &.no > div:last-child {
+ transition: all 0.4s ease-in-out;
+ }
+ ${({ finished, percentage, disabled }) => {
+ if (finished) {
+ if (percentage > 80) {
+ return `
+ &.no > div:last-child {
+ color: rgb(var(--vote-button-color)) !important;
+ }
+ `;
+ }
+ } else if (!disabled) {
+ return `
+ &:hover.no > div:last-child {
+ color: rgb(var(--vote-button-color)) !important;
+ }
+ `;
+ }
+ }}}
+
+ &.spam {
+ --vote-button-bg: 245, 197, 24;
+ }
+
+ &.abstain {
+ --vote-button-bg: 169, 169, 169;
+ }
+
+ &:before {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ border-radius: 12px;
+ transition: all 0.4s ease-in-out;
+ z-index: 0;
+ background-color: rgb(var(--vote-button-bg));
+ ${({ percentage }) => `
+ min-width: ${percentage && percentage > 5 ? `${percentage}%` : "5px"};
+ `}
+ }
+
+ &:after {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ border-radius: 12px;
+ transition: all 0.4s ease-in-out;
+ z-index: 1;
+ background-color: var(--vote-button-bg);
+
+ min-width: ${({ percentage }) =>
+ percentage && percentage > 5 ? `${percentage}%` : "5px"};
+
+ ${({ finished, wins }) =>
+ finished &&
+ wins &&
+ `
+ display: none;
+ `}
+ }
+
+ ${({ disabled }) =>
+ !disabled &&
+ `
+ &:hover {
+ &:before {
+ min-width: 100%;
+ }
+ }
+ `}
+
+ & > div {
+ z-index: 2;
+ }
+
+ & > div:last-child span {
+ display: block;
+ font-size: 15px;
+ font-weight: 600;
+ line-height: 1.4;
+
+ &:last-child {
+ font-size: 12px;
+ font-weight: 400;
+ }
+ }
+ `;
+
+ const getPercentage = (vote) => {
+ const percentage = Math.round((vote / totalVotesNeeded) * 100);
+ return percentage || 0;
+ };
+
+ const percentages = {
+ yes: getPercentage(totalVotes.yes),
+ no: getPercentage(totalVotes.no),
+ spam: getPercentage(totalVotes.spam),
+ abstain: getPercentage(totalVotes.abstain)
+ };
+
+ const wins = {
+ yes: status === "Approved",
+ no: status === "Rejected",
+ spam: status === "Failed" || status === "Spam"
+ };
+
+ const voted = {
+ yes: checkVotes("Approve"),
+ no: checkVotes("Reject"),
+ spam: checkVotes("Remove")
+ };
+
+ const alreadyVoted = voted.yes || voted.no || voted.spam || voted.abstain;
+
+ const VotePercentage = ({ vote }) => (
+
+
+ {percentages[vote]}
+
+
+
+ {totalVotes[vote]} {totalVotes[vote] === 1 ? "Vote" : "Votes"}
+
+
+ );
+
+ return (
+
+
+ {voted.yes &&
}
+
handleVote("VoteApprove")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[0]}
+ >
+
+ {wins.yes && (
+
+
+
+ )}
+ Approve
+
+
+
+
+
+ {voted.no &&
}
+
handleVote("VoteReject")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[1]}
+ >
+
+ {wins.no && (
+
+
+
+ )}
+ Reject
+
+
+
+
+
+
+ {voted.spam &&
}
+
handleVote("VoteRemove")}
+ disabled={alreadyVoted || finished || !isAllowedToVote[2]}
+ >
+
+ Spam
+
+
+
+
+
+ );
+}
+
+function renderFooter({ totalVotes, votes, comments, daoId, proposal }) {
+ const items = [
+ {
+ title: "Comments",
+ icon: "bi bi-chat-left-text",
+ count: comments.length || 0,
+ widget: "Common.Modals.Comments",
+ props: {
+ daoId,
+ proposal,
+ commentsCount: comments.length,
+ item: {
+ type: "dao_proposal_comment",
+ path: `${daoId}/proposal/main`,
+ proposal_id: proposal.id + "-beta"
+ }
+ }
+ },
+ {
+ title: "Voters",
+ icon: "bi bi-people",
+ count: totalVotes.total,
+ widget: "Common.Modals.Voters",
+ props: {
+ daoId,
+ votes,
+ totalVotes,
+ proposalId: proposal.id,
+ votersCount: totalVotes.total
+ }
+ },
+ {
+ title: "Share",
+ icon: "bi bi-share",
+ widget: "Common.Modals.Share",
+ props: {
+ url: `https://near.org/buildhub.near/widget/Proposals?daoId=${daoId}&proposalId=${
+ proposalData.id
+ }${props.dev ? "&dev=true" : ""}`,
+ text: "Explore this new proposal from our DAO! Your support and feedback are essential as we work towards a decentralized future. Review the details and join the discussion here:"
+ }
+ }
+ ];
+
+ if (proposal.typeName !== "Text") {
+ items.push({
+ title: "More details",
+ icon: "bi bi-three-dots",
+ widget: "Common.Modals.ProposalArguments",
+ props: {
+ daoId,
+ proposal,
+ showCard: true
+ }
+ });
+ }
+
+ const renderModal = (item, index) => {
+ return (
+
+ ),
+ toggle: (
+
+
+ {item.count && {item.count} }
+ {item.title}
+
+ ),
+ toggleContainerProps: {
+ className: "flex-fill"
+ }
+ }}
+ />
+ );
+ };
+
+ return (
+
+ {items.map(renderModal)}
+
+ );
+}
+
+const voted = {
+ yes: checkVotes("Approve"),
+ no: checkVotes("Reject"),
+ spam: checkVotes("Remove"),
+ abstain: checkVotes("Abstain")
+};
+
+const alreadyVoted = voted.yes || voted.no || voted.spam;
+
+const canVote =
+ isAllowedToVote.every((v) => v) && status === "In Progress" && !alreadyVoted;
+
+return (
+
+ {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
+ {renderHeader({ typeName, id, daoId, status })}
+ {renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+ })}
+ {renderVoteButtons({
+ totalVotes,
+ status,
+ votes,
+ accountId,
+ isAllowedToVote,
+ handleVote: (action) => {
+ return handleVote({
+ action,
+ proposalId: id,
+ proposer
+ });
+ }
+ })}
+ {renderFooter({
+ totalVotes,
+ votes,
+ comments,
+ daoId,
+ proposal: proposalData
+ })}
+
+);
From 3334b2f563b3e67e5bbc2ccbcc9179eda5547709 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:34:50 +0530
Subject: [PATCH 073/132] minor css updates
---
apps/builddao/widget/components/ProposalCard.jsx | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index 4ea759d2..52719412 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -103,17 +103,16 @@ const Wrapper = styled.div`
color: #51b6ff !important;
}
- // TODO
.danger {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid rgba(253, 42, 92, 0.1);
+ background: rgba(253, 42, 92, 0.1);
+ color: #fd2a5c !important;
}
.black {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ background: rgba(255, 255, 255, 0.1);
+ color: #fff !important;
}
.word-wrap {
From a848323d6ed9672c68121e65d3fcbe09e40a1d0d Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Mon, 29 Jan 2024 08:24:21 +0500
Subject: [PATCH 074/132] Rename ProposeModal.jsx to CreateProposal.jsx
---
apps/builddao/widget/components/Post.jsx | 2 +-
.../components/modals/{ProposeModal.jsx => CreateProposal.jsx} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename apps/builddao/widget/components/modals/{ProposeModal.jsx => CreateProposal.jsx} (100%)
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 126a1aeb..7166bcad 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -297,7 +297,7 @@ return (
<>
{props.feedType === "request" && (
Date: Mon, 29 Jan 2024 08:27:35 +0500
Subject: [PATCH 075/132] Add Proposal description for Add and Remove Member
options of proposal
---
.../components/modals/propose/AddMember.jsx | 160 +++++++++++++++++-
.../modals/propose/RemoveMember.jsx | 160 +++++++++++++++++-
2 files changed, 318 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index a8f95e33..9b89e91c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -6,6 +6,144 @@ const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
return (
@@ -36,6 +174,26 @@ return (
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
Near.call(selectedDAO, "add_proposal", {
proposal: {
- description: "Potential member",
+ description: text,
kind: {
AddMemberToRole: {
member_id: accountId,
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
index a9490e50..3b502c15 100644
--- a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -6,6 +6,144 @@ const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const [text, setText] = useState("");
+const [editorKey, setEditorKey] = useState(0);
+useEffect(() => {
+ const { path, blockHeight } = props.item;
+ setText(`[EMBED](${path}@${blockHeight})`);
+ setEditorKey((editorKey) => editorKey + 1);
+}, [props.item]);
+const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+
+const MarkdownEditor = `
+ html {
+ background: #23242b;
+ }
+
+ * {
+ border: none !important;
+ }
+
+ .rc-md-editor {
+ background: #4f5055;
+ border-top: 1px solid #4f5055 !important;
+ border-radius: 8px;
+ }
+
+ .editor-container {
+ background: #4f5055;
+ }
+
+ .drop-wrap {
+ top: -110px !important;
+ border-radius: 0.5rem !important;
+ }
+
+ .header-list {
+ display: flex;
+ align-items: center;
+ }
+
+ textarea {
+ background: #23242b !important;
+ color: #fff !important;
+
+ font-family: sans-serif !important;
+ font-size: 1rem;
+
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-navigation {
+ background: #23242b !important;
+ border: 1px solid #4f5055 !important;
+ border-top: 0 !important;
+ border-bottom: 0 !important;
+ border-radius: 8px 8px 0 0;
+
+ i {
+ color: #cdd0d5;
+ }
+ }
+
+ .editor-container {
+ border-radius: 0 0 8px 8px;
+ }
+
+ .rc-md-editor .editor-container .sec-md .input {
+ overflow-y: auto;
+ padding: 8px !important;
+ line-height: normal;
+ border-radius: 0 0 8px 8px;
+ }
+`;
+
+const TextareaWrapper = styled.div`
+ display: grid;
+ vertical-align: top;
+ align-items: center;
+ position: relative;
+ align-items: stretch;
+ width: 100%;
+
+ textarea {
+ display: flex;
+ align-items: center;
+ transition: all 0.3s ease;
+ }
+
+ textarea::placeholder {
+ padding-top: 4px;
+ font-size: 20px;
+ }
+
+ textarea:focus::placeholder {
+ font-size: inherit;
+ padding-top: 0px;
+ }
+
+ &::after,
+ textarea,
+ iframe {
+ width: 100%;
+ min-width: 1em;
+ height: unset;
+ min-height: 3em;
+ font: inherit;
+ margin: 0;
+ resize: none;
+ background: none;
+ appearance: none;
+ border: 0px solid #eee;
+ grid-area: 1 / 1;
+ overflow: hidden;
+ outline: none;
+ }
+
+ iframe {
+ padding: 0;
+ }
+
+ textarea:focus,
+ textarea:not(:empty) {
+ border-bottom: 1px solid #eee;
+ min-height: 5em;
+ }
+
+ &::after {
+ content: attr(data-value) " ";
+ visibility: hidden;
+ white-space: pre-wrap;
+ }
+ &.markdown-editor::after {
+ padding-top: 66px;
+ font-family: monospace;
+ font-size: 14px;
+ }
+`;
+
return (
@@ -40,6 +178,26 @@ return (
+
+ Proposal Description
+
+ {
+ setText(v);
+ },
+ }}
+ />
+
+
+
Near.call(selectedDAO, "add_proposal", {
proposal: {
- description: "Potential member",
+ description: text,
kind: {
RemoveMemberFromRole: {
member_id: accountId,
From 17909dcbaae1c6dab32407fb5b0fb5b88ab95c43 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Mon, 29 Jan 2024 09:04:33 +0500
Subject: [PATCH 076/132] Add Validations
---
.../components/modals/CreateProposal.jsx | 10 ++++-
.../components/modals/propose/AddMember.jsx | 27 ++++++++++++--
.../modals/propose/FunctionCall.jsx | 8 +++-
.../modals/propose/RemoveMember.jsx | 27 ++++++++++++--
.../components/modals/propose/Transfer.jsx | 37 +++++++++++++++++--
5 files changed, 93 insertions(+), 16 deletions(-)
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 57f22cb3..822a96ab 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -37,7 +37,7 @@ const StyledTypeahead = styled.div`
input,
input:focus,
.rbt-input-hint {
- background: #23242b;
+ background: #212529;
color: #fff;
&::placeholder {
@@ -47,9 +47,13 @@ const StyledTypeahead = styled.div`
border: 1px solid #434950;
}
+ .rbt-input-hint {
+ color: rgba(255, 255, 255, 0.2) !important;
+ }
+
.rbt-menu,
.dropdown-item {
- background: #23242b;
+ background: #212529;
color: #fff;
}
`;
@@ -153,6 +157,7 @@ return (
props={{
roles: roles,
selectedDAO: selectedDAO,
+ item: props.item,
}}
/>
>
@@ -164,6 +169,7 @@ return (
props={{
roles: roles,
selectedDAO: selectedDAO,
+ item: props.item,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 9b89e91c..818b3f0c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -14,6 +14,16 @@ useEffect(() => {
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const [validatedAddresss, setValidatedAddresss] = useState(true);
+
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(accountId) || accountId === "") {
+ setValidatedAddresss(true);
+ } else {
+ setValidatedAddresss(false);
+ }
+});
const MarkdownEditor = `
html {
@@ -147,7 +157,9 @@ const TextareaWrapper = styled.div`
return (
- Account ID
+
+ Account ID*
+
setAccountId(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
-
Role
+
+ Role*
+
setRole(e.target.value)}
selected={role}
>
- Select a role
+ Select a role
{roles.length > 0 &&
roles.map((role) => {role} )}
@@ -198,7 +217,7 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index efb5932d..8b653cfa 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -149,7 +149,9 @@ const TextareaWrapper = styled.div`
return (
- Contract
+
+ Contract*
+
-
Method
+
+ Method*
+
{
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
+const [validatedAddresss, setValidatedAddresss] = useState(true);
+
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(accountId) || accountId === "") {
+ setValidatedAddresss(true);
+ } else {
+ setValidatedAddresss(false);
+ }
+});
const MarkdownEditor = `
html {
@@ -147,7 +157,9 @@ const TextareaWrapper = styled.div`
return (
- Account ID
+
+ Account ID*
+
setAccountId(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
-
Role
+
+ Role*
+
setRole(e.target.value)}
selected={role}
>
- Select a role
+ Select a role
{roles.length > 0 &&
roles.map((role) => (
@@ -202,7 +221,7 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index 4e184e9d..07cfc31c 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -5,6 +5,7 @@ const [recipient, setRecipient] = useState("");
const [token, setToken] = useState("");
const [amount, setAmount] = useState(0);
const [description, setDescription] = useState("");
+const [validatedAddresss, setValidatedAddress] = useState(true);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -16,6 +17,22 @@ useEffect(() => {
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
const selectedDao = props.selectedDao;
+// handle checking
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(recipient) || recipient === "") {
+ setValidatedAddress(true);
+ } else {
+ setValidatedAddress(false);
+ }
+}, [recipient]);
+
+useEffect(() => {
+ if (amount < 0) {
+ setAmount(0);
+ }
+}, [amount]);
+
const MarkdownEditor = `
html {
background: #23242b;
@@ -148,18 +165,28 @@ const TextareaWrapper = styled.div`
return (
- Recipient
+
+ Recipient*
+
setRecipient(e.target.value)}
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
- Token
+
+ Token*
+
setToken(e.target.value)}
>
- Select a token
+ Select a token
NEAR
ETH
USDC
@@ -177,7 +204,9 @@ return (
-
Amount
+
+ Amount*
+
Date: Mon, 29 Jan 2024 16:38:55 +0530
Subject: [PATCH 077/132] minor fixes
---
.prettierrc.json | 6 ++++++
apps/builddao/widget/Proposals.jsx | 2 +-
.../components/modals/propose/AddMember.jsx | 13 ++++++++-----
.../components/modals/propose/FunctionCall.jsx | 17 ++++++++++-------
.../components/modals/propose/RemoveMember.jsx | 13 ++++++++-----
.../widget/components/modals/propose/Text.jsx | 9 ++++++---
.../components/modals/propose/Transfer.jsx | 13 ++++++++-----
7 files changed, 47 insertions(+), 26 deletions(-)
create mode 100644 .prettierrc.json
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 00000000..daa2aef0
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,6 @@
+{
+ "trailingComma": "none",
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": false
+}
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 0ad5aa1e..8d6923cc 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -219,7 +219,7 @@ const ProposalsComponent = () => {
return (
setShowModal(!showProposalModal)
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 818b3f0c..266926df 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -9,6 +9,9 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -207,7 +210,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -225,10 +228,10 @@ return (
kind: {
AddMemberToRole: {
member_id: accountId,
- role: role,
- },
- },
- },
+ role: role
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 8b653cfa..2d661c87 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -10,6 +10,9 @@ const [deposit, useDeposit] = useState(0);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -223,7 +226,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -245,12 +248,12 @@ return (
method_name: method,
args: args,
deposit: deposit,
- gas: gas,
- },
- ],
- },
- },
- },
+ gas: gas
+ }
+ ]
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
index 798ccc3a..c8134e27 100644
--- a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -9,6 +9,9 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -211,7 +214,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -229,10 +232,10 @@ return (
kind: {
RemoveMemberFromRole: {
member_id: accountId,
- role: role,
- },
- },
- },
+ role: role
+ }
+ }
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
index 95ee37d4..29633005 100644
--- a/apps/builddao/widget/components/modals/propose/Text.jsx
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -4,6 +4,9 @@ const { Button } =
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -155,7 +158,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -167,8 +170,8 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
description: text,
- kind: "Vote",
- },
+ kind: "Vote"
+ }
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index 07cfc31c..b132e97e 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -10,6 +10,9 @@ const [validatedAddresss, setValidatedAddress] = useState(true);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
useEffect(() => {
+ if (!props.item) {
+ return;
+ }
const { path, blockHeight } = props.item;
setText(`[EMBED](${path}@${blockHeight})`);
setEditorKey((editorKey) => editorKey + 1);
@@ -231,7 +234,7 @@ return (
embedCss: MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -249,10 +252,10 @@ return (
Transfer: {
token_id: token,
reciever_id: recipient,
- amount: amount,
- },
- },
- },
+ amount: amount
+ }
+ }
+ }
})
}
>
From cd63a338ca2f9f11b1891113f97f9070c94a918a Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:42:18 +0530
Subject: [PATCH 078/132] remove prettier
---
.prettierrc.json | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 .prettierrc.json
diff --git a/.prettierrc.json b/.prettierrc.json
deleted file mode 100644
index daa2aef0..00000000
--- a/.prettierrc.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "trailingComma": "none",
- "tabWidth": 2,
- "semi": true,
- "singleQuote": false
-}
From ff9925b2bc1ad87db70cece5da3c3230b07ef522 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 16:43:43 +0530
Subject: [PATCH 079/132] remove logs
---
apps/builddao/widget/Proposals.jsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 8d6923cc..666fa85e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -99,7 +99,6 @@ if (Array.isArray(policy.roles)) {
}
const proposalPeriod = policy.proposal_period;
-console.log(policy);
const ProposalsComponent = () => {
return (
From f7e11ab920651cc2e803a171b3daa82579f17dbd Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Mon, 29 Jan 2024 23:46:09 +0530
Subject: [PATCH 080/132] add theme support
---
apps/builddao/widget/Proposals.jsx | 215 ++++++++----------
apps/builddao/widget/components.jsx | 4 +-
.../builddao/widget/components/Pagination.jsx | 82 ++++---
.../widget/components/ProposalCard.jsx | 192 +++++++++-------
4 files changed, 252 insertions(+), 241 deletions(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 666fa85e..238d89a9 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -29,19 +29,44 @@ const proposals = proposalId
limit: resPerPage
}) || [];
+const PaginationThemeContainer = props.PaginationThemeContainer;
+
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --primary-bg-color: #23242b;
+ --secondary-bg-color: #ffffff1a;
+ --primary-border-color: #fff;
+ --primary-text-color: #ffffff;
+ --secondary-text-color: #b0b0b0;
+ --primary-btn-bg-color: #ffaf51;
+ --primary-btn-text-color: #000;
+ --approve-bg-color: #82e299;
+ --reject-bg-color: #c23f38;
+ --spam-bg-color: #f5c518;
+ --vote-button-color: #ffffff;
+ --success-badge-bg-color: #38c7931a;
+ --success-badge-text-color: #38c793;
+ --primary-badge-bg-color: #ffaf5133;
+ --primary-badge-text-color: #ffaf51;
+ --info-badge-bg-color: #51b6ff33;
+ --info-badge-text-color: #51b6ff;
+ --danger-badge-bg-color: #fd2a5c1a;
+ --danger-badge-text-color: #fd2a5c;
+ --black-badge-bg-color: #ffffff1a;
+ --black-badge-text-color: #fff;
+ `;
+
const Container = styled.div`
.ndc-card {
border: none;
- background-color: #23242b;
- color: white !important;
+ background-color: var(--primary-bg-color);
+ color: var(--primary-text-color) !important;
padding: 2rem;
}
`;
const handleVote = ({ action, proposalId, proposer }) => {
- let args = {};
- args["id"] = JSON.parse(proposalId);
- args["action"] = action;
const customAction = action.replace("Vote", "");
const notification = {
[accountId]: {
@@ -63,22 +88,23 @@ const handleVote = ({ action, proposalId, proposer }) => {
}
}
};
- Near.call([
- {
- contractName: daoId,
- methodName: "act_proposal",
- args: args,
- gas: 200000000000000
- },
- {
- contractName: "social.near",
- methodName: "set",
- args: { data: notification },
- deposit: Big(JSON.stringify(notification).length * 16).mul(
- Big(10).pow(20)
- )
- }
- ]);
+
+ sdk.actProposal({
+ proposalId,
+ action,
+ deposit: "",
+ gas: 200000000000000,
+ additionalCalls: [
+ {
+ contractName: "social.near",
+ methodName: "set",
+ args: { data: notification },
+ deposit: Big(JSON.stringify(notification).length * 16).mul(
+ Big(10).pow(20)
+ )
+ }
+ ]
+ });
};
const policy = sdk.getPolicy();
@@ -110,84 +136,34 @@ const ProposalsComponent = () => {
? item.kind
: Object.keys(item.kind)[0];
- const comments = Social.index("comment", {
- type: "dao_proposal_comment",
- path: `${daoId}/proposal/main`,
- proposal_id: item.id + "-beta"
- });
- const permissionKind = proposalKinds[kindName];
- let totalVotesNeeded = 0;
+ const comments = sdk.getCommentsByProposalId({ proposalId: item.id });
+
const isAllowedToVote = [
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteApprove
}),
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteReject
}),
sdk.hasPermission({
accountId,
- permissionKind,
+ kindName,
actionType: actions.VoteRemove
})
];
- policy.roles.forEach((role) => {
- const isRoleAllowedToVote =
- role.permissions.includes(
- `${proposalKinds[kindName]}:VoteApprove`
- ) ||
- role.permissions.includes(
- `${proposalKinds[kindName]}:VoteReject`
- ) ||
- role.permissions.includes(`${proposalKinds[kindName]}:*`) ||
- role.permissions.includes(`*:VoteApprove`) ||
- role.permissions.includes(`*:VoteReject`) ||
- role.permissions.includes("*:*");
- if (isRoleAllowedToVote) {
- const threshold = (role.vote_policy &&
- role.vote_policy[proposalKinds[kindName]]?.threshold) ||
- policy["default_vote_policy"]?.threshold || [0, 0];
- const eligibleVoters = role.kind.Group
- ? role.kind.Group.length
- : 0;
-
- // Apply the threshold
- if (eligibleVoters === 0) {
- return;
- }
-
- const votesNeeded =
- Math.floor((threshold[0] / threshold[1]) * eligibleVoters) + 1;
- console.log(item.id, "votesNeeded", votesNeeded);
- totalVotesNeeded += votesNeeded;
- }
+ const { thresholdVoteCount } = getVotersAndThresholdForProposalKind({
+ kindName
+ });
+ const totalVotes = calculateVoteCountByType({ votes: item.votes });
+ let expirationTime = sdk.getProposalExpirationTime({
+ submissionTime: item.submission_time
});
-
- let totalVotes = {
- yes: 0,
- no: 0,
- spam: 0,
- total: 0
- };
- for (const vote of Object.values(item.votes)) {
- if (vote === "Approve") {
- totalVotes.yes++;
- } else if (vote === "Reject") {
- totalVotes.no++;
- } else if (vote === "Spam") {
- totalVotes.spam++;
- }
- }
- totalVotes.total = totalVotes.yes + totalVotes.no + totalVotes.spam;
-
- let expirationTime = Big(item.submission_time).add(
- Big(proposalPeriod)
- );
return (
{
proposalData: {
...item,
typeName: kindName.replace(/([A-Z])/g, " $1").trim(),
- totalVotesNeeded,
- totalVotes,
+ totalVotesNeeded: thresholdVoteCount,
+ totalVotes: {
+ ...totalVotes,
+ yes: totalVotes.approve,
+ no: totalVotes.reject
+ },
expirationTime
},
daoId: daoId,
@@ -216,39 +196,38 @@ const ProposalsComponent = () => {
};
return (
-
- setShowModal(!showProposalModal)
- }}
- />
-
-
Proposals
- setShowModal(true)}>
- Create Proposal
-
-
-
- {!proposalId && (
-
-
0,
- hasNext: proposals?.[0].id !== resPerPage,
- onPrev: () => {
- setCurrentPage(currentPage - 1);
- },
- onNext: () => {
- setCurrentPage(currentPage + 1);
- }
- }}
- />
+
+
+ setShowModal(!showProposalModal)
+ }}
+ />
+
+
Proposals
+ setShowModal(true)}>
+ Create Proposal
+
- )}
-
+
+ {!proposalId && (
+
+ setCurrentPage(v),
+ selectedPage: currentPage,
+ ThemeContainer: PaginationThemeContainer
+ }}
+ />
+
+ )}
+
+
);
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index f01cde64..d3cf4b9f 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -19,6 +19,7 @@ function Pagination({
maxVisiblePages,
onPageClick,
selectedPage,
+ ThemeContainer
}) {
return (
);
@@ -59,5 +61,5 @@ return {
TextEditor,
Checkbox,
Avatar,
- User,
+ User
};
diff --git a/apps/builddao/widget/components/Pagination.jsx b/apps/builddao/widget/components/Pagination.jsx
index 5e39fb73..8e0a109e 100644
--- a/apps/builddao/widget/components/Pagination.jsx
+++ b/apps/builddao/widget/components/Pagination.jsx
@@ -4,9 +4,18 @@ const onPageClick = props.onPageClick
? props.onPageClick
: () => console.log("clicked");
const pagesToShow = Math.min(totalPages, maxVisiblePages);
-const [selectedPage, setSelectedPage] = useState(props.selectedPage ?? 11);
+const selectedPage = props.selectedPage === 0 ? 1 : props.selectedPage;
const totalPageSets = Math.ceil(totalPages / maxVisiblePages);
-const [currentPageSet, setCurrentPageSet] = useState(totalPageSets);
+const [currentPageSet, setCurrentPageSet] = useState(1);
+
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --font-color: #fff;
+ --bg-color: none;
+ --selected-bg-color: #23242b;
+ --arrow-stroke-color: #ffffff1a;
+ `;
const Pagination = styled.div`
display: flex;
@@ -21,9 +30,10 @@ const Pagination = styled.div`
align-items: center;
gap: 10px;
border-radius: 8px;
- color: var(--font-color, #fff);
+ color: var(--font-color);
transition: all 300ms;
cursor: pointer;
+ background-color: var(--bg-color);
/* Other/Button_text */
font-size: 14px;
@@ -33,11 +43,11 @@ const Pagination = styled.div`
&.selected,
&:hover {
- background-color: var(--bg-1, #23242b);
+ background-color: var(--selected-bg-color);
}
&.arrow {
- border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ border: 1px solid var(--arrow-stroke-color);
}
&.disabled {
@@ -64,34 +74,36 @@ const getPageNumber = (index) =>
(currentPageSet - 1) * maxVisiblePages + index + 1;
return (
-
- handleArrowClick("left")}
- >
-
-
- {Array.from({ length: pagesToShow }).map((_, index) => {
- const pageNumber = getPageNumber(index);
- return (
- handlePageClick(pageNumber)}
- >
- {pageNumber}
-
- );
- })}
- handleArrowClick("right")}
- >
-
-
-
+
+
+ handleArrowClick("left")}
+ >
+
+
+ {Array.from({ length: pagesToShow }).map((_, index) => {
+ const pageNumber = getPageNumber(index);
+ return (
+ handlePageClick(pageNumber)}
+ >
+ {pageNumber}
+
+ );
+ })}
+ handleArrowClick("right")}
+ >
+
+
+
+
);
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index 52719412..a2fe30bf 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -14,6 +14,32 @@ const {
const { daoId, isAllowedToVote, handleVote, comments, proposalData } = props;
const accountId = context.accountId;
+const ThemeContainer =
+ props.ThemeContainer ||
+ styled.div`
+ --primary-bg-color: #23242b;
+ --secondary-bg-color: #ffffff1a;
+ --primary-border-color: #fff;
+ --primary-text-color: #ffffff;
+ --secondary-text-color: #b0b0b0;
+ --primary-btn-bg-color: #ffaf51;
+ --primary-btn-text-color: #000;
+ --approve-bg-color: #82e299;
+ --reject-bg-color: #c23f38;
+ --spam-bg-color: #f5c518;
+ --vote-button-color: #ffffff;
+ --success-badge-bg-color: #38c7931a;
+ --success-badge-text-color: #38c793;
+ --primary-badge-bg-color: #ffaf5133;
+ --primary-badge-text-color: #ffaf51;
+ --info-badge-bg-color: #51b6ff33;
+ --info-badge-text-color: #51b6ff;
+ --danger-badge-bg-color: #fd2a5c1a;
+ --danger-badge-text-color: #fd2a5c;
+ --black-badge-bg-color: #ffffff1a;
+ --black-badge-text-color: #fff;
+ `;
+
function checkVotes(value) {
return votes[accountId] === value;
}
@@ -27,41 +53,37 @@ const Wrapper = styled.div`
gap: 24px;
min-height: 500px;
width: 100%;
- border: 1px solid #fff;
+ border: 1px solid var(--primary-border-color);
b {
font-weight: 600;
}
- .grey-bg {
- background: rgba(255, 255, 255, 0.1) !important;
- }
-
- .light-grey-text {
- color: rgba(176, 176, 176, 1) !important;
+ .secondary-bg {
+ background: var(--secondary-bg-color) !important;
}
- .text-muted {
- color: rgba(176, 176, 176, 1) !important;
+ .secondary-text {
+ color: var(--secondary-text-color) !important;
}
a {
- background: rgba(255, 255, 255, 0.1) !important;
- color: white !important;
+ background: var(--secondary-bg-color) !important;
+ color: var(--primary-text-color) !important;
}
.social_url {
- background: rgba(255, 255, 255, 0.1) !important;
- color: white !important;
+ background: var(--secondary-bg-color) !important;
}
.btn-primary {
- background-color: #ffaf51 !important;
- color: black !important;
+ background-color: var(--primary-btn-bg-color) !important;
+ color: var(--primary-btn-text-color) !important;
+ border: none;
}
ul {
- background-color: #23242b;
+ background-color: var(--primary-bg-color);
}
.Approve {
@@ -86,33 +108,33 @@ const Wrapper = styled.div`
}
.success {
- border: 1px solid rgba(56, 199, 147, 0.2) !important;
- background: rgba(56, 199, 147, 0.1) !important;
- color: #38c793 !important;
+ border: 1px solid var(--success-badge-bg-color) !important;
+ background: var(--success-badge-bg-color) !important;
+ color: var(--success-badge-text-color) !important;
}
.primary {
- border: 1px solid rgba(255, 175, 81, 0.2) !important;
- background: rgba(255, 175, 81, 0.2) !important;
- color: #ffaf51 !important;
+ border: 1px solid var(--primary-badge-bg-color) !important;
+ background: var(--primary-badge-bg-color) !important;
+ color: var(--primary-badge-text-color) !important;
}
.info {
- border: 1px solid rgba(81, 182, 255, 0.2) !important;
- background: rgba(81, 182, 255, 0.2) !important;
- color: #51b6ff !important;
+ border: 1px solid var(--info-badge-bg-color) !important;
+ background: var(--info-badge-bg-color) !important;
+ color: var(--info-badge-text-color) !important;
}
.danger {
- border: 1px solid rgba(253, 42, 92, 0.1);
- background: rgba(253, 42, 92, 0.1);
- color: #fd2a5c !important;
+ border: 1px solid var(--danger-badge-bg-color) !important;
+ background: var(--danger-badge-bg-color) !important;
+ color: var(--danger-badge-text-color) !important;
}
.black {
- border: 1px solid rgba(255, 255, 255, 0.1);
- background: rgba(255, 255, 255, 0.1);
- color: #fff !important;
+ border: 1px solid var(--black-badge-bg-color) !important;
+ background: var(--black-badge-bg-color) !important;
+ color: var(--black-badge-text-color) !important;
}
.word-wrap {
@@ -122,7 +144,7 @@ const Wrapper = styled.div`
${({ status }) =>
status === "Approved" &&
`
- border-color: #82E299;
+ border-color: var(--approve-bg-color);
`}
${({ status }) =>
@@ -134,7 +156,7 @@ const Wrapper = styled.div`
${({ status }) =>
(status === "Failed" || status === "Rejected") &&
`
- border-color: #C23F38;
+ border-color: var(--reject-bg-color);
`}
.text-sm {
@@ -184,7 +206,7 @@ const YouVotedBadge = () => {
function renderPermission({ isAllowedToVote }) {
return (
-
+
{isAllowedToVote
? "You are allowed to vote on this proposal"
: "You are not allowed to vote on this proposal"}
@@ -246,7 +268,7 @@ function renderHeader({ typeName, id, status }) {
props={{
children: `Proposal ID #${id}`,
variant: "",
- className: "grey-bg",
+ className: "secondary-bg",
size: "lg"
}}
/>
@@ -314,7 +336,7 @@ function renderData({
Proposer
-
+
Description
-
@@ -339,7 +361,7 @@ function renderData({
Submitted at
-
+
{new Date(
parseInt(Big(submission_time).div(1000000))
).toLocaleString()}
@@ -351,7 +373,7 @@ function renderData({
Expired at
-
+
{new Date(
parseInt(Big(expirationTime).div(1000000))
).toLocaleString()}
@@ -362,7 +384,7 @@ function renderData({
Required Votes
- {totalVotesNeeded}
+ {totalVotesNeeded}
@@ -388,13 +410,11 @@ function renderVoteButtons({
align-items: center;
position: relative;
overflow: hidden;
- color: rgb(var(--vote-button-color));
- background-color: rgba(255, 255, 255, 0.10);
- --vote-button-bg: 130, 226, 153;
- --vote-button-color: 255, 255, 255;
-
+ color: var(--vote-button-color);
+ background-color: var(--secondary-bg-color);
+ --vote-button-bg: var(--approve-bg-color);
&.no {
- --vote-button-bg: 194, 63, 56;
+ --vote-button-bg: var(--reject-bg-color);
}
&.no > div:last-child {
@@ -405,27 +425,23 @@ function renderVoteButtons({
if (percentage > 80) {
return `
&.no > div:last-child {
- color: rgb(var(--vote-button-color)) !important;
+ color: var(--vote-button-color) !important;
}
`;
}
} else if (!disabled) {
return `
&:hover.no > div:last-child {
- color: rgb(var(--vote-button-color)) !important;
+ color: var(--vote-button-color) !important;
}
`;
}
}}}
&.spam {
- --vote-button-bg: 245, 197, 24;
+ --vote-button-bg: var(--spam-bg-color);
}
- &.abstain {
- --vote-button-bg: 169, 169, 169;
- }
-
&:before {
content: "";
position: absolute;
@@ -435,7 +451,7 @@ function renderVoteButtons({
border-radius: 12px;
transition: all 0.4s ease-in-out;
z-index: 0;
- background-color: rgb(var(--vote-button-bg));
+ background-color: var(--vote-button-bg);
${({ percentage }) => `
min-width: ${percentage && percentage > 5 ? `${percentage}%` : "5px"};
`}
@@ -544,7 +560,7 @@ function renderVoteButtons({
wins={wins.yes}
myVote={voted.yes}
onClick={() => handleVote("VoteApprove")}
- disabled={alreadyVoted || finished || !isAllowedToVote[0]}
+ // disabled={alreadyVoted || finished || !isAllowedToVote[0]}
>
{wins.yes && (
@@ -673,7 +689,7 @@ function renderFooter({ totalVotes, votes, comments, daoId, proposal }) {
@@ -710,35 +726,37 @@ const canVote =
isAllowedToVote.every((v) => v) && status === "In Progress" && !alreadyVoted;
return (
-
- {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
- {renderHeader({ typeName, id, daoId, status })}
- {renderData({
- proposer,
- description,
- submission_time,
- totalVotesNeeded
- })}
- {renderVoteButtons({
- totalVotes,
- status,
- votes,
- accountId,
- isAllowedToVote,
- handleVote: (action) => {
- return handleVote({
- action,
- proposalId: id,
- proposer
- });
- }
- })}
- {renderFooter({
- totalVotes,
- votes,
- comments,
- daoId,
- proposal: proposalData
- })}
-
+
+
+ {renderPermission({ isAllowedToVote: isAllowedToVote.every((v) => v) })}
+ {renderHeader({ typeName, id, daoId, status })}
+ {renderData({
+ proposer,
+ description,
+ submission_time,
+ totalVotesNeeded
+ })}
+ {renderVoteButtons({
+ totalVotes,
+ status,
+ votes,
+ accountId,
+ isAllowedToVote,
+ handleVote: (action) => {
+ return handleVote({
+ action,
+ proposalId: id,
+ proposer
+ });
+ }
+ })}
+ {renderFooter({
+ totalVotes,
+ votes,
+ comments,
+ daoId,
+ proposal: proposalData
+ })}
+
+
);
From b335d19a11d7c4951612438e41344d435fcaa6c7 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Tue, 30 Jan 2024 01:38:38 +0530
Subject: [PATCH 081/132] fix sdk method
---
apps/builddao/widget/Proposals.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 238d89a9..e4fccf8e 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -157,10 +157,10 @@ const ProposalsComponent = () => {
})
];
- const { thresholdVoteCount } = getVotersAndThresholdForProposalKind({
+ const { thresholdVoteCount } = sdk.getVotersAndThresholdForProposalKind({
kindName
});
- const totalVotes = calculateVoteCountByType({ votes: item.votes });
+ const totalVotes = sdk.calculateVoteCountByType({ votes: item.votes });
let expirationTime = sdk.getProposalExpirationTime({
submissionTime: item.submission_time
});
From 7c5b3a46f86e95fc649b456a82eb5541ea939f28 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:20:29 +0500
Subject: [PATCH 082/132] Add css variables and props for custom styling
---
apps/builddao/widget/components/Modal.jsx | 6 ++--
.../components/modals/CreateProposal.jsx | 14 ++++++++-
.../components/modals/propose/AddMember.jsx | 18 +++++++-----
.../modals/propose/FunctionCall.jsx | 29 ++++++++++---------
.../modals/propose/RemoveMember.jsx | 18 +++++++-----
.../components/modals/propose/Transfer.jsx | 20 +++++++------
6 files changed, 63 insertions(+), 42 deletions(-)
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx
index 65d551f5..62c857ce 100644
--- a/apps/builddao/widget/components/Modal.jsx
+++ b/apps/builddao/widget/components/Modal.jsx
@@ -14,7 +14,7 @@ const Overlay = styled.div`
z-index: 1000;
width: 100vw;
height: 100vh;
- background: rgba(11, 12, 20, 0.5);
+ background: var(--modal-overlay-color, rgba(11, 12, 20, 0.5));
`;
const Content = styled.div`
@@ -22,9 +22,9 @@ const Content = styled.div`
max-width: 1000px;
padding: 24px;
outline: none !important;
- background: #23242b;
+ background: var(--modal-background-color, #23242b);
border-radius: 16px;
- color: white;
+ color: var(--modal-text-color, #fff);
@media screen and (max-width: 768px) {
width: 80%;
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 822a96ab..a32f224f 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -15,6 +15,9 @@ const { Modal, Button, User } = VM.require(
const showModal = props.showModal;
const toggleModal = props.toggleModal;
const toggle = props.toggle;
+const bootstrapTheme = props.bootstrapTheme || "dark";
+const editorCSS = props.editorCSS;
+
if (!showModal) {
return "";
}
@@ -102,7 +105,7 @@ return (
setSelectedOption(e.target.value)}
value={selectedOption}
@@ -124,6 +127,7 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
}}
/>
>
@@ -135,6 +139,8 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -146,6 +152,8 @@ return (
props={{
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -158,6 +166,8 @@ return (
roles: roles,
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
@@ -170,6 +180,8 @@ return (
roles: roles,
selectedDAO: selectedDAO,
item: props.item,
+ bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index 266926df..ae08e83c 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -8,6 +8,8 @@ const selectedDAO = props.selectedDAO;
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
+
+const bootstrapTheme = props.bootstrapTheme;
useEffect(() => {
if (!props.item) {
return;
@@ -167,7 +169,7 @@ return (
name="accountId"
id="accountId"
className="form-control"
- data-bs-theme="dark"
+ data-bs-theme={bootstrapTheme}
value={accountId}
onChange={(e) => setAccountId(e.target.value)}
/>
@@ -185,7 +187,7 @@ return (
setRole(e.target.value)}
selected={role}
@@ -207,10 +209,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -228,10 +230,10 @@ return (
kind: {
AddMemberToRole: {
member_id: accountId,
- role: role
- }
- }
- }
+ role: role,
+ },
+ },
+ },
})
}
>
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 2d661c87..7ed6ca9b 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -9,6 +9,9 @@ const [deposit, useDeposit] = useState(0);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
+
+const bootstrapTheme = props.bootstrapTheme;
+
useEffect(() => {
if (!props.item) {
return;
@@ -158,7 +161,7 @@ return (
setContract(e.target.value)}
className="form-control"
@@ -171,7 +174,7 @@ return (
setMethod(e.target.value)}
className="form-control"
@@ -182,7 +185,7 @@ return (
@@ -231,10 +233,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -252,10 +254,10 @@ return (
Transfer: {
token_id: token,
reciever_id: recipient,
- amount: amount
- }
- }
- }
+ amount: amount,
+ },
+ },
+ },
})
}
>
From 44fec7800ed0a2ec219171d657fa379b3e541d7b Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:22:55 +0500
Subject: [PATCH 083/132] Add missing prop to text widget
---
apps/builddao/widget/components/modals/CreateProposal.jsx | 1 +
apps/builddao/widget/components/modals/propose/Text.jsx | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index a32f224f..68b433c2 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -128,6 +128,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
+ customCSS: editorCSS,
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
index 29633005..a786f840 100644
--- a/apps/builddao/widget/components/modals/propose/Text.jsx
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -155,10 +155,10 @@ return (
src="mob.near/widget/MarkdownEditorIframe"
props={{
initialText: text,
- embedCss: MarkdownEditor,
+ embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- }
+ },
}}
/>
@@ -170,8 +170,8 @@ return (
Near.call(selectedDAO, "add_proposal", {
proposal: {
description: text,
- kind: "Vote"
- }
+ kind: "Vote",
+ },
})
}
>
From d43fad0d53862a666735da0fb7c0fb0918bf3c20 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 01:37:31 +0500
Subject: [PATCH 084/132] Add proposals widget to route
---
apps/builddao/widget/Proposals.jsx | 59 ++++++++++---------
apps/builddao/widget/config.jsx | 4 +-
.../page/{proposal.jsx => proposals.jsx} | 4 +-
3 files changed, 35 insertions(+), 32 deletions(-)
rename apps/builddao/widget/page/{proposal.jsx => proposals.jsx} (54%)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index e4fccf8e..37ba6e54 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -1,5 +1,5 @@
const { Button } = VM.require("buildhub.near/widget/components.Button") || {
- Button: <>>
+ Button: <>>,
};
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
@@ -18,15 +18,15 @@ const lastProposalId = sdk.getLastProposalId();
const proposals = proposalId
? [
sdk.getProposalById({
- proposalId
- })
+ proposalId,
+ }),
] || []
: sdk.getProposals({
offset:
currentPage === 0
? lastProposalId - resPerPage
: lastProposalId - currentPage * resPerPage,
- limit: resPerPage
+ limit: resPerPage,
}) || [];
const PaginationThemeContainer = props.PaginationThemeContainer;
@@ -78,15 +78,15 @@ const handleVote = ({ action, proposalId, proposer }) => {
message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
params: {
daoId: daoId,
- proposalId: proposalId
+ proposalId: proposalId,
},
type: "custom",
- widget: "buildhub.near/widget/Proposals"
- }
- }
- ])
- }
- }
+ widget: "buildhub.near/widget/Proposals",
+ },
+ },
+ ]),
+ },
+ },
};
sdk.actProposal({
@@ -101,9 +101,9 @@ const handleVote = ({ action, proposalId, proposer }) => {
args: { data: notification },
deposit: Big(JSON.stringify(notification).length * 16).mul(
Big(10).pow(20)
- )
- }
- ]
+ ),
+ },
+ ],
});
};
@@ -142,27 +142,30 @@ const ProposalsComponent = () => {
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteApprove
+ actionType: actions.VoteApprove,
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteReject
+ actionType: actions.VoteReject,
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteRemove
- })
+ actionType: actions.VoteRemove,
+ }),
];
- const { thresholdVoteCount } = sdk.getVotersAndThresholdForProposalKind({
- kindName
+ const { thresholdVoteCount } =
+ sdk.getVotersAndThresholdForProposalKind({
+ kindName,
+ });
+ const totalVotes = sdk.calculateVoteCountByType({
+ votes: item.votes,
});
- const totalVotes = sdk.calculateVoteCountByType({ votes: item.votes });
let expirationTime = sdk.getProposalExpirationTime({
- submissionTime: item.submission_time
+ submissionTime: item.submission_time,
});
return (
@@ -176,14 +179,14 @@ const ProposalsComponent = () => {
totalVotes: {
...totalVotes,
yes: totalVotes.approve,
- no: totalVotes.reject
+ no: totalVotes.reject,
},
- expirationTime
+ expirationTime,
},
daoId: daoId,
comments: comments,
isAllowedToVote,
- handleVote
+ handleVote,
}}
/>
);
@@ -202,11 +205,11 @@ return (
src="buildhub.near/widget/components.modals.CreateProposal"
props={{
showModal: showProposalModal,
- toggleModal: () => setShowModal(!showProposalModal)
+ toggleModal: () => setShowModal(!showProposalModal),
}}
/>
-
Proposals
+ Proposals
setShowModal(true)}>
Create Proposal
@@ -223,7 +226,7 @@ return (
totalPages: Math.round(lastProposalId / resPerPage),
onPageClick: (v) => setCurrentPage(v),
selectedPage: currentPage,
- ThemeContainer: PaginationThemeContainer
+ ThemeContainer: PaginationThemeContainer,
}}
/>
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config.jsx
index 34290fbb..cc1f593e 100644
--- a/apps/builddao/widget/config.jsx
+++ b/apps/builddao/widget/config.jsx
@@ -16,10 +16,10 @@ return {
},
},
proposal: {
- path: "buildhub.near/widget/page.proposal",
+ path: "buildhub.near/widget/page.proposals",
blockHeight: "final",
init: {
- name: "Proposal",
+ name: "Proposals",
},
},
},
diff --git a/apps/builddao/widget/page/proposal.jsx b/apps/builddao/widget/page/proposals.jsx
similarity index 54%
rename from apps/builddao/widget/page/proposal.jsx
rename to apps/builddao/widget/page/proposals.jsx
index b3529c33..fc72ecaa 100644
--- a/apps/builddao/widget/page/proposal.jsx
+++ b/apps/builddao/widget/page/proposals.jsx
@@ -1,7 +1,7 @@
return (
-
+
From c9f1a683e55c2d142507324b2bae38422327ad8d Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Mon, 29 Jan 2024 22:36:17 -0500
Subject: [PATCH 085/132] move routes
---
apps/builddao/widget/app.jsx | 2 +-
apps/builddao/widget/{config.jsx => config/routes.jsx} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename apps/builddao/widget/{config.jsx => config/routes.jsx} (100%)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index e4200242..c1588e22 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,6 +1,6 @@
const { page, layout, loading, ...passProps } = props;
-const { routes } = VM.require("buildhub.near/widget/config") ?? {
+const { routes } = VM.require("buildhub.near/widget/config.routes") ?? {
routes: {},
};
diff --git a/apps/builddao/widget/config.jsx b/apps/builddao/widget/config/routes.jsx
similarity index 100%
rename from apps/builddao/widget/config.jsx
rename to apps/builddao/widget/config/routes.jsx
From 9abb9873a41e9381fd5404b3cd65e949bcb96598 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 00:10:11 -0500
Subject: [PATCH 086/132] converts Feed into every app pattern
---
apps/builddao/widget/Feed.jsx | 261 ++++++++++--------
.../item.jsx => OrderedGraphFeed.jsx} | 37 ++-
apps/builddao/widget/app.jsx | 6 +-
apps/builddao/widget/components.jsx | 18 +-
.../builddao/widget/components/ButtonLink.jsx | 24 +-
apps/builddao/widget/config/feed.jsx | 253 +++++++++--------
apps/builddao/widget/page/feed.jsx | 119 ++++++--
.../template/{layout.jsx => AppLayout.jsx} | 16 +-
.../widget/template/SidebarLayout.jsx | 83 ++++++
9 files changed, 530 insertions(+), 287 deletions(-)
rename apps/builddao/widget/{adapters/item.jsx => OrderedGraphFeed.jsx} (57%)
rename apps/builddao/widget/template/{layout.jsx => AppLayout.jsx} (89%)
create mode 100644 apps/builddao/widget/template/SidebarLayout.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index e26ab588..4ac90f8d 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -1,119 +1,164 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed") || (() => <>>);
+const { Feed } = VM.require("devs.near/widget/Module.Feed") || {
+ Feed: () => <>>,
+};
const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
Post: () => <>>,
ButtonLink: () => <>>,
};
-const daoName = props.daoName || "Build DAO";
-const feedLink = props.feedLink || "https://nearbuilders.org/feed";
-const daoTag = props.daoTag || "build";
-
-const feeds = props.feeds || {};
-
-if (!feeds) {
- return "";
-}
-
-const tab = props.tab || Object.keys(feeds)[0];
-if (Object.keys(feeds).includes(props.hashtag)) {
- tab = props.hashtag;
-}
-const [activeFeed, setActiveFeed] = useState(tab);
+const { template, requiredHashtags, customActions } = props;
return (
<>
-
{
- const data = feeds[route];
- return (
-
-
- {data.label}
-
- );
- }),
- mainContent: (
- <>
- {feeds[activeFeed].hideCompose ? null : context.accountId ? (
-
- ) : (
-
- )}
- {feeds[activeFeed].customWidget ? (
-
- ) : (
- (
-
- )}
- />
- )}
- >
- ),
- }}
+ {!context.accountId ? ( // if not logged in
+
+ ) : (
+
+ )}
+ ({
+ action: "hashtag",
+ key: it,
+ options: {
+ limit: 10,
+ order: "desc",
+ },
+ cacheOptions: {
+ ignoreCache: true,
+ },
+ required: true,
+ }))}
+ Item={(p) => (
+
+ )}
/>
>
);
+
+// const daoName = props.daoName || "Build DAO";
+// const feedLink = props.feedLink || "https://nearbuilders.org/feed";
+// const daoTag = props.daoTag || "build";
+
+// const feeds = props.feeds || {};
+
+// if (!feeds) {
+// return "";
+// }
+
+// const tab = props.tab || Object.keys(feeds)[0];
+// if (Object.keys(feeds).includes(props.hashtag)) {
+// tab = props.hashtag;
+// }
+// const [activeFeed, setActiveFeed] = useState(tab);
+
+// return (
+// <>
+// {
+// const data = feeds[route];
+// return (
+//
+//
+// {data.label}
+//
+// );
+// }),
+// mainContent: (
+// <>
+// {feeds[activeFeed].hideCompose ? null : context.accountId ? (
+//
+// ) : (
+//
+// )}
+// {feeds[activeFeed].customWidget ? (
+//
+// ) : (
+// (
+//
+// )}
+// />
+// )}
+// >
+// ),
+// }}
+// />
+// >
+// );
diff --git a/apps/builddao/widget/adapters/item.jsx b/apps/builddao/widget/OrderedGraphFeed.jsx
similarity index 57%
rename from apps/builddao/widget/adapters/item.jsx
rename to apps/builddao/widget/OrderedGraphFeed.jsx
index 9b9956c7..a5308554 100644
--- a/apps/builddao/widget/adapters/item.jsx
+++ b/apps/builddao/widget/OrderedGraphFeed.jsx
@@ -1,32 +1,27 @@
-/**
- * generalized graph item fetcher,
- * Social adapter (getr(`${accountId}/graph/${item}`, "final")
- */
-
const accountId = props.accountId ?? context.accountId;
-const item = props.item;
+const itemType = props.itemType;
const renderItem = props.renderItem;
-if (!item) {
- return No item prop passed
;
+if (!itemType) {
+ return No graph item type passed.
;
}
-const items = Social.getr(`${accountId}/graph/${item}`, "final", {
+const items = Social.getr(`${accountId}/graph/${itemType}`, "final", {
withBlockHeight: true,
});
const StorageKey = "order";
const order = Storage.privateGet(StorageKey);
-const apps = useMemo(() => {
+const graphItems = useMemo(() => {
if (items === null || order === null) {
return [];
}
- const starredApps = new Map();
+ const itemMap = new Map();
const path = [];
const buildSrc = (node) => {
if (node.hasOwnProperty("")) {
- starredApps.set(path.join("/"), node[":block"]);
+ itemMap.set(path.join("/"), node[":block"]);
}
Object.entries(node).forEach(([key, value]) => {
if (typeof value === "object") {
@@ -37,19 +32,19 @@ const apps = useMemo(() => {
});
};
- buildSrc(items ?? {}, [], starredApps);
- let apps = [...starredApps.entries()];
- apps.sort((a, b) => b[1] - a[1]);
- apps = apps.map((a) => a[0]);
- apps.sort((a, b) => (order?.[a] || 0) - (order?.[b] || 0));
+ buildSrc(items ?? {}, [], itemMap);
+ let entries = [...itemMap.entries()];
+ entries.sort((a, b) => b[1] - a[1]);
+ entries = entries.map((a) => a[0]);
+ entries.sort((a, b) => (order?.[a] || 0) - (order?.[b] || 0));
Storage.privateSet(
StorageKey,
- Object.fromEntries(apps.map((a, i) => [a, i + 1]))
+ Object.fromEntries(entries.map((a, i) => [a, i + 1]))
);
- return apps;
+ return entries;
}, [items, order]);
-let transformedArray = apps.map((item) => {
+let transformedArray = graphItems.map((item) => {
let splitParts = item.split("/");
let accountId = splitParts[0];
let lastPart = splitParts[splitParts.length - 1];
@@ -66,7 +61,7 @@ return (
<>
{(filteredArray ?? []).map((item) => renderItem(item))}
{filteredArray.length === 0 && (
- No items!
+ No {itemType}s!
)}
>
);
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index c1588e22..64797276 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,4 +1,4 @@
-const { page, layout, loading, ...passProps } = props;
+const { page, tab, layout, loading, ...passProps } = props;
const { routes } = VM.require("buildhub.near/widget/config.routes") ?? {
routes: {},
@@ -8,7 +8,7 @@ const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
theme: {},
};
-const { AppLayout } = VM.require("buildhub.near/widget/template.layout") || {
+const { AppLayout } = VM.require("buildhub.near/widget/template.AppLayout") || {
AppLayout: () => <>Layout loading...>,
};
@@ -48,7 +48,7 @@ function Router({ active, routes }) {
return (
-
+
);
}
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index d3cf4b9f..cf321740 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -19,7 +19,7 @@ function Pagination({
maxVisiblePages,
onPageClick,
selectedPage,
- ThemeContainer
+ ThemeContainer,
}) {
return (
);
@@ -37,13 +37,21 @@ function Pagination({
function Post(props) {
return (
-
+ }
+ src={"buildhub.near/widget/components.Post"}
+ props={{ ...props }}
+ />
);
}
function User(props) {
return (
-
+ }
+ src="buildhub.near/widget/components.User"
+ props={{ ...props }}
+ />
);
}
@@ -61,5 +69,5 @@ return {
TextEditor,
Checkbox,
Avatar,
- User
+ User,
};
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index 11283685..1136d1cd 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -65,17 +65,19 @@ const StyledLink = styled.a`
function ButtonLink({ id, children, variant, type, href, className, style }) {
return (
-
- {children}
-
+
+
+ {children}
+
+
);
}
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 64125cfe..feb64b56 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -8,44 +8,43 @@ function formatDate(date) {
const daoName = "Build DAO";
const feedLink = "https://nearbuilders.org/feed";
-const feeds = {
- resolutions: {
- // metadata
- name: "resolution",
-
- // start sidebar
- label: "Resolutions",
- icon: "bi-calendar3",
- // end sidebar
- // start compose
- hashtag: "nearyearresolutions2024",
-
- // better way to provide a template? reference to document -- maybe rename "initialText" or more general, "defaultProps"
- // this could be moved to metadata, maybe daoName and feedLink = source: { label, href }, "context", or reference to other thing
- // I like if it came from context cuz then unconfigurable unless from a forked VM
- template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
+return {
+ type: "app", // every.near/type/app
+ routes: {
+ resolutions: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Resolutions", // maybe these should be moved to navbar specific
+ icon: "bi-calendar3",
+ requiredHashtags: ["build", "resolution", "nearyearresolutions2024"],
+ template: `
+### 🎉 NEAR YEAR RESOLUTIONS: 2024
(posted via [${daoName} Gateway](${feedLink}))
-
+
**🌟 REFLECTIONS ON THE PAST YEAR:**
- [Reflection 1 from the past year]
- [Reflection 2 from the past year]
-
+
**🎯 NEW YEAR'S RESOLUTIONS:**
- [Resolution 1]
- [Resolution 2]
-
+
**📊 MEASURING SUCCESS:**
- [Metric 1 for Success]
- [Metric 2 for Success]
`,
- // end compose
- },
- updates: {
- label: "Updates",
- icon: "bi-bell",
- name: "update",
- hashtag: "update",
- template: `### BUILDER UPDATE: ${formatDate(new Date())}
+ },
+ },
+ updates: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Updates",
+ icon: "bi-bell",
+ requiredHashtags: ["build", "update"],
+ template: `
+### BUILDER UPDATE: ${formatDate(new Date())}
(posted via [${daoName} Gateway](${feedLink}?tab=update))
**✅ DONE**
@@ -60,13 +59,17 @@ const feeds = {
- [what's blocking you?]
- [how can someone help?]
`,
- },
- documentation: {
- label: "Documentation",
- icon: "bi-book",
- name: "documentation",
- hashtag: "documentation",
- template: `## TITLE
+ },
+ },
+ documentation: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Documentation",
+ icon: "bi-book",
+ requiredHashtags: ["build", "documentation"],
+ template: `
+## TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=documentation))
**WHAT IS _____?**
@@ -81,25 +84,33 @@ const feeds = {
- [where is it used?]
- [how to use it]
`,
- },
- question: {
- label: "Question",
- icon: "bi-question-lg",
- name: "question",
- hashtag: "question",
- template: `## what is your question?
+ },
+ },
+ question: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Question",
+ icon: "bi-question-lg",
+ requiredHashtags: ["build", "question"],
+ template: `
+## what is your question?
(posted via [${daoName} Gateway](${feedLink}?tab=question))
[what are you thinking about?]
[why are you asking?]
`,
- },
- answer: {
- label: "Answer",
- icon: "bi-journal-code",
- name: "answer",
- hashtag: "answer",
- template: `## Share an answer
+ },
+ },
+ answer: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Answer",
+ icon: "bi-journal-code",
+ requiredHashtags: ["build", "answer"],
+ template: `
+## Share an answer
(posted via [${daoName} Gateway](${feedLink}?tab=answer))
[please restate the question you are answering]
@@ -108,27 +119,34 @@ const feeds = {
[link to relevant docs, examples, or resources]
`,
- },
- opportunity: {
- label: "Opportunity",
- icon: "bi-briefcase",
- name: "opportunity",
- hashtag: "opportunity",
- template: `## TITLE
+ },
+ },
+ opportunity: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Opportunity",
+ icon: "bi-briefcase",
+ requiredHashtags: ["build", "opportunity"],
+ template: `
+## TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
[what is the opportunity?]
[explain the motivation or reason]
-
`,
- },
- idea: {
- label: "Idea",
- icon: "bi-lightbulb",
- name: "idea",
- hashtag: "idea",
- template: `## IDEA TITLE
+ },
+ },
+ idea: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Idea",
+ icon: "bi-lightbulb",
+ requiredHashtags: ["build", "idea"],
+ template: `
+## IDEA TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=idea))
**What idea are you proposing?**
@@ -137,13 +155,17 @@ const feeds = {
**Context or additional information:**
- [Provide any context or details]
`,
- },
- task: {
- label: "Task",
- icon: "bi-check-lg",
- name: "task",
- hashtag: "task",
- template: `## TASK TITLE
+ },
+ },
+ task: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Task",
+ icon: "bi-check-lg",
+ requiredHashtags: ["build", "task"],
+ template: `
+## TASK TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=task))
**What needs to be done?**
@@ -152,57 +174,62 @@ const feeds = {
**Context or additional information:**
- [Provide any context or details]
`,
- },
- request: {
- label: "Request",
- icon: "bi-file-earmark-text",
- name: "request",
- hashtag: "request",
- template: `## REQUEST TITLE
+ },
+ },
+ request: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Request",
+ icon: "bi-file-earmark-text",
+ requiredHashtags: ["build", "request"],
+ customActions: [
+ {
+ label: "Propose",
+ icon: "bi-file-earmark-text",
+ type: "modal",
+ onClick: (modalToggle) => modalToggle(),
+ },
+ ],
+ template: `
+## REQUEST TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=request))
#### Description
[Detailed description of what the proposal is about.]
#### Why This Proposal?
-[Explanation of why this proposal is necessary or beneficial.]`,
- customActions: [
- {
- label: "Propose",
- icon: "bi-file-earmark-text",
- type: "modal",
- onClick: (modalToggle) => modalToggle(),
- },
- ],
- },
- feedback: {
- label: "Feedback",
- icon: "bi-chat-left-text",
- name: "feedback",
- hashtag: "feedback",
- template: `## TITLE
+[Explanation of why this proposal is necessary or beneficial.]
`,
- },
- bookmarks: {
- label: "Bookmarks",
- icon: "bi-bookmark",
- name: "bookmark",
- hideCompose: true,
- customWidget: "buildhub.near/widget/adapters.item",
- customProps: {
- item: "bookmark",
- renderItem: (item) => {
- return (
-
- );
+ },
+ },
+ feedback: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Feedback",
+ icon: "bi-chat-left-text",
+ requiredHashtags: ["build", "feedback"],
+ },
+ },
+ bookmarks: {
+ path: "buildhub.near/widget/OrderedGraphFeed",
+ blockHeight: "final",
+ init: {
+ name: "Bookmarks",
+ icon: "bi-bookmark",
+ itemType: "bookmark",
+ renderItem: (item) => {
+ return (
+
+ );
+ },
},
},
},
};
-
-return { type: "feed", feeds: feeds };
diff --git a/apps/builddao/widget/page/feed.jsx b/apps/builddao/widget/page/feed.jsx
index a15974fd..55a649c9 100644
--- a/apps/builddao/widget/page/feed.jsx
+++ b/apps/builddao/widget/page/feed.jsx
@@ -1,26 +1,107 @@
-const { feeds } = VM.require("buildhub.near/widget/config.feed") || {}; // this is the thing, which works better as a module if it needs to be provided with context
+const { currentPath, page, ...passProps } = props;
-console.log(feeds);
+const { routes } = VM.require("buildhub.near/widget/config.feed") ?? {
+ routes: {},
+};
-if (!feeds) {
- return "...";
-}
+const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+ theme: {},
+};
-const defaultProps = {
- feeds: feeds,
- daoName: "Build DAO", // I think we could take this out, not specific to feeds
- feedLink: "https://nearbuilders.org/feed", // this is good idea, could be used for the "share post" button
- daoTag: "build", // maybe we can make this an array of "required hashtags"
- pagePath: "/?page=feed", // great idea, @mattb.near RoutesManager
- //hashtag: "something"
+const { SidebarLayout } = VM.require(
+ "buildhub.near/widget/template.SidebarLayout"
+) || {
+ SidebarLayout: () => <>Layout loading...>,
};
+if (!page) page = Object.keys(routes)[0] || "home";
+
+const Root = styled.div`
+ ${theme}// can come from config
+`;
+
+const [activeRoute, setActiveRoute] = useState(page);
+
+useEffect(() => {
+ setActiveRoute(page);
+}, [page]);
+
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
+ const routeParts = active.split(".");
+
+ let currentRoute = routes;
+ let src = "";
+ let defaultProps = {};
+
+ for (let part of routeParts) {
+ if (currentRoute[part]) {
+ currentRoute = currentRoute[part];
+ src = currentRoute.path;
+
+ if (currentRoute.init) {
+ defaultProps = { ...defaultProps, ...currentRoute.init };
+ }
+ } else {
+ // Handle 404 or default case for unknown routes
+ return 404 Not Found
;
+ }
+ }
+
+ return (
+
+
+
+ );
+}
+
+const Container = styled.div`
+ // display: flex;
+ height: 100%;
+`;
+
+const Content = styled.div`
+ width: 100%;
+ height: 100%;
+`;
+
return (
-
-
-
+
+
+
+
+
+
+
+
+
);
+
+return;
+
+// const { feeds } = VM.require("buildhub.near/widget/config.feed") || {}; // this is the thing, which works better as a module if it needs to be provided with context
+
+// console.log(feeds);
+
+// if (!feeds) {
+// return "...";
+// }
+
+// const defaultProps = {
+// feeds: feeds,
+// daoName: "Build DAO", // I think we could take this out, not specific to feeds
+// feedLink: "https://nearbuilders.org/feed", // this is good idea, could be used for the "share post" button
+// daoTag: "build", // maybe we can make this an array of "required hashtags"
+// pagePath: "/?page=feed", // great idea, @mattb.near RoutesManager
+// //hashtag: "something"
+// };
+
+// return (
+//
+//
+//
+// );
diff --git a/apps/builddao/widget/template/layout.jsx b/apps/builddao/widget/template/AppLayout.jsx
similarity index 89%
rename from apps/builddao/widget/template/layout.jsx
rename to apps/builddao/widget/template/AppLayout.jsx
index 201bf9a3..c22782bd 100644
--- a/apps/builddao/widget/template/layout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -1,3 +1,7 @@
+/**
+ * This is a standard layout with a header, body, and a footer
+ */
+
const { Button } = VM.require("buildhub.near/widget/components");
const Container = styled.div`
@@ -89,13 +93,11 @@ const Footer = (props) => {
// Define the new component that follows the AppLayout pattern
function AppLayout({ routes, page, children }) {
return (
- <>
-
-
- {children}
-
-
- >
+
+
+ {children}
+
+
);
}
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
new file mode 100644
index 00000000..14ee6290
--- /dev/null
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -0,0 +1,83 @@
+const { ButtonLink } = VM.require("buildhub.near/widget/components");
+
+const Container = styled.div`
+ display: grid;
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ gap: 1rem;
+
+ @media screen and (max-width: 768px) {
+ display: flex;
+ flex-direction: column;
+ }
+`;
+
+const SidebarContainer = styled.div`
+ border-radius: 16px;
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ background: var(--bg-1, #0b0c14);
+ width: 100%;
+
+ display: flex;
+ padding: 24px 12px;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 16px;
+ margin-bottom: 1rem;
+ height: max-content;
+
+ @media screen and (max-width: 768px) {
+ border: 0px;
+ flex-direction: row;
+ overflow-x: auto;
+ }
+`;
+
+const ContentContainer = styled.div`
+ grid-column: span 4 / span 4;
+`;
+
+const Sidebar = ({ currentPath, page, routes }) => (
+ <>
+ {routes &&
+ (Object.keys(routes) || []).map((k) => {
+ const route = routes[k];
+ if (route.hide) {
+ return null;
+ }
+ return (
+
+ {route.init.icon && }
+ {route.init.name}
+
+ );
+ })}
+ >
+);
+
+// Define the new component that follows the SidebarLayout pattern
+function SidebarLayout({ currentPath, routes, page, children }) {
+ return (
+
+
+
+
+ {children}
+
+ );
+}
+
+return { SidebarLayout };
From 2120513ea42e2d9717656f236f52f882738788f7 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 01:05:25 -0500
Subject: [PATCH 087/132] clean up
---
apps/builddao/widget/Compose.jsx | 10 +-
apps/builddao/widget/Feed.jsx | 128 +-----------------
.../components/AsideWithMainContent.jsx | 50 -------
apps/builddao/widget/components/Post.jsx | 8 +-
apps/builddao/widget/config/feed.jsx | 29 ++--
5 files changed, 26 insertions(+), 199 deletions(-)
delete mode 100644 apps/builddao/widget/components/AsideWithMainContent.jsx
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 98b83572..6740cb8c 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -1,9 +1,9 @@
-const { Avatar, Button } = VM.require("buildhub.near/widget/components");
-
-Avatar = Avatar || (() => <>>);
-Button = Button || (() => <>>);
+const { Avatar, Button } = VM.require("buildhub.near/widget/components") || {
+ Avatar: () => <>>,
+ Button: () => <>>,
+};
-const draftKey = props.feed.name || "draft";
+const draftKey = props.draftKey || "draft";
const draft = Storage.privateGet(draftKey);
if (draft === null) {
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 4ac90f8d..a625c43f 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -1,4 +1,4 @@
-const { Feed } = VM.require("devs.near/widget/Module.Feed") || {
+const { Feed } = VM.require("devs.near/widget/Feed") || {
Feed: () => <>>,
};
const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
@@ -6,17 +6,17 @@ const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
ButtonLink: () => <>>,
};
-const { template, requiredHashtags, customActions } = props;
+const { name, template, requiredHashtags, customActions } = props;
return (
- <>
+
{!context.accountId ? ( // if not logged in
) : (
)}
/>
- >
-);
-
-// const daoName = props.daoName || "Build DAO";
-// const feedLink = props.feedLink || "https://nearbuilders.org/feed";
-// const daoTag = props.daoTag || "build";
-
-// const feeds = props.feeds || {};
-
-// if (!feeds) {
-// return "";
-// }
-
-// const tab = props.tab || Object.keys(feeds)[0];
-// if (Object.keys(feeds).includes(props.hashtag)) {
-// tab = props.hashtag;
-// }
-// const [activeFeed, setActiveFeed] = useState(tab);
-
-// return (
-// <>
-//
{
-// const data = feeds[route];
-// return (
-//
-//
-// {data.label}
-//
-// );
-// }),
-// mainContent: (
-// <>
-// {feeds[activeFeed].hideCompose ? null : context.accountId ? (
-//
-// ) : (
-//
-// )}
-// {feeds[activeFeed].customWidget ? (
-//
-// ) : (
-// (
-//
-// )}
-// />
-// )}
-// >
-// ),
-// }}
-// />
-// >
-// );
+
+);
\ No newline at end of file
diff --git a/apps/builddao/widget/components/AsideWithMainContent.jsx b/apps/builddao/widget/components/AsideWithMainContent.jsx
deleted file mode 100644
index c56a243c..00000000
--- a/apps/builddao/widget/components/AsideWithMainContent.jsx
+++ /dev/null
@@ -1,50 +0,0 @@
-const { routes, active, setActiveRoute, mainContent, sideContent } = props;
-
-const Container = styled.div`
- display: grid;
- grid-template-columns: repeat(5, minmax(0, 1fr));
- gap: 1rem;
-
- @media screen and (max-width: 768px) {
- display: flex;
- flex-direction: column;
- }
-`;
-
-const AsideContainer = styled.div`
- border-radius: 16px;
- border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
- background: var(--bg-1, #0b0c14);
- width: 100%;
-
- display: flex;
- padding: 24px 12px;
- flex-direction: column;
- align-items: flex-start;
- gap: 16px;
- margin-bottom: 1rem;
- height: max-content;
-
- @media screen and (max-width: 768px) {
- border: 0px;
- flex-direction: row;
- overflow-x: auto;
- }
-`;
-
-const Aside = styled.div`
- grid-column: span 1 / span 1;
-`;
-
-const MainContentContainer = styled.div`
- grid-column: span 4 / span 4;
-`;
-
-return (
-
-
- {mainContent}
-
-);
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 7166bcad..733a50a3 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -1,7 +1,7 @@
-const { User, Button } = VM.require("buildhub.near/widget/components");
-
-User = User || (() => <>>);
-Button = Button || (() => <>>);
+const { User, Button } = VM.require("buildhub.near/widget/components") || {
+ User: () => <>>,
+ Button: () => <>>,
+};
const StyledPost = styled.div`
margin-bottom: 1rem;
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index feb64b56..f1ae8cdf 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -18,8 +18,7 @@ return {
name: "Resolutions", // maybe these should be moved to navbar specific
icon: "bi-calendar3",
requiredHashtags: ["build", "resolution", "nearyearresolutions2024"],
- template: `
-### 🎉 NEAR YEAR RESOLUTIONS: 2024
+ template: `### 🎉 NEAR YEAR RESOLUTIONS: 2024
(posted via [${daoName} Gateway](${feedLink}))
**🌟 REFLECTIONS ON THE PAST YEAR:**
@@ -43,8 +42,7 @@ return {
name: "Updates",
icon: "bi-bell",
requiredHashtags: ["build", "update"],
- template: `
-### BUILDER UPDATE: ${formatDate(new Date())}
+ template: `### BUILDER UPDATE: ${formatDate(new Date())}
(posted via [${daoName} Gateway](${feedLink}?tab=update))
**✅ DONE**
@@ -68,8 +66,7 @@ return {
name: "Documentation",
icon: "bi-book",
requiredHashtags: ["build", "documentation"],
- template: `
-## TITLE
+ template: `## TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=documentation))
**WHAT IS _____?**
@@ -93,8 +90,7 @@ return {
name: "Question",
icon: "bi-question-lg",
requiredHashtags: ["build", "question"],
- template: `
-## what is your question?
+ template: `## what is your question?
(posted via [${daoName} Gateway](${feedLink}?tab=question))
[what are you thinking about?]
@@ -109,8 +105,7 @@ return {
name: "Answer",
icon: "bi-journal-code",
requiredHashtags: ["build", "answer"],
- template: `
-## Share an answer
+ template: `## Share an answer
(posted via [${daoName} Gateway](${feedLink}?tab=answer))
[please restate the question you are answering]
@@ -128,8 +123,7 @@ return {
name: "Opportunity",
icon: "bi-briefcase",
requiredHashtags: ["build", "opportunity"],
- template: `
-## TITLE
+ template: `## TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=opportunity))
[what is the opportunity?]
@@ -145,8 +139,7 @@ return {
name: "Idea",
icon: "bi-lightbulb",
requiredHashtags: ["build", "idea"],
- template: `
-## IDEA TITLE
+ template: `## IDEA TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=idea))
**What idea are you proposing?**
@@ -164,8 +157,7 @@ return {
name: "Task",
icon: "bi-check-lg",
requiredHashtags: ["build", "task"],
- template: `
-## TASK TITLE
+ template: `## TASK TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=task))
**What needs to be done?**
@@ -188,11 +180,10 @@ return {
label: "Propose",
icon: "bi-file-earmark-text",
type: "modal",
- onClick: (modalToggle) => modalToggle(),
+ onClick: (modalToggle) => modalToggle(), // want to fix
},
],
- template: `
-## REQUEST TITLE
+ template: `## REQUEST TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=request))
#### Description
From 191bb5f9c9af09cafe008b93f5d8a7ca378d183e Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 20:33:20 +0500
Subject: [PATCH 088/132] Fix styles, links, and match desktop navbar
---
apps/builddao/widget/Feed.jsx | 2 +-
.../builddao/widget/components/ButtonLink.jsx | 2 +-
.../widget/components/buttons/Connect.jsx | 43 ++++++++++---------
apps/builddao/widget/template/AppLayout.jsx | 32 +++++++-------
.../widget/template/SidebarLayout.jsx | 2 +-
5 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index a625c43f..9a84bf12 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -47,4 +47,4 @@ return (
)}
/>
-);
\ No newline at end of file
+);
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index 1136d1cd..c3823ddb 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -65,7 +65,7 @@ const StyledLink = styled.a`
function ButtonLink({ id, children, variant, type, href, className, style }) {
return (
-
+
{
[userAccountId]: {
graph: {
connect: {
- [daoId]: ""
- }
+ [daoId]: "",
+ },
},
index: {
graph: JSON.stringify({
key: "connect",
value: {
type: "connect",
- accountId: daoId
- }
- })
+ accountId: daoId,
+ },
+ }),
},
notify: JSON.stringify({
key: daoId,
value: {
- type: "connect"
- }
- })
- }
+ type: "connect",
+ },
+ }),
+ },
};
Near.call([
@@ -69,13 +70,13 @@ const handleJoin = () => {
kind: {
AddMemberToRole: {
member_id: accountId,
- role: roleId
- }
- }
- }
+ role: roleId,
+ },
+ },
+ },
},
gas: 219000000000000,
- deposit: deposit
+ deposit: deposit,
},
{
contractName: "social.near",
@@ -83,8 +84,8 @@ const handleJoin = () => {
deposit: Big(JSON.stringify(connectData).length * 16).mul(
Big(10).pow(20)
),
- args: { data: connectData }
- }
+ args: { data: connectData },
+ },
]);
};
@@ -131,7 +132,7 @@ const Component = () => {
{data.isDaoMember ? "Joined" : "Pending application"}
-
+
View Activity{" "}
{
} else {
return (
- {joinBtnChildren}
+ {joinBtnChildren}
);
}
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index c22782bd..bd894025 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -27,7 +27,7 @@ const Navbar = styled.div`
flex-direction: row;
justify-content: space-between;
align-items: center;
- padding: 24px;
+ padding: 48px;
width: 100%;
background-color: #0b0c14;
@@ -50,6 +50,10 @@ const { NavLink } = props || {
const AppHeader = ({ page, routes }) => (
+
{routes &&
(Object.keys(routes) || []).map((k) => {
@@ -67,22 +71,16 @@ const AppHeader = ({ page, routes }) => (
);
})}
- {routes && (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
- >
- )}
+ User Dropdown ,
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
);
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
index 14ee6290..a1a63e24 100644
--- a/apps/builddao/widget/template/SidebarLayout.jsx
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -50,7 +50,7 @@ const Sidebar = ({ currentPath, page, routes }) => (
variant={page === k ? "primary" : "outline"}
href={`?${currentPath}&tab=${k}`}
className={
- "align-self-stretch flex-shrink-0 justify-content-start fw-medium"
+ "justify-content-start fw-medium align-self-stretch w-100"
}
style={{
fontSize: "14px",
From ede8bce586ae3700ced65a63826d3c746daca01b Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 20:58:37 +0500
Subject: [PATCH 089/132] Add dropdown for mobile navigation
---
.../widget/components/navigation/header.jsx | 118 ++++++++++++++++++
apps/builddao/widget/template/AppLayout.jsx | 70 +----------
2 files changed, 123 insertions(+), 65 deletions(-)
create mode 100644 apps/builddao/widget/components/navigation/header.jsx
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
new file mode 100644
index 00000000..edb36573
--- /dev/null
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -0,0 +1,118 @@
+const { Button } = VM.require("buildhub.near/widget/components");
+
+const Navbar = styled.div`
+ width: 64px;
+
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ align-items: center;
+ padding: 48px;
+ width: 100%;
+
+ background-color: #0b0c14;
+ border-bottom: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+`;
+
+const ButtonGroup = styled.div`
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 8px;
+`;
+
+const DesktopNavigation = styled.div`
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+
+ @media screen and (max-width: 768px) {
+ display: none;
+ }
+`;
+
+const MobileNavigation = styled.div`
+ display: none;
+
+ @media screen and (max-width: 768px) {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+ }
+`;
+
+const NavLink = ({ to, children }) => (
+
+ {children}
+
+);
+
+const [showMenu, setShowMenu] = useState(false);
+const toggleDropdown = () => setShowMenu(!showMenu);
+
+const AppHeader = ({ page, routes }) => (
+
+
+
+
+
+
+
+ {routes &&
+ (Object.keys(routes) || []).map((k) => {
+ const route = routes[k];
+ if (route.hide) {
+ return null;
+ }
+ return (
+
+
+ {route.init.icon && }
+ {route.init.name}
+
+
+ );
+ })}
+
+ User Dropdown ,
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+ {showMenu && Test
}
+
+
+);
+
+return ;
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index bd894025..f89ef72d 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -20,70 +20,6 @@ const ContentContainer = styled.div`
width: 100%;
`;
-const Navbar = styled.div`
- width: 64px;
-
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 48px;
- width: 100%;
-
- background-color: #0b0c14;
-`;
-
-const ButtonGroup = styled.div`
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 8px;
-`;
-
-const { NavLink } = props || {
- NavLink: ({ to, children }) => (
-
- {children}
-
- ),
-};
-
-const AppHeader = ({ page, routes }) => (
-
-
-
- {routes &&
- (Object.keys(routes) || []).map((k) => {
- const route = routes[k];
- if (route.hide) {
- return null;
- }
- return (
-
-
- {route.init.icon && }
- {route.init.name}
-
-
- );
- })}
-
- User Dropdown ,
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- href: "/join",
- }}
- />
-
-);
-
const Footer = (props) => {
return <>>;
};
@@ -92,7 +28,11 @@ const Footer = (props) => {
function AppLayout({ routes, page, children }) {
return (
-
+ {/* */}
+
{children}
From 368343127bdf275e03ae0cb60a6352b5c8f6c12a Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 21:12:31 +0500
Subject: [PATCH 090/132] Add mobile dropdown items
---
.../builddao/widget/components/ButtonLink.jsx | 13 ++++-
.../widget/components/navigation/header.jsx | 47 ++++++++++++++++++-
.../widget/template/SidebarLayout.jsx | 1 +
3 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/components/ButtonLink.jsx b/apps/builddao/widget/components/ButtonLink.jsx
index c3823ddb..6557b9dc 100644
--- a/apps/builddao/widget/components/ButtonLink.jsx
+++ b/apps/builddao/widget/components/ButtonLink.jsx
@@ -63,9 +63,18 @@ const StyledLink = styled.a`
}
`;
-function ButtonLink({ id, children, variant, type, href, className, style }) {
+function ButtonLink({
+ id,
+ children,
+ linkClassName,
+ variant,
+ type,
+ href,
+ className,
+ style,
+}) {
return (
-
+
(
- {showMenu && Test
}
+ {showMenu && (
+
+
+ {routes &&
+ (Object.keys(routes) || []).map((k) => {
+ const route = routes[k];
+ if (route.hide) {
+ return null;
+ }
+ return (
+
+
+ {route.init.icon && }
+ {route.init.name}
+
+
+ );
+ })}
+
+ User Dropdown
+ ),
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
+
+ )}
);
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
index a1a63e24..6117cbde 100644
--- a/apps/builddao/widget/template/SidebarLayout.jsx
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -52,6 +52,7 @@ const Sidebar = ({ currentPath, page, routes }) => (
className={
"justify-content-start fw-medium align-self-stretch w-100"
}
+ linkClassName={"d-flex w-100"}
style={{
fontSize: "14px",
textDecoration: "none",
From 85ac5e91b0e9f9baaaae23b33e83dfa1f9ad7fcd Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 21:17:53 +0500
Subject: [PATCH 091/132] Make login-now forward to /join
---
apps/builddao/widget/components/login-now.jsx | 35 +++++--------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/apps/builddao/widget/components/login-now.jsx b/apps/builddao/widget/components/login-now.jsx
index b82ba89a..09f87aa6 100644
--- a/apps/builddao/widget/components/login-now.jsx
+++ b/apps/builddao/widget/components/login-now.jsx
@@ -1,3 +1,5 @@
+const { Button } = VM.require("buildhub.near/widget/components");
+
const Container = styled.div`
background-color: #23242b;
color: #fff;
@@ -7,40 +9,19 @@ const Container = styled.div`
border-radius: 1rem;
display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
-
- button {
- all: unset;
- cursor: pointer;
- display: flex;
- padding: 16px 20px;
- justify-content: center;
- align-items: center;
- gap: 4px;
-
- border-radius: 8px;
- border: 1px solid var(--white-100, #fff);
- background: #fff;
- transition: all 300ms;
-
- &:hover {
- text-decoration: none;
- }
-
- color: var(--black-100, #000);
-
- font-size: 14px;
- font-style: normal;
- font-weight: 500;
- line-height: normal;
- }
`;
return (
- Login
+ User not signed in. Please login in order to post.
+
+ Login
+
);
From 76bacaceeaac9f9824856f25954ae56415f5c606 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 21:25:21 +0500
Subject: [PATCH 092/132] Create Post header
---
apps/builddao/widget/components/Post.jsx | 29 +--
apps/builddao/widget/components/User.jsx | 151 ++-----------
.../widget/components/post/Header.jsx | 207 ++++++++++++++++++
3 files changed, 238 insertions(+), 149 deletions(-)
create mode 100644 apps/builddao/widget/components/post/Header.jsx
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 733a50a3..9bffe3e2 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -1,7 +1,5 @@
-const { User, Button } = VM.require("buildhub.near/widget/components") || {
- User: () => <>>,
- Button: () => <>>,
-};
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
const StyledPost = styled.div`
margin-bottom: 1rem;
@@ -318,16 +316,19 @@ return (
>
-
{fullPostLink ? (
<>>);
-const Button = styled.div`
- line-height: 20px;
- min-height: 20px;
- display: inline-flex;
- align-items: center;
- justify-content: left;
- background: inherit;
- color: #6c757d;
- font-size: 16px;
- .icon {
- position: relative;
- &:before {
- margin: -8px;
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- border-radius: 50%;
- }
- }
-
- &:not([disabled]) {
- cursor: pointer;
- }
-
- &:not([disabled]):hover {
- opacity: 1 !important;
- color: DeepSkyBlue;
-
- .icon:before {
- background: rgba(0, 191, 255, 0.1);
- }
- }
-`;
-
const Wrapper = styled.div`
color: #fff;
@@ -84,18 +47,8 @@ const Wrapper = styled.div`
`;
const accountId = props.accountId;
-const blockHeight = props.blockHeight;
-const pinned = !!props.pinned;
-const hideMenu = !!props.hideMenu;
const name = props.name || Social.get(`${accountId}/profile/name`);
-
-const postType = props.postType ?? "post";
-const link = props.link;
const isPremium = !!props.isPremium;
-const flagItem = props.flagItem;
-const customActions = props.customActions ?? [];
-const showTime = props.showTime ?? true;
-const toggleModal = props.toggleModal;
const Overlay = (props) => (
(
);
return (
-
-
-
-
-
-
-
{name || "No-Name Profile"}
-
-
-
-
- {accountId}
- {showTime && (
-
- {blockHeight === "now" ? (
- "now"
- ) : (
-
-
-
- )}
-
- )}
-
- {pinned && (
-
-
-
- )}
-
-
- {!pinned && !hideMenu && blockHeight !== "now" && (
-
-
-
-
-
-
-
- View raw markdown source
-
-
-
+
+
+
+
+
+
{name || "No-Name Profile"}
+
-
- {flagItem && (
-
-
-
- )}
- {customActions.length > 0 &&
- customActions.map((action) => (
-
-
- action.type === "modal"
- ? action.onClick(toggleModal)
- : action.onClick(flagItem)
- }
- className="btn btn-outline-dark dropdown-item"
- >
- {" "}
- {action.label}
-
-
- ))}
-
-
- )}
-
+
+
+ {accountId}
+
+
+
);
diff --git a/apps/builddao/widget/components/post/Header.jsx b/apps/builddao/widget/components/post/Header.jsx
new file mode 100644
index 00000000..7930170e
--- /dev/null
+++ b/apps/builddao/widget/components/post/Header.jsx
@@ -0,0 +1,207 @@
+const { Avatar } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+
+const Button = styled.div`
+ line-height: 20px;
+ min-height: 20px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: left;
+ background: inherit;
+ color: #6c757d;
+ font-size: 16px;
+ .icon {
+ position: relative;
+ &:before {
+ margin: -8px;
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ border-radius: 50%;
+ }
+ }
+
+ &:not([disabled]) {
+ cursor: pointer;
+ }
+
+ &:not([disabled]):hover {
+ opacity: 1 !important;
+ color: DeepSkyBlue;
+
+ .icon:before {
+ background: rgba(0, 191, 255, 0.1);
+ }
+ }
+`;
+
+const Wrapper = styled.div`
+ color: #fff;
+
+ p {
+ color: #fff;
+ color: var(--White-100, #fff);
+
+ font-size: ${(props) => (props.variant === "mobile" ? "13px" : "14px")};
+ font-style: normal;
+ font-weight: 500;
+ line-height: normal;
+ margin: 0;
+ }
+
+ p.username {
+ color: var(--White-50, #cdd0d5);
+ font-size: ${(props) => (props.variant === "mobile" ? "10px" : "13px")};
+ margin: 0;
+ }
+
+ p.time {
+ color: var(--White-100, #fff);
+ font-size: ${(props) => (props.variant === "mobile" ? "10px" : "13px")};
+ margin: 0;
+ }
+
+ @media screen and (max-width: 768px) {
+ ${(props) =>
+ !props.variant &&
+ `
+ p {
+ font-size: 13px !important;
+ }
+
+ p.username {
+ font-size: 10px !important;
+ }
+
+ p.time {
+ font-size: 10px !important;
+ }
+ `}
+ }
+`;
+
+const accountId = props.accountId;
+const blockHeight = props.blockHeight;
+const pinned = !!props.pinned;
+const hideMenu = !!props.hideMenu;
+const name = props.name || Social.get(`${accountId}/profile/name`);
+
+const postType = props.postType ?? "post";
+const link = props.link;
+const isPremium = !!props.isPremium;
+const flagItem = props.flagItem;
+const customActions = props.customActions ?? [];
+const showTime = props.showTime ?? true;
+const toggleModal = props.toggleModal;
+
+const Overlay = (props) => (
+
+
+
+);
+
+return (
+
+
+
+
+
+
+
{name || "No-Name Profile"}
+
+
+
+
+ {accountId}
+ {showTime && (
+
+ {blockHeight === "now" ? (
+ "now"
+ ) : (
+
+
+
+ )}
+
+ )}
+
+ {pinned && (
+
+
+
+ )}
+
+
+ {!pinned && !hideMenu && blockHeight !== "now" && (
+
+
+
+
+
+
+
+ View raw markdown source
+
+
+
+
+
+ {flagItem && (
+
+
+
+ )}
+ {customActions.length > 0 &&
+ customActions.map((action) => (
+
+
+ action.type === "modal"
+ ? action.onClick(toggleModal)
+ : action.onClick(flagItem)
+ }
+ className="btn btn-outline-dark dropdown-item"
+ >
+ {" "}
+ {action.label}
+
+
+ ))}
+
+
+ )}
+
+);
From 103961fca32ba89f90105c10d9530c85415cde4b Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 22:07:48 +0500
Subject: [PATCH 093/132] Convert home widgets into modules
---
apps/builddao/widget/Home.jsx | 29 +++++
apps/builddao/widget/home.jsx | 22 ----
.../builddao/widget/{section => home}/cta.jsx | 44 ++++----
.../widget/{section => home}/footer.jsx | 93 ++++++++--------
.../widget/{section => home}/goals.jsx | 62 ++++++-----
.../widget/{section => home}/governance.jsx | 36 ++++---
.../widget/{section => home}/hero.jsx | 32 +++---
.../widget/{section => home}/join.jsx | 102 +++++++++---------
apps/builddao/widget/page/home.jsx | 2 +-
9 files changed, 226 insertions(+), 196 deletions(-)
create mode 100644 apps/builddao/widget/Home.jsx
delete mode 100644 apps/builddao/widget/home.jsx
rename apps/builddao/widget/{section => home}/cta.jsx (80%)
rename apps/builddao/widget/{section => home}/footer.jsx (71%)
rename apps/builddao/widget/{section => home}/goals.jsx (75%)
rename apps/builddao/widget/{section => home}/governance.jsx (85%)
rename apps/builddao/widget/{section => home}/hero.jsx (81%)
rename apps/builddao/widget/{section => home}/join.jsx (81%)
diff --git a/apps/builddao/widget/Home.jsx b/apps/builddao/widget/Home.jsx
new file mode 100644
index 00000000..553edd88
--- /dev/null
+++ b/apps/builddao/widget/Home.jsx
@@ -0,0 +1,29 @@
+const { Hero } = VM.require("buildhub.near/widget/home.hero");
+const { Goals } = VM.require("buildhub.near/widget/home.goals");
+const { Join } = VM.require("buildhub.near/widget/home.join");
+const { Governance } = VM.require("buildhub.near/widget/home.governance");
+const { CTA } = VM.require("buildhub.near/widget/home.cta");
+const { Footer } = VM.require("buildhub.near/widget/home.footer");
+
+const ownerId = "/*__@appAccount__*/";
+
+const Root = styled.div`
+ background-color: #0b0c14;
+ color: #ffffff;
+ font-family: Satoshi;
+
+ width: 100%;
+`;
+
+const sections = ["hero", "goals", "join", "governance", "cta", "footer"];
+
+return (
+
+
+
+
+
+
+
+
+);
diff --git a/apps/builddao/widget/home.jsx b/apps/builddao/widget/home.jsx
deleted file mode 100644
index d486bfab..00000000
--- a/apps/builddao/widget/home.jsx
+++ /dev/null
@@ -1,22 +0,0 @@
-const ownerId = "/*__@appAccount__*/";
-
-const Root = styled.div`
- background-color: #0b0c14;
- color: #ffffff;
- font-family: Satoshi;
-
- width: 100%;
-`;
-
-const sections = ["hero", "goals", "join", "governance", "cta", "footer"];
-
-return (
-
- {sections.map((section) => (
-
- ))}
-
-);
diff --git a/apps/builddao/widget/section/cta.jsx b/apps/builddao/widget/home/cta.jsx
similarity index 80%
rename from apps/builddao/widget/section/cta.jsx
rename to apps/builddao/widget/home/cta.jsx
index acc5cf7c..7bda2ee4 100644
--- a/apps/builddao/widget/section/cta.jsx
+++ b/apps/builddao/widget/home/cta.jsx
@@ -128,23 +128,27 @@ const Logo = styled.img`
object-fit: cover;
`;
-return (
-
-
-
- Together, we can build a better future.
-
-
-
-
-
-
-);
+const CTA = () => {
+ return (
+
+
+
+ Together, we can build a better future.
+
+
+
+
+
+
+ );
+};
+
+return { CTA };
diff --git a/apps/builddao/widget/section/footer.jsx b/apps/builddao/widget/home/footer.jsx
similarity index 71%
rename from apps/builddao/widget/section/footer.jsx
rename to apps/builddao/widget/home/footer.jsx
index c380d1d7..cd5bfef7 100644
--- a/apps/builddao/widget/section/footer.jsx
+++ b/apps/builddao/widget/home/footer.jsx
@@ -1,4 +1,4 @@
-const Footer = styled.div`
+const Container = styled.div`
display: flex;
flex-direction: column;
padding: 3.125rem;
@@ -82,34 +82,33 @@ const GitHubIcon = (
viewBox="0 0 24 24"
fill="white"
>
-
+
);
const NearSocialIcon = (
-
-
-
-
-
+
+
+
+
);
const SocialContainer = styled.div`
@@ -118,24 +117,28 @@ const SocialContainer = styled.div`
align-items: center;
`;
-const date = new Date();
+const Footer = () => {
+ const date = new Date();
-return (
-
-);
+ return (
+
+
+
+ {XIcon}
+
+
+ {TelegramIcon}
+
+
+ {GitHubIcon}
+
+
+ {NearSocialIcon}
+
+
+ {date.getFullYear()} | Build DAO
+
+ );
+};
+
+return { Footer };
diff --git a/apps/builddao/widget/section/goals.jsx b/apps/builddao/widget/home/goals.jsx
similarity index 75%
rename from apps/builddao/widget/section/goals.jsx
rename to apps/builddao/widget/home/goals.jsx
index 5664344b..a68deda3 100644
--- a/apps/builddao/widget/section/goals.jsx
+++ b/apps/builddao/widget/home/goals.jsx
@@ -212,32 +212,36 @@ const GridItem = ({ tag, title, description, image, isFirst }) => {
);
};
-return (
-
-
-
- Primary Objectives
-
-
-
-
-
-
-
-);
+const Goals = () => {
+ return (
+
+
+
+ Primary Objectives
+
+
+
+
+
+
+
+ );
+};
+
+return { Goals };
diff --git a/apps/builddao/widget/section/governance.jsx b/apps/builddao/widget/home/governance.jsx
similarity index 85%
rename from apps/builddao/widget/section/governance.jsx
rename to apps/builddao/widget/home/governance.jsx
index ded4bcd8..451e1231 100644
--- a/apps/builddao/widget/section/governance.jsx
+++ b/apps/builddao/widget/home/governance.jsx
@@ -148,19 +148,23 @@ const Image = styled.img`
max-width: 1200px;
`;
-return (
-
-
-
-
- Let's coordinate!
-
-
- Build DAO upholds the principles of openness and accountability in its
- decision-making processes. We believe success depends on metagovernance
- of builders, by builders, for builders.
-
-
-
-
-);
+const Governance = () => {
+ return (
+
+
+
+
+ Let's coordinate!
+
+
+ Build DAO upholds the principles of openness and accountability in its
+ decision-making processes. We believe success depends on
+ metagovernance of builders, by builders, for builders.
+
+
+
+
+ );
+};
+
+return { Governance };
diff --git a/apps/builddao/widget/section/hero.jsx b/apps/builddao/widget/home/hero.jsx
similarity index 81%
rename from apps/builddao/widget/section/hero.jsx
rename to apps/builddao/widget/home/hero.jsx
index c920be77..430ee0ea 100644
--- a/apps/builddao/widget/section/hero.jsx
+++ b/apps/builddao/widget/home/hero.jsx
@@ -95,17 +95,21 @@ const Content = styled.div`
margin: 0 auto;
`;
-return (
-
-
-
-
- Designed to connect and empower builders in a{" "}
- multi-chain ecosystem
-
-
-
-
-
-
-);
+const Hero = () => {
+ return (
+
+
+
+
+ Designed to connect and empower builders in a{" "}
+ multi-chain ecosystem
+
+
+
+
+
+
+ );
+};
+
+return { Hero };
diff --git a/apps/builddao/widget/section/join.jsx b/apps/builddao/widget/home/join.jsx
similarity index 81%
rename from apps/builddao/widget/section/join.jsx
rename to apps/builddao/widget/home/join.jsx
index 01e9f958..e5f5dad6 100644
--- a/apps/builddao/widget/section/join.jsx
+++ b/apps/builddao/widget/home/join.jsx
@@ -317,55 +317,59 @@ const CTAContent = styled.div`
}
`;
-return (
-
-
-
-
- Open call for members to{" "}
- join and contribute
-
-
- Build DAO is an innovative, community-led organization designed to serve
- the open web ecosystem in multiple ways:
-
-
-
-
-
-
-
-
-
- How to join
-
-
+const Join = () => {
+ return (
+
+
+
+
+ Open call for members to{" "}
+ join and contribute
+
- 1. Sign membership agreement (on-chain)
-
- 2. Propose to be added to the “Community” role
-
- 3. Fulfill contribution requirements
+ Build DAO is an innovative, community-led organization designed to
+ serve the open web ecosystem in multiple ways:
-
+
+
-
-
-
-);
+
+
+
+
+
+ How to join
+
+
+
+ 1. Sign membership agreement (on-chain)
+
+ 2. Propose to be added to the “Community” role
+
+ 3. Fulfill contribution requirements
+
+
+
+
+
+ );
+};
+
+return { Join };
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index a74adcab..065c4419 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -1 +1 @@
-return ;
+return ;
From 945fffa58a7c67e5c8cda8f15033b330805d332a Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Tue, 30 Jan 2024 22:38:36 +0500
Subject: [PATCH 094/132] Convert all to
---
apps/builddao/widget/Feed.jsx | 5 +-
apps/builddao/widget/JoinSection.jsx | 8 +-
apps/builddao/widget/components.jsx | 2 -
apps/builddao/widget/components/Button.jsx | 24 +++++
.../builddao/widget/components/ButtonLink.jsx | 93 -------------------
apps/builddao/widget/components/User.jsx | 4 +-
.../widget/components/buttons/Connect.jsx | 8 +-
.../widget/components/post/Content.jsx | 4 +-
.../builddao/widget/components/post/Embed.jsx | 2 +-
.../widget/components/post/Header.jsx | 12 +--
apps/builddao/widget/page/feed.jsx | 8 +-
apps/builddao/widget/propose.jsx | 4 +-
.../widget/template/SidebarLayout.jsx | 6 +-
13 files changed, 56 insertions(+), 124 deletions(-)
delete mode 100644 apps/builddao/widget/components/ButtonLink.jsx
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 9a84bf12..0ff60681 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -1,9 +1,8 @@
const { Feed } = VM.require("devs.near/widget/Feed") || {
Feed: () => <>>,
};
-const { Post, ButtonLink } = VM.require("buildhub.near/widget/components") || {
+const { Post } = VM.require("buildhub.near/widget/components") || {
Post: () => <>>,
- ButtonLink: () => <>>,
};
const { name, template, requiredHashtags, customActions } = props;
@@ -40,7 +39,7 @@ return (
accountId={p.accountId}
blockHeight={p.blockHeight}
noBorder={true}
- currentPath={`${props.pagePath}`}
+ currentPath={`/?page=feed`}
customActions={customActions}
feedType={name}
/>
diff --git a/apps/builddao/widget/JoinSection.jsx b/apps/builddao/widget/JoinSection.jsx
index f1827e04..edece143 100644
--- a/apps/builddao/widget/JoinSection.jsx
+++ b/apps/builddao/widget/JoinSection.jsx
@@ -164,7 +164,7 @@ const proposalId = Near.view(daoId, "get_last_proposal_id") - 1;
// get data from last proposal
const proposal = Near.view(daoId, "get_proposal", {
- id: proposalId
+ id: proposalId,
});
if (proposal === null) {
@@ -197,7 +197,7 @@ const CreateSomethingView = (props) => {
{userWidgets.length === 0 ? (
<>
In order to join Build DAO, you need to create a widget
-
+
Create Something{" "}
{
fill="black"
/>
-
+
>
) : (
{
>
),
className: "custom-button",
- showActivity: true
+ showActivity: true,
}}
/>
)}{" "}
diff --git a/apps/builddao/widget/components.jsx b/apps/builddao/widget/components.jsx
index cf321740..65f404f0 100644
--- a/apps/builddao/widget/components.jsx
+++ b/apps/builddao/widget/components.jsx
@@ -1,5 +1,4 @@
const { Button } = VM.require("buildhub.near/widget/components.Button");
-const { ButtonLink } = VM.require("buildhub.near/widget/components.ButtonLink");
const { ProgressState } = VM.require(
"buildhub.near/widget/components.ProgressState"
);
@@ -57,7 +56,6 @@ function User(props) {
return {
Button,
- ButtonLink,
Pagination,
Post,
ProgressState,
diff --git a/apps/builddao/widget/components/Button.jsx b/apps/builddao/widget/components/Button.jsx
index 5958ea6e..f20a4e0b 100644
--- a/apps/builddao/widget/components/Button.jsx
+++ b/apps/builddao/widget/components/Button.jsx
@@ -76,8 +76,32 @@ function Button({
type,
onClick,
className,
+ linkClassName,
+ href,
style,
}) {
+ if (href) {
+ return (
+
+
+ {children}
+
+
+ );
+ }
+
return (
- props.type === "icon" &&
- `
- display: flex;
- width: 40px;
- height: 40px;
- padding: 5px;
- flex-shrink: 0;
- border-radius: 50%;
- `}
-
- /* Colors based on variant prop */
- background: ${(props) => {
- switch (props.variant) {
- case "primary":
- return "var(--button-primary-bg, #FFAF51)";
- case "outline":
- return "var(--button-outline-bg, transparent)";
- default:
- return "var(--button-default-bg, #23242B)";
- }
- }};
-
- color: ${(props) => {
- switch (props.variant) {
- case "primary":
- return "var(--button-primary-color, #000)";
- case "outline":
- return "var(--button-outline-color, #fff)";
- default:
- return "var(--button-default-color, #CDD0D5)";
- }
- }};
-
- border: ${(props) =>
- props.variant === "outline"
- ? "1px solid var(--stroke-color, rgba(255, 255, 255, 0.20))"
- : ""};
-
- /* Hover states */
- &:hover {
- background: ${(props) => {
- switch (props.variant) {
- case "primary":
- return "var(--button-primary-hover-bg, #e49b48)";
- case "outline":
- return "var(--button-outline-hover-bg, rgba(255, 255, 255, 0.20))";
- default:
- return "var(--button-default-hover-bg, #17181c)";
- }
- }};
- }
-`;
-
-function ButtonLink({
- id,
- children,
- linkClassName,
- variant,
- type,
- href,
- className,
- style,
-}) {
- return (
-
-
- {children}
-
-
- );
-}
-
-return { ButtonLink };
diff --git a/apps/builddao/widget/components/User.jsx b/apps/builddao/widget/components/User.jsx
index 0d300c77..d4ceabe5 100644
--- a/apps/builddao/widget/components/User.jsx
+++ b/apps/builddao/widget/components/User.jsx
@@ -51,7 +51,7 @@ const name = props.name || Social.get(`${accountId}/profile/name`);
const isPremium = !!props.isPremium;
const Overlay = (props) => (
-
@@ -63,7 +63,7 @@ const Overlay = (props) => (
children: props.children,
}}
/>
-
+
);
return (
diff --git a/apps/builddao/widget/components/buttons/Connect.jsx b/apps/builddao/widget/components/buttons/Connect.jsx
index 5ac749a1..c07d4c82 100644
--- a/apps/builddao/widget/components/buttons/Connect.jsx
+++ b/apps/builddao/widget/components/buttons/Connect.jsx
@@ -132,7 +132,7 @@ const Component = () => {
{data.isDaoMember ? "Joined" : "Pending application"}
-
+
View Activity{" "}
{
fill="black"
/>
-
+
);
}
@@ -154,9 +154,9 @@ const Component = () => {
} else {
if (href) {
return (
-
+
{joinBtnChildren}
-
+
);
} else {
return (
diff --git a/apps/builddao/widget/components/post/Content.jsx b/apps/builddao/widget/components/post/Content.jsx
index 5d18cc8d..10d8bac1 100644
--- a/apps/builddao/widget/components/post/Content.jsx
+++ b/apps/builddao/widget/components/post/Content.jsx
@@ -53,13 +53,15 @@ const Wrapper = styled.div`
}
`;
+const currentPath = props.currentPath ?? "/?page=feed";
+
const [onHashtag] = useState(() => (hashtag) => (
- #{hashtag}
+ #{hashtag}
));
diff --git a/apps/builddao/widget/components/post/Embed.jsx b/apps/builddao/widget/components/post/Embed.jsx
index 8bd146b0..0e4006e3 100644
--- a/apps/builddao/widget/components/post/Embed.jsx
+++ b/apps/builddao/widget/components/post/Embed.jsx
@@ -39,7 +39,7 @@ const parsed = useMemo(() => {
}, [href]);
if (!parsed || !EmbedMap.has(parsed.widgetSrc)) {
- return
{props.children} ;
+ return
{props.children};
}
const widgetSrc = EmbedMap.get(parsed.widgetSrc);
diff --git a/apps/builddao/widget/components/post/Header.jsx b/apps/builddao/widget/components/post/Header.jsx
index 7930170e..3b6f736c 100644
--- a/apps/builddao/widget/components/post/Header.jsx
+++ b/apps/builddao/widget/components/post/Header.jsx
@@ -98,7 +98,7 @@ const showTime = props.showTime ?? true;
const toggleModal = props.toggleModal;
const Overlay = (props) => (
-
@@ -110,7 +110,7 @@ const Overlay = (props) => (
children: props.children,
}}
/>
-
+
);
return (
@@ -135,13 +135,13 @@ return (
{blockHeight === "now" ? (
"now"
) : (
-
+
-
+
)}
)}
@@ -160,12 +160,12 @@ return (
-
View raw markdown source
-
+
-
+
@@ -77,8 +81,6 @@ return (
);
-return;
-
// const { feeds } = VM.require("buildhub.near/widget/config.feed") || {}; // this is the thing, which works better as a module if it needs to be provided with context
// console.log(feeds);
diff --git a/apps/builddao/widget/propose.jsx b/apps/builddao/widget/propose.jsx
index 8d0af761..221707ba 100644
--- a/apps/builddao/widget/propose.jsx
+++ b/apps/builddao/widget/propose.jsx
@@ -170,7 +170,7 @@ return (
/>
- selection === 2 && setView("proposal")}
>
@@ -187,7 +187,7 @@ return (
fill="black"
/>
-
+
>
) : (
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
index 6117cbde..572eab97 100644
--- a/apps/builddao/widget/template/SidebarLayout.jsx
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -1,4 +1,4 @@
-const { ButtonLink } = VM.require("buildhub.near/widget/components");
+const { Button } = VM.require("buildhub.near/widget/components");
const Container = styled.div`
display: grid;
@@ -45,7 +45,7 @@ const Sidebar = ({ currentPath, page, routes }) => (
return null;
}
return (
- (
>
{route.init.icon && }
{route.init.name}
-
+
);
})}
>
From 2614fea357415b921e6defbbca6ee25100d71d43 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 01:31:09 +0500
Subject: [PATCH 095/132] Add testing about route
---
apps/builddao/widget/Home.jsx | 2 +-
apps/builddao/widget/config/routes.jsx | 7 ++++
apps/builddao/widget/lib/url.jsx | 44 ++++++++++++++++++++++++++
apps/builddao/widget/page/about.jsx | 18 +++++++++++
4 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 apps/builddao/widget/lib/url.jsx
create mode 100644 apps/builddao/widget/page/about.jsx
diff --git a/apps/builddao/widget/Home.jsx b/apps/builddao/widget/Home.jsx
index 553edd88..72d8acf3 100644
--- a/apps/builddao/widget/Home.jsx
+++ b/apps/builddao/widget/Home.jsx
@@ -10,7 +10,7 @@ const ownerId = "/*__@appAccount__*/";
const Root = styled.div`
background-color: #0b0c14;
color: #ffffff;
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
width: 100%;
`;
diff --git a/apps/builddao/widget/config/routes.jsx b/apps/builddao/widget/config/routes.jsx
index cc1f593e..97bdf06a 100644
--- a/apps/builddao/widget/config/routes.jsx
+++ b/apps/builddao/widget/config/routes.jsx
@@ -8,6 +8,13 @@ return {
name: "Home",
},
},
+ about: {
+ path: "buildhub.near/widget/page.about",
+ blockHeight: "final",
+ init: {
+ name: "About",
+ },
+ },
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
diff --git a/apps/builddao/widget/lib/url.jsx b/apps/builddao/widget/lib/url.jsx
new file mode 100644
index 00000000..c9af8f72
--- /dev/null
+++ b/apps/builddao/widget/lib/url.jsx
@@ -0,0 +1,44 @@
+/**
+ * kanged from https://github.com/NEAR-DevHub/neardevhub-bos/blob/main/src/core/lib/url.jsx
+ * Generates a URL to a widget.
+ *
+ * @param {Object} options - Configuration options for constructing the URL.
+ * @param {string} [options.gateway] - The gateway or server address where the widget source is hosted (optional).
+ * @param {string} options.widgetSrc - The source path of the widget (required).
+ * @param {Object} [options.params] - An object containing key-value pairs representing query parameters to be appended to the URL (optional).
+ * @returns {string} - The constructed URL.
+ */
+function href({ gateway, widgetSrc, params }) {
+ // Check if query parameters are provided and filter out null values
+ if (params) {
+ params = (Object.entries(params) || [])
+ .filter(([_key, nullable]) => (nullable ?? null) !== null)
+ .map(([key, value]) => {
+ // Omit the parameter if the value is null or the array is empty
+ if (value === null || (Array.isArray(value) && value.length === 0)) {
+ return null;
+ }
+
+ // Convert array values to a comma-separated string with no spaces
+ if (Array.isArray(value)) {
+ return `${key}=${value.join(",")}`;
+ } else {
+ return `${key}=${value}`;
+ }
+ })
+ .join("&");
+ }
+
+ // Check if the gateway already includes "https://" and construct the final URL accordingly
+ if (gateway) {
+ if (/(^https:\/\/)|(^http:\/\/)/.test(gateway)) {
+ return `/${gateway}/${widgetSrc}${params && `?${params}`}`;
+ } else {
+ return `https://${gateway}/${widgetSrc}${params && `?${params}`}`;
+ }
+ } else {
+ return `/${widgetSrc}${params && `?${params}`}`;
+ }
+}
+
+return { href };
diff --git a/apps/builddao/widget/page/about.jsx b/apps/builddao/widget/page/about.jsx
new file mode 100644
index 00000000..9b0c70fc
--- /dev/null
+++ b/apps/builddao/widget/page/about.jsx
@@ -0,0 +1,18 @@
+const { Button } =
+ VM.require("buildhub.near/widget/components") || (() => <>>);
+const { href } = VM.require("buildhub.near/widget/lib.url") || (() => null);
+
+return (
+
+
+ Go Back
+
+
+);
From 49b1de689db70402ffbba203209d43123d2d8aa9 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 01:49:26 +0500
Subject: [PATCH 096/132] Replace href with href function
---
apps/builddao/widget/components/User.jsx | 9 ++++-
.../widget/components/buttons/Connect.jsx | 13 +++++++-
.../widget/components/navigation/header.jsx | 33 ++++++++++++++++---
.../widget/components/post/Header.jsx | 9 ++++-
4 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/apps/builddao/widget/components/User.jsx b/apps/builddao/widget/components/User.jsx
index d4ceabe5..5c2307ba 100644
--- a/apps/builddao/widget/components/User.jsx
+++ b/apps/builddao/widget/components/User.jsx
@@ -46,6 +46,8 @@ const Wrapper = styled.div`
}
`;
+const { href } = VM.require("buildhub.near/widget/lib.url") || (() => {});
+
const accountId = props.accountId;
const name = props.name || Social.get(`${accountId}/profile/name`);
const isPremium = !!props.isPremium;
@@ -53,7 +55,12 @@ const isPremium = !!props.isPremium;
const Overlay = (props) => (
{});
+
const Component = () => {
if (data.isDaoMember || isConnected) {
if (showActivity) {
@@ -132,7 +135,15 @@ const Component = () => {
{data.isDaoMember ? "Joined" : "Pending application"}
-
+
View Activity{" "}
{});
+
const NavLink = ({ to, children }) => (
-
+
{children}
);
@@ -67,7 +78,14 @@ const AppHeader = ({ page, routes }) => (
-
+
(
/>
-
+
{});
+
const Overlay = (props) => (
Date: Wed, 31 Jan 2024 02:00:02 +0500
Subject: [PATCH 097/132] Fix issues with
---
apps/builddao/widget/Feed.jsx | 2 +-
apps/builddao/widget/app.jsx | 10 +++++++++-
apps/builddao/widget/components/navigation/header.jsx | 6 +++---
apps/builddao/widget/components/post/Content.jsx | 2 +-
apps/builddao/widget/components/post/Header.jsx | 2 +-
apps/builddao/widget/template/SidebarLayout.jsx | 2 +-
6 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 0ff60681..6926ca97 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -39,7 +39,7 @@ return (
accountId={p.accountId}
blockHeight={p.blockHeight}
noBorder={true}
- currentPath={`/?page=feed`}
+ currentPath={`/buildhub.near/widget/app?page=feed`}
customActions={customActions}
feedType={name}
/>
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 64797276..711bf8ae 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -48,7 +48,15 @@ function Router({ active, routes }) {
return (
-
+
);
}
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 6d11903f..3ae22f2d 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -62,7 +62,7 @@ const NavLink = ({ to, children }) => (
// to={`/?page=${to}`}
to={href({
widgetSrc: "buildhub.near/widget/app",
- props: {
+ params: {
page: to,
},
})}
@@ -81,7 +81,7 @@ const AppHeader = ({ page, routes }) => (
(
(hashtag) => (
(
className="link-dark text-truncate d-inline-flex mw-100"
to={href({
widgetSrc: "mob.near/widget/ProfilePage",
- props: {
+ params: {
accountId,
},
})}
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
index 572eab97..367dd17e 100644
--- a/apps/builddao/widget/template/SidebarLayout.jsx
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -48,7 +48,7 @@ const Sidebar = ({ currentPath, page, routes }) => (
Date: Wed, 31 Jan 2024 02:02:43 +0500
Subject: [PATCH 098/132] Add loading to widget for smoother loading
---
apps/builddao/widget/components/navigation/header.jsx | 2 ++
apps/builddao/widget/page/home.jsx | 2 +-
apps/builddao/widget/template/AppLayout.jsx | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 3ae22f2d..7715dbcb 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -110,6 +110,7 @@ const AppHeader = ({ page, routes }) => (
User Dropdown ,
showActivity: false,
@@ -169,6 +170,7 @@ const AppHeader = ({ page, routes }) => (
User Dropdown
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index 065c4419..137e5ce6 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -1 +1 @@
-return
;
+return
;
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index f89ef72d..b3108156 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -31,6 +31,7 @@ function AppLayout({ routes, page, children }) {
{/*
*/}
{children}
From 6ad825ef2f9e10924577d22ef67d6af5a5e36f17 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 16:06:42 -0500
Subject: [PATCH 099/132] remove useEffect in app
---
apps/builddao/widget/app.jsx | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 711bf8ae..0773b66d 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -18,11 +18,11 @@ const Root = styled.div`
${theme}// can come from config
`;
-const [activeRoute, setActiveRoute] = useState(page);
+// const [activeRoute, setActiveRoute] = useState(page);
-useEffect(() => {
- setActiveRoute(page);
-}, [page]);
+// useEffect(() => {
+// setActiveRoute(page);
+// }, [page]);
function Router({ active, routes }) {
// this may be converted to a module at devs.near/widget/Router
@@ -74,9 +74,9 @@ const Content = styled.div`
return (
-
+
-
+
From d77769d60a05c3dd51b112c7dd6f8b2c83b7831f Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 02:23:26 +0500
Subject: [PATCH 100/132] Remove about page
---
apps/builddao/widget/config/routes.jsx | 7 -------
apps/builddao/widget/page/about.jsx | 18 ------------------
2 files changed, 25 deletions(-)
delete mode 100644 apps/builddao/widget/page/about.jsx
diff --git a/apps/builddao/widget/config/routes.jsx b/apps/builddao/widget/config/routes.jsx
index 97bdf06a..cc1f593e 100644
--- a/apps/builddao/widget/config/routes.jsx
+++ b/apps/builddao/widget/config/routes.jsx
@@ -8,13 +8,6 @@ return {
name: "Home",
},
},
- about: {
- path: "buildhub.near/widget/page.about",
- blockHeight: "final",
- init: {
- name: "About",
- },
- },
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
diff --git a/apps/builddao/widget/page/about.jsx b/apps/builddao/widget/page/about.jsx
deleted file mode 100644
index 9b0c70fc..00000000
--- a/apps/builddao/widget/page/about.jsx
+++ /dev/null
@@ -1,18 +0,0 @@
-const { Button } =
- VM.require("buildhub.near/widget/components") || (() => <>>);
-const { href } = VM.require("buildhub.near/widget/lib.url") || (() => null);
-
-return (
-
-
- Go Back
-
-
-);
From 36ea16212f1f1585455d719ce4a2d8a3a9c1240e Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 16:23:30 -0500
Subject: [PATCH 101/132] clean nav
---
apps/bos-blocks/widget/Router.jsx | 159 +++++++++++-------
apps/builddao/widget/Home.jsx | 24 ++-
apps/builddao/widget/app.jsx | 81 +++++----
.../widget/components/navigation/header.jsx | 4 +-
apps/builddao/widget/config/routes.jsx | 1 -
apps/builddao/widget/page/home.jsx | 42 ++++-
apps/builddao/widget/template/AppLayout.jsx | 18 +-
src/pages/Viewer.js | 2 +-
8 files changed, 213 insertions(+), 118 deletions(-)
diff --git a/apps/bos-blocks/widget/Router.jsx b/apps/bos-blocks/widget/Router.jsx
index c6bea38c..05dbcaa2 100644
--- a/apps/bos-blocks/widget/Router.jsx
+++ b/apps/bos-blocks/widget/Router.jsx
@@ -1,72 +1,111 @@
// We eventually want to merge this with what we have in buildhub.near/widget/app
-const routes = props.routes;
-if (!routes) {
- routes = [];
-}
-const Navigator = props.Navigator;
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
+ const routeParts = active.split(".");
+
+ let currentRoute = routes;
+ let src = "";
+ let defaultProps = {};
-State.init({
- CurrentWidget: null,
-});
+ for (let part of routeParts) {
+ if (currentRoute[part]) {
+ currentRoute = currentRoute[part];
+ src = currentRoute.path;
-function init() {
- if (!state.CurrentWidget) {
- // TODO: check from local storage or props
- const initialSrc = Object.values(props.routes)[0].src;
- State.update({ CurrentWidget: initialSrc });
- // () =>
+ if (currentRoute.init) {
+ defaultProps = { ...defaultProps, ...currentRoute.init };
+ }
+ } else {
+ // Handle 404 or default case for unknown routes
+ return 404 Not Found
;
+ }
}
+
+ return (
+
+
+
+ );
}
-init();
+return { Router };
-// Function to handle navigation
-function handleNavigate(newRoute, passProps) {
- const currentSrc = props.routes[newRoute]?.src;
- State.update({ CurrentWidget: currentSrc, passProps });
-}
+// const routes = props.routes;
+// if (!routes) {
+// routes = [];
+// }
+// const Navigator = props.Navigator;
-// const activePage = pages.find((p) => p.active);
+// State.init({
+// CurrentWidget: null,
+// });
-// const navigate = (v, params) => {
-// State.update({ page: v, project: params?.project });
-// const url = Url.construct("#//*__@appAccount__*//widget/home", params);
-// Storage.set("url", url);
-// };
+// function init() {
+// if (!state.CurrentWidget) {
+// // TODO: check from local storage or props
+// const initialSrc = Object.values(props.routes)[0].src;
+// State.update({ CurrentWidget: initialSrc });
+// // () =>
+// }
+// }
-function RouterLink({ to, children, passProps }) {
- return (
- handleNavigate(to, passProps)}
- key={"link-to-" + to}
- style={{ cursor: "pointer" }}
- >
- {children}
-
- );
-}
+// init();
-// Render the current widget or a default message if the route is not found
-return (
-
- {/* Navigation buttons -- this should be passed to a Navigator widget */}
-
-
-
- {/** This could already render all of the children, but just put them as display none (lazy loading) */}
- {state.CurrentWidget ? (
-
- ) : (
-
{JSON.stringify(state.CurrentWidget)}
- )}
-
-);
\ No newline at end of file
+// // Function to handle navigation
+// function handleNavigate(newRoute, passProps) {
+// const currentSrc = props.routes[newRoute]?.src;
+// State.update({ CurrentWidget: currentSrc, passProps });
+// }
+
+// // const activePage = pages.find((p) => p.active);
+
+// // const navigate = (v, params) => {
+// // State.update({ page: v, project: params?.project });
+// // const url = Url.construct("#//*__@appAccount__*//widget/home", params);
+// // Storage.set("url", url);
+// // };
+
+// function RouterLink({ to, children, passProps }) {
+// return (
+// handleNavigate(to, passProps)}
+// key={"link-to-" + to}
+// style={{ cursor: "pointer" }}
+// >
+// {children}
+//
+// );
+// }
+
+// // Render the current widget or a default message if the route is not found
+// return (
+//
+// {/* Navigation buttons -- this should be passed to a Navigator widget */}
+//
+//
+//
+// {/** This could already render all of the children, but just put them as display none (lazy loading) */}
+// {state.CurrentWidget ? (
+//
+// ) : (
+//
{JSON.stringify(state.CurrentWidget)}
+// )}
+//
+// );
diff --git a/apps/builddao/widget/Home.jsx b/apps/builddao/widget/Home.jsx
index 72d8acf3..b7dde69b 100644
--- a/apps/builddao/widget/Home.jsx
+++ b/apps/builddao/widget/Home.jsx
@@ -1,9 +1,21 @@
-const { Hero } = VM.require("buildhub.near/widget/home.hero");
-const { Goals } = VM.require("buildhub.near/widget/home.goals");
-const { Join } = VM.require("buildhub.near/widget/home.join");
-const { Governance } = VM.require("buildhub.near/widget/home.governance");
-const { CTA } = VM.require("buildhub.near/widget/home.cta");
-const { Footer } = VM.require("buildhub.near/widget/home.footer");
+const { Hero } = VM.require("buildhub.near/widget/home.hero") || {
+ Hero: () => <>>
+};
+const { Goals } = VM.require("buildhub.near/widget/home.goals") || {
+ Goals: () => <>>
+};
+const { Join } = VM.require("buildhub.near/widget/home.join") || {
+ Join: () => <>>
+};
+const { Governance } = VM.require("buildhub.near/widget/home.governance") || {
+ Governance: () => <>>
+};
+const { CTA } = VM.require("buildhub.near/widget/home.cta") || {
+ CTA: () => <>>
+};
+const { Footer } = VM.require("buildhub.near/widget/home.footer") || {
+ Footer: () => <>>
+};
const ownerId = "/*__@appAccount__*/";
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 0773b66d..238de048 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,21 +1,55 @@
const { page, tab, layout, loading, ...passProps } = props;
-const { routes } = VM.require("buildhub.near/widget/config.routes") ?? {
- routes: {},
+const { routes } = {
+ type: "app",
+ routes: {
+ home: {
+ path: "buildhub.near/widget/page.home",
+ blockHeight: "final",
+ init: {
+ name: "Home",
+ },
+ },
+ about: {
+ path: "buildhub.near/widget/page.about",
+ blockHeight: "final",
+ init: {
+ name: "About",
+ },
+ },
+ feed: {
+ path: "buildhub.near/widget/page.feed",
+ blockHeight: "final",
+ init: {
+ name: "Feed",
+ },
+ },
+ proposal: {
+ path: "buildhub.near/widget/page.proposals",
+ blockHeight: "final",
+ init: {
+ name: "Proposals",
+ },
+ },
+ },
};
-const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
- theme: {},
-};
+// const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+// theme: {},
+// };
const { AppLayout } = VM.require("buildhub.near/widget/template.AppLayout") || {
AppLayout: () => <>Layout loading...>,
};
+const { Router } = VM.require("devs.near/widget/Router") || {
+ Router: () => <>Router loading...>,
+}
+
if (!page) page = Object.keys(routes)[0] || "home";
const Root = styled.div`
- ${theme}// can come from config
+ // can come from config
`;
// const [activeRoute, setActiveRoute] = useState(page);
@@ -24,42 +58,7 @@ const Root = styled.div`
// setActiveRoute(page);
// }, [page]);
-function Router({ active, routes }) {
- // this may be converted to a module at devs.near/widget/Router
- const routeParts = active.split(".");
-
- let currentRoute = routes;
- let src = "";
- let defaultProps = {};
- for (let part of routeParts) {
- if (currentRoute[part]) {
- currentRoute = currentRoute[part];
- src = currentRoute.path;
-
- if (currentRoute.init) {
- defaultProps = { ...defaultProps, ...currentRoute.init };
- }
- } else {
- // Handle 404 or default case for unknown routes
- return 404 Not Found
;
- }
- }
-
- return (
-
-
-
- );
-}
const Container = styled.div`
display: flex;
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 7715dbcb..31326b8f 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -1,4 +1,6 @@
-const { Button } = VM.require("buildhub.near/widget/components");
+const { Button } = VM.require("buildhub.near/widget/components") || {
+ Button: () => <>>
+};
const Navbar = styled.div`
width: 64px;
diff --git a/apps/builddao/widget/config/routes.jsx b/apps/builddao/widget/config/routes.jsx
index cc1f593e..dd312e46 100644
--- a/apps/builddao/widget/config/routes.jsx
+++ b/apps/builddao/widget/config/routes.jsx
@@ -23,5 +23,4 @@ return {
},
},
},
- theme: theme,
};
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index 137e5ce6..b7dde69b 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -1 +1,41 @@
-return ;
+const { Hero } = VM.require("buildhub.near/widget/home.hero") || {
+ Hero: () => <>>
+};
+const { Goals } = VM.require("buildhub.near/widget/home.goals") || {
+ Goals: () => <>>
+};
+const { Join } = VM.require("buildhub.near/widget/home.join") || {
+ Join: () => <>>
+};
+const { Governance } = VM.require("buildhub.near/widget/home.governance") || {
+ Governance: () => <>>
+};
+const { CTA } = VM.require("buildhub.near/widget/home.cta") || {
+ CTA: () => <>>
+};
+const { Footer } = VM.require("buildhub.near/widget/home.footer") || {
+ Footer: () => <>>
+};
+
+const ownerId = "/*__@appAccount__*/";
+
+const Root = styled.div`
+ background-color: #0b0c14;
+ color: #ffffff;
+ font-family: Satoshi, sans-serif;
+
+ width: 100%;
+`;
+
+const sections = ["hero", "goals", "join", "governance", "cta", "footer"];
+
+return (
+
+
+
+
+
+
+
+
+);
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index b3108156..087544e1 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -2,7 +2,9 @@
* This is a standard layout with a header, body, and a footer
*/
-const { Button } = VM.require("buildhub.near/widget/components");
+const { Button } = VM.require("buildhub.near/widget/components") || {
+ Button: () => <>>,
+};
const Container = styled.div`
display: flex;
@@ -20,6 +22,13 @@ const ContentContainer = styled.div`
width: 100%;
`;
+const Header = ({ page, routes }) => (
+
+);
+
const Footer = (props) => {
return <>>;
};
@@ -28,12 +37,7 @@ const Footer = (props) => {
function AppLayout({ routes, page, children }) {
return (
- {/* */}
-
+
{children}
diff --git a/src/pages/Viewer.js b/src/pages/Viewer.js
index 5310c7bd..f36eca7b 100644
--- a/src/pages/Viewer.js
+++ b/src/pages/Viewer.js
@@ -60,7 +60,7 @@ function Viewer({ code }) {
return (
Date: Wed, 31 Jan 2024 02:25:07 +0500
Subject: [PATCH 102/132] Remove about
---
apps/builddao/widget/app.jsx | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 238de048..a4dfd395 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -10,13 +10,6 @@ const { routes } = {
name: "Home",
},
},
- about: {
- path: "buildhub.near/widget/page.about",
- blockHeight: "final",
- init: {
- name: "About",
- },
- },
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
@@ -44,12 +37,12 @@ const { AppLayout } = VM.require("buildhub.near/widget/template.AppLayout") || {
const { Router } = VM.require("devs.near/widget/Router") || {
Router: () => <>Router loading...>,
-}
+};
if (!page) page = Object.keys(routes)[0] || "home";
const Root = styled.div`
- // can come from config
+ // can come from config
`;
// const [activeRoute, setActiveRoute] = useState(page);
@@ -58,8 +51,6 @@ const Root = styled.div`
// setActiveRoute(page);
// }, [page]);
-
-
const Container = styled.div`
display: flex;
height: 100%;
From fa3218e33dd7a3d511af586fe3607a7203193c01 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 16:26:29 -0500
Subject: [PATCH 103/132] adds theme and router
---
apps/builddao/widget/app.jsx | 106 +++++++++++++++++++++++------------
1 file changed, 69 insertions(+), 37 deletions(-)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index a4dfd395..9634351c 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,55 +1,87 @@
const { page, tab, layout, loading, ...passProps } = props;
-const { routes } = {
- type: "app",
- routes: {
- home: {
- path: "buildhub.near/widget/page.home",
- blockHeight: "final",
- init: {
- name: "Home",
- },
- },
- feed: {
- path: "buildhub.near/widget/page.feed",
- blockHeight: "final",
- init: {
- name: "Feed",
- },
- },
- proposal: {
- path: "buildhub.near/widget/page.proposals",
- blockHeight: "final",
- init: {
- name: "Proposals",
- },
- },
- },
+const { routes } = VM.require("buildhub.near/widget/config.routes") ?? {
+ routes: {},
};
-// const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
-// theme: {},
-// };
+const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+ theme: {},
+};
const { AppLayout } = VM.require("buildhub.near/widget/template.AppLayout") || {
AppLayout: () => <>Layout loading...>,
};
-const { Router } = VM.require("devs.near/widget/Router") || {
- Router: () => <>Router loading...>,
-};
-
if (!page) page = Object.keys(routes)[0] || "home";
const Root = styled.div`
- // can come from config
+ --stroke-color: rgba(255, 255, 255, 0.2);
+ --bg-1: #0b0c14;
+ --bg-1-hover: #17181c;
+ --bg-1-hover-transparent: rgba(23, 24, 28, 0);
+ --bg-2: ##23242b;
+ --label-color: #fff;
+ --font-color: #fff;
+ --font-muted-color: #cdd0d5;
+ --black: #000;
+ --system-red: #fd2a5c;
+ --yellow: #ffaf51;
+
+ --compose-bg: #23242b;
+
+ --post-bg: #0b0c14;
+ --post-bg-hover: #17181c;
+ --post-bg-transparent: rgba(23, 24, 28, 0);
+
+ --button-primary-bg: #ffaf51;
+ --button-outline-bg: transparent;
+ --button-default-bg: #23242b;
+
+ --button-primary-color: #000;
+ --button-outline-color: #cdd0d5;
+ --button-default-color: #cdd0d5;
+
+ --button-primary-hover-bg: #e49b48;
+ --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
+ --button-default-hover-bg: #17181c;
`;
-// const [activeRoute, setActiveRoute] = useState(page);
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
+ const routeParts = active.split(".");
+
+ let currentRoute = routes;
+ let src = "";
+ let defaultProps = {};
+
+ for (let part of routeParts) {
+ if (currentRoute[part]) {
+ currentRoute = currentRoute[part];
+ src = currentRoute.path;
+
+ if (currentRoute.init) {
+ defaultProps = { ...defaultProps, ...currentRoute.init };
+ }
+ } else {
+ // Handle 404 or default case for unknown routes
+ return 404 Not Found
;
+ }
+ }
-// useEffect(() => {
-// setActiveRoute(page);
-// }, [page]);
+ return (
+
+
+
+ );
+}
const Container = styled.div`
display: flex;
From 1f16d1f1c964cbb0348fcf37f0bd3287f6852189 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 02:30:21 +0500
Subject: [PATCH 104/132] Fix some links
---
apps/builddao/widget/components/User.jsx | 2 +-
apps/builddao/widget/components/buttons/Connect.jsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/components/User.jsx b/apps/builddao/widget/components/User.jsx
index 5c2307ba..4d754ef6 100644
--- a/apps/builddao/widget/components/User.jsx
+++ b/apps/builddao/widget/components/User.jsx
@@ -57,7 +57,7 @@ const Overlay = (props) => (
className="link-dark text-truncate d-inline-flex mw-100"
to={href({
widgetSrc: "mob.near/widget/ProfilePage",
- props: {
+ params: {
accountId,
},
})}
diff --git a/apps/builddao/widget/components/buttons/Connect.jsx b/apps/builddao/widget/components/buttons/Connect.jsx
index bb11c9a5..b46c5d94 100644
--- a/apps/builddao/widget/components/buttons/Connect.jsx
+++ b/apps/builddao/widget/components/buttons/Connect.jsx
@@ -139,7 +139,7 @@ const Component = () => {
// href={"/?page=feed"}
to={linkHref({
widgetSrc: "buildhub.near/widget/app",
- props: {
+ params: {
page: "feed",
},
})}
From 90eea92531ec3e5341e8b393880f049794d5f716 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 16:30:11 -0500
Subject: [PATCH 105/132] cleanup
---
apps/builddao/widget/app.jsx | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 9634351c..4b843b5b 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -1,13 +1,9 @@
-const { page, tab, layout, loading, ...passProps } = props;
+const { page, tab, ...passProps } = props;
const { routes } = VM.require("buildhub.near/widget/config.routes") ?? {
routes: {},
};
-const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
- theme: {},
-};
-
const { AppLayout } = VM.require("buildhub.near/widget/template.AppLayout") || {
AppLayout: () => <>Layout loading...>,
};
From b47cf41b861c5d70950a2b9874a7b83d496ab314 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 16:43:03 -0500
Subject: [PATCH 106/132] move home
---
apps/builddao/widget/Home.jsx | 41 ---------------------------
apps/builddao/widget/config/theme.jsx | 33 ---------------------
apps/builddao/widget/page/home.jsx | 2 --
3 files changed, 76 deletions(-)
delete mode 100644 apps/builddao/widget/Home.jsx
delete mode 100644 apps/builddao/widget/config/theme.jsx
diff --git a/apps/builddao/widget/Home.jsx b/apps/builddao/widget/Home.jsx
deleted file mode 100644
index b7dde69b..00000000
--- a/apps/builddao/widget/Home.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-const { Hero } = VM.require("buildhub.near/widget/home.hero") || {
- Hero: () => <>>
-};
-const { Goals } = VM.require("buildhub.near/widget/home.goals") || {
- Goals: () => <>>
-};
-const { Join } = VM.require("buildhub.near/widget/home.join") || {
- Join: () => <>>
-};
-const { Governance } = VM.require("buildhub.near/widget/home.governance") || {
- Governance: () => <>>
-};
-const { CTA } = VM.require("buildhub.near/widget/home.cta") || {
- CTA: () => <>>
-};
-const { Footer } = VM.require("buildhub.near/widget/home.footer") || {
- Footer: () => <>>
-};
-
-const ownerId = "/*__@appAccount__*/";
-
-const Root = styled.div`
- background-color: #0b0c14;
- color: #ffffff;
- font-family: Satoshi, sans-serif;
-
- width: 100%;
-`;
-
-const sections = ["hero", "goals", "join", "governance", "cta", "footer"];
-
-return (
-
-
-
-
-
-
-
-
-);
diff --git a/apps/builddao/widget/config/theme.jsx b/apps/builddao/widget/config/theme.jsx
deleted file mode 100644
index 4a24853c..00000000
--- a/apps/builddao/widget/config/theme.jsx
+++ /dev/null
@@ -1,33 +0,0 @@
-const theme = `
- --stroke-color: rgba(255, 255, 255, 0.2);
- --bg-1: #0b0c14;
- --bg-1-hover: #17181c;
- --bg-1-hover-transparent: rgba(23, 24, 28, 0);
- --bg-2: ##23242b;
- --label-color: #fff;
- --font-color: #fff;
- --font-muted-color: #cdd0d5;
- --black: #000;
- --system-red: #fd2a5c;
- --yellow: #ffaf51;
-
- --compose-bg: #23242b;
-
- --post-bg: #0b0c14;
- --post-bg-hover: #17181c;
- --post-bg-transparent: rgba(23, 24, 28, 0);
-
- --button-primary-bg: #ffaf51;
- --button-outline-bg: transparent;
- --button-default-bg: #23242b;
-
- --button-primary-color: #000;
- --button-outline-color: #cdd0d5;
- --button-default-color: #cdd0d5;
-
- --button-primary-hover-bg: #e49b48;
- --button-outline-hover-bg: rgba(255, 255, 255, 0.2);
- --button-default-hover-bg: #17181c;
-`;
-
-return { type: "theme", theme: theme };
diff --git a/apps/builddao/widget/page/home.jsx b/apps/builddao/widget/page/home.jsx
index b7dde69b..e752c1e0 100644
--- a/apps/builddao/widget/page/home.jsx
+++ b/apps/builddao/widget/page/home.jsx
@@ -17,8 +17,6 @@ const { Footer } = VM.require("buildhub.near/widget/home.footer") || {
Footer: () => <>>
};
-const ownerId = "/*__@appAccount__*/";
-
const Root = styled.div`
background-color: #0b0c14;
color: #ffffff;
From 064724650f9380d163fd61b53f4df04177ac9e0a Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 03:06:50 +0500
Subject: [PATCH 107/132] Add routes to navbar
---
apps/builddao/widget/config/routes.jsx | 14 ++++++++++++++
apps/builddao/widget/page/library.jsx | 5 +++++
apps/builddao/widget/page/proposals.jsx | 2 +-
apps/builddao/widget/page/resources.jsx | 5 +++++
4 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 apps/builddao/widget/page/library.jsx
create mode 100644 apps/builddao/widget/page/resources.jsx
diff --git a/apps/builddao/widget/config/routes.jsx b/apps/builddao/widget/config/routes.jsx
index dd312e46..81e2d431 100644
--- a/apps/builddao/widget/config/routes.jsx
+++ b/apps/builddao/widget/config/routes.jsx
@@ -22,5 +22,19 @@ return {
name: "Proposals",
},
},
+ resources: {
+ path: "buildhub.near/widget/page.resources",
+ blockHeight: "final",
+ init: {
+ name: "Resources",
+ },
+ },
+ library: {
+ path: "buildhub.near/widget/page.library",
+ blockHeight: "final",
+ init: {
+ name: "Library",
+ },
+ },
},
};
diff --git a/apps/builddao/widget/page/library.jsx b/apps/builddao/widget/page/library.jsx
new file mode 100644
index 00000000..72183db2
--- /dev/null
+++ b/apps/builddao/widget/page/library.jsx
@@ -0,0 +1,5 @@
+return (
+
+
+
+);
diff --git a/apps/builddao/widget/page/proposals.jsx b/apps/builddao/widget/page/proposals.jsx
index fc72ecaa..65c49e18 100644
--- a/apps/builddao/widget/page/proposals.jsx
+++ b/apps/builddao/widget/page/proposals.jsx
@@ -1,5 +1,5 @@
return (
-
+
+
+
+);
From 0ca7f2d6afa5fcef0cfe5c49cb965a55530d5cd6 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Tue, 30 Jan 2024 18:03:13 -0500
Subject: [PATCH 108/132] proposal feed
---
apps/builddao/widget/config/feed.jsx | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index f1ae8cdf..caf90069 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -194,6 +194,15 @@ return {
`,
},
},
+ proposals: {
+ path: "buildhub.near/widget/Proposals",
+ blockHeight: "final",
+ init: {
+ name: "Proposals",
+ icon: "bi-file-earmark-text",
+ daoId: "build.sputnik-dao.near"
+ }
+ },
feedback: {
path: "buildhub.near/widget/Feed",
blockHeight: "final",
From 142ffac5b2d1cc42f645c49c531f6fcb4a42485a Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 11:40:18 +0500
Subject: [PATCH 109/132] Add Userdropdown to navbar
---
apps/builddao/widget/app.jsx | 4 +-
.../components/buttons/UserDropdown.jsx | 200 ++++++++++++++++++
.../widget/components/navigation/header.jsx | 73 ++++---
apps/builddao/widget/template/AppLayout.jsx | 6 +-
src/pages/Viewer.js | 3 +-
5 files changed, 252 insertions(+), 34 deletions(-)
create mode 100644 apps/builddao/widget/components/buttons/UserDropdown.jsx
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index 4b843b5b..bfc528ec 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -89,10 +89,12 @@ const Content = styled.div`
height: 100%;
`;
+console.log("app", props);
+
return (
-
+
diff --git a/apps/builddao/widget/components/buttons/UserDropdown.jsx b/apps/builddao/widget/components/buttons/UserDropdown.jsx
new file mode 100644
index 00000000..6b5a75b4
--- /dev/null
+++ b/apps/builddao/widget/components/buttons/UserDropdown.jsx
@@ -0,0 +1,200 @@
+const StyledDropdown = styled.div`
+ button,
+ a {
+ font-weight: var(--font-weight-medium);
+ }
+ .dropdown-toggle {
+ display: flex;
+ align-items: center;
+ text-align: left;
+ background-color: var(--slate-dark-5);
+ border-radius: 50px;
+ outline: none;
+ border: 0;
+
+ &:after {
+ margin: 0 15px;
+ border-top-color: var(--slate-dark-11);
+ }
+
+ img {
+ border-radius: 50% !important;
+ }
+
+ .profile-info {
+ margin: 5px 10px;
+ line-height: normal;
+ max-width: 140px;
+
+ .profile-name,
+ .profile-username {
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+
+ .profile-name {
+ color: var(--slate-dark-12);
+ }
+ .profile-username {
+ color: var(--slate-dark-11);
+ }
+ }
+ }
+
+ ul {
+ background-color: var(--slate-dark-5);
+ width: 100%;
+ width: 240px;
+
+ li {
+ padding: 0 6px;
+ }
+
+ button,
+ a {
+ color: var(--slate-dark-11);
+ display: flex;
+ align-items: center;
+ border-radius: 8px;
+ padding: 12px;
+
+ :hover,
+ :focus {
+ text-decoration: none;
+ background-color: var(--slate-dark-1);
+ color: white;
+
+ svg {
+ path {
+ stroke: white;
+ }
+ }
+ }
+
+ svg {
+ margin-right: 7px;
+ min-width: 24px;
+ path {
+ stroke: var(--slate-dark-9);
+ }
+ }
+ }
+ }
+`;
+
+function User() {
+ return (
+
+
+
+
+ );
+}
+
+function LogOut() {
+ return (
+
+
+
+
+
+ );
+}
+
+console.log("props", props);
+
+return (
+
+
+
+
+
+
+ My Profile
+
+
+
+ props.logOut()}
+ >
+
+ Sign Out
+
+
+
+
+);
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 31326b8f..62638410 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -1,5 +1,5 @@
const { Button } = VM.require("buildhub.near/widget/components") || {
- Button: () => <>>
+ Button: () => <>>,
};
const Navbar = styled.div`
@@ -75,12 +75,14 @@ const NavLink = ({ to, children }) => (
const [showMenu, setShowMenu] = useState(false);
const toggleDropdown = () => setShowMenu(!showMenu);
+console.log("header", props);
-const AppHeader = ({ page, routes }) => (
+const AppHeader = ({ page, routes, ...props }) => (
(
src="https://ipfs.near.social/ipfs/bafkreihbwho3qfvnu4yss3eh5jrx6uxhrlzdgtdjyzyjrpa6odro6wdxya"
/>
-
+
{routes &&
(Object.keys(routes) || []).map((k) => {
const route = routes[k];
@@ -110,17 +112,25 @@ const AppHeader = ({ page, routes }) => (
);
})}
- User Dropdown
,
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- href: "/join",
- }}
- />
+
+
+
+ ),
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
+
(
return null;
}
return (
-
+
(
);
})}
- User Dropdown
- ),
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- href: "/join",
- }}
- />
+
+
+ ),
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
+
)}
);
-return
;
+return
;
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index 087544e1..dc439ad2 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -22,7 +22,7 @@ const ContentContainer = styled.div`
width: 100%;
`;
-const Header = ({ page, routes }) => (
+const Header = ({ page, routes, ...props }) => (
{
};
// Define the new component that follows the AppLayout pattern
-function AppLayout({ routes, page, children }) {
+function AppLayout({ routes, page, children, ...props }) {
return (
-
+
{children}
diff --git a/src/pages/Viewer.js b/src/pages/Viewer.js
index f36eca7b..c5d3922b 100644
--- a/src/pages/Viewer.js
+++ b/src/pages/Viewer.js
@@ -4,7 +4,7 @@ import { useLocation, useParams } from "react-router-dom";
const SESSION_STORAGE_REDIRECT_MAP_KEY = "nearSocialVMredirectMap";
-function Viewer({ code }) {
+function Viewer({ code, ...props }) {
const { path } = useParams(); // get path from url, could be socialdb path or relative to "core"
const location = useLocation(); // get query params from url
const searchParams = new URLSearchParams(location.search);
@@ -65,6 +65,7 @@ function Viewer({ code }) {
props={{
path: src,
...passProps,
+ ...props,
}}
config={{ redirectMap }}
/>
From 0cd32c84215d4b9587dee85ec8781979b5297b76 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 12:19:40 +0500
Subject: [PATCH 110/132] Fix styling on other gateways
---
.../components/buttons/UserDropdown.jsx | 38 ++++++++++---------
apps/builddao/widget/template/AppLayout.jsx | 1 +
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/apps/builddao/widget/components/buttons/UserDropdown.jsx b/apps/builddao/widget/components/buttons/UserDropdown.jsx
index 6b5a75b4..476cbf8e 100644
--- a/apps/builddao/widget/components/buttons/UserDropdown.jsx
+++ b/apps/builddao/widget/components/buttons/UserDropdown.jsx
@@ -1,20 +1,20 @@
const StyledDropdown = styled.div`
button,
a {
- font-weight: var(--font-weight-medium);
+ font-weight: 500;
}
.dropdown-toggle {
display: flex;
align-items: center;
text-align: left;
- background-color: var(--slate-dark-5);
+ background-color: #2b2f31;
border-radius: 50px;
outline: none;
border: 0;
&:after {
margin: 0 15px;
- border-top-color: var(--slate-dark-11);
+ border-top-color: #9ba1a6;
}
img {
@@ -23,6 +23,7 @@ const StyledDropdown = styled.div`
.profile-info {
margin: 5px 10px;
+ margin-right: 0;
line-height: normal;
max-width: 140px;
@@ -33,16 +34,16 @@ const StyledDropdown = styled.div`
}
.profile-name {
- color: var(--slate-dark-12);
+ color: #ecedee;
}
.profile-username {
- color: var(--slate-dark-11);
+ color: #9ba1a6;
}
}
}
ul {
- background-color: var(--slate-dark-5);
+ background-color: #2b2f31;
width: 100%;
width: 240px;
@@ -52,7 +53,7 @@ const StyledDropdown = styled.div`
button,
a {
- color: var(--slate-dark-11);
+ color: #9ba1a6;
display: flex;
align-items: center;
border-radius: 8px;
@@ -61,7 +62,7 @@ const StyledDropdown = styled.div`
:hover,
:focus {
text-decoration: none;
- background-color: var(--slate-dark-1);
+ background-color: #151718;
color: white;
svg {
@@ -75,7 +76,7 @@ const StyledDropdown = styled.div`
margin-right: 7px;
min-width: 24px;
path {
- stroke: var(--slate-dark-9);
+ stroke: #0091ff;
}
}
}
@@ -153,15 +154,18 @@ return (
id="dropdownMenu2222"
data-bs-toggle="dropdown"
aria-expanded="false"
+ style={{ background: "#2b2f31" }}
>
-
+
+
+
diff --git a/apps/builddao/widget/template/AppLayout.jsx b/apps/builddao/widget/template/AppLayout.jsx
index dc439ad2..ecf5dcf3 100644
--- a/apps/builddao/widget/template/AppLayout.jsx
+++ b/apps/builddao/widget/template/AppLayout.jsx
@@ -12,6 +12,7 @@ const Container = styled.div`
width: 100%;
height: 100%;
// margin-top: calc(-1 * var(--body-top-padding));
+ background-color: var(--bg-1, #0b0c14);
`;
const ContentContainer = styled.div`
From 6f20e103f14012cabe7b2e2ec155969c1c8f4df1 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Wed, 31 Jan 2024 17:24:12 +0500
Subject: [PATCH 111/132] Fix footer text on other gateways
---
apps/builddao/widget/home/footer.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/builddao/widget/home/footer.jsx b/apps/builddao/widget/home/footer.jsx
index cd5bfef7..d5237146 100644
--- a/apps/builddao/widget/home/footer.jsx
+++ b/apps/builddao/widget/home/footer.jsx
@@ -18,7 +18,7 @@ const Container = styled.div`
text-align: center;
/* Body/Large */
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 400;
From bfa499277123d2763f998f6e03b1b3965e47639d Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Wed, 31 Jan 2024 22:06:07 +0530
Subject: [PATCH 112/132] fix create proposal
---
apps/builddao/widget/Proposals.jsx | 72 +++++++++----------
.../components/modals/CreateProposal.jsx | 12 ++--
.../components/modals/propose/AddMember.jsx | 31 ++++----
.../modals/propose/FunctionCall.jsx | 45 ++++++------
.../modals/propose/RemoveMember.jsx | 30 ++++----
.../widget/components/modals/propose/Text.jsx | 23 +++---
.../components/modals/propose/Transfer.jsx | 68 ++++++++++++------
7 files changed, 155 insertions(+), 126 deletions(-)
diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx
index 37ba6e54..081047fc 100644
--- a/apps/builddao/widget/Proposals.jsx
+++ b/apps/builddao/widget/Proposals.jsx
@@ -1,5 +1,5 @@
const { Button } = VM.require("buildhub.near/widget/components.Button") || {
- Button: <>>,
+ Button: <>>
};
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
@@ -15,20 +15,23 @@ const accountId = context.accountId;
const [showProposalModal, setShowModal] = useState(false);
const lastProposalId = sdk.getLastProposalId();
-const proposals = proposalId
+const reversedProposals = proposalId
? [
sdk.getProposalById({
- proposalId,
- }),
+ proposalId
+ })
] || []
: sdk.getProposals({
offset:
currentPage === 0
- ? lastProposalId - resPerPage
+ ? lastProposalId > 10
+ ? lastProposalId - resPerPage
+ : lastProposalId ?? 10
: lastProposalId - currentPage * resPerPage,
- limit: resPerPage,
+ limit: resPerPage
}) || [];
+const proposals = reversedProposals.reverse();
const PaginationThemeContainer = props.PaginationThemeContainer;
const ThemeContainer =
@@ -78,32 +81,31 @@ const handleVote = ({ action, proposalId, proposer }) => {
message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
params: {
daoId: daoId,
- proposalId: proposalId,
+ proposalId: proposalId
},
type: "custom",
- widget: "buildhub.near/widget/Proposals",
- },
- },
- ]),
- },
- },
+ widget: "buildhub.near/widget/Proposals"
+ }
+ }
+ ])
+ }
+ }
};
sdk.actProposal({
proposalId,
action,
- deposit: "",
gas: 200000000000000,
additionalCalls: [
{
contractName: "social.near",
methodName: "set",
args: { data: notification },
- deposit: Big(JSON.stringify(notification).length * 16).mul(
- Big(10).pow(20)
- ),
- },
- ],
+ deposit: Big(JSON.stringify(notification).length * 16)
+ .mul(Big(10).pow(20))
+ .toString()
+ }
+ ]
});
};
@@ -126,7 +128,7 @@ if (Array.isArray(policy.roles)) {
const proposalPeriod = policy.proposal_period;
-const ProposalsComponent = () => {
+const proposalsComponent = useMemo(() => {
return (
{Array.isArray(proposals) ? (
@@ -142,30 +144,30 @@ const ProposalsComponent = () => {
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteApprove,
+ actionType: actions.VoteApprove
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteReject,
+ actionType: actions.VoteReject
}),
sdk.hasPermission({
accountId,
kindName,
- actionType: actions.VoteRemove,
- }),
+ actionType: actions.VoteRemove
+ })
];
const { thresholdVoteCount } =
sdk.getVotersAndThresholdForProposalKind({
- kindName,
+ kindName
});
const totalVotes = sdk.calculateVoteCountByType({
- votes: item.votes,
+ votes: item.votes
});
let expirationTime = sdk.getProposalExpirationTime({
- submissionTime: item.submission_time,
+ submissionTime: item.submission_time
});
return (
@@ -179,14 +181,14 @@ const ProposalsComponent = () => {
totalVotes: {
...totalVotes,
yes: totalVotes.approve,
- no: totalVotes.reject,
+ no: totalVotes.reject
},
- expirationTime,
+ expirationTime
},
daoId: daoId,
comments: comments,
isAllowedToVote,
- handleVote,
+ handleVote
}}
/>
);
@@ -196,7 +198,7 @@ const ProposalsComponent = () => {
)}
);
-};
+}, [proposals]);
return (
@@ -205,7 +207,7 @@ return (
src="buildhub.near/widget/components.modals.CreateProposal"
props={{
showModal: showProposalModal,
- toggleModal: () => setShowModal(!showProposalModal),
+ toggleModal: () => setShowModal(!showProposalModal)
}}
/>
@@ -214,9 +216,7 @@ return (
Create Proposal
-
+ {proposalsComponent}
{!proposalId && (
setCurrentPage(v),
selectedPage: currentPage,
- ThemeContainer: PaginationThemeContainer,
+ ThemeContainer: PaginationThemeContainer
}}
/>
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 68b433c2..205d5976 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -9,7 +9,7 @@ const { Modal, Button, User } = VM.require(
) || {
Modal: () => <>>,
Button: () => <>>,
- User: () => <>>,
+ User: () => <>>
};
const showModal = props.showModal;
@@ -128,7 +128,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS,
+ customCSS: editorCSS
}}
/>
>
@@ -141,7 +141,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS,
+ customCSS: editorCSS
}}
/>
>
@@ -154,7 +154,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS,
+ customCSS: editorCSS
}}
/>
>
@@ -168,7 +168,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS,
+ customCSS: editorCSS
}}
/>
>
@@ -182,7 +182,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS,
+ customCSS: editorCSS
}}
/>
>
diff --git a/apps/builddao/widget/components/modals/propose/AddMember.jsx b/apps/builddao/widget/components/modals/propose/AddMember.jsx
index ae08e83c..5af6bd05 100644
--- a/apps/builddao/widget/components/modals/propose/AddMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/AddMember.jsx
@@ -1,11 +1,18 @@
const { Button } =
VM.require("buildhub.near/widget/components") || (() => <>>);
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+
+if (!DaoSDK) {
+ return <>>;
+}
const [accountId, setAccountId] = useState("");
const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const sdk = DaoSDK(selectedDAO);
+
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -212,7 +219,7 @@ return (
embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -223,19 +230,15 @@ return (
className="ms-auto"
variant="primary"
disabled={!accountId || !role || !validatedAddresss}
- onClick={() =>
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: {
- AddMemberToRole: {
- member_id: accountId,
- role: role,
- },
- },
- },
- })
- }
+ onClick={() => {
+ sdk.createAddMemberProposal({
+ description: text,
+ memberId: accountId,
+ roleId: role,
+ gas: 180000000000000,
+ deposit: 200000000000000
+ });
+ }}
>
Next
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 7ed6ca9b..03c7f9b2 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -1,11 +1,14 @@
const { Button } =
VM.require("buildhub.near/widget/components") || (() => <>>);
-
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+if (!DaoSDK) {
+ return <>>;
+}
const [contract, setContract] = useState("");
const [method, setMethod] = useState("");
const [args, setArgs] = useState("{}");
const [gas, setGas] = useState(50000000000000);
-const [deposit, useDeposit] = useState(0);
+const [deposit, setDeposit] = useState(0);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -21,8 +24,8 @@ useEffect(() => {
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
-const selectedDao = props.selectedDao;
-
+const selectedDAO = props.selectedDAO;
+const sdk = DaoSDK(selectedDAO);
const MarkdownEditor = `
html {
background: #23242b;
@@ -229,7 +232,7 @@ return (
embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -239,26 +242,18 @@ return (
disabled={!contract || !method}
className="ms-auto"
variant="primary"
- onClick={() =>
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: {
- FunctionCall: {
- reciever_id: contract,
- actions: [
- {
- method_name: method,
- args: args,
- deposit: deposit,
- gas: gas,
- },
- ],
- },
- },
- },
- })
- }
+ onClick={() => {
+ sdk.createFunctionCallProposal({
+ description: text,
+ receiverId: contract,
+ methodName: method,
+ args: args,
+ proposalDeposit: deposit,
+ proposalGas: gas,
+ gas: 180000000000000,
+ deposit: 200000000000000
+ });
+ }}
>
Next
diff --git a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
index 9b0a3eef..9334bfc6 100644
--- a/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
+++ b/apps/builddao/widget/components/modals/propose/RemoveMember.jsx
@@ -1,11 +1,17 @@
const { Button } =
VM.require("buildhub.near/widget/components") || (() => <>>);
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+if (!DaoSDK) {
+ return <>>;
+}
const [accountId, setAccountId] = useState("");
const [role, setRole] = useState("");
const roles = props.roles;
const selectedDAO = props.selectedDAO;
+const sdk = DaoSDK(selectedDAO);
+
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -216,7 +222,7 @@ return (
embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -227,19 +233,15 @@ return (
className="ms-auto"
variant="primary"
disabled={!accountId || !role || !validatedAddresss}
- onClick={() =>
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: {
- RemoveMemberFromRole: {
- member_id: accountId,
- role: role,
- },
- },
- },
- })
- }
+ onClick={() => {
+ sdk.createRemoveMemberProposal({
+ description: text,
+ memberId: accountId,
+ roleId: role,
+ gas: 180000000000000,
+ deposit: 200000000000000
+ });
+ }}
>
Next
diff --git a/apps/builddao/widget/components/modals/propose/Text.jsx b/apps/builddao/widget/components/modals/propose/Text.jsx
index a786f840..33d5feca 100644
--- a/apps/builddao/widget/components/modals/propose/Text.jsx
+++ b/apps/builddao/widget/components/modals/propose/Text.jsx
@@ -1,5 +1,10 @@
const { Button } =
VM.require("buildhub.near/widget/components") || (() => <>>);
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+
+if (!DaoSDK) {
+ return <>>;
+}
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -14,6 +19,7 @@ useEffect(() => {
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
const selectedDAO = props.selectedDAO;
+const sdk = DaoSDK(selectedDAO);
const MarkdownEditor = `
html {
background: #23242b;
@@ -158,7 +164,7 @@ return (
embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -166,14 +172,13 @@ return (
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: "Vote",
- },
- })
- }
+ onClick={() => {
+ sdk.createPollProposal({
+ description: text,
+ gas: 180000000000000,
+ deposit: 200000000000000
+ });
+ }}
>
Next
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index b1f0febe..7c9a8480 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -1,6 +1,9 @@
const { Button } =
VM.require("buildhub.near/widget/components") || (() => <>>);
-
+const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
+if (!DaoSDK) {
+ return <>>;
+}
const [recipient, setRecipient] = useState("");
const [token, setToken] = useState("");
const [amount, setAmount] = useState(0);
@@ -20,7 +23,28 @@ useEffect(() => {
setEditorKey((editorKey) => editorKey + 1);
}, [props.item]);
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
-const selectedDao = props.selectedDao;
+const selectedDAO = props.selectedDAO;
+const sdk = DaoSDK(selectedDAO);
+
+const res = fetch(`https://api.nearblocks.io/v1/account/${selectedDAO}/tokens`);
+
+const tokensData = [
+ {
+ decimals: 24,
+ icon: "",
+ name: "NEAR",
+ symbol: "NEAR"
+ }
+];
+if (res.body) {
+ res.body?.tokens?.fts.map((item) => {
+ const ftMetadata = Near.view(item, "ft_metadata", {});
+ if (ftMetadata === null) {
+ return;
+ }
+ tokensData.push(ftMetadata);
+ });
+}
// handle checking
const regex = /.{1}\.near$/;
@@ -201,11 +225,9 @@ return (
onChange={(e) => setToken(e.target.value)}
>
Select a token
- NEAR
- ETH
- USDC
- USDT
- AURORA
+ {tokensData?.map((item) => {
+ return {item.symbol} ;
+ })}
@@ -236,7 +258,7 @@ return (
embedCss: props.customCSS || MarkdownEditor,
onChange: (v) => {
setText(v);
- },
+ }
}}
/>
@@ -246,20 +268,22 @@ return (
disabled={!token || !recipient || !amount}
className="ms-auto"
variant="primary"
- onClick={() =>
- Near.call(selectedDAO, "add_proposal", {
- proposal: {
- description: text,
- kind: {
- Transfer: {
- token_id: token,
- reciever_id: recipient,
- amount: amount,
- },
- },
- },
- })
- }
+ onClick={() => {
+ let ftMetadata = tokensData.find((item) => item.symbol === token);
+ const amountInYocto = Big(amount)
+ .mul(Big(10).pow(ftMetadata.decimals))
+ .toFixed();
+ sdk.createTransferProposal({
+ description: text,
+ tokenId: token,
+ receiverId: recipient,
+ amount: amountInYocto,
+ gas,
+ deposit,
+ gas: 180000000000000,
+ deposit: 200000000000000
+ });
+ }}
>
Next
From f85cf7a26d673bea02eab9260d1d549da83f0dd6 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Wed, 31 Jan 2024 22:13:13 +0530
Subject: [PATCH 113/132] uncomment code
---
apps/builddao/widget/components/ProposalCard.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index a2fe30bf..88cd7d4c 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -560,7 +560,7 @@ function renderVoteButtons({
wins={wins.yes}
myVote={voted.yes}
onClick={() => handleVote("VoteApprove")}
- // disabled={alreadyVoted || finished || !isAllowedToVote[0]}
+ disabled={alreadyVoted || finished || !isAllowedToVote[0]}
>
{wins.yes && (
From 4492e4a150b26ea928c16d68d8b4c29ead237f1f Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Wed, 31 Jan 2024 22:15:25 +0530
Subject: [PATCH 114/132] css update
---
apps/builddao/widget/components/ProposalCard.jsx | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/apps/builddao/widget/components/ProposalCard.jsx b/apps/builddao/widget/components/ProposalCard.jsx
index 88cd7d4c..3194bda2 100644
--- a/apps/builddao/widget/components/ProposalCard.jsx
+++ b/apps/builddao/widget/components/ProposalCard.jsx
@@ -59,6 +59,10 @@ const Wrapper = styled.div`
font-weight: 600;
}
+ .font-monospace {
+ color: var(--secondary-text-color) !important;
+ }
+
.secondary-bg {
background: var(--secondary-bg-color) !important;
}
From de8da545afbba377f93bb672aecbe6dd3cdcf459 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Wed, 31 Jan 2024 22:49:46 +0530
Subject: [PATCH 115/132] minor fixes
---
.../modals/propose/FunctionCall.jsx | 21 ++++++++++++++++---
.../components/modals/propose/Transfer.jsx | 15 ++++++-------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
index 03c7f9b2..f653046b 100644
--- a/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
+++ b/apps/builddao/widget/components/modals/propose/FunctionCall.jsx
@@ -7,9 +7,9 @@ if (!DaoSDK) {
const [contract, setContract] = useState("");
const [method, setMethod] = useState("");
const [args, setArgs] = useState("{}");
-const [gas, setGas] = useState(50000000000000);
+const [gas, setGas] = useState(180000000000000);
const [deposit, setDeposit] = useState(0);
-
+const [validatedAddresss, setValidatedAddress] = useState(true);
const [text, setText] = useState("");
const [editorKey, setEditorKey] = useState(0);
@@ -26,6 +26,16 @@ useEffect(() => {
const memoizedKey = useMemo((editorKey) => editorKey, [editorKey]);
const selectedDAO = props.selectedDAO;
const sdk = DaoSDK(selectedDAO);
+
+const regex = /.{1}\.near$/;
+useEffect(() => {
+ if (regex.test(contract) || contract === "") {
+ setValidatedAddress(true);
+ } else {
+ setValidatedAddress(false);
+ }
+}, [contract]);
+
const MarkdownEditor = `
html {
background: #23242b;
@@ -169,6 +179,11 @@ return (
onChange={(e) => setContract(e.target.value)}
className="form-control"
/>
+ {!validatedAddresss && (
+
+ Please check if the NEAR address is valid!
+
+ )}
@@ -239,7 +254,7 @@ return (
{
diff --git a/apps/builddao/widget/components/modals/propose/Transfer.jsx b/apps/builddao/widget/components/modals/propose/Transfer.jsx
index 7c9a8480..18ad5930 100644
--- a/apps/builddao/widget/components/modals/propose/Transfer.jsx
+++ b/apps/builddao/widget/components/modals/propose/Transfer.jsx
@@ -27,13 +27,14 @@ const selectedDAO = props.selectedDAO;
const sdk = DaoSDK(selectedDAO);
const res = fetch(`https://api.nearblocks.io/v1/account/${selectedDAO}/tokens`);
-
+const NearTokenId = "NEAR";
const tokensData = [
{
decimals: 24,
icon: "",
name: "NEAR",
- symbol: "NEAR"
+ symbol: "NEAR",
+ tokenId: NearTokenId
}
];
if (res.body) {
@@ -42,7 +43,7 @@ if (res.body) {
if (ftMetadata === null) {
return;
}
- tokensData.push(ftMetadata);
+ tokensData.push({ ...ftMetadata, tokenId: item });
});
}
@@ -226,7 +227,7 @@ return (
>
Select a token
{tokensData?.map((item) => {
- return {item.symbol} ;
+ return {item.symbol} ;
})}
@@ -265,17 +266,17 @@ return (
{
- let ftMetadata = tokensData.find((item) => item.symbol === token);
+ let ftMetadata = tokensData.find((item) => item.tokenId === token);
const amountInYocto = Big(amount)
.mul(Big(10).pow(ftMetadata.decimals))
.toFixed();
sdk.createTransferProposal({
description: text,
- tokenId: token,
+ tokenId: token === NearTokenId ? "" : token,
receiverId: recipient,
amount: amountInYocto,
gas,
From d749f6262d784174c9f34c1f770225e596bf745a Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Wed, 31 Jan 2024 12:46:51 -0500
Subject: [PATCH 116/132] navbar and login flow
---
apps/builddao/widget/app.jsx | 2 -
.../components/buttons/UserDropdown.jsx | 22 ++++---
.../widget/components/navigation/header.jsx | 62 +++++++++----------
src/components/navigation/Navbar.js | 28 ++++-----
4 files changed, 54 insertions(+), 60 deletions(-)
diff --git a/apps/builddao/widget/app.jsx b/apps/builddao/widget/app.jsx
index bfc528ec..6cf10cae 100644
--- a/apps/builddao/widget/app.jsx
+++ b/apps/builddao/widget/app.jsx
@@ -89,8 +89,6 @@ const Content = styled.div`
height: 100%;
`;
-console.log("app", props);
-
return (
diff --git a/apps/builddao/widget/components/buttons/UserDropdown.jsx b/apps/builddao/widget/components/buttons/UserDropdown.jsx
index 476cbf8e..7e91cbe9 100644
--- a/apps/builddao/widget/components/buttons/UserDropdown.jsx
+++ b/apps/builddao/widget/components/buttons/UserDropdown.jsx
@@ -189,16 +189,18 @@ return (
My Profile
-
- props.logOut()}
- >
-
- Sign Out
-
-
+ {props.logOut && (
+
+ props.logOut()}
+ >
+
+ Sign Out
+
+
+ )}
);
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 62638410..27c017c3 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -75,7 +75,33 @@ const NavLink = ({ to, children }) => (
const [showMenu, setShowMenu] = useState(false);
const toggleDropdown = () => setShowMenu(!showMenu);
-console.log("header", props);
+
+const SignInOrConnect = () => (
+ <>
+ {context.accountId ? (
+
+ ),
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren: "Join Now",
+ href: "/join",
+ }}
+ />
+ ) : (
+
+ Sign In
+
+ )}
+ >
+);
const AppHeader = ({ page, routes, ...props }) => (
@@ -114,22 +140,7 @@ const AppHeader = ({ page, routes, ...props }) => (
-
- ),
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- href: "/join",
- }}
- />
+
@@ -181,22 +192,7 @@ const AppHeader = ({ page, routes, ...props }) => (
})}
-
- ),
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- href: "/join",
- }}
- />
+
)}
diff --git a/src/components/navigation/Navbar.js b/src/components/navigation/Navbar.js
index eb822c18..b2cf1e4d 100644
--- a/src/components/navigation/Navbar.js
+++ b/src/components/navigation/Navbar.js
@@ -203,21 +203,19 @@ export function Navbar(props) {
)}
{props.signedIn && (
-
-
,
- showActivity: false,
- className: "custom-button",
- joinBtnChildren: "Join Now",
- // href: "/join",
- }}
- />
-
+
,
+ showActivity: false,
+ className: "custom-button",
+ joinBtnChildren:
Join Now,
+ // href: "/join",
+ }}
+ />
)}
From 4a186ba77f1a67f2a9e39531057aa0545cf0e242 Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Wed, 31 Jan 2024 23:37:55 +0530
Subject: [PATCH 117/132] rename proposals to projects
---
apps/builddao/widget/config/feed.jsx | 77 +++++------------
.../builddao/widget/config/project-routes.jsx | 50 +++++++++++
apps/builddao/widget/config/routes.jsx | 26 +++---
apps/builddao/widget/page/projects.jsx | 82 +++++++++++++++++++
apps/builddao/widget/page/proposals.jsx | 8 --
5 files changed, 166 insertions(+), 77 deletions(-)
create mode 100644 apps/builddao/widget/config/project-routes.jsx
create mode 100644 apps/builddao/widget/page/projects.jsx
delete mode 100644 apps/builddao/widget/page/proposals.jsx
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index caf90069..fc155f3b 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -32,8 +32,8 @@ return {
**📊 MEASURING SUCCESS:**
- [Metric 1 for Success]
- [Metric 2 for Success]
-`,
- },
+`
+ }
},
updates: {
path: "buildhub.near/widget/Feed",
@@ -56,8 +56,8 @@ return {
**🛑 BLOCKERS**
- [what's blocking you?]
- [how can someone help?]
-`,
- },
+`
+ }
},
documentation: {
path: "buildhub.near/widget/Feed",
@@ -80,8 +80,8 @@ return {
**USAGE**
- [where is it used?]
- [how to use it]
-`,
- },
+`
+ }
},
question: {
path: "buildhub.near/widget/Feed",
@@ -95,8 +95,8 @@ return {
[what are you thinking about?]
[why are you asking?]
-`,
- },
+`
+ }
},
answer: {
path: "buildhub.near/widget/Feed",
@@ -113,8 +113,8 @@ return {
[your answer]
[link to relevant docs, examples, or resources]
-`,
- },
+`
+ }
},
opportunity: {
path: "buildhub.near/widget/Feed",
@@ -129,8 +129,8 @@ return {
[what is the opportunity?]
[explain the motivation or reason]
-`,
- },
+`
+ }
},
idea: {
path: "buildhub.near/widget/Feed",
@@ -147,8 +147,8 @@ return {
**Context or additional information:**
- [Provide any context or details]
-`,
- },
+`
+ }
},
task: {
path: "buildhub.near/widget/Feed",
@@ -165,42 +165,7 @@ return {
**Context or additional information:**
- [Provide any context or details]
-`,
- },
- },
- request: {
- path: "buildhub.near/widget/Feed",
- blockHeight: "final",
- init: {
- name: "Request",
- icon: "bi-file-earmark-text",
- requiredHashtags: ["build", "request"],
- customActions: [
- {
- label: "Propose",
- icon: "bi-file-earmark-text",
- type: "modal",
- onClick: (modalToggle) => modalToggle(), // want to fix
- },
- ],
- template: `## REQUEST TITLE
-(posted via [${daoName} Gateway](${feedLink}?tab=request))
-
-#### Description
-[Detailed description of what the proposal is about.]
-
-#### Why This Proposal?
-[Explanation of why this proposal is necessary or beneficial.]
-`,
- },
- },
- proposals: {
- path: "buildhub.near/widget/Proposals",
- blockHeight: "final",
- init: {
- name: "Proposals",
- icon: "bi-file-earmark-text",
- daoId: "build.sputnik-dao.near"
+`
}
},
feedback: {
@@ -209,8 +174,8 @@ return {
init: {
name: "Feedback",
icon: "bi-chat-left-text",
- requiredHashtags: ["build", "feedback"],
- },
+ requiredHashtags: ["build", "feedback"]
+ }
},
bookmarks: {
path: "buildhub.near/widget/OrderedGraphFeed",
@@ -228,8 +193,8 @@ return {
hideComments={true}
/>
);
- },
- },
- },
- },
+ }
+ }
+ }
+ }
};
diff --git a/apps/builddao/widget/config/project-routes.jsx b/apps/builddao/widget/config/project-routes.jsx
new file mode 100644
index 00000000..6dedf528
--- /dev/null
+++ b/apps/builddao/widget/config/project-routes.jsx
@@ -0,0 +1,50 @@
+const { Post } = VM.require("buildhub.near/widget/components") || (() => <>>);
+
+function formatDate(date) {
+ const options = { year: "numeric", month: "short", day: "numeric" };
+ return date.toLocaleDateString("en-US", options);
+}
+
+const daoName = "Build DAO";
+const feedLink = "https://nearbuilders.org/feed";
+
+return {
+ type: "app", // every.near/type/app
+ routes: {
+ request: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "Request",
+ icon: "bi-file-earmark-text",
+ requiredHashtags: ["build", "request"],
+ customActions: [
+ {
+ label: "Propose",
+ icon: "bi-file-earmark-text",
+ type: "modal",
+ onClick: (modalToggle) => modalToggle() // want to fix
+ }
+ ],
+ template: `## REQUEST TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=request))
+
+#### Description
+[Detailed description of what the proposal is about.]
+
+#### Why This Proposal?
+[Explanation of why this proposal is necessary or beneficial.]
+`
+ }
+ },
+ proposals: {
+ path: "buildhub.near/widget/Proposals",
+ blockHeight: "final",
+ init: {
+ name: "Proposals",
+ icon: "bi-file-earmark-text",
+ daoId: "build.sputnik-dao.near"
+ }
+ }
+ }
+};
diff --git a/apps/builddao/widget/config/routes.jsx b/apps/builddao/widget/config/routes.jsx
index 81e2d431..b2eb2e18 100644
--- a/apps/builddao/widget/config/routes.jsx
+++ b/apps/builddao/widget/config/routes.jsx
@@ -5,36 +5,36 @@ return {
path: "buildhub.near/widget/page.home",
blockHeight: "final",
init: {
- name: "Home",
- },
+ name: "Home"
+ }
},
feed: {
path: "buildhub.near/widget/page.feed",
blockHeight: "final",
init: {
- name: "Feed",
- },
+ name: "Feed"
+ }
},
proposal: {
- path: "buildhub.near/widget/page.proposals",
+ path: "buildhub.near/widget/page.projects",
blockHeight: "final",
init: {
- name: "Proposals",
- },
+ name: "Projects"
+ }
},
resources: {
path: "buildhub.near/widget/page.resources",
blockHeight: "final",
init: {
- name: "Resources",
- },
+ name: "Resources"
+ }
},
library: {
path: "buildhub.near/widget/page.library",
blockHeight: "final",
init: {
- name: "Library",
- },
- },
- },
+ name: "Library"
+ }
+ }
+ }
};
diff --git a/apps/builddao/widget/page/projects.jsx b/apps/builddao/widget/page/projects.jsx
new file mode 100644
index 00000000..fc5a2f60
--- /dev/null
+++ b/apps/builddao/widget/page/projects.jsx
@@ -0,0 +1,82 @@
+const { currentPath, page, ...passProps } = props;
+
+const { routes } = VM.require("buildhub.near/widget/config.project-routes") ?? {
+ routes: {}
+};
+
+const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
+ theme: {}
+};
+
+const { SidebarLayout } = VM.require(
+ "buildhub.near/widget/template.SidebarLayout"
+) || {
+ SidebarLayout: () => <>Layout loading...>
+};
+
+if (!page) page = Object.keys(routes)[0] || "home";
+
+const Root = styled.div`
+ ${theme}// can come from config
+`;
+
+const [activeRoute, setActiveRoute] = useState(page);
+
+useEffect(() => {
+ setActiveRoute(page);
+}, [page]);
+
+function Router({ active, routes }) {
+ // this may be converted to a module at devs.near/widget/Router
+ const routeParts = active.split(".");
+
+ let currentRoute = routes;
+ let src = "";
+ let defaultProps = {};
+
+ for (let part of routeParts) {
+ if (currentRoute[part]) {
+ currentRoute = currentRoute[part];
+ src = currentRoute.path;
+
+ if (currentRoute.init) {
+ defaultProps = { ...defaultProps, ...currentRoute.init };
+ }
+ } else {
+ // Handle 404 or default case for unknown routes
+ return 404 Not Found
;
+ }
+ }
+
+ return (
+
+
+
+ );
+}
+
+const Container = styled.div`
+ // display: flex;
+ height: 100%;
+`;
+
+const Content = styled.div`
+ width: 100%;
+ height: 100%;
+`;
+
+return (
+
+
+
+
+
+
+
+
+
+);
diff --git a/apps/builddao/widget/page/proposals.jsx b/apps/builddao/widget/page/proposals.jsx
deleted file mode 100644
index 65c49e18..00000000
--- a/apps/builddao/widget/page/proposals.jsx
+++ /dev/null
@@ -1,8 +0,0 @@
-return (
-
-
-
-);
From f175eb5232f34d79b9dd264e3670a50797eff7fe Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 14:39:49 +0500
Subject: [PATCH 118/132] Fix request feed
---
apps/builddao/widget/components/Post.jsx | 21 ++++----
apps/builddao/widget/config/feed.jsx | 64 ++++++++++++++++--------
2 files changed, 54 insertions(+), 31 deletions(-)
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 9bffe3e2..6f2a5ac0 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -286,6 +286,7 @@ const contentWidget = (
>
);
+// need to refactor this
const [showModal, setShowModal] = useState(false);
const toggleModal = () => {
setShowModal(!showModal);
@@ -293,15 +294,17 @@ const toggleModal = () => {
return (
<>
- {props.feedType === "request" && (
-
+ {props.feedType.toLowerCase() === "request" && (
+ <>
+
+ >
)}
{
+ console.log("modal", modalToggle);
+ modalToggle();
+ },
+ },
+ ],
+ },
},
bookmarks: {
path: "buildhub.near/widget/OrderedGraphFeed",
@@ -193,8 +213,8 @@ return {
hideComments={true}
/>
);
- }
- }
- }
- }
+ },
+ },
+ },
+ },
};
From eefc30f1fc588c0b2ade3017a58f16628f45068c Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 14:58:41 +0500
Subject: [PATCH 119/132] Refactor modals out of post to feed
---
apps/builddao/widget/Feed.jsx | 32 ++++++++++++++++---
apps/builddao/widget/components/Post.jsx | 21 ++----------
.../components/modals/CreateProposal.jsx | 12 +++----
.../widget/components/post/Header.jsx | 14 ++++----
apps/builddao/widget/config/feed.jsx | 7 ++--
5 files changed, 48 insertions(+), 38 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 6926ca97..4af476fb 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -5,17 +5,40 @@ const { Post } = VM.require("buildhub.near/widget/components") || {
Post: () => <>>,
};
-const { name, template, requiredHashtags, customActions } = props;
+const { name: feedName, template, requiredHashtags, customActions } = props;
+
+// for modals
+const [item, setItem] = useState(null);
+const [showProposeModal, setShowProposeModal] = useState(false);
+const toggleProposeModal = () => {
+ setShowProposeModal(!showProposeModal);
+};
+const modalToggles = {
+ propose: toggleProposeModal,
+};
return (
-
+
+ {feedName.toLowerCase() === "request" && (
+ <>
+
+ >
+ )}
{!context.accountId ? ( // if not logged in
) : (
)}
/>
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 6f2a5ac0..4e68b626 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -286,26 +286,8 @@ const contentWidget = (
>
);
-// need to refactor this
-const [showModal, setShowModal] = useState(false);
-const toggleModal = () => {
- setShowModal(!showModal);
-};
-
return (
<>
- {props.feedType.toLowerCase() === "request" && (
- <>
-
- >
- )}
{fullPostLink ? (
diff --git a/apps/builddao/widget/components/modals/CreateProposal.jsx b/apps/builddao/widget/components/modals/CreateProposal.jsx
index 205d5976..68b433c2 100644
--- a/apps/builddao/widget/components/modals/CreateProposal.jsx
+++ b/apps/builddao/widget/components/modals/CreateProposal.jsx
@@ -9,7 +9,7 @@ const { Modal, Button, User } = VM.require(
) || {
Modal: () => <>>,
Button: () => <>>,
- User: () => <>>
+ User: () => <>>,
};
const showModal = props.showModal;
@@ -128,7 +128,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS
+ customCSS: editorCSS,
}}
/>
>
@@ -141,7 +141,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS
+ customCSS: editorCSS,
}}
/>
>
@@ -154,7 +154,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS
+ customCSS: editorCSS,
}}
/>
>
@@ -168,7 +168,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS
+ customCSS: editorCSS,
}}
/>
>
@@ -182,7 +182,7 @@ return (
selectedDAO: selectedDAO,
item: props.item,
bootstrapTheme: bootstrapTheme,
- customCSS: editorCSS
+ customCSS: editorCSS,
}}
/>
>
diff --git a/apps/builddao/widget/components/post/Header.jsx b/apps/builddao/widget/components/post/Header.jsx
index 3a3f94f7..078cb2f8 100644
--- a/apps/builddao/widget/components/post/Header.jsx
+++ b/apps/builddao/widget/components/post/Header.jsx
@@ -95,7 +95,8 @@ const isPremium = !!props.isPremium;
const flagItem = props.flagItem;
const customActions = props.customActions ?? [];
const showTime = props.showTime ?? true;
-const toggleModal = props.toggleModal;
+const modalToggles = props.modalToggles;
+const setItem = props.setItem;
const { href } = VM.require("buildhub.near/widget/lib.url") || (() => {});
@@ -195,11 +196,12 @@ return (
customActions.map((action) => (
- action.type === "modal"
- ? action.onClick(toggleModal)
- : action.onClick(flagItem)
- }
+ onClick={() => {
+ if (action.type === "modal") {
+ action.onClick(modalToggles);
+ setItem(flagItem);
+ }
+ }}
className="btn btn-outline-dark dropdown-item"
>
{" "}
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 3bf1f342..67eb9b37 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -189,9 +189,10 @@ return {
type: "modal",
icon: "bi-file",
label: "Propose",
- onClick: (modalToggle) => {
- console.log("modal", modalToggle);
- modalToggle();
+ onClick: (modalToggles) => {
+ console.log(modalToggles);
+ const toggle = modalToggles.propose;
+ toggle();
},
},
],
From 3a806455313a443ce7023f33e477e6a3a90c0d80 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 15:12:19 +0500
Subject: [PATCH 120/132] Finish Request Feed
---
apps/builddao/widget/Feed.jsx | 14 ++++++++++++--
apps/builddao/widget/components/Post.jsx | 1 +
.../widget/components/modals/CreateProposal.jsx | 4 +++-
apps/builddao/widget/config/feed.jsx | 13 +++++++++++--
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 4af476fb..8e54ae35 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -23,7 +23,7 @@ return (
<>
)}
{!context.accountId ? ( // if not logged in
-
+
) : (
+ }
src="buildhub.near/widget/Compose"
props={{
draftKey: feedName,
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 4e68b626..160a28cb 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -303,6 +303,7 @@ return (
setSelectedOption(e.target.value)}
value={selectedOption}
>
- Open this select menu
+
+ Open this select menu
+
Text
Transfer
Function Call
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index 67eb9b37..e6475d42 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -182,12 +182,21 @@ return {
blockHeight: "final",
init: {
name: "Request",
- icon: "bi-file",
+ icon: "bi-file-earmark-text",
requiredHashtags: ["build", "request"],
+ template: `## REQUEST TITLE
+(posted via [${daoName} Gateway](${feedLink}?tab=request))
+
+**What are you requesting?**
+- [Describe your request]
+
+**Context or additional information:**
+- [Provide any context or details]
+`,
customActions: [
{
type: "modal",
- icon: "bi-file",
+ icon: "bi-file-earmark-text",
label: "Propose",
onClick: (modalToggles) => {
console.log(modalToggles);
From f34cc07a94faf54e340390a46e4ce3a87ff65fef Mon Sep 17 00:00:00 2001
From: Megha-Dev-19
Date: Thu, 1 Feb 2024 19:52:59 +0530
Subject: [PATCH 121/132] fix min height of sidebar
---
apps/builddao/widget/template/SidebarLayout.jsx | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/apps/builddao/widget/template/SidebarLayout.jsx b/apps/builddao/widget/template/SidebarLayout.jsx
index 367dd17e..9b57130a 100644
--- a/apps/builddao/widget/template/SidebarLayout.jsx
+++ b/apps/builddao/widget/template/SidebarLayout.jsx
@@ -16,14 +16,13 @@ const SidebarContainer = styled.div`
border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
background: var(--bg-1, #0b0c14);
width: 100%;
-
+ min-height: 80vh;
display: flex;
padding: 24px 12px;
flex-direction: column;
align-items: flex-start;
gap: 16px;
margin-bottom: 1rem;
- height: max-content;
@media screen and (max-width: 768px) {
border: 0px;
@@ -58,7 +57,7 @@ const Sidebar = ({ currentPath, page, routes }) => (
textDecoration: "none",
cursor: "pointer",
padding: "8px 12px",
- gap: "10px",
+ gap: "10px"
}}
>
{route.init.icon && }
From 39d22d489fd381aaeef3dfff878846daaffd05ef Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 19:57:31 +0500
Subject: [PATCH 122/132] Fix request feed modal for projects route
---
apps/builddao/widget/Compose.jsx | 17 ++--
apps/builddao/widget/Feed.jsx | 1 +
apps/builddao/widget/config/feed.jsx | 30 -------
.../builddao/widget/config/project-routes.jsx | 24 +++---
apps/builddao/widget/home/join.jsx | 4 +-
src/components/Editor/FileTab.js | 7 +-
src/pages/EditorPage.js | 85 +++++++++----------
7 files changed, 67 insertions(+), 101 deletions(-)
diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx
index 6740cb8c..6cf5406d 100644
--- a/apps/builddao/widget/Compose.jsx
+++ b/apps/builddao/widget/Compose.jsx
@@ -86,18 +86,15 @@ function checkAndAppendHashtag(input, target) {
}
const postToCustomFeed = ({ feed, text, labels }) => {
- const postId = generateUID();
- if (!labels) labels = [];
+ // if (!labels) labels = [];
- labels = labels.map((label) => label.toLowerCase());
- labels.push(feed.name.toLowerCase());
+ // labels = labels.map((label) => label.toLowerCase());
+ // labels.push(feed.name.toLowerCase());
const requiredHashtags = props.requiredHashtags || ["build"];
if (feed.hashtag) requiredHashtags.push(feed.hashtag.toLowerCase());
requiredHashtags.push(feed.name.toLowerCase());
-
text = text + `\n\n`;
-
requiredHashtags.forEach((hashtag) => {
text = checkAndAppendHashtag(text, hashtag);
});
@@ -394,7 +391,7 @@ return (
- postToCustomFeed({ feed: props.feed, text: postContent, labels })
+ postToCustomFeed({
+ feed: props.feed,
+ text: postContent,
+ labels,
+ })
}
>
Post {props.feed.name}
diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx
index 8e54ae35..7b0308b6 100644
--- a/apps/builddao/widget/Feed.jsx
+++ b/apps/builddao/widget/Feed.jsx
@@ -51,6 +51,7 @@ return (
draftKey: feedName,
template: template,
requiredHashtags: requiredHashtags,
+ feed: { ...props },
}}
/>
)}
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index e6475d42..fc771e52 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -177,36 +177,6 @@ return {
requiredHashtags: ["build", "feedback"],
},
},
- request: {
- path: "buildhub.near/widget/Feed",
- blockHeight: "final",
- init: {
- name: "Request",
- icon: "bi-file-earmark-text",
- requiredHashtags: ["build", "request"],
- template: `## REQUEST TITLE
-(posted via [${daoName} Gateway](${feedLink}?tab=request))
-
-**What are you requesting?**
-- [Describe your request]
-
-**Context or additional information:**
-- [Provide any context or details]
-`,
- customActions: [
- {
- type: "modal",
- icon: "bi-file-earmark-text",
- label: "Propose",
- onClick: (modalToggles) => {
- console.log(modalToggles);
- const toggle = modalToggles.propose;
- toggle();
- },
- },
- ],
- },
- },
bookmarks: {
path: "buildhub.near/widget/OrderedGraphFeed",
blockHeight: "final",
diff --git a/apps/builddao/widget/config/project-routes.jsx b/apps/builddao/widget/config/project-routes.jsx
index 6dedf528..286182ee 100644
--- a/apps/builddao/widget/config/project-routes.jsx
+++ b/apps/builddao/widget/config/project-routes.jsx
@@ -20,11 +20,15 @@ return {
requiredHashtags: ["build", "request"],
customActions: [
{
- label: "Propose",
- icon: "bi-file-earmark-text",
type: "modal",
- onClick: (modalToggle) => modalToggle() // want to fix
- }
+ icon: "bi-file-earmark-text",
+ label: "Propose",
+ onClick: (modalToggles) => {
+ console.log(modalToggles);
+ const toggle = modalToggles.propose;
+ toggle();
+ },
+ },
],
template: `## REQUEST TITLE
(posted via [${daoName} Gateway](${feedLink}?tab=request))
@@ -34,8 +38,8 @@ return {
#### Why This Proposal?
[Explanation of why this proposal is necessary or beneficial.]
-`
- }
+`,
+ },
},
proposals: {
path: "buildhub.near/widget/Proposals",
@@ -43,8 +47,8 @@ return {
init: {
name: "Proposals",
icon: "bi-file-earmark-text",
- daoId: "build.sputnik-dao.near"
- }
- }
- }
+ daoId: "build.sputnik-dao.near",
+ },
+ },
+ },
};
diff --git a/apps/builddao/widget/home/join.jsx b/apps/builddao/widget/home/join.jsx
index e5f5dad6..eb3216fc 100644
--- a/apps/builddao/widget/home/join.jsx
+++ b/apps/builddao/widget/home/join.jsx
@@ -251,7 +251,7 @@ const CTAContainer = styled.div`
color: var(--white-100, #fff);
/* H2/Large */
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
font-size: 40px;
font-style: normal;
font-weight: 500;
@@ -282,7 +282,7 @@ const CTAContent = styled.div`
p {
color: var(--Sea-Blue, #51ffea);
/* Body/Large */
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
font-size: 1rem;
font-style: normal;
font-weight: 400;
diff --git a/src/components/Editor/FileTab.js b/src/components/Editor/FileTab.js
index 1d7a7298..d0e3dd74 100644
--- a/src/components/Editor/FileTab.js
+++ b/src/components/Editor/FileTab.js
@@ -97,7 +97,7 @@ export function FileTab(props) {
color: var(--black-100, #000);
/* Other/Button_text */
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
font-size: 0.875rem;
font-style: normal;
font-weight: 500;
@@ -148,9 +148,8 @@ export function FileTab(props) {
)}
{
e.preventDefault();
e.stopPropagation();
diff --git a/src/pages/EditorPage.js b/src/pages/EditorPage.js
index 65fb232f..c357095e 100644
--- a/src/pages/EditorPage.js
+++ b/src/pages/EditorPage.js
@@ -80,7 +80,7 @@ const Button = styled.button`
gap: 4px;
/* Other/Button_text */
- font-family: Satoshi;
+ font-family: Satoshi, sans-serif;
font-size: 0.875rem;
font-style: normal;
font-weight: 500;
@@ -437,20 +437,20 @@ export default function EditorPage(props) {
(uncommittedPreviews) => {
return uncommittedPreviews
? {
- redirectMap: Object.fromEntries(
- Object.entries(allSaved)
- .filter(([jpath, code]) => code !== true)
- .map(([jpath, code]) => {
- const path = JSON.parse(jpath);
- return [
- pathToSrc(path),
- {
- code,
- },
- ];
- })
- ),
- }
+ redirectMap: Object.fromEntries(
+ Object.entries(allSaved)
+ .filter(([jpath, code]) => code !== true)
+ .map(([jpath, code]) => {
+ const path = JSON.parse(jpath);
+ return [
+ pathToSrc(path),
+ {
+ code,
+ },
+ ];
+ })
+ ),
+ }
: undefined;
},
[allSaved, pathToSrc]
@@ -466,7 +466,7 @@ export default function EditorPage(props) {
color: "black",
padding: "10px 20px",
borderRadius: 8,
- fontFamily: "Satoshi",
+ fontFamily: "Satoshi, sans-serif",
fontWeight: "500",
fontSize: "0.875rem",
}}
@@ -696,9 +696,8 @@ export default function EditorPage(props) {
setTab(Tab.Metadata)}
>
@@ -748,15 +744,13 @@ export default function EditorPage(props) {
{
renderPreview(code);
@@ -859,11 +853,10 @@ export default function EditorPage(props) {
)}
@@ -917,9 +909,8 @@ export default function EditorPage(props) {
From 435557ca18916dead700605232733b5b1f9011d0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 20:17:35 +0500
Subject: [PATCH 123/132] Fix Library issues and some loading states
---
apps/builddao/widget/components/Library.jsx | 10 +++++++---
apps/builddao/widget/components/Post.jsx | 2 +-
apps/builddao/widget/components/User.jsx | 2 +-
apps/builddao/widget/components/navigation/header.jsx | 2 +-
apps/builddao/widget/components/post/Header.jsx | 2 +-
5 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/apps/builddao/widget/components/Library.jsx b/apps/builddao/widget/components/Library.jsx
index fc5ff7c4..dc0a1929 100644
--- a/apps/builddao/widget/components/Library.jsx
+++ b/apps/builddao/widget/components/Library.jsx
@@ -147,12 +147,12 @@ const components = [
},
preview: (
<>
- {/*
>
),
embedCode: `
@@ -274,7 +274,11 @@ const components = [
preview: (
<>
-
+ setChecked(!checked)}
+ label="Checkbox"
+ />
>
),
diff --git a/apps/builddao/widget/components/Post.jsx b/apps/builddao/widget/components/Post.jsx
index 160a28cb..8f9ebb96 100644
--- a/apps/builddao/widget/components/Post.jsx
+++ b/apps/builddao/widget/components/Post.jsx
@@ -400,7 +400,7 @@ return (
(
>
(
{context.accountId ? (
(
>
Date: Thu, 1 Feb 2024 21:13:03 +0500
Subject: [PATCH 124/132] Navbar style updates
---
apps/builddao/widget/components/navigation/header.jsx | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx
index 1296f403..af143bc7 100644
--- a/apps/builddao/widget/components/navigation/header.jsx
+++ b/apps/builddao/widget/components/navigation/header.jsx
@@ -20,7 +20,7 @@ const ButtonGroup = styled.div`
display: flex;
flex-direction: row;
align-items: center;
- gap: 8px;
+ gap: 0.5rem;
@media screen and (max-width: 768px) {
flex-direction: column;
@@ -130,7 +130,11 @@ const AppHeader = ({ page, routes, ...props }) => (
}
return (
-
+
{route.init.icon && }
{route.init.name}
From b7b1486004736c7e4d0b5aac71e039a901bb6b70 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 21:37:10 +0500
Subject: [PATCH 125/132] Consistant UI for library page
---
apps/builddao/widget/components/Library.jsx | 68 ++++++++++++++++++---
1 file changed, 60 insertions(+), 8 deletions(-)
diff --git a/apps/builddao/widget/components/Library.jsx b/apps/builddao/widget/components/Library.jsx
index dc0a1929..e626315d 100644
--- a/apps/builddao/widget/components/Library.jsx
+++ b/apps/builddao/widget/components/Library.jsx
@@ -676,13 +676,7 @@ const Wrapper = styled.div`
const renderMenuItem = (c, i) => {
const prev = i ? components[i - 1] : null;
const res = [];
- if (!prev || prev.category !== c.category) {
- res.push(
-
- {c.category}
-
- );
- }
+
const id = c.name.toLowerCase().replaceAll(" ", "-");
res.push(
@@ -695,6 +689,7 @@ const renderMenuItem = (c, i) => {
const Grid = styled.div`
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
+ gap: 1rem;
.main {
grid-column: span 4 / span 4;
@@ -702,17 +697,74 @@ const Grid = styled.div`
.aside {
grid-column: span 1 / span 1;
+ border-radius: 16px;
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ background: var(--bg-1, #0b0c14);
+ width: 100%;
+ min-height: 80vh;
+ display: flex;
+ padding: 24px 12px;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 16px;
+ margin-bottom: 1rem;
+
+ .menu-item {
+ width: 100%;
+ display: flex;
+ }
+
+ a {
+ all: unset;
+ display: inline-flex;
+ padding: 8px 12px;
+ justify-content: flex-start;
+ align-items: center;
+ gap: 4px;
+ border-radius: 8px;
+ font-size: 14px;
+ font-weight: 500;
+ transition: all 300ms;
+ background: var(--button-outline-bg, transparent);
+ color: var(--button-outline-color, #fff);
+ border: 1px solid var(--stroke-color, rgba(255, 255, 255, 0.2));
+ cursor: pointer;
+ align-self: stretch;
+ width: 100%;
+ text-align: left;
+
+ &:hover {
+ background: var(--button-outline-hover-bg, rgba(255, 255, 255, 0.1));
+ color: var(--button-outline-hover-color, #fff);
+ }
+ }
}
@media screen and (max-width: 768px) {
display: flex;
flex-direction: column;
gap: 1rem;
+
+ .aside {
+ flex-direction: row;
+ border: none;
+ overflow-x: auto;
+ min-height: auto;
+ gap: 2rem;
+
+ .menu-item {
+ width: max-content;
+ flex-shrink: 0;
+ a {
+ flex-shrink: 0;
+ }
+ }
+ }
}
`;
return (
-
+
{components.map((component, index) => renderMenuItem(component, index))}
From 9b81e7d248421e5082e296a543f46396349d8546 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 22:27:18 +0500
Subject: [PATCH 126/132] Remove console logs
---
apps/builddao/widget/components/buttons/UserDropdown.jsx | 2 --
apps/builddao/widget/config/project-routes.jsx | 1 -
2 files changed, 3 deletions(-)
diff --git a/apps/builddao/widget/components/buttons/UserDropdown.jsx b/apps/builddao/widget/components/buttons/UserDropdown.jsx
index 7e91cbe9..1e06e701 100644
--- a/apps/builddao/widget/components/buttons/UserDropdown.jsx
+++ b/apps/builddao/widget/components/buttons/UserDropdown.jsx
@@ -144,8 +144,6 @@ function LogOut() {
);
}
-console.log("props", props);
-
return (
{
- console.log(modalToggles);
const toggle = modalToggles.propose;
toggle();
},
From a6beed679d6aac62e5623e3990c9b6c025cabc64 Mon Sep 17 00:00:00 2001
From: Zeeshan Ahmad
Date: Thu, 1 Feb 2024 22:57:45 +0500
Subject: [PATCH 127/132] Add redirects to app
---
src/App.js | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/App.js b/src/App.js
index b0f84a8a..e69275de 100644
--- a/src/App.js
+++ b/src/App.js
@@ -26,7 +26,7 @@ import {
import React, { useCallback, useEffect, useState } from "react";
import "react-bootstrap-typeahead/css/Typeahead.bs5.css";
import "react-bootstrap-typeahead/css/Typeahead.css";
-import { Link, Route, BrowserRouter as Router, Switch } from "react-router-dom";
+import { Link, Route, BrowserRouter as Router, Switch, Redirect } from "react-router-dom";
import { BosLoaderBanner } from "./components/BosLoaderBanner";
import { Navbar } from "./components/navigation/Navbar";
import { useEthersProviderContext } from "./data/web3";
@@ -110,7 +110,7 @@ function App() {
if (props.to) {
props.to =
typeof props.to === "string" &&
- isValidAttribute("a", "href", props.to)
+ isValidAttribute("a", "href", props.to)
? props.to
: "about:blank";
}
@@ -206,27 +206,24 @@ function App() {
- {/* I've added the below as the isolated route for rendering the app */}
-
-
-
+
+
- {/* Legacy: */}
-
-
-
-
-
+
-
-
+
-
-
+
+ {/* I've added the below as the isolated route for rendering the app */}
+
+
+
+
+ {/* Legacy: */}
@@ -234,11 +231,11 @@ function App() {
-
+ {/*
-
+ */}
From ce06520bdf147372ba79ed66613a3adeaffb0e5d Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Thu, 1 Feb 2024 16:30:16 -0700
Subject: [PATCH 128/132] working required hashtag
---
apps/bos-blocks/widget/PR/MergedIndexFeed.jsx | 57 ++++++++++++++++++-
1 file changed, 55 insertions(+), 2 deletions(-)
diff --git a/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
index 9a62accb..5818013f 100644
--- a/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
+++ b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
@@ -4,6 +4,7 @@ if (!props.index) {
const indices = JSON.parse(
JSON.stringify(Array.isArray(props.index) ? props.index : [props.index])
);
+const requiredIndices = indices.filter((index) => index.required);
const filter = props.filter;
@@ -118,6 +119,38 @@ for (let iIndex = 0; iIndex < indices.length; ++iIndex) {
}
}
+let itemsByRequiredIndex = [];
+let commonUniqueIdentifiers = [];
+
+// If there are required indices, filter mergedItems to include only items that appear in all required feeds
+if (requiredIndices.length > 0) {
+ for (let iIndex = 0; iIndex < indices.length; ++iIndex) {
+ const index = indices[iIndex];
+ if (index.required) {
+ const feed = state.feeds[iIndex];
+ if (!feed.items) {
+ continue;
+ } else {
+ itemsByRequiredIndex.push(
+ feed.items.map((item) =>
+ JSON.stringify({
+ blockHeight: item.blockHeight,
+ accountId: item.accountId,
+ })
+ )
+ );
+ }
+ } else {
+ continue;
+ }
+ }
+ // Compute the intersection of uniqueIdentifiers across all required indices
+ commonUniqueIdentifiers = itemsByRequiredIndex.reduce((a, b) =>
+ a.filter((c) => b.includes(c))
+ );
+}
+
+
// Construct merged feed and compute usage per feed.
const filteredItems = [];
@@ -154,7 +187,27 @@ while (filteredItems.length < state.displayCount) {
}
}
}
- filteredItems.push(bestItem);
+
+ if (requiredIndices.length > 0) {
+ const uniqueIdentifier = JSON.stringify({
+ blockHeight: bestItem.blockHeight,
+ accountId: bestItem.accountId,
+ });
+
+ if (!commonUniqueIdentifiers.includes(uniqueIdentifier)) {
+ continue;
+ }
+ }
+ // remove duplicate posts
+ const existingItemIndex = filteredItems.findIndex(
+ (item) =>
+ item.blockHeight === bestItem.blockHeight &&
+ item.accountId === bestItem.accountId
+ );
+
+ if (existingItemIndex === -1) {
+ filteredItems.push(bestItem);
+ }
}
// Fetch new items for feeds that don't have enough items.
@@ -256,4 +309,4 @@ return props.manual ? (
>
{Layout ? {renderedItems} : <>{renderedItems}>}
-);
\ No newline at end of file
+);
From 1c6764da737311e38c8d1850b8ba33b0b568e794 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Thu, 1 Feb 2024 17:50:44 -0700
Subject: [PATCH 129/132] some improvements to merged index feed
---
apps/bos-blocks/widget/PR/MergedIndexFeed.jsx | 82 +++++++++++++------
apps/builddao/widget/config/feed.jsx | 9 ++
2 files changed, 66 insertions(+), 25 deletions(-)
diff --git a/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
index 5818013f..b88ab2c5 100644
--- a/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
+++ b/apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
@@ -37,27 +37,60 @@ const computeFetchFrom = (items, limit, desc) => {
return desc ? blockHeight - 1 : blockHeight + 1;
};
-const mergeItems = (iIndex, oldItems, newItems, desc) => {
- const index = indices[iIndex];
- const items = [
- ...new Set(
- [
- ...newItems.map((item) => ({
- ...item,
- action: index.action,
- key: index.key,
- index: iIndex,
- })),
- ...oldItems,
- ].map((i) => JSON.stringify(i))
- ),
- ].map((i) => JSON.parse(i));
- items.sort((a, b) => a.blockHeight - b.blockHeight);
- if (desc) {
- items.reverse();
- }
- return items;
-};
+function mergeItems(iIndex, oldItems, newItems, desc) {
+ const itemMap = new Map();
+
+ const generateKey = (item) => ({
+ accountId: item.accountId,
+ blockHeight: item.blockHeight,
+ });
+
+ // Add old items to the map
+ oldItems.forEach((item) => {
+ const key = generateKey(item);
+ itemMap.set(key, item);
+ });
+
+ newItems.forEach((item) => {
+ const key = generateKey(item);
+ if (!itemMap.has(key)) {
+ itemMap.set(key, {
+ ...item,
+ index: iIndex,
+ });
+ }
+ });
+
+ // Convert the Map values to an array
+ let mergedItems = Array.from(itemMap.values());
+
+ // Sort items by blockHeight, ascending or descending based on the `desc` flag
+ mergedItems.sort((a, b) =>
+ desc ? b.blockHeight - a.blockHeight : a.blockHeight - b.blockHeight
+ );
+
+ return mergedItems;
+}
+
+// const mergeItems = (iIndex, newItems, desc) => {
+// const uniqueItems = new Map();
+
+// newItems.forEach((item) => {
+// const key = { blockHeight: item.blockHeight, accountId: item.accountId };
+// if (!uniqueItems.has(key)) {
+// uniqueItems.set(key, {
+// ...item,
+// index: iIndex,
+// });
+// }
+// });
+
+// const sortedItems = Array.from(uniqueItems.values()).sort((a, b) =>
+// desc ? b.blockHeight - a.blockHeight : a.blockHeight - b.blockHeight
+// );
+
+// return sortedItems;
+// };
const jIndices = JSON.stringify(indices);
if (jIndices !== state.jIndices) {
@@ -145,12 +178,11 @@ if (requiredIndices.length > 0) {
}
}
// Compute the intersection of uniqueIdentifiers across all required indices
- commonUniqueIdentifiers = itemsByRequiredIndex.reduce((a, b) =>
- a.filter((c) => b.includes(c))
- );
+ commonUniqueIdentifiers =
+ itemsByRequiredIndex.length &&
+ itemsByRequiredIndex.reduce((a, b) => a.filter((c) => b.includes(c)));
}
-
// Construct merged feed and compute usage per feed.
const filteredItems = [];
diff --git a/apps/builddao/widget/config/feed.jsx b/apps/builddao/widget/config/feed.jsx
index fc771e52..ef0a352f 100644
--- a/apps/builddao/widget/config/feed.jsx
+++ b/apps/builddao/widget/config/feed.jsx
@@ -11,6 +11,15 @@ const feedLink = "https://nearbuilders.org/feed";
return {
type: "app", // every.near/type/app
routes: {
+ all: {
+ path: "buildhub.near/widget/Feed",
+ blockHeight: "final",
+ init: {
+ name: "All", // maybe these should be moved to navbar specific
+ icon: "bi-list",
+ requiredHashtags: ["build"]
+ },
+ },
resolutions: {
path: "buildhub.near/widget/Feed",
blockHeight: "final",
From d86e5b8564e46b7848f36019ec2497bca2f0ba74 Mon Sep 17 00:00:00 2001
From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com>
Date: Thu, 1 Feb 2024 17:55:45 -0700
Subject: [PATCH 130/132] remvoe bos-blocks
---
apps/bos-blocks/bos.config.json | 3 -
apps/bos-blocks/widget/Compose.jsx | 99 -----
apps/bos-blocks/widget/Feed.jsx | 89 -----
apps/bos-blocks/widget/Library.jsx | 270 --------------
.../widget/PR/FilteredIndexFeed.jsx | 11 -
apps/bos-blocks/widget/PR/IndexFeed.jsx | 192 ----------
apps/bos-blocks/widget/PR/MergedIndexFeed.jsx | 344 ------------------
apps/bos-blocks/widget/Router.jsx | 111 ------
8 files changed, 1119 deletions(-)
delete mode 100644 apps/bos-blocks/bos.config.json
delete mode 100644 apps/bos-blocks/widget/Compose.jsx
delete mode 100644 apps/bos-blocks/widget/Feed.jsx
delete mode 100644 apps/bos-blocks/widget/Library.jsx
delete mode 100644 apps/bos-blocks/widget/PR/FilteredIndexFeed.jsx
delete mode 100644 apps/bos-blocks/widget/PR/IndexFeed.jsx
delete mode 100644 apps/bos-blocks/widget/PR/MergedIndexFeed.jsx
delete mode 100644 apps/bos-blocks/widget/Router.jsx
diff --git a/apps/bos-blocks/bos.config.json b/apps/bos-blocks/bos.config.json
deleted file mode 100644
index 25f7b186..00000000
--- a/apps/bos-blocks/bos.config.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "appAccount": "devs.near"
-}
\ No newline at end of file
diff --git a/apps/bos-blocks/widget/Compose.jsx b/apps/bos-blocks/widget/Compose.jsx
deleted file mode 100644
index 203c52cf..00000000
--- a/apps/bos-blocks/widget/Compose.jsx
+++ /dev/null
@@ -1,99 +0,0 @@
-if (!context.accountId) {
- return "";
-}
-
-const index = props.index || {
- post: JSON.stringify({
- key: "main",
- value: {
- type: "md",
- },
- }),
-};
-
-const composeData = () => {
- if (props.appendHashtags) {
- state.content.text = props.appendHashtags(state.content.text);
- }
- const data = {
- post: {
- main: JSON.stringify(state.content),
- },
- index,
- };
-
- const item = {
- type: "social",
- path: `${context.accountId}/post/main`,
- };
-
- const notifications = state.extractMentionNotifications(
- state.content.text,
- item
- );
-
- if (notifications.length) {
- data.index.notify = JSON.stringify(
- notifications.length > 1 ? notifications : notifications[0]
- );
- }
-
- const hashtags = state.extractHashtags(state.content.text);
-
- if (hashtags.length) {
- data.index.hashtag = JSON.stringify(
- hashtags.map((hashtag) => ({
- key: hashtag,
- value: item,
- }))
- );
- }
-
- return data;
-};
-
-State.init({
- onChange: ({ content }) => {
- State.update({ content });
- },
-});
-
-return (
- <>
-
- {
- State.update({ extractMentionNotifications, extractHashtags });
- },
- composeButton: (onCompose) => (
- {
- onCompose();
- }}
- >
- Post
-
- ),
- }}
- />
-
- {state.content && (
-
- )}
- >
-);
diff --git a/apps/bos-blocks/widget/Feed.jsx b/apps/bos-blocks/widget/Feed.jsx
deleted file mode 100644
index f252659e..00000000
--- a/apps/bos-blocks/widget/Feed.jsx
+++ /dev/null
@@ -1,89 +0,0 @@
-const Feed = ({ index, typeWhitelist, Item, Layout, showCompose }) => {
- Item = Item || ((props) => {JSON.stringify(props)}
);
- Layout = Layout || (({ children }) => children);
-
- const renderItem = (a, i) => {
- if (typeWhitelist && !typeWhitelist.includes(a.value.type)) {
- return false;
- }
- return (
-
-
-
- );
- };
-
- const composeIndex = () => {
- const arr = Array.isArray(index) ? index : [index];
-
- const grouped = arr.reduce((acc, i) => {
- if (i.action !== "repost") {
- if (!acc[i.action]) {
- acc[i.action] = [];
- }
- acc[i.action].push({ key: i.key, value: { type: "md" } });
- }
- return acc;
- }, {});
-
- Object.keys(grouped).forEach((action) => {
- if (grouped[action].length === 1) {
- grouped[action] = grouped[action][0];
- }
- grouped[action] = JSON.stringify(grouped[action]);
- });
-
- return grouped;
- };
-
- const appendHashtags = (v) => {
- const arr = Array.isArray(index) ? index : [index];
- const hashtags = arr
- .filter((i) => i.action === "hashtag")
- .map((i) => i.key);
-
- hashtags.forEach((hashtag) => {
- if (v.toLowerCase().includes(`#${hashtag.toLowerCase()}`)) return;
- else v += ` #${hashtag}`;
- });
-
- return v;
- };
-
- return (
- <>
- {showCompose && (
-
- )}
- {Array.isArray(index) ? (
- {children} ,
- }}
- />
- ) : (
- {children} ,
- }}
- />
- )}
- >
- );
-};
-
-return { Feed };
diff --git a/apps/bos-blocks/widget/Library.jsx b/apps/bos-blocks/widget/Library.jsx
deleted file mode 100644
index c164e5b9..00000000
--- a/apps/bos-blocks/widget/Library.jsx
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * This is just a direct copy of mob.near/widget/N.Library
- */
-const accountId = context.accountId || "root.near";
-const authorId = "mob.near";
-
-const itemDescription =
- 'The identifier item. It will be used as a unique identifier of the entity that receives the action. It\'s also used as a key of the action in the index.\nThe item should be an object with the following keys: `type`, `path` and optional `blockHeight`.\n- `type`: If the data is stored in the social DB, then the type is likely `"social"`, other types can be defined in the standards.\n- `path`: The path to the item. For a `"social"` type, it\'s absolute path within SocialDB, e.g. `alice.near/post/main`.\n- `blockHeight`: An optional paremeter to indicate the block when the data was stored. Since SocialDB data can be overwritten to save storage, the exact data should be referenced by the block height (e.g. for a given post). But if the latest data should be used, then `blockHeight` should be ommited.\n\nExamples of `item`:\n- `{type: "social", path: "mob.near/widget/N.Library"}`\n- `{type: "social", path: "mob.near/post/main", blockHeight: 81101335}`\n';
-
-const components = [
- {
- title: "Feed",
- // category: "Profile",
- widgetName: "Feed",
- description:
- "",
- // demoProps: { accountId },
- // requiredProps: {
- // accountId: "The account ID of the profile",
- // },
- // optionalProps: {
- // profile: "Object that holds profile information to display",
- // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
- // hideDescription: "Don't show description, default false",
- // },
- },
- {
- title: "Context Menu",
- // category: "Profile",
- widgetName: "ContextMenu",
- description:
- "",
- // demoProps: { accountId, tooltip: true },
- // requiredProps: {
- // accountId: "The account ID of the profile",
- // },
- // optionalProps: {
- // profile: "Object that holds profile information to display",
- // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
- // tooltip:
- // "Display overlay tooltip when you hover over the profile, default false",
- // },
- },
- {
- title: "Router",
- // category: "Profile",
- widgetName: "Router",
- description:
- "",
- // demoProps: { accountId, tooltip: true },
- // requiredProps: {
- // accountId: "The account ID of the profile",
- // },
- // optionalProps: {
- // link: "Whether to make profile clickable with a link to the profile page, default true.",
- // hideAccountId: "Don't show account ID, default false",
- // hideName: "Don't show profile name, default false",
- // hideImage: "Don't show profile picture, default false",
- // hideCheckmark: "Don't show premium checkmark, default false",
- // profile: "Object that holds profile information to display",
- // fast: "Render profile picture faster using external cache, default true if the `props.profile` is not provided",
- // title:
- // 'Optional title when you hover over the profile. Default `"${name} ${accountId}"`',
- // tooltip:
- // "Display overlay tooltip or title when you hover over the profile, default false. Will display a custom title if tooltip is given. If tooltip is true, the full tooltip is displayed. Default false",
- // },
- },
-];
-
-const renderProps = (props, optional) => {
- return Object.entries(props || {}).map(([key, desc]) => {
- return (
-
-
-