Skip to content

Commit

Permalink
🩹 [#3593] Un-break mail styling with local design token overrides
Browse files Browse the repository at this point in the history
Do not remove the refactored header/footer design tokens yet,
as the mail styling makes use of these.

See the Github issue for more context on why we're not structurally
fixing this yet, as we'd ideally like to use the dist/tokens.json
of organizations in mail rendering too.
  • Loading branch information
sergei-maertens committed Nov 14, 2023
1 parent 8cd62a5 commit 9c6f3b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ def apply_mapping(design_tokens: TokenContainer) -> TokenContainer:
assign(result, new, old_value, missing=dict)
tokens_to_unset.add(old)

for token in tokens_to_unset:
# don't delete utility tokens!
if not any(token.startswith(prefix) for prefix in OBSOLETE_PREFIXES):
continue
delete(result, token)
# TODO: re-enable this when #3593 is properly resolved.
# for token in tokens_to_unset:
# # don't delete utility tokens!
# if not any(token.startswith(prefix) for prefix in OBSOLETE_PREFIXES):
# continue
# delete(result, token)

return remove_empty_design_tokens(result)

Expand Down
17 changes: 14 additions & 3 deletions src/openforms/config/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def test_map_old_token_to_new(self):

self.assertEqual(
updated,
{"utrecht": {"page-footer": {"background-color": {"value": "blue"}}}},
{
"of": {"page-footer": {"bg": {"value": "blue"}}},
"utrecht": {"page-footer": {"background-color": {"value": "blue"}}},
},
)

def test_map_and_merge_old_token_to_new(self):
Expand All @@ -102,12 +105,13 @@ def test_map_and_merge_old_token_to_new(self):
self.assertEqual(
updated,
{
"of": {"page-header": {"bg": {"value": "blue"}}},
"utrecht": {
"page-header": {
"background-color": {"value": "blue"},
"color": {"value": "pink"},
}
}
},
},
)

Expand All @@ -121,7 +125,10 @@ def test_do_not_overwrite_existing_token(self):

self.assertEqual(
updated,
{"utrecht": {"page-header": {"background-color": {"value": "blue"}}}},
{
"of": {"page-header": {"bg": {"value": "red"}}},
"utrecht": {"page-header": {"background-color": {"value": "blue"}}},
},
)


Expand Down Expand Up @@ -259,6 +266,10 @@ def test_design_tokens_updated_correctly(self):
expected = {
"of": {
"text": {"font-size": {"value": "1rem"}},
"page-header": {
"bg": {"value": "#07838f"},
"fg": {"value": "#FFFFFF"},
},
},
"utrecht": {
"page-footer": {
Expand Down

0 comments on commit 9c6f3b7

Please sign in to comment.