From b541485c6ca914d01f09cb62a82dbb3ef6ed6ece Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 13 Oct 2020 12:57:44 -0700 Subject: [PATCH] Revamp the Home page of our app to start looking like what we want This gets rid of the original placeholder blocks which I had gotten from a tutorial and replaces it with placeholders that look more like what we are going to want, (a list of hunts and a button to create a new hunt). While doing this, we provide some utility functions to create blocks to reduce the amount of boilerplate we need while constructing these things. --- turbot/views.py | 60 ++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/turbot/views.py b/turbot/views.py index 95b7b08..122d92c 100644 --- a/turbot/views.py +++ b/turbot/views.py @@ -1,3 +1,33 @@ +def text(body): + return { + "text": { + "type": "mrkdwn", + "text": body + } + } + +def section(block): + return { + "type": "section", + **block + } + +def actions(*elements): + return { + "type": "actions", + "elements": list(elements) + } + +def button(label): + return { + "type": "button", + "text": { + "type": "plain_text", + "text": label, + "emoji": True + } + } + def home(user_id, body): """Returns a view to be published as the turbot home tab for user_id @@ -8,33 +38,7 @@ def home(user_id, body): return { "type": "home", "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "A simple stack of blocks for the simple sample Block Kit Home tab." - } - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Action A", - "emoji": True - } - }, - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Action B", - "emoji": True - } - } - ] - } + section(text("This is (or soon will be) a list of available puzzle hunts)")), + actions(button("New hunt")) ] } -- 2.43.0