Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nofos/bloom_nofos/static/theme-orientation-portrait.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@ section.before-you-begin--era {
font-size: 8.5pt;
}

.section--content--right-col.section--content--right-col--dense
.callout-box--questions
.callout-box--contents
p,
.section--content--right-col.section--content--right-col--dense
.callout-box--contents {
font-size: 8pt;
}

.section--content--right-col .callout-box--contents p {
padding-right: 5px;
}
Expand Down
2 changes: 1 addition & 1 deletion nofos/nofos/templates/nofos/nofo_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ <h2 id="{{ section.html_id }}">
{% if nofo_theme_orientation == 'portrait' %}
{% with callouts=section|get_floating_callout_boxes_from_section %}
{% if callouts %}
<div class="section--content--right-col{% if callouts|get_combined_wordcount_for_subsections > 99 %} section--content--right-col--tiny{% elif callouts|get_combined_wordcount_for_subsections > 79 %} section--content--right-col--smaller{% endif %}">
<div class="section--content--right-col {{ callouts|get_floating_callout_size_classes }}">
{% for subsection in callouts %}
{% include "includes/callout_box.html" with subsection=subsection nofo=nofo break_colons=True only %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ def get_combined_wordcount_for_subsections(subsections):
word_count += len(subsection.body.split())

return word_count


@register.filter()
def get_floating_callout_size_classes(subsections):
word_count = get_combined_wordcount_for_subsections(subsections)

if word_count > 149:
return "section--content--right-col--tiny section--content--right-col--dense"
if word_count > 99:
return "section--content--right-col--tiny"
if word_count > 79:
return "section--content--right-col--smaller"

return ""
53 changes: 53 additions & 0 deletions nofos/nofos/tests_nofos/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from nofos.models import Nofo, Section, Subsection
from nofos.templatetags.add_classes_to_links import add_classes_to_broken_links
from nofos.templatetags.get_floating_callout_boxes_from_section import (
get_floating_callout_size_classes,
)
from nofos.templatetags.replace_unicode_with_icon import replace_unicode_with_icon
from nofos.templatetags.safe_br import safe_br
from nofos.templatetags.utils import (
Expand Down Expand Up @@ -37,6 +40,56 @@ def __init__(self, name):
self.name = name


class GetFloatingCalloutSizeClassesTests(TestCase):
@staticmethod
def callouts_with_word_count(word_count):
return [Subsection(body="word " * word_count)]

@staticmethod
def callouts_with_word_counts(*word_counts):
return [Subsection(body="word " * count) for count in word_counts]

def test_default_size_through_79_words(self):
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(79)),
"",
)

def test_smaller_size_from_80_through_99_words(self):
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(80)),
"section--content--right-col--smaller",
)
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(99)),
"section--content--right-col--smaller",
)

def test_tiny_size_from_100_through_149_words(self):
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(100)),
"section--content--right-col--tiny",
)
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(149)),
"section--content--right-col--tiny",
)

def test_dense_size_at_150_words(self):
self.assertEqual(
get_floating_callout_size_classes(self.callouts_with_word_count(150)),
"section--content--right-col--tiny section--content--right-col--dense",
)

def test_dense_size_combines_all_floating_callouts(self):
self.assertEqual(
get_floating_callout_size_classes(
self.callouts_with_word_counts(6, 23, 124)
),
"section--content--right-col--tiny section--content--right-col--dense",
)


class ReplaceUnicodeWithIconTests(TestCase):
def render_cell(self, cell_html):
result = replace_unicode_with_icon(
Expand Down
Loading