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

Refactoring CSS and JS #146

Open
torgeirl opened this issue Jan 5, 2024 · 6 comments
Open

Refactoring CSS and JS #146

torgeirl opened this issue Jan 5, 2024 · 6 comments
Assignees
Milestone

Comments

@torgeirl
Copy link
Contributor

torgeirl commented Jan 5, 2024

Goals

  • improve performance
  • reduce technical debt
  • enable the use of CSP

Possible solutions

  • since Trix's overall usage of JavaScript is limited, perhaps we could replace jQuery and Angular with more limited approaches such as HTMX and Alpine.js; they are also more appropriate for our update cadence

Tasks

  • eliminate the use of inline styling
  • eliminate the use of inline scripts ✔️
  • avoid use of eval() functions

Inline styling:

(* Inline styling is removed from /trix_admin/statistics.django.html, but that has caused (at least) two changes:

  1. the table header styling now has working directional arrows («A-Z indicators») 🎉
  2. the course tag has a nonfunctional X (should only be displayed on optional tags) ❌)

Inline scripts:


HTMX features that rely on eval() are:

  • event filters
  • hx-on: attributes
  • hx-vals with the js: prefix
  • hx-headers with the js: prefix

Note that all features removed by disabling eval() can be reimplemented using your own custom javascript and the htmx event model.

@Levijatan
Copy link
Collaborator

The print button in trix/trix_student/templates/trix_student/assignment_list_base.django.html is pretty much the standard way to have a print button so I don't know if there is any other cleaner way to do it.

torgeirl added a commit that referenced this issue Jan 11, 2024
@Levijatan
Copy link
Collaborator

Moved the inline javascript in statistics.django.html out into their own file in 7aa0f05

@Levijatan
Copy link
Collaborator

Looking through all the javascript I think it wouldn't be to hard to replace most of it with HTMX, most of what angular is being used for seems to be simple state control. It would require some work on most of the views to get most out of it, but atleast I feel that it would be worth it.

@torgeirl
Copy link
Contributor Author

torgeirl commented Jan 11, 2024

The print button in trix/trix_student/templates/trix_student/assignment_list_base.django.html is pretty much the standard way to have a print button so I don't know if there is any other cleaner way to do it.

I've landed on simply removing it; most users are familiar with Ctrl+P and that has the bonus of allowing the user to print only select parts of the page instead of all assignments on a give page. 🍃

torgeirl added a commit that referenced this issue Jan 11, 2024
@Levijatan
Copy link
Collaborator

Moved out the inline styles in statistics. 4888329.
Quite happy that Less could generate css so it was quite nice to generate classes for progress bar width 1-100%

@Levijatan
Copy link
Collaborator

Could use the same css classes in assignment_list, pushed up in 62e0aa9

@torgeirl torgeirl modified the milestones: Trix 4.1, Trix 4.2 Jan 25, 2024
torgeirl added a commit that referenced this issue Jan 25, 2024
* Improved contrast course admin assignment and editor

* Fixed missing labels and iframe title

* wrapped in fieldset

* Fixed Empty header

* Empty table header fix, and added missing label to search field

* Fixed language not being set

* Added link icon to link

* Removed redundant login button

* Removed django.middleware.clickjacking.XFrameOptionsMiddleware

* Added the ability to hide courses from students

* Hopefully fixed 145

* Statics view optimization

* redirect url cleanup

* (re-)moved some inline styling (#146)

* added and improved translation for add admin (#148)

* moved more inline styling (#146)

* Move inline javascript to own file

* removed «Print this page» (#146)

* Moved out inline styles

* Replace inline style with correct css classes

* Fixed #149

* added `TRIX_VERSION` template variable

* releasing Trix 4.1.0

---------

Co-authored-by: Levijatan <[email protected]>
torgeirl added a commit that referenced this issue Feb 23, 2024
torgeirl added a commit that referenced this issue Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants