diff --git a/examples/docs/widget/PR/Router.jsx b/examples/docs/widget/PR/Router.jsx
new file mode 100644
index 0000000..0da70f9
--- /dev/null
+++ b/examples/docs/widget/PR/Router.jsx
@@ -0,0 +1,73 @@
+const { href } = VM.require("devs.near/widget/lib.url") || {
+ href: () => "/",
+};
+
+const Content = styled.div`
+ width: 100%;
+ height: 100%;
+`;
+
+function findDefaultRoute(routesObject) {
+ const routeKey =
+ routesObject &&
+ Object.keys(routesObject).find((key) => {
+ const route = routesObject[key];
+ return route.default === true;
+ });
+
+ if (routeKey) {
+ return routesObject[routeKey];
+ } else {
+ return null;
+ }
+}
+
+function Router({ config, ...passProps }) {
+ const { routes, PageNotFound, debug, param } = config;
+
+ if (!param) param = "page";
+
+ const defaultRoute =
+ findDefaultRoute(routes) ??
+ (routes && Object.keys(routes).length && routes[Object.keys(routes)[0]]);
+ const activeRoute =
+ (routes &&
+ routes.hasOwnProperty(passProps[param]) &&
+ routes[passProps[param]]) ||
+ defaultRoute;
+
+ if (!PageNotFound) PageNotFound = () =>
404 Not Found
;
+
+ if (!activeRoute) {
+ // Handle 404 or default case for unknown routes
+ return ;
+ }
+
+ // An improvement may be to "lazy load", e.g. load all widgets at once and only "display" the active one
+ // potentionally add a "lazy: true" prop to the route object
+
+ // for each route, if lazy, load the widget and store it in a map
+ // set display for the active route
+
+ // we may want to convert this to a widget for that purpose, to manage state?
+ if (debug) {
+ return (
+
+
{JSON.stringify(activeRoute, null, 2)}
+
{JSON.stringify(props, null, 2)}
+
+ );
+ } else {
+ return (
+
+ }
+ />
+
+ );
+ }
+}
+
+return { Router };
\ No newline at end of file
diff --git a/examples/docs/widget/PR/view.jsx b/examples/docs/widget/PR/view.jsx
index eacc269..dc68efb 100644
--- a/examples/docs/widget/PR/view.jsx
+++ b/examples/docs/widget/PR/view.jsx
@@ -1,4 +1,4 @@
-const { Router } = VM.require("devs.near/widget/Router") || {
+const { Router } = VM.require("${config_account}/widget/PR.Router") || {
Router: () => <>>,
};
diff --git a/examples/docs/widget/components/Header.jsx b/examples/docs/widget/components/Header.jsx
index 663d91e..ec2703b 100644
--- a/examples/docs/widget/components/Header.jsx
+++ b/examples/docs/widget/components/Header.jsx
@@ -1,5 +1,5 @@
return (
-
everything
+ bos-workspace
);
diff --git a/examples/docs/widget/components/Sidebar.jsx b/examples/docs/widget/components/Sidebar.jsx
new file mode 100644
index 0000000..7e5507b
--- /dev/null
+++ b/examples/docs/widget/components/Sidebar.jsx
@@ -0,0 +1,20 @@
+const pages = {
+ home: {
+ path: "${config_account}/widget/home",
+ blockHeight: "final",
+ init: {
+ name: "Home",
+ },
+ default: true,
+ },
+};
+
+return (
+
+ {Object.keys(pages).map((pageKey) => (
+
+ {pages[pageKey].init.name}
+
+ ))}
+
+);
diff --git a/examples/docs/widget/home.jsx b/examples/docs/widget/home.jsx
index 09e532e..493ca51 100644
--- a/examples/docs/widget/home.jsx
+++ b/examples/docs/widget/home.jsx
@@ -27,8 +27,41 @@ const Button = styled.button`
}
`;
+const BosWorkspaceInfo = styled.p`
+ text-align: center;
+ font-size: 1.1rem;
+ color: #444;
+ margin: 2rem;
+`;
+
+const CodeSnippet = styled.div`
+ background-color: #f5f5f5;
+ padding: 0.5rem 1rem;
+ border-radius: 5px;
+ font-size: 0.9rem;
+`;
+
return (
bos-workspace
+
+ bos-workspace is a comprehensive toolset designed to simplify the
+ development and deployment of NEAR components and applications. With
+ support for hot reload, TypeScript, and multiple app management, it caters
+ to developers looking for an efficient and scalable developer environment.
+
+ Quickstart
+
+ To begin, either use this template repository or install bos-workspace
+ within an existing project:
+
+ yarn add -D bos-workspace
+
+ Then, you can clone widgets from an existing account via:
+
+ bos-workspace clone [accountId]
+
+ Or ensure the proper workspace structure and usage.
+
);
diff --git a/examples/docs/widget/index.jsx b/examples/docs/widget/index.jsx
index d462f50..d87d69c 100644
--- a/examples/docs/widget/index.jsx
+++ b/examples/docs/widget/index.jsx
@@ -9,7 +9,7 @@ const config = {
layout: {
src: "${config_account}/widget/layout",
props: {
- variant: "standard",
+ variant: "sidebar",
},
},
blocks: {
@@ -22,6 +22,12 @@ const config = {
/>
),
Footer: () => <>>, // customize your footer
+ Sidebar: () => (
+
+ ),
},
router: {
param: "page",
@@ -39,11 +45,30 @@ const config = {
};
const Root = styled.div`
+ .sidebar {
+ min-width: 250px;
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+
+ .button {
+ width: 100%;
+ padding: 10px;
+ border: "none";
+ background-color: "#007bff";
+ color: "#fff";
+ border-radius: "5px";
+ cursor: "pointer";
+ }
// you can override classnames here
`;
return (
-
+
);