From 2e94a78c5597b4e1324448bfc8b9d33113a8b6ab Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Fri, 28 May 2021 13:05:14 -0700 Subject: [PATCH 1/2] Create a pricing page template with pricing card components --- examples/pricing_page.py | 28 ++++ splashgen/components/__init__.py | 1 + splashgen/components/pricing_card.py | 23 +++ .../jinja_templates/pricing_page.html.jinja | 137 ++++++++++++++++++ splashgen/templates/__init__.py | 1 + splashgen/templates/pricing_page.py | 50 +++++++ 6 files changed, 240 insertions(+) create mode 100644 examples/pricing_page.py create mode 100644 splashgen/components/pricing_card.py create mode 100644 splashgen/jinja_templates/pricing_page.html.jinja create mode 100644 splashgen/templates/pricing_page.py diff --git a/examples/pricing_page.py b/examples/pricing_page.py new file mode 100644 index 0000000..3e1250d --- /dev/null +++ b/examples/pricing_page.py @@ -0,0 +1,28 @@ +from splashgen import launch +from splashgen.components import PricingCard, CTAButton +from splashgen.templates import PricingPage + +site = PricingPage(title="Splashgen - Splash Pages Built In Python", + theme="dark") +site.headline = "Get started immediately!" +site.subtext = """ +Splashgen's plans scale for any organization—from startups to Fortune 500s +""" + +freeCard = PricingCard(tier="Free", price_description="Free forever.") +freeCard.call_to_action = CTAButton( + "https://github.com/true3dco/splashgen", "Get Started") +freeCard.feature_checklist = ["Custom Code", "Unlimited pages", "Continuous deployment"] + +teamsCard = PricingCard(tier="Teams", price_description="8$/month.") +teamsCard.call_to_action = CTAButton( + "https://github.com/true3dco/splashgen", "Sign up") +teamsCard.feature_checklist = [ + "All of the features of free", + "Analytics", + "Custom domains",] + +site.pricing_cards = [freeCard, teamsCard] + + +launch(site) diff --git a/splashgen/components/__init__.py b/splashgen/components/__init__.py index 59f41c1..7b17682 100644 --- a/splashgen/components/__init__.py +++ b/splashgen/components/__init__.py @@ -2,3 +2,4 @@ from .cta_button_secondary import CTAButtonSecondary from .form import Form, TextInput, EmailInput, SelectInput from .link import Link +from .pricing_card import PricingCard diff --git a/splashgen/components/pricing_card.py b/splashgen/components/pricing_card.py new file mode 100644 index 0000000..e6d73e6 --- /dev/null +++ b/splashgen/components/pricing_card.py @@ -0,0 +1,23 @@ +from splashgen import Component + + +class PricingCard(Component): + def __init__(self, tier: str = "<>", price_description: str = "<>", call_to_action: Component = None) -> None: + self.tier = tier + self.price_description = price_description + self.call_to_action: Component = call_to_action + self.feature_checklist: list[str] = None + + def render(self) -> str: + return f""" + +
+

{self.tier}

+

{self.price_description}

+ {self.call_to_action} +
+
+ {self.feature_checklist} +
+ + """ diff --git a/splashgen/jinja_templates/pricing_page.html.jinja b/splashgen/jinja_templates/pricing_page.html.jinja new file mode 100644 index 0000000..20cc97b --- /dev/null +++ b/splashgen/jinja_templates/pricing_page.html.jinja @@ -0,0 +1,137 @@ + + + + + + + {{ title }} + {% for favicon in favicons %} + + {% endfor %} + + {% if meta %} + + + + + + {% if meta.canonical_url %} + + + {% endif %} + + + + + + + {% if meta.image %} + + + {% endif %} {% endif %} + + + + {% if enable_splashgen_analytics %} + + + {% endif %} + + +
+ {# Nav bar #} +
+ {% if logo %} + + {%endif%} + +
+

+ {{ headline }} +

+
+

+ {{ subtext }} +

+
+ + {% for pricing_card in pricing_cards %} +
+
+

{{pricing_card.tier}}

+

{{pricing_card.description}}

+ {{pricing_card.call_to_action}} +
+
+ {% for feature in pricing_card.feature_checklist %} +

{{feature}}

+ {% endfor %} +
+
+ {% endfor %} + +
+ + diff --git a/splashgen/templates/__init__.py b/splashgen/templates/__init__.py index 823fdac..628578f 100644 --- a/splashgen/templates/__init__.py +++ b/splashgen/templates/__init__.py @@ -1,2 +1,3 @@ from .SplashSite import SplashSite from .SplashSite2 import SplashSite2 +from .pricing_page import PricingPage \ No newline at end of file diff --git a/splashgen/templates/pricing_page.py b/splashgen/templates/pricing_page.py new file mode 100644 index 0000000..fd35552 --- /dev/null +++ b/splashgen/templates/pricing_page.py @@ -0,0 +1,50 @@ +from splashgen import Component, MetaTags + +from os import path + +_ASSET_DIR = path.join(path.dirname(__file__), '../assets') + + +class PricingPage(Component): + meta: MetaTags + + headline: str + subtext: str + + # Only supports 2 pricing cards for now + pricing_cards = None# : list[PricingCard] + + + def __init__(self, title: str = "Pricing Page 2", logo: str = None, meta: MetaTags = None, theme: str = "light") -> str: + super().__init__() + self.title = title + if not logo: + logo = path.join(_ASSET_DIR, "logo-default.png") + + self.logo = logo + self.meta = meta + if theme not in ["light", "dark"]: + raise ValueError( + "Invalid theme option. Please specify 'light' or 'dark'") + self.theme = theme + self.favicon_img = self.logo + + # Splash site 2 fields + self.headline = "Fill out your headline here by assigning to `headline`" + self.subtext = "Fill out subtext by assigning to `subtext`" + + self.pricingCards = None + + self.enable_splashgen_analytics = True + + + def render(self) -> str: + logo_url = self.write_asset_to_build(self.logo) + + favicons = self._gen_favicons() + return self.into_template("pricing_page.html.jinja", extras={ + "logo": logo_url, + "favicons": favicons, + }) + + From aa1212e212e256ed7155e35082f529e173a7b588 Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Fri, 28 May 2021 13:18:14 -0700 Subject: [PATCH 2/2] Inherit from template --- splashgen/templates/pricing_page.py | 45 ++++------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/splashgen/templates/pricing_page.py b/splashgen/templates/pricing_page.py index fd35552..162df51 100644 --- a/splashgen/templates/pricing_page.py +++ b/splashgen/templates/pricing_page.py @@ -1,50 +1,17 @@ -from splashgen import Component, MetaTags +from .base import Template -from os import path -_ASSET_DIR = path.join(path.dirname(__file__), '../assets') - - -class PricingPage(Component): - meta: MetaTags +class PricingPage(Template): headline: str subtext: str - - # Only supports 2 pricing cards for now - pricing_cards = None# : list[PricingCard] + pricing_cards = None # : list[PricingCard] + template = "pricing_page.html.jinja" - def __init__(self, title: str = "Pricing Page 2", logo: str = None, meta: MetaTags = None, theme: str = "light") -> str: - super().__init__() - self.title = title - if not logo: - logo = path.join(_ASSET_DIR, "logo-default.png") - - self.logo = logo - self.meta = meta - if theme not in ["light", "dark"]: - raise ValueError( - "Invalid theme option. Please specify 'light' or 'dark'") - self.theme = theme - self.favicon_img = self.logo + def __init__(self, **kwargs) -> str: + super().__init__(**kwargs) - # Splash site 2 fields self.headline = "Fill out your headline here by assigning to `headline`" self.subtext = "Fill out subtext by assigning to `subtext`" - self.pricingCards = None - - self.enable_splashgen_analytics = True - - - def render(self) -> str: - logo_url = self.write_asset_to_build(self.logo) - - favicons = self._gen_favicons() - return self.into_template("pricing_page.html.jinja", extras={ - "logo": logo_url, - "favicons": favicons, - }) - -