-
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.
* adds resources ideation doc to repo for collab * init * more * update sources and layout * Update resources.md Updates resources.md to incorporate team contributed resources * App router layout for resources * Remove AsideWithMainContent.jsx * cleanup * remove yarn --------- Co-authored-by: Elliot Braem <[email protected]> Co-authored-by: James Waugh <[email protected]> Co-authored-by: Zeeshan Ahmad <[email protected]>
- Loading branch information
1 parent
a2daa53
commit 94e42a1
Showing
9 changed files
with
16,832 additions
and
12,190 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,50 +1,11 @@ | ||
const { MarkdownView } = VM.require("buildhub.near/widget/md-view") || { | ||
MarkdownView: () => <></>, | ||
}; | ||
const { Button } = VM.require("buildhub.near/widget/components.Button") || { | ||
Button: () => <></>, | ||
}; | ||
|
||
Button || (Button = () => <></>); | ||
MarkdownView || (MarkdownView = () => <></>); | ||
|
||
const fetchResources = () => { | ||
const res = fetch( | ||
"https://raw.githubusercontent.com/itexpert120/buildhub-resources/main/resources.json" | ||
); | ||
return JSON.parse(res.body); | ||
}; | ||
const mdPath = props.mdPath; | ||
|
||
const resources = fetchResources(); | ||
|
||
if (!resources) { | ||
return <div>Loading...</div>; | ||
if (!mdPath) { | ||
return <p>No Markdown path configured</p>; | ||
} | ||
|
||
const [currentResource, setCurrentResource] = useState(resources[0]); | ||
|
||
return ( | ||
<Widget | ||
src="/*__@appAccount__*//widget/components.AsideWithMainContent" | ||
props={{ | ||
sideContent: Object.keys(resources || {}).map((resource) => { | ||
const data = resources[resource]; | ||
return ( | ||
<Button | ||
id={resource} | ||
variant={currentResource.name === data.name ? "primary" : "outline"} | ||
onClick={() => setCurrentResource(data)} | ||
className={ | ||
"align-self-stretch flex-shrink-0 justify-content-start fw-medium" | ||
} | ||
style={{ fontSize: "14px" }} | ||
> | ||
<i className={`bi ${data.biIcon} `}></i> | ||
{data.name} | ||
</Button> | ||
); | ||
}), | ||
mainContent: <MarkdownView path={currentResource.mdLink} />, | ||
}} | ||
/> | ||
); | ||
return <MarkdownView path={mdPath} />; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
return { | ||
type: "app", | ||
routes: { | ||
guide: { | ||
path: "buildhub.near/widget/Resources", | ||
blockHeight: "final", | ||
init: { | ||
name: "Guide", | ||
icon: "bi-map", | ||
mdPath: | ||
"https://raw.githubusercontent.com/NEARBuilders/gateway/resources-page-ideation/resources.md", | ||
}, | ||
}, | ||
library: { | ||
path: "buildhub.near/widget/Resources", | ||
blockHeight: "final", | ||
init: { | ||
name: "Library", | ||
icon: "bi-collection", | ||
mdPath: | ||
"https://raw.githubusercontent.com/NEARBuilders/docs/main/build-library.md", | ||
}, | ||
}, | ||
}, | ||
}; |
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
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,5 +1,70 @@ | ||
const { currentPath, page, ...passProps } = props; | ||
|
||
const { routes } = VM.require("buildhub.near/widget/config.resources") ?? { | ||
routes: {}, | ||
}; | ||
|
||
const { SidebarLayout } = VM.require( | ||
"buildhub.near/widget/template.SidebarLayout" | ||
) || { | ||
SidebarLayout: () => <></>, | ||
}; | ||
|
||
if (!page) page = Object.keys(routes)[0] || "home"; | ||
|
||
const Root = styled.div``; | ||
|
||
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 <p>404 Not Found</p>; | ||
} | ||
} | ||
|
||
return ( | ||
<div key={active}> | ||
<Widget src={src} props={{ ...passProps, ...defaultProps }} /> | ||
</div> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
// display: flex; | ||
height: 100%; | ||
`; | ||
|
||
const Content = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
return ( | ||
<div className="container-xl mt-3"> | ||
<Widget src="buildhub.near/widget/Resources" /> | ||
</div> | ||
<Root> | ||
<Container> | ||
<SidebarLayout | ||
currentPath={currentPath} | ||
page={page} | ||
routes={routes} | ||
> | ||
<Content> | ||
<Router active={page} routes={routes} /> | ||
</Content> | ||
</SidebarLayout> | ||
</Container> | ||
</Root> | ||
); |
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.