-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): add a lightweight "storybook" route so we can test c…
…omponents more easily
- Loading branch information
1 parent
7b384f0
commit 3740b5d
Showing
8 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
set_lang, | ||
sign_in, | ||
sign_out, | ||
storybook, | ||
styleguide, | ||
templates, | ||
two_factor, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from flask import render_template, request | ||
|
||
from app.main import main | ||
|
||
|
||
@main.route("/_storybook") | ||
def storybook(): | ||
component = None | ||
if "component" in request.args: | ||
component = request.args["component"] | ||
|
||
return render_template("views/storybook.html", component=component) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% extends "admin_template.html" %} | ||
{% from 'views/storybook/storybook-menu.html' import storybook_menu %} | ||
|
||
{% block page_title %} Storybook {% endblock %} | ||
|
||
{% block maincolumn_content %} | ||
<style> | ||
.container { | ||
max-width: 1536px; | ||
} | ||
</style> | ||
|
||
<div class="flex"> | ||
<!-- Left Column --> | ||
<div class="w-1/4 p-4 bg-gray-100"> | ||
<h2 class="text-lg font-bold mb-4">Components</h2> | ||
{{ storybook_menu() }} | ||
</div> | ||
|
||
<!-- Main Content Area --> | ||
<div class="w-3/4 p-4"> | ||
{% if component %} | ||
{% include 'views/storybook/' ~ component ~ '.html' %} | ||
{% else %} | ||
<p>Choose a component</p> | ||
{% endif %} | ||
</div> | ||
|
||
{% endblock %} |
78 changes: 78 additions & 0 deletions
78
app/templates/views/storybook/remaining-messages-summary.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{% from 'components/remaining-messages-summary.html' import remaining_messages_summary with context %} | ||
|
||
<h1><pre>remaining_messages_summary</pre></h1> | ||
<hr /> | ||
<h2 class="heading-medium">Below limits</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-checks"> | ||
|
||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 799, 1000, 799, "email") }} | ||
</div> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(10000, 699, 10000, 699, "sms") }} | ||
</div> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 0, 1000, 0, "email") }} | ||
</div> | ||
</div> | ||
|
||
<h2 class="heading-medium">Warning</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-warnings"> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 800, 1000, 800, "email") }} | ||
</div> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 900, 1000, 900, "email") }} | ||
</div> | ||
</div> | ||
|
||
<h2 class="heading-medium">At both limits</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-both-limits"> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 1000, 1000, 1000, "email") }} | ||
</div> | ||
</div> | ||
|
||
<h2 class="heading-medium">Mixed</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-both-limits"> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 100, 1000, 1000, "email") }} | ||
</div> | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 1000, 1000, 100, "email") }} | ||
</div> | ||
</div> | ||
|
||
<h2 class="heading-medium">Text only</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-at-limit">at limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 1000, 1000, 1000, "email", "text") }} | ||
</div> | ||
</div> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-below-limit">below limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(10000, 700, 10000, 750, "email", "text") }} | ||
</div> | ||
</div> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-near-limit">near limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 800, 1000, 900, "email", "text") }} | ||
</div> | ||
</div> | ||
|
||
<h2 class="heading-medium">Text only emoji</h2> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-at-limit">at limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 1000, 1000, 1000, "email", "emoji") }} | ||
</div> | ||
</div> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-below-limit">below limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 700, 1000, 750, "email", "emoji") }} | ||
</div> | ||
</div> | ||
<div class="grid grid-cols-2 gap-6 bg-gray p-6" data-testid="remaining-summary-text-only-near-limit">near limit | ||
<div class="mb-6 bg-white p-4"> | ||
{{ remaining_messages_summary(1000, 800, 1000, 900, "email", "emoji") }} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% from 'components/remaining-messages.html' import remaining_messages with context %} | ||
|
||
<h1 class="heading-large">remaining_messages</h1> | ||
<hr /> | ||
<h2 class="heading-medium">Below limits</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=1) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=250) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=500) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=799) }} | ||
</div> | ||
|
||
<h2 class="heading-medium">Warning</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=800) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=825) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=900) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=999) }} | ||
</div> | ||
|
||
<h2 class="heading-medium">At limit</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=1000) }} | ||
</div> | ||
|
||
|
||
<h2 class="heading-medium">Muted - Below limits</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=1, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=250, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=500, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=799, muted=true) }} | ||
</div> | ||
|
||
<h2 class="heading-medium">Muted - Warning</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=800, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=825, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=900, muted=true) }} | ||
{{ remaining_messages(header=_('emails'), total=1000, used=999, muted=true) }} | ||
</div> | ||
|
||
<h2 class="heading-medium">Muted - At limit</h2> | ||
<div class="grid grid-cols-2 gap-4" data-testid="remaining-messages-below"> | ||
{{ remaining_messages(header=_('emails'), total=1000, used=1000, muted=true) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- macro to display the component menu --> | ||
{% set components = [ | ||
{ | ||
'name': 'Remaining Messages Summary', | ||
'path': 'remaining-messages-summary' | ||
}, | ||
{ | ||
'name': 'Remaining Messages', | ||
'path': 'remaining-messages' | ||
}, | ||
] %} | ||
|
||
{% macro storybook_menu() %} | ||
<ul> | ||
<!-- loop through components --> | ||
{% for component in components %} | ||
<li><a href="{{ url_for('main.storybook', component=component.path) }}" | ||
class="text-blue-500 hover:underline">{{ component.name }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters