Skip to content

Commit

Permalink
Resources page creation (#127)
Browse files Browse the repository at this point in the history
* 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
4 people authored Feb 13, 2024
1 parent a2daa53 commit 94e42a1
Show file tree
Hide file tree
Showing 9 changed files with 16,832 additions and 12,190 deletions.
47 changes: 4 additions & 43 deletions apps/builddao/widget/Resources.jsx
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} />;
2 changes: 1 addition & 1 deletion apps/builddao/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Root = styled.div`
--bg-1: #0b0c14;
--bg-1-hover: #17181c;
--bg-1-hover-transparent: rgba(23, 24, 28, 0);
--bg-2: ##23242b;
--bg-2: #23242b;
--label-color: #fff;
--font-color: #fff;
--font-muted-color: #cdd0d5;
Expand Down
25 changes: 25 additions & 0 deletions apps/builddao/widget/config/resources.jsx
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",
},
},
},
};
64 changes: 45 additions & 19 deletions apps/builddao/widget/md-view.jsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,72 @@
const MarkdownContainer = styled.div`
max-width: 500px;
margin: 0 auto;
padding: 40px 0;
max-width: 888px;
padding: 0 55px 55px 55px;
background: var(--bg-1, #0b0c14);
border-radius: 23px;
h1,
h2,
h3,
h4,
h5,
h6,
span {
color: #fff !important;
span,
li,
ul,
ol,
p {
color: var(--text-color, #fff) !important;
font-family: "Inter", sans-serif !important;
}
pre {
margin: 1rem 0;
padding: 1rem;
background: var(--bg-2, #23242b);
border-radius: 1rem;
}
code {
background: var(--bg-2, #23242b);
color: var(--text-color, #fff) !important;
font-family: monospace !important;
}
h1 {
/* H1/large */
font-size: 48px;
font-style: normal;
padding: 1rem 0;
font-weight: 800;
}
h2 {
padding: 0.5rem 0;
font-weight: 700;
}
h3 {
padding: 0.25rem 0;
font-weight: 600;
}
h4,
h5,
h6 {
font-weight: 500;
line-height: 120%; /* 57.6px */
}
p,
ul,
li {
color: var(--White-50, #cdd0d5);
color: #000;
/* Body/14px */
font-family: "Inter", sans-serif !important;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 170%; /* 23.8px */
line-height: 170%;
}
@media screen and (max-width: 768px) {
padding: 24px;
padding: 40px;
border-radius: 10px;
}
`;

Expand All @@ -45,12 +76,7 @@ function MarkdownView(props) {

return (
<MarkdownContainer>
<Widget
src="openwebbuild.near/widget/Post.Markdown"
props={{
text: content.body,
}}
/>
<Markdown text={content.body} />
</MarkdownContainer>
);
}
Expand Down
45 changes: 3 additions & 42 deletions apps/builddao/widget/page/feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const { routes } = VM.require("buildhub.near/widget/config.feed") ?? {
routes: {},
};

const { theme } = VM.require("buildhub.near/widget/config.theme") ?? {
theme: {},
};

const { SidebarLayout } = VM.require(
"buildhub.near/widget/template.SidebarLayout"
) || {
Expand All @@ -16,15 +12,7 @@ const { SidebarLayout } = VM.require(

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]);
const Root = styled.div``;

function Router({ active, routes }) {
// this may be converted to a module at devs.near/widget/Router
Expand Down Expand Up @@ -70,40 +58,13 @@ return (
<Container>
<SidebarLayout
currentPath={currentPath}
page={activeRoute}
page={page}
routes={routes}
>
<Content>
<Router active={activeRoute} routes={routes} />
<Router active={page} routes={routes} />
</Content>
</SidebarLayout>
</Container>
</Root>
);

// 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 (
// <div className="container-xl my-3">
// <Widget
// src="buildhub.near/widget/Feed"
// loading="Feed loading..."
// props={{ ...props, ...defaultProps }}
// />
// </div>
// );
71 changes: 68 additions & 3 deletions apps/builddao/widget/page/resources.jsx
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>
);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"homepage": "/",
"private": true,
"dependencies": {
"@monaco-editor/react": "^4.4.6",
"@keypom/selector": "1.2.3",
"@monaco-editor/react": "^4.4.6",
"@near-wallet-selector/core": "^8.5.0",
"@near-wallet-selector/here-wallet": "^8.5.0",
"@near-wallet-selector/meteor-wallet": "^8.5.0",
Expand Down Expand Up @@ -77,9 +77,9 @@
"@babel/preset-react": "^7.14.5",
"assert": "^2.0.0",
"babel-loader": "^8.2.2",
"bos-workspace": "^0.0.1-alpha.4",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"bos-workspace": "^0.0.1-alpha.4",
"clean-webpack-plugin": "^4.0.0",
"concurrently": "^8.2.1",
"copy-webpack-plugin": "^9.0.1",
Expand Down
Loading

0 comments on commit 94e42a1

Please sign in to comment.