Skip to content

Instantly share code, notes, and snippets.

@Xiryl
Created Jan 5, 2022
Embed
What would you like to do?
function createHomeCard() {
const imgLogoUri = "http://your.home.page.image.link";
const imgLogo = CardService.newImage()
.setImageUrl(imgLogoUri)
.setAltText("Digit-Atoms");
const footer = CardService.newFixedFooter().setPrimaryButton(
CardService.newTextButton()
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setText("by company.xyz")
.setBackgroundColor("#10141F")
.setOpenLink(
CardService.newOpenLink().setUrl("https://cool.company.xyz")
)
);
const cardHeader = CardService.newCardHeader()
.setTitle(`Hi!`)
.setSubtitle("I'm a header.")
.setImageStyle(CardService.ImageStyle.CIRCLE)
.setImageUrl("http://your.icon.link");
const section1 = CardService.newCardSection().addWidget(imgLogo);
const txtInsertId =
CardService.newTextParagraph().setText("<b>Bold text</b><br/> -Can you read this?");
const textInput = CardService.newTextInput()
.setFieldName("txt_input_id_to_process")
.setTitle("Write something here...");
const ico = CardService.newIconImage().setIconUrl(
"ico link"
);
const actionBtnDoWork =
CardService.newAction().setFunctionName("onDoWorkBtn");
const multilineDecoratedText = CardService.newDecoratedText()
.setText("UPLOAD")
.setTopLabel("EXECUTE COMMAND")
.setWrapText(true)
.setOnClickAction(actionBtnDoWork)
.setStartIcon(ico);
const section2 = CardService.newCardSection()
.addWidget(txtInsertId)
.addWidget(textInput)
.addWidget(multilineDecoratedText);
const actionCaricaModuli = CardService.newAction().setFunctionName(
"onBtnCaricaModuliClick"
);
const ico1 = CardService.newIconImage().setIconUrl(
"http://your.icon.link"
);
const multilineDecoratedText1 = CardService.newDecoratedText()
.setText("DOWNLOAD")
.setTopLabel("EXECUTE SOMETHING")
.setWrapText(true)
.setOnClickAction(actionCaricaModuli)
.setStartIcon(ico1);
const section3 = CardService.newCardSection()
//.addWidget(textParagraph1)
.addWidget(multilineDecoratedText1);
const actionBtnSettings =
CardService.newAction().setFunctionName("createSettingsCard");
const icoBtnSettings = CardService.newIconImage().setIconUrl(
"http://your.icon.link"
);
const btnSettings = CardService.newDecoratedText()
.setText("Impostazioni")
.setTopLabel("Script settings")
.setWrapText(true)
.setOnClickAction(actionBtnSettings)
.setStartIcon(icoBtnSettings);
const section4 = CardService.newCardSection()
//.addWidget(textParagraph1)
.addWidget(btnSettings);
const card = CardService.newCardBuilder()
.setHeader(cardHeader)
.addSection(section1)
.addSection(section2)
.addSection(section3)
.addSection(section4)
.setFixedFooter(footer);
return card.build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment