Skip to content

Commit

Permalink
feat: add form macro templates
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Sep 25, 2024
1 parent 9c6092e commit d3ba0de
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
56 changes: 56 additions & 0 deletions mkdocs_nype/macros_includes/contact_form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{#-
!!!NOTE: This macro is included in all contact.md / offer.md / free-offer.md files. Edit with caution.
-#}

{%- include 'setup_vars.md' -%}

{#- nype_config is the reference to page.meta.nype_config, so modify this to pass data to the theme templates. -#}
{%- set _ = nype_config.required_js_keys.update({ 'contact_form_action_hex': {} }) -%}

{%- set email_label = "E-mail:" if nype_config.js.contact_form_allow_personal_emails else "Company E-mail:" -%}
{%- set email_placeholder = "Input your e-mail" if nype_config.js.contact_form_allow_personal_emails else "Input your company e-mail" -%}

<div class="nype-form-wrapper">
<form class="nype-form" method="POST">
<label for="fullname">Full Name:</label>
<input
class="md-input"
id="fullname"
name="fullname"
placeholder="Input your name"
required
type="text"
>
<label for="companyname">Company Name:</label>
<input
class="md-input"
id="companyname"
name="companyname"
placeholder="Input your company name"
required
type="text"
>
<label for="email">{{- email_label -}}</label>
<input
autocomplete="email"
class="md-input"
id="email"
name="email"
placeholder="{{- email_placeholder -}}"
required
type="email"
>
<label for="message">What can we do for you?:</label>
<textarea
class="md-input"
id="message"
name="message"
placeholder="Input your message"
required
></textarea>
<button
class="md-button md-button--primary"
type="submit"
>Submit</button>
</form>
</div>
11 changes: 4 additions & 7 deletions mkdocs_nype/macros_includes/discord_invite.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{%- if not nype_config -%}
{%- set nype_config = {} -%}
{%- endif -%}

{%- if not nype_config.js -%}
{%- set _ = nype_config.update({ 'js': {} }) -%}
{%- endif -%}
{%- include 'setup_vars.md' -%}

{%- set discord_invite = nype_config.js.discord_invite or "" -%}
{%- set discord_header = nype_config.discord_header or "" -%}
{%- set discord_logo = nype_config.discord_logo or "" -%}
{%- set discord_title = nype_config.discord_title or "" -%}
{%- set discord_button = nype_config.discord_button or "Join" -%}

{#- nype_config is the reference to page.meta.nype_config, so modify this to pass data to the theme templates. -#}
{%- set _ = nype_config.required_js_keys.update({ 'discord_invite': {} }) -%}

<div class="nype-discord-invite not-loaded" markdown>

<p class="nype-discord-invite-loading">Loading...</p>
Expand Down
10 changes: 10 additions & 0 deletions mkdocs_nype/macros_includes/hidden_email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{#-
!!!NOTE: This macro is included in all contact.md / offer.md / free-offer.md files. Edit with caution.
-#}

{%- include 'setup_vars.md' -%}

{#- nype_config is the reference to page.meta.nype_config, so modify this to pass data to the theme templates. -#}
{%- set _ = nype_config.required_js_keys.update({ 'contact_form_email_hex': {} }) -%}

{#- Whitespace #} <span class="nype-code-button nype-show-email">`Show e-mail`</span> {# Whitespace -#}
15 changes: 15 additions & 0 deletions mkdocs_nype/macros_includes/setup_vars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{%- if page.meta and not page.meta.nype_config -%}
{%- set _ = page.meta.update({ 'nype_config': {} }) -%}
{%- endif -%}

{%- if not nype_config -%}
{%- set nype_config = page.meta.nype_config -%}
{%- endif -%}

{%- if not nype_config.js -%}
{%- set _ = nype_config.update({ 'js': {} }) -%}
{%- endif -%}

{%- if not nype_config.required_js_keys -%}
{%- set _ = nype_config.update({ 'required_js_keys': {} }) -%}
{%- endif -%}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "hatchling.build"

[project]
name = "mkdocs-nype"
version = "0.16.5"
version = "0.16.6"
description = "MkDocs theme for Nype MkDocs projects, extends the Material for MkDocs theme"
authors = [
{ name = "Kamil Krzyśków", email = "kk@npe.cm" }
Expand Down

0 comments on commit d3ba0de

Please sign in to comment.