Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RTL using tailwindcss #305

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
fde3222
Fixed account links rtl issue
M97Chahboun Mar 5, 2024
e079462
Fixed admin title and icons rtl issue
M97Chahboun Mar 5, 2024
707ffc3
Fixed theme switcher icons issues
M97Chahboun Mar 5, 2024
c62885c
Fixed nav-sidebar border and open sidebar icon rtl issues
M97Chahboun Mar 5, 2024
4b6ca1e
Added required border-l
M97Chahboun Mar 5, 2024
68e3c71
Used tailwind for handled rtl cases instead of django tag
M97Chahboun Mar 5, 2024
8b5715d
Improved admin title
M97Chahboun Mar 5, 2024
04abf7b
minor fix on checkbox fields
M97Chahboun Mar 5, 2024
37647c8
removed absoulte from datetimeshortcuts
M97Chahboun Mar 5, 2024
ca66e5a
handled rtl on datetimeshortcuts
M97Chahboun Mar 5, 2024
654214a
Handled border of datetimeshortcuts on rtl
M97Chahboun Mar 5, 2024
d76ac9d
Handled submit line rtl
M97Chahboun Mar 5, 2024
12ea990
Handled sidebar position when opened on rtl
M97Chahboun Mar 5, 2024
6178ffe
Handled submit line order on rtl
M97Chahboun Mar 5, 2024
7a19fb5
improved side-bar icon margin rtl
M97Chahboun Mar 5, 2024
4c578c3
more imrpovements on sidebar icon
M97Chahboun Mar 5, 2024
69d392d
Changed sidebar icon
M97Chahboun Mar 5, 2024
45d56fe
improved sidebar icon
M97Chahboun Mar 5, 2024
728675e
fixed theme and accounts linkes popup align
M97Chahboun Mar 5, 2024
6c17298
hide sidebar icon on md and lg
M97Chahboun Mar 5, 2024
825b32b
Improved sidebar display on screens cases
M97Chahboun Mar 5, 2024
7cc8041
Fixed menu icon for mobile rtl issue
M97Chahboun Mar 5, 2024
8e8430a
Added language switcher to admin navbar
M97Chahboun Mar 5, 2024
20b543f
Use translate for languages
M97Chahboun Mar 5, 2024
de7cccd
updated icons order
M97Chahboun Mar 5, 2024
31789be
Handled language switcher display based on urls
M97Chahboun Mar 5, 2024
ca32fe0
Handled action icon rtl
M97Chahboun Mar 5, 2024
ab328ce
Revert "Added language switcher to admin navbar"
M97Chahboun Mar 6, 2024
7e5cd9a
improved boolean field rtl
M97Chahboun Mar 6, 2024
5bfce22
Handled filter and search icons rtl
M97Chahboun Mar 6, 2024
219f381
Fixed trailing-whitespace issue
M97Chahboun Mar 6, 2024
c6c2ad8
handled change lit RTL
M97Chahboun Mar 7, 2024
be54fe1
Handled apps icons RTL
M97Chahboun Mar 7, 2024
065488a
Handled nav search RTL
M97Chahboun Mar 7, 2024
264353c
Fixed search input issue
M97Chahboun Mar 9, 2024
b7066b5
Handled table list value RTL
M97Chahboun Mar 9, 2024
08e5253
minor fixes on side bar
M97Chahboun Mar 9, 2024
d53f0a8
Fixed minor issue on mobile menu
M97Chahboun Mar 10, 2024
5002a30
minor fix on search field
M97Chahboun Mar 10, 2024
1526014
Handled related-widget-wrapper-link RTL
M97Chahboun Mar 11, 2024
e229d02
Fixed multi select field styling issues
M97Chahboun Mar 11, 2024
a70ee61
Handled tabular form RTL
M97Chahboun Mar 11, 2024
a8bbe22
Handled change list results table RTL
M97Chahboun Mar 12, 2024
8a2d70a
Improved change list results table RTL
M97Chahboun Mar 12, 2024
d6f32c6
Improved filter button RTL
M97Chahboun Mar 12, 2024
62ddbb9
Fixed filter button align issue
M97Chahboun Mar 12, 2024
a301f57
Improved border RTL handled
M97Chahboun Mar 12, 2024
1d540e3
Improved RTL handler on nav_bar
M97Chahboun Mar 12, 2024
f263321
Used ms/me instead or handle rtl using rtl:
M97Chahboun Mar 12, 2024
03e6c5a
Upgrade tailwind
M97Chahboun Mar 12, 2024
3533736
Merge branch 'main' of https://github.com/unfoldadmin/django-unfold
M97Chahboun Mar 12, 2024
77e415b
Added endline to styles.css
M97Chahboun Mar 12, 2024
caac78c
Fixed account links and theme siwtch popup RTL issue
M97Chahboun Mar 12, 2024
01bfd10
Improved all items using inline approach
M97Chahboun Mar 12, 2024
f4b7429
extra styles
M97Chahboun Mar 16, 2024
6ed8ad7
Merge branch 'main' of https://github.com/unfoldadmin/django-unfold
M97Chahboun Mar 18, 2024
e52bf81
re-generate styles
M97Chahboun Mar 18, 2024
7bccb68
fixed end-of-file issue
M97Chahboun Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
"tailwind:watch": "tailwindcss -i src/unfold/styles.css -o src/unfold/static/unfold/css/styles.css --watch --minify"
},
"dependencies": {
"tailwindcss": "^3.4.0"
"tailwindcss": "^3.4.1"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.10"
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/static/unfold/css/styles.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/unfold/styles.css
Expand Up @@ -109,7 +109,7 @@ table tr.selected {
Datetime
*******************************************************/
.datetimeshortcuts {
@apply absolute flex flex-row-reverse items-center right-0 text-0 top-px;
@apply absolute flex flex-row-reverse items-center right-0 rtl:left-0 text-0 top-px;
}

.datetimeshortcuts a {
Expand All @@ -134,7 +134,7 @@ table tr.selected {
}

.date-icon:after {
@apply border-l h-9 items-center justify-center leading-none material-symbols-outlined py-2 text-base text-center w-9 hover:text-gray-700 dark:border-gray-700;
@apply border-l rtl:border-r h-9 items-center justify-center leading-none material-symbols-outlined py-2 text-base text-center w-9 hover:text-gray-700 dark:border-gray-700;
content: "edit";
}

Expand All @@ -147,7 +147,7 @@ table tr.selected {
}

.clock-icon:after {
@apply border-l h-9 items-center justify-center material-symbols-outlined py-2 text-base text-center w-9 hover:text-gray-700 dark:border-gray-700 dark:hover:text-white;
@apply border-l rtl:border-r h-9 items-center justify-center material-symbols-outlined py-2 text-base text-center w-9 hover:text-gray-700 dark:border-gray-700 dark:hover:text-white;
content: "edit";
}

Expand Down
3 changes: 2 additions & 1 deletion src/unfold/templates/admin/actions.html
@@ -1,4 +1,5 @@
{% load i18n %}
{% get_current_language_bidi as is_rtl %}

<div class="actions flex flex-col md:flex-row md:items-center">
{% block actions %}
Expand All @@ -20,7 +21,7 @@

{% block actions-submit %}
<button type="submit" class="bg-white border flex items-center h-9.5 ml-3 px-2 rounded shadow-sm text-gray-400 w-9.5 hover:text-gray-700 focus:outline-none dark:bg-gray-900 dark:border-gray-700 dark:text-gray-500 dark:hover:text-gray-200" title="{% translate "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">
<span class="material-symbols-outlined md-18">chevron_right</span>
<span class="material-symbols-outlined md-18">chevron_{% if is_rtl %}left{% else %}right{% endif %}</span>
</button>
{% endblock %}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/unfold/templates/admin/app_list.html
Expand Up @@ -25,9 +25,9 @@ <h3 class="font-medium my-3 text-gray-900 text-sm dark:text-gray-200">

{% if model.admin_url %}
<a href="{{ model.admin_url }}" id="link-{{ app.app_label }}-{{ model.object_name|lower }}"
class="block border border-transparent flex h-11 items-center -mx-3 px-3 py-2 rounded-md transition-all {% if model.admin_url in request.path|urlencode %}bg-gray-100 font-semibold text-primary-500 dark:border dark:border-gray-800 dark:bg-white/[.02]{% else %}text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200{% endif %}">
class="border border-transparent flex h-11 items-center -mx-3 px-3 py-2 rounded-md transition-all {% if model.admin_url in request.path|urlencode %}bg-gray-100 font-semibold text-primary-500 dark:border dark:border-gray-800 dark:bg-white/[.02]{% else %}text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200{% endif %}">
{% if model.icon %}
<span class="material-symbols-outlined md-18 mr-3">{{ model.icon }}</span>
<span class="material-symbols-outlined md-18 ms-3">{{ model.icon }}</span>
{% endif %}

<span class="text-sm">
Expand Down
4 changes: 2 additions & 2 deletions src/unfold/templates/admin/change_list.html
Expand Up @@ -95,10 +95,10 @@

{% block filters %}
{% if cl.has_filters %}
<a class="{% if cl.has_active_filters %}bg-primary-600 border-primary-600 text-white{% else %}bg-white text-gray-500 hover:text-gray-700 dark:bg-gray-900 dark:border-gray-700 dark:hover:text-gray-200 dark:text-gray-400{% endif %} border cursor-pointer flex font-medium group items-center px-3 py-2 rounded-md shadow-sm text-sm md:ml-auto md:mt-0" x-on:click="filterOpen = true" x-on:keydown.escape.window="filterOpen = false">
<a class="{% if cl.has_active_filters %}bg-primary-600 border-primary-600 text-white{% else %}bg-white text-gray-500 hover:text-gray-700 dark:bg-gray-900 dark:border-gray-700 dark:hover:text-gray-200 dark:text-gray-400{% endif %} border cursor-pointer flex justify-center gap-2 font-medium group px-3 py-2 rounded-md shadow-sm text-sm md:ms-auto md:mt-0" x-on:click="filterOpen = true" x-on:keydown.escape.window="filterOpen = false">
{% trans "Filters" %}

<span class="material-symbols-outlined md-18 ml-auto -mr-1 pl-4 {% if cl.has_active_filters %}text-white{% else %}text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200 dark:text-gray-500{% endif %}">filter_list</span>
<span class="material-symbols-outlined md-18 {% if cl.has_active_filters %}text-white{% else %}text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200 dark:text-gray-500{% endif %}">filter_list</span>
</a>
{% endif %}
{% endblock %}
Expand Down
10 changes: 5 additions & 5 deletions src/unfold/templates/admin/change_list_results.html
Expand Up @@ -11,7 +11,7 @@
<thead class="hidden lg:table-header-group">
<tr>
{% for header in result_headers %}
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm {{ header.class_attrib }} {% if "action-toggle" in header.text and forloop.counter == 1 %}w-10{% endif %}" scope="col">
<th class="align-middle font-medium px-3 py-2 text-start text-gray-400 text-sm {{ header.class_attrib }} {% if "action-toggle" in header.text and forloop.counter == 1 %}w-10{% endif %}" scope="col">
<div class="flex items-center">
<div class="text">
{% if header.sortable %}
Expand All @@ -25,7 +25,7 @@

{% if header.sortable %}
{% if header.sort_priority > 0 %}
<div class="sortoptions flex items-center ml-2">
<div class="sortoptions flex items-center ms-2">
<a href="{{ header.url_toggle }}" class="flex items-center leading-none text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 toggle {% if header.ascending %}ascending{% else %}descending{% endif %}" title="{% translate "Toggle sorting" %}">
{% if header.ascending %}
<span class="block material-symbols-outlined">arrow_circle_down</span>
Expand All @@ -34,13 +34,13 @@
{% endif %}
</a>

<a class="sortremove flex items-center leading-none ml-1 text-gray-400 transition-all hover:text-red-700 dark:hover:text-red-500" href="{{ header.url_remove }}" title="{% translate "Remove from sorting" %}">
<a class="sortremove flex items-center leading-none ms-1 text-gray-400 transition-all hover:text-red-700 dark:hover:text-red-500" href="{{ header.url_remove }}" title="{% translate "Remove from sorting" %}">
<span class="block material-symbols-outlined">cancel</span>
</a>
</div>

{% if num_sorted_fields > 1 %}
<span class="sortpriority font-medium ml-2 text-xs" title="{% blocktranslate with priority_number=header.sort_priority %}Sorting priority: {{ priority_number }}{% endblocktranslate %}">
<span class="sortpriority font-medium ms-2 text-xs" title="{% blocktranslate with priority_number=header.sort_priority %}Sorting priority: {{ priority_number }}{% endblocktranslate %}">
{{ header.sort_priority }}
</span>
{% endif %}
Expand All @@ -56,7 +56,7 @@
{% for result in results %}
{% if result.form and result.form.non_field_errors %}
<tr>
<td class="text-left" colspan="{{ result|length }}">
<td class="text-start" colspan="{{ result|length }}">
{{ result.form.non_field_errors }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/edit_inline/tabular.html
Expand Up @@ -109,7 +109,7 @@ <h2 class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 ro
{% with is_last_col=forloop.last %}
{% for field in line %}
{% if field.is_readonly or not field.field.is_hidden %}
<td{% if field.field.name %} class="field-{{ field.field.name }}{% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell dark:border-gray-800"{% endif %} data-label="{{ field.field.label }}">
<td{% if field.field.name %} class="field-{{ field.field.name }}{% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto rtl:before:ml-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-left rtl:text-right text-sm lg:table-cell dark:border-gray-800"{% endif %} data-label="{{ field.field.label }}">
{% if field.is_readonly %}
<p class="bg-gray-50 border font-medium max-w-lg px-3 py-2 rounded-md shadow-sm text-gray-500 text-sm truncate whitespace-nowrap dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800">
{{ field.contents }}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/includes/fieldset.html
Expand Up @@ -19,7 +19,7 @@ <h2 class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 ro
{% for field in line %}
<div class="flex group {% if field.errors %}errors {% endif %}{% if not line.fields|length_is:1 %}lg:max-w-xs w-full {% endif %}{% if not forloop.parentloop.last %} mb-6 {% else %} mb-3{% endif %} {% if row %}flex-row items-center{% else %}flex-col{% endif %}">
{% if field.is_checkbox %}
<div class="flex flex-row items-center">
<div class="flex flex-row items-center gap-2">
{{ field.field }}{{ field.label_tag }}
</div>
{% else %}
Expand Down
22 changes: 15 additions & 7 deletions src/unfold/templates/admin/nav_sidebar.html
Expand Up @@ -4,17 +4,25 @@
<div @click="sidebarDesktopOpen = !sidebarDesktopOpen"
hx-get="{% url "admin:toggle_sidebar" %}"
hx-swap="none"
class="block bg-white border cursor-pointer fixed flex h-6 hidden items-center justify-center rounded-full text-gray-500 top-5 -translate-x-1/2 w-6 z-50 xl:flex dark:bg-gray-800 dark:border-gray-700 dark:text-gray-200"
:class="{'ml-6 rotate-180': !sidebarDesktopOpen, 'ml-72': sidebarDesktopOpen}">
<span class="material-symbols-outlined md-16">
first_page
class="xl:flex hidden bg-white border cursor-pointer fixed h-8 w-8 items-center justify-center rounded-full text-gray-500 top-5 -translate-x-1/2 z-50 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-200"
:class="{'ms-6': !sidebarDesktopOpen, 'ms-72 rtl:rotate-180': sidebarDesktopOpen}">
<span x-show='sidebarDesktopOpen' class="material-symbols-outlined">
menu_open
</span>
<span x-show='!sidebarDesktopOpen' class="material-symbols-outlined">
menu
</span>
</div>

<div @click="sidebarMobileOpen = !sidebarMobileOpen"
class="fixed bottom-0 bg-gray-700 flex cursor-pointer flex items-center left-0 mb-2 ml-2 justify-center px-2 py-1 rounded-full shadow-sm text-xs text-white uppercase z-50 xl:hidden"
:class="{'ml-72 -translate-x-1/2': sidebarMobileOpen}">
{% trans "Menu" %}
class="fixed bottom-0 bg-gray-700 flex cursor-pointer items-center mb-2 ms-2 w-8 justify-center px-2 py-1 rounded-full shadow-sm text-xs text-white uppercase z-50 xl:hidden"
:class="{'ms-72 -translate-x-1/2 rtl:rotate-180': sidebarMobileOpen}">
<span x-show='sidebarMobileOpen' class="material-symbols-outlined">
menu_open
</span>
<span x-show='!sidebarMobileOpen' class="material-symbols-outlined">
menu
</span>
</div>

<div :class="{'xl:block': sidebarDesktopOpen, 'xl:hidden': !sidebarDesktopOpen, 'max-xl:fixed': sidebarMobileOpen, 'hidden': !sidebarMobileOpen }">
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/search_form.html
Expand Up @@ -6,7 +6,7 @@
<div class="bg-white border flex rounded-md overflow-hidden shadow-sm focus-within:ring focus-within:ring-primary-300 focus-within:border-primary-600 dark:bg-gray-900 dark:border-gray-700 dark:focus-within:border-primary-600 dark:focus-within:ring-primary-700 dark:focus-within:ring-opacity-50">
<input class="font-medium h-9 px-3 text-gray-500 text-sm w-40 lg:w-60 focus:outline-none dark:bg-gray-900 dark:text-gray-400" type="text" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" placeholder="{% trans 'Type to search' %}" />

<button type="submit" class="flex items-center ml-auto px-2 focus:outline-none" id="searchbar-submit">
<button type="submit" class="flex items-center ms-auto px-2 focus:outline-none" id="searchbar-submit">
<span class="material-symbols-outlined md-18 text-gray-400 dark:text-gray-500">search</span>
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/unfold/templates/admin/submit_line.html
@@ -1,9 +1,9 @@
{% load i18n admin_urls %}

<div {% if not is_popup %}id="submit-row"{% endif %} class="relative z-20 {% if not is_popup %} mt-20 lg:mt-8{% endif %}">
<div class="{% if not is_popup %}bottom-0 fixed left-0 right-0{% endif %}" {% if not is_popup %}x-bind:class="{'xl:left-0': !sidebarDesktopOpen, 'xl:left-72': sidebarDesktopOpen}"{% endif %}>
<div class="{% if not is_popup %}bottom-0 fixed left-0 right-0{% endif %}" {% if not is_popup %}x-bind:class="{'xl:left-0': !sidebarDesktopOpen, 'xl:start-72': sidebarDesktopOpen}"{% endif %}>
<div class="bg-white dark:bg-gray-900 {% if not is_popup %}border-t px-4 py-4 relative scrollable-top lg:px-12 dark:border-gray-800{% endif %}">
<div class="container flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse">
<div class="container flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse rtl:lg:flex-row">
{% block submit-row %}
{% if show_save %}
<button type="submit" name="_save" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md text-sm text-white w-full lg:w-auto">
Expand Down