def page(page_id): page_id = int(page_id) content = f"this is page {page_id}" return cccp.render( [ t.p(content), t.button( f"replace with page {page_id-1}", onClick=cccp.replaceHtml( f"http://127.0.0.1:9999/page/{page_id-1}", "pageContent" ), ), t.button( f"replace with page {page_id+1}", onClick=cccp.replaceHtml( f"http://127.0.0.1:9999/page/{page_id+1}", "pageContent" ), ), t.button( "append page", onClick=cccp.appendHtml( f"http://127.0.0.1:9999/append-page", "pageContent" ), ), t.button( "prepend page", onClick=cccp.prependHtml( f"http://127.0.0.1:9999/prepend-page", "pageContent" ), ), ] )
def home(): return t.html( [ t.head( [ cccp.REQUIRED, cccp.BOOTSTRAP, cccp.CreateReplaceHtmlFunc(), cccp.CreateAppendHtmlFunc(), cccp.CreatePrependHtmlFunc(), ] ), t.body( [ t.h1("Hello, CCCP!"), t.div(id="pageContent"), t.button( "go to blog", onClick=cccp.replaceHtml( "http://127.0.0.1:9999/page/1", "pageContent" ), ), ] ), ] ).render()
def more_buttons(): letter = flask.request.args["letter"] return t.div(children=[ t.button( cls=["is-danger"], onclick=cccp.appendHtml("/shine/", "shine_" + letter), children=["Add some more shine"], ), t.button( cls=["is-success"], onclick=[ cccp.replaceHtml("/nothing/", "shine_" + letter), cccp.replaceHtml("/one_button/?letter=" + letter, "butt_" + letter), ], children=["Remove everything"], ), ]).render()
def one_button(): letter = flask.request.args["letter"] return t.div(children=[ t.button( cls=["is-warning"], onclick=[ cccp.replaceHtml("/more_buttons/?letter=" + letter, "butt_" + letter), cccp.appendHtml("/shine/", "shine_" + letter) ], children=["Add some shine"], ), ], ).render()
def column_jack(letter): return t.column( id="coll_" + letter, cls=["is-primary", "has-text-centered"], children=[ t.div(id="shine_" + letter, ), t.div( id="butt_" + letter, children=[ t.button( cls=["is-warning"], onclick=[ cccp.replaceHtml("/more_buttons/?letter=" + letter, "butt_" + letter), cccp.appendHtml("/shine/", "shine_" + letter), ], children=["Add some shine"], ), ], ) ])