Skip to content

Commit 062885d

Browse files
Merge pull request #147 from gridaco/plugin-hosting
Plugin hosting
2 parents 0bd3be4 + 5cf2be2 commit 062885d

26 files changed

+340
-17555
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ yarn figma
5050
yarn sketch
5151

5252
# [OPTIONAL 3 & Contributors only] run plugin ui in webdev mode
53-
yarn webdev
53+
yarn web
54+
# visit http://localhost:3000/init-webdev to work on browser
5455
```
5556

5657
_soon as the subpackages are released as stable, we will remove git submodule dependency for ease of use. until then, this will be the primary repository and all the edits and PRs will be caused by this project._ - [Learn more here](https://github.com/bridgedxyz/.github/blob/main/contributing/working-with-submodules.md)

figma-lite/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "Grida lite",
3-
"id": "1009859297533324545",
2+
"name": "Grida",
3+
"id": "896445082033423994",
44
"api": "1.0.0",
55
"main": "dist/code.js",
66
"ui": "dist/ui.html"

figma/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2+
"name": "Grida (Heavy)",
3+
"id": "1009859297533324545",
24
"api": "1.0.0",
3-
"id": "896445082033423994",
4-
"name": "Grida",
55
"main": "dist/code.js",
66
"ui": "dist/ui.html"
77
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"pull:all": "git submodule update --init --recursive",
3434
"figma": "yarn workspace figma run webpack:watch",
3535
"figma-lite": "yarn workspace figma-lite run build:dev && yarn web",
36+
"build:figma:prod": "yarn workspace figma-lite run build",
3637
"sketch": "yarn workspace sketch run render",
3738
"web": "yarn workspace web run dev",
38-
"webdev": "yarn workspace webdev run start",
3939
"xd": "yarn workspace xd run build",
4040
"test": "cd figma && yarn build"
4141
},

web/README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1+
# Grida Assistant on Web (Webdev)
2+
3+
> this project is for inspecting and developing the ui package, and running the tests.
4+
5+
![grida assistant running on chrome as webdev](../docs/images/assistant-webdev-example.png)
26

37
## Getting Started
48

@@ -17,18 +21,3 @@ You can start editing the page by modifying `pages/index.js`. The page auto-upda
1721
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
1822

1923
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20-
21-
## Learn More
22-
23-
To learn more about Next.js, take a look at the following resources:
24-
25-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27-
28-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29-
30-
## Deploy on Vercel
31-
32-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33-
34-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

web/lib/gtag.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
2+
3+
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
4+
export const pageview = (url) => {
5+
window.gtag("config", GA_TRACKING_ID, {
6+
page_path: url,
7+
});
8+
};
9+
10+
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
11+
export const event = ({ action, category, label, value }) => {
12+
window.gtag("event", action, {
13+
event_category: category,
14+
event_label: label,
15+
value: value,
16+
});
17+
};

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7-
"build": "next build",
7+
"build": "next build && next export",
88
"start": "next start"
99
},
1010
"dependencies": {

web/pages/_app.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
import React from "react";
1+
import React, { useEffect } from "react";
22
import type { AppProps } from "next/app";
3+
import { useRouter } from "next/router";
4+
import * as gtag from "../lib/gtag";
35

46
function WebApp({ Component, pageProps }: AppProps) {
7+
// region GA
8+
const router = useRouter();
9+
useEffect(() => {
10+
const handleRouteChange = (url) => {
11+
gtag.pageview(url);
12+
};
13+
router.events.on("routeChangeComplete", handleRouteChange);
14+
return () => {
15+
router.events.off("routeChangeComplete", handleRouteChange);
16+
};
17+
}, [router.events]);
18+
// endregion GA
19+
520
return <Component {...pageProps} />;
621
}
722
export default WebApp;

web/pages/_document.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Document, { Html, Head, Main, NextScript } from "next/document";
2+
import { GA_TRACKING_ID } from "../lib/gtag";
3+
4+
export default class HeadDocument extends Document {
5+
render() {
6+
return (
7+
<Html>
8+
<Head>
9+
{/* Global Site Tag (gtag.js) - Google Analytics */}
10+
<script
11+
async
12+
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
13+
/>
14+
<script
15+
dangerouslySetInnerHTML={{
16+
__html: `
17+
window.dataLayer = window.dataLayer || [];
18+
function gtag(){dataLayer.push(arguments);}
19+
gtag('js', new Date());
20+
gtag('config', '${GA_TRACKING_ID}', {
21+
page_path: window.location.pathname,
22+
});
23+
`,
24+
}}
25+
/>
26+
</Head>
27+
<body>
28+
<Main />
29+
<NextScript />
30+
</body>
31+
</Html>
32+
);
33+
}
34+
}

webdev/.env.defaults

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)