in gemini/sample-apps/gemini-mesop-cloudrun/main.py [0:0]
def marketing_page() -> None:
"""Marketing page"""
state = me.state(State)
# Main header
vertex_gemini_header()
# Nav header
nav_menu(state.current_page)
# Main content
with me.box(style=_STYLE_MAIN_COLUMN):
me.text(text="Generate your marketing campaign", type="headline-6")
with me.box(style=me.Style(display="flex", flex_direction="row", gap=15)):
with me.box(style=me.Style(display="flex", flex_direction="column", gap=2)):
# product name
me.input(
key="marketing_product",
label="Name of your product",
value="ZomZoo",
on_input=on_input,
style=_STORY_INPUT_STYLE,
)
# category
me.text("Select your product category")
marketing_product_category_options = []
for c in state.marketing_product_categories:
marketing_product_category_options.append(
me.RadioOption(label=c.title(), value=c)
)
me.radio(
key="marketing_product_category",
on_change=on_change_marketing_radio_choice,
options=marketing_product_category_options,
value=state.marketing_product_category,
)
# audience
me.text("Select your target audience")
me.text("Target age", type="caption")
marketing_target_age_options = []
for c in state.marketing_target_audiences:
marketing_target_age_options.append(
me.RadioOption(label=c.title(), value=c)
)
me.radio(
key="marketing_target_audience",
on_change=on_change_marketing_radio_choice,
options=marketing_target_age_options,
value=state.marketing_target_audience,
)
me.text("Target location", type="caption")
marketing_target_location_options = []
for c in state.marketing_target_locations:
marketing_target_location_options.append(
me.RadioOption(label=c.title(), value=c)
)
me.radio(
key="marketing_target_location",
on_change=on_change_marketing_radio_choice,
options=marketing_target_location_options,
value=state.marketing_target_location,
)
# campaign goal
me.text("Select your marketing campaign goal")
me.text("Campaign goal", type="caption")
marketing_campaign_goal_options = []
for c in state.marketing_campaign_goals:
marketing_campaign_goal_options.append(
me.SelectOption(label=c.title(), value=c)
)
me.select(
style=me.Style(width="50vh"),
key="marketing_campaign_goal",
label="Campaign goal",
options=marketing_campaign_goal_options,
multiple=True,
value=state.marketing_campaign_selected_goals,
on_selection_change=on_selection_change_marketing_goals,
)
me.text("Brand voice", type="caption")
marketing_brand_voice_options = []
for c in state.marketing_brand_voices:
marketing_brand_voice_options.append(
me.RadioOption(label=c.title(), value=c)
)
me.radio(
key="marketing_brand_voice",
on_change=on_change_marketing_radio_choice,
options=marketing_brand_voice_options,
value=state.marketing_brand_voice,
)
me.text("Estimated budget ($)", type="caption")
marketing_budget_options = []
for c in state.marketing_budgets:
marketing_budget_options.append(
me.RadioOption(label=c.title(), value=c)
)
me.radio(
key="marketing_budget",
on_change=on_change_marketing_radio_choice,
options=marketing_budget_options,
value=state.marketing_budget,
)
with me.box(
style=me.Style(
display="flex", gap=10, padding=me.Padding(bottom=20)
)
):
me.button(
"Clear",
color="primary",
type="stroked",
on_click=on_click_clear_marketing_campaign,
)
me.button(
"Generate my campaign",
color="primary",
type="flat",
on_click=generate_marketing_campaign,
)
with me.box(style=_BOX_STYLE):
me.text("Output", style=me.Style(font_weight=500))
if state.marketing_campaign_output:
with me.box(
style=me.Style(
display="grid",
justify_content="center",
justify_items="center",
)
):
me.markdown(
key="marketing_campaign_output",
text=state.marketing_campaign_output,
style=me.Style(width="100%", margin=me.Margin(top=10)),
)