-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converts Feed into every app pattern
- Loading branch information
1 parent
c9f1a68
commit 9abb987
Showing
9 changed files
with
530 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<Widget | ||
src="buildhub.near/widget/components.AsideWithMainContent" | ||
props={{ | ||
sideContent: Object.keys(feeds || {}).map((route) => { | ||
const data = feeds[route]; | ||
return ( | ||
<ButtonLink | ||
id={route} | ||
variant={activeFeed === route ? "primary" : "outline"} | ||
href={`${props.pagePath}&tab=${route}`} | ||
className={ | ||
"align-self-stretch flex-shrink-0 justify-content-start fw-medium" | ||
} | ||
style={{ | ||
fontSize: "14px", | ||
textDecoration: "none", | ||
cursor: "pointer", | ||
padding: "8px 12px", | ||
gap: "10px", | ||
}} | ||
> | ||
<i className={`bi ${data.icon} `}></i> | ||
<span>{data.label}</span> | ||
</ButtonLink> | ||
); | ||
}), | ||
mainContent: ( | ||
<> | ||
{feeds[activeFeed].hideCompose ? null : context.accountId ? ( | ||
<Widget | ||
src="buildhub.near/widget/Compose" | ||
props={{ | ||
feed: feeds[activeFeed], | ||
template: feeds[activeFeed].template, | ||
requiredHashtags: [daoTag], | ||
}} | ||
/> | ||
) : ( | ||
<Widget | ||
src="buildhub.near/widget/components.login-now" | ||
props={props} | ||
/> | ||
)} | ||
{feeds[activeFeed].customWidget ? ( | ||
<Widget | ||
src={feeds[activeFeed].customWidget} | ||
props={{ ...props, ...feeds[activeFeed].customProps }} | ||
/> | ||
) : ( | ||
<Feed | ||
index={[ | ||
{ | ||
action: "hashtag", | ||
key: feeds[activeFeed].hashtag, // resolution | ||
options: { | ||
limit: 10, | ||
order: "desc", | ||
}, | ||
cacheOptions: { | ||
ignoreCache: true, | ||
}, | ||
required: true, | ||
}, | ||
// fix this | ||
// { | ||
// action: "hashtag", | ||
// key: daoTag, // build | ||
// options: { | ||
// limit: 10, | ||
// order: "desc", | ||
// }, | ||
// cacheOptions: { | ||
// ignoreCache: true, | ||
// }, | ||
// required: true, | ||
// }, | ||
]} | ||
Item={(p) => ( | ||
<Post | ||
accountId={p.accountId} | ||
blockHeight={p.blockHeight} | ||
noBorder={true} | ||
currentPath={`${props.pagePath}`} | ||
customActions={feeds[activeFeed].customActions} | ||
feedType={feeds[activeFeed].name} | ||
/> | ||
)} | ||
/> | ||
)} | ||
</> | ||
), | ||
}} | ||
{!context.accountId ? ( // if not logged in | ||
<Widget src="buildhub.near/widget/components.login-now" props={props} /> | ||
) : ( | ||
<Widget | ||
src="buildhub.near/widget/Compose" | ||
props={{ | ||
feed: feeds[activeFeed], | ||
template: template, | ||
requiredHashtags: requiredHashtags, | ||
}} | ||
/> | ||
)} | ||
<Feed | ||
index={(requiredHashtags || []).map((it) => ({ | ||
action: "hashtag", | ||
key: it, | ||
options: { | ||
limit: 10, | ||
order: "desc", | ||
}, | ||
cacheOptions: { | ||
ignoreCache: true, | ||
}, | ||
required: true, | ||
}))} | ||
Item={(p) => ( | ||
<Post | ||
accountId={p.accountId} | ||
blockHeight={p.blockHeight} | ||
noBorder={true} | ||
currentPath={`${props.pagePath}`} | ||
customActions={customActions} | ||
feedType={feeds[activeFeed].name} | ||
/> | ||
)} | ||
/> | ||
</> | ||
); | ||
|
||
// 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 ( | ||
// <> | ||
// <Widget | ||
// src="buildhub.near/widget/components.AsideWithMainContent" | ||
// props={{ | ||
// sideContent: Object.keys(feeds || {}).map((route) => { | ||
// const data = feeds[route]; | ||
// return ( | ||
// <ButtonLink | ||
// id={route} | ||
// variant={activeFeed === route ? "primary" : "outline"} | ||
// href={`${props.pagePath}&tab=${route}`} | ||
// className={ | ||
// "align-self-stretch flex-shrink-0 justify-content-start fw-medium" | ||
// } | ||
// style={{ | ||
// fontSize: "14px", | ||
// textDecoration: "none", | ||
// cursor: "pointer", | ||
// padding: "8px 12px", | ||
// gap: "10px", | ||
// }} | ||
// > | ||
// <i className={`bi ${data.icon} `}></i> | ||
// <span>{data.label}</span> | ||
// </ButtonLink> | ||
// ); | ||
// }), | ||
// mainContent: ( | ||
// <> | ||
// {feeds[activeFeed].hideCompose ? null : context.accountId ? ( | ||
// <Widget | ||
// src="buildhub.near/widget/Compose" | ||
// props={{ | ||
// feed: feeds[activeFeed], | ||
// template: feeds[activeFeed].template, | ||
// requiredHashtags: [daoTag], | ||
// }} | ||
// /> | ||
// ) : ( | ||
// <Widget | ||
// src="buildhub.near/widget/components.login-now" | ||
// props={props} | ||
// /> | ||
// )} | ||
// {feeds[activeFeed].customWidget ? ( | ||
// <Widget | ||
// src={feeds[activeFeed].customWidget} | ||
// props={{ ...props, ...feeds[activeFeed].customProps }} | ||
// /> | ||
// ) : ( | ||
// <Feed | ||
// index={[ | ||
// { | ||
// action: "hashtag", | ||
// key: feeds[activeFeed].hashtag, // resolution | ||
// options: { | ||
// limit: 10, | ||
// order: "desc", | ||
// }, | ||
// cacheOptions: { | ||
// ignoreCache: true, | ||
// }, | ||
// required: true, | ||
// }, | ||
// // fix this | ||
// // { | ||
// // action: "hashtag", | ||
// // key: daoTag, // build | ||
// // options: { | ||
// // limit: 10, | ||
// // order: "desc", | ||
// // }, | ||
// // cacheOptions: { | ||
// // ignoreCache: true, | ||
// // }, | ||
// // required: true, | ||
// // }, | ||
// ]} | ||
// Item={(p) => ( | ||
// <Post | ||
// accountId={p.accountId} | ||
// blockHeight={p.blockHeight} | ||
// noBorder={true} | ||
// currentPath={`${props.pagePath}`} | ||
// customActions={feeds[activeFeed].customActions} | ||
// feedType={feeds[activeFeed].name} | ||
// /> | ||
// )} | ||
// /> | ||
// )} | ||
// </> | ||
// ), | ||
// }} | ||
// /> | ||
// </> | ||
// ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.