-
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.
Add option for rtl template content (#1968)
* feat(rtl template): refactor template content into a macro that will handle the RTL switch * chore: regen css/js * feat(rtl template content): add switch to template form; pass switch to backend on save; pass switch to backend on create; * chore: formatting * chore: add translations * chore: update temporary translation * chore: update temporary translatio again * chore: 😱 * chore: formatting * a11y(rtl): update translations, add hint for users of assistive tech * chore: fix form label - will be overridden by .html * feat(highlighttags): make this plugin aware of RTL attribute * feat(templateContent.js): only run the code when the checkbox is present * fix(rtl): include text direction in preview data * chore(rtl): update tests * chore: formatting * fix(highlighttags): ensure checkbox exists before setting text direction * feat(rtl): wrap in feature flag * chore: update label name to match designs * chore: formatting * feat(rtl): remove `use_styled_checkbox` switch; implement fieldset; update design to match figma * chore: re-gen css * chore: add missing translation * fix(highlightTags): only set `dir` attribute on template content * chore: read FF_RTL from environment * chore: bump utils * chore: bump utils * fix(rtl): remember rtl setting when previewing/editing * feat(checkbox): add testid param * test(rtl): add test-ids * test(rtl): add ui tests * chore: re gen poetry.lock * chore: remove duplicated button * chore(ci): add text-direction tests to CI suite
- Loading branch information
1 parent
4a17a93
commit 1d8c95d
Showing
21 changed files
with
194 additions
and
47 deletions.
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
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,20 @@ | ||
/* | ||
* This module enhances the template content text area with a switch to enable right-to-left text direction. | ||
*/ | ||
(function () { | ||
const checkbox = document.getElementById("text_direction_rtl"); | ||
const content = document.getElementById("template_content"); | ||
|
||
// update the dir attribute when checkbox is clicked | ||
if (checkbox) { | ||
checkbox.addEventListener("change", function () { | ||
content.dir = this.checked ? "rtl" : "ltr"; | ||
content.closest(".textbox-highlight-wrapper").dir = content.dir; | ||
}); | ||
|
||
// on page load, if the checkbox is checked, set the dir attribute | ||
if (checkbox.checked) { | ||
content.dir = "rtl"; | ||
} | ||
} | ||
})(); |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% from "components/checkbox.html" import checkbox, checkbox_input %} | ||
{% from "components/textbox.html" import textbox %} | ||
|
||
{% macro template_content(content_field, checkbox_field) %} | ||
<!-- TODO: remove `use_styled_checkbox` and this if statement once we decide on the UI element to use here --> | ||
|
||
<fieldset class="contain-floats w-full" role="radiogroup"> | ||
<legend> | ||
<span>{{ _('Email message') }}</span> | ||
</legend> | ||
{% if config["FF_RTL"] %} | ||
<div class="p-2 bg-gray-300 flex items-center"> | ||
{{ checkbox_input(checkbox_field.id, checkbox_field.name, checkbox_field.data, class="h-8 w-8 mr-2", testid="template-rtl") }} | ||
<label class="pb-0 inline-block text-small" for="text_direction_rtl">{{ _('Display') }}<span class="sr-only"> {{ _('email content') }} </span> {{ _('right to left') }}</label> | ||
</div> | ||
{% endif %} | ||
|
||
{{ textbox(content_field, highlight_tags=True, width='w-full', rows=8, testid="template-content", label_class="sr-only" ) }} | ||
</fieldset> | ||
|
||
{% 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.