Skip to content

Commit 00fb765

Browse files
committed
feat: Dynamically compile pages
* No need to specify every page on webpack.config * Use a template.html instead of creating one on every page
1 parent b14c0f9 commit 00fb765

File tree

17 files changed

+62
-296
lines changed

17 files changed

+62
-296
lines changed

src/client/dialog-demo-bootstrap/components/FormInput.tsx

-57
This file was deleted.

src/client/dialog-demo-bootstrap/components/SheetEditor.jsx

-95
This file was deleted.

src/client/dialog-demo-bootstrap/index.html

-18
This file was deleted.

src/client/dialog-demo-bootstrap/styles.css

-29
This file was deleted.

src/client/dialog-demo/index.js

-7
This file was deleted.

src/client/dialog-demo/components/SheetEditor.jsx src/client/pages/dialog-demo/components/SheetEditor.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import FormInput from './FormInput';
44
import SheetButton from './SheetButton';
55

66
// This is a wrapper for google.script.run that lets us use promises.
7-
import server from '../../utils/server';
7+
import server from '../../../utils/server';
88

99
const { serverFunctions } = server;
1010

@@ -19,14 +19,14 @@ const SheetEditor = () => {
1919
.catch(alert);
2020
}, []);
2121

22-
const deleteSheet = sheetIndex => {
22+
const deleteSheet = (sheetIndex) => {
2323
serverFunctions
2424
.deleteSheet(sheetIndex)
2525
.then(setNames)
2626
.catch(alert);
2727
};
2828

29-
const setActiveSheet = sheetName => {
29+
const setActiveSheet = (sheetName) => {
3030
serverFunctions
3131
.setActiveSheet(sheetName)
3232
.then(setNames)
@@ -35,7 +35,7 @@ const SheetEditor = () => {
3535

3636
// You can also use async/await notation for server calls with our server wrapper.
3737
// (This does the same thing as .then().catch() in the above handlers.)
38-
const submitNewSheet = async newSheetName => {
38+
const submitNewSheet = async (newSheetName) => {
3939
try {
4040
const response = await serverFunctions.addSheet(newSheetName);
4141
setNames(response);
@@ -58,7 +58,7 @@ const SheetEditor = () => {
5858
<FormInput submitNewSheet={submitNewSheet} />
5959
<TransitionGroup className="sheet-list">
6060
{names.length > 0 &&
61-
names.map(name => (
61+
names.map((name) => (
6262
<CSSTransition
6363
classNames="sheetNames"
6464
timeout={500}
File renamed without changes.

src/client/sidebar-about-page/components/About.jsx

-26
This file was deleted.

src/client/sidebar-about-page/index.html

-12
This file was deleted.

src/client/sidebar-about-page/index.js

-5
This file was deleted.

src/client/dialog-demo/index.html src/client/template.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html>
33
<head>
44
<base target="_top" />
5-
<!-- Add any external scripts and stylesheets here -->
65
<link
7-
href="https://fonts.googleapis.com/css2?family=Nunito"
86
rel="stylesheet"
7+
href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"
98
/>
9+
<!-- Add any external scripts and stylesheets here -->
1010
</head>
1111
<body>
1212
<section id="index">

src/server/sheets.js src/server/sheets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ export const getSheetsData = () => {
1414
});
1515
};
1616

17-
export const addSheet = sheetTitle => {
17+
export const addSheet = (sheetTitle) => {
1818
SpreadsheetApp.getActive().insertSheet(sheetTitle);
1919
return getSheetsData();
2020
};
2121

22-
export const deleteSheet = sheetIndex => {
22+
export const deleteSheet = (sheetIndex) => {
2323
const sheets = getSheets();
2424
SpreadsheetApp.getActive().deleteSheet(sheets[sheetIndex]);
2525
return getSheetsData();
2626
};
2727

28-
export const setActiveSheet = sheetName => {
28+
export const setActiveSheet = (sheetName) => {
2929
SpreadsheetApp.getActive()
3030
.getSheetByName(sheetName)
3131
.activate();

src/server/ui.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const onOpen = () => {
22
const menu = SpreadsheetApp.getUi()
33
.createMenu('My Sample React Project') // edit me!
4-
.addItem('Sheet Editor', 'openDialog')
5-
.addItem('Sheet Editor (Bootstrap)', 'openDialogBootstrap')
6-
.addItem('About me', 'openAboutSidebar');
4+
.addItem('Sheet Editor', 'openDialog');
5+
// .addItem('Sheet Editor (Bootstrap)', 'openDialogBootstrap')
6+
// .addItem('About me', 'openAboutSidebar');
77

88
menu.addToUi();
99
};
@@ -15,14 +15,14 @@ export const openDialog = () => {
1515
SpreadsheetApp.getUi().showModalDialog(html, 'Sheet Editor');
1616
};
1717

18-
export const openDialogBootstrap = () => {
19-
const html = HtmlService.createHtmlOutputFromFile('dialog-demo-bootstrap')
20-
.setWidth(600)
21-
.setHeight(600);
22-
SpreadsheetApp.getUi().showModalDialog(html, 'Sheet Editor (Bootstrap)');
23-
};
18+
// export const openDialogBootstrap = () => {
19+
// const html = HtmlService.createHtmlOutputFromFile('dialog-demo-bootstrap')
20+
// .setWidth(600)
21+
// .setHeight(600);
22+
// SpreadsheetApp.getUi().showModalDialog(html, 'Sheet Editor (Bootstrap)');
23+
// };
2424

25-
export const openAboutSidebar = () => {
26-
const html = HtmlService.createHtmlOutputFromFile('sidebar-about-page');
27-
SpreadsheetApp.getUi().showSidebar(html);
28-
};
25+
// export const openAboutSidebar = () => {
26+
// const html = HtmlService.createHtmlOutputFromFile('sidebar-about-page');
27+
// SpreadsheetApp.getUi().showSidebar(html);
28+
// };

0 commit comments

Comments
 (0)