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

refactor (various) to move inline styles #1262

Merged
merged 6 commits into from
Nov 11, 2024
Merged

Conversation

koeaw
Copy link
Contributor

@koeaw koeaw commented Oct 3, 2024

Move leftover inline styles from HTML templates to static CSS files.

Closes #1258


Not included are the scroll button styles already covered by #1234 and styling applied in Python code as that's harder to untangle. Ex.

attrs = {
"data-placeholder": "Type to get suggestions",
"data-minimum-input-length": getattr(settings, "APIS_MIN_CHAR", 3),
"data-html": True,
"style": "width: 100%",
}

The styles in apis_relations.css may be redundant as they belong to relations_detail_generic.html, see #1259, but I didn't want to leave strays. I've added TODO comments in the file to make note of that.

@koeaw koeaw force-pushed the kk/refactor/inline_styles branch from 811b9a4 to a5cdb3c Compare October 3, 2024 11:18
@koeaw koeaw requested a review from b1rger October 3, 2024 11:24
@b1rger
Copy link
Member

b1rger commented Oct 3, 2024

I'm removing myself from the reviewers as I won't have time to look at this.

There is only one commit that touches multiple apps, it could easily be split up into smaller, easier to review, commits. It also mixes the refactoring with functional changes, i.e. replacing the style assignment in one element with a css class in another element without any explanation as to why. It also moves bootstrap inclusion without any mention in the commit message and overrides bootstrap code without explanation except the comment "fixes an issue with select2".

Feel free to assign to someone who either has more time to untangle all that stuff or who knows what all those changes mean by simply looking at them

@b1rger b1rger removed their request for review October 3, 2024 11:52
@koeaw
Copy link
Contributor Author

koeaw commented Oct 3, 2024

I'm removing myself from the reviewers as I won't have time to look at this.

Ok.

There is only one commit that touches multiple apps, it could easily be split up into smaller, easier to review, commits.

I didn't think of splitting the changes up because they didn't seem substantial to me, but point taken about the scoping.

It also mixes the refactoring with functional changes, i.e. replacing the style assignment in one element with a css class in another element without any explanation as to why.

I understand refactoring to mean to replace [code] (markup, whatever) with other (simpler, cleaner etc.) [code] to achieve the same result. That's what these changes are doing.

Moving "pointers" to elements to other elements in the chain and manipulating them from there is a basic concept in CSS, so it didn't even occur to me it may need explaining. But I'm coming at this from a full-stack perspective, and frontend development is a whole separate field of work with its own separate domain-specific knowledge and skill sets. But frontend stuff is not a primary concern in this project. So it's difficult to know what or how much detail to try to cram into e.g. commit messages.

I'd suggest we discuss how we should deal with frontend-related code & documentation at a JF.

It also moves bootstrap inclusion without any mention in the commit message and overrides bootstrap code without explanation except the comment "fixes an issue with select2".

Ah, thx for pointing out the HTML move got subsumed here.

I refactored the template away because it seemed pointless to keep for the one remaining line of HTML (+ the comment) after moving the styles, but you are right, that shouldn't have got included.

@koeaw koeaw force-pushed the kk/refactor/inline_styles branch 2 times, most recently from 71794ba to 9a4b195 Compare October 3, 2024 14:56
@koeaw koeaw requested a review from gythaogg October 3, 2024 14:58
@koeaw koeaw changed the title refactor(apis_entities,apis_relations,core): move inline styles refactor (various) to move inline styles Oct 3, 2024
@b1rger
Copy link
Member

b1rger commented Oct 5, 2024

There is only one commit that touches multiple apps, it could easily be split up into smaller, easier to review, commits.

I didn't think of splitting the changes up because they didn't seem substantial to me, but point taken about the scoping.

Its not primarily about the scope, splitting up into commits per app was only an example. Its about consideration for the person that has to review the PR. Also, if there are 5 different changes in a commit and one of those changes require more discussion, the remaining 4 changes have to be postponed until the discussion points are resolved. Some of those changes in the PR at hand could already have been merged.

Regarding the commit messages, I don't think that full-stack/frontend changes should be held to a lower standards than other changes. From https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/

To come up with thoughtful commits, consider the following:
Why have I made these changes?
What effect have my changes made?
Why was the change needed?
What are the changes in reference to?

See also this example: https://dhwthompson.com/2019/my-favourite-git-commit

Regarding the specific wording:
"move inline styles" sounds to me as if the inline styles where moved somewhere else, which is not what is happening in those commits. The inline styles are replaced by non-inline styles.

@koeaw
Copy link
Contributor Author

koeaw commented Oct 7, 2024

Regarding the specific wording: "move inline styles" sounds to me as if the inline styles where moved somewhere else, which is not what is happening in those commits. The inline styles are replaced by non-inline styles.

IMO the wording describes well enough what's happening here.

"Inline styles" means "styles which are applied (or which appear/...) on a line with HTML". When "these styles which appear inline" are put in an external file, that's primarily a matter of placement, not replacement. I think it's perfectly legitimate to call this "moving".

This is no different from moving Django template code from one template file (block,...) to another. Yes, sure, if I wanted to be literal, I could say I'm replacing x lines of template language with an include statement + a new file with a duplicate of those x lines, but I didn't think I would be misunderstood if I called this moving those lines to a separate template/include/...?

Would it help if the commit subjects were changed to e.g. "move styles to external files"?

@b1rger
Copy link
Member

b1rger commented Oct 7, 2024

IMO the wording describes well enough what's happening here.

🤷
suit yourself

@@ -5,3 +5,8 @@
a #logo:hover {
opacity: 0.5;
}

/* main modal in modal block */
#modal .modal-dialog {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to scope the style to child elements of an element with id="modal"? I am assuming that it's fair for all elements with modal-dialog in their classes to pick up this style...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the customisation in the first place. Out of the box, the component looks like what I'd expect a modal to typically look like. This seems to hard-override a max-width setting originally defined via @media rules to create a wide-screen version of that.

I would not force this formatting on any and all components of this type. Modals are primarily meant for dialogues, which I expect to contain little text, which shouldn't be made harder to read by increasing paragraph width.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a next step, I'd suggest to replace the custom styling with the modifier class Bootstrap provides. But that's for another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I just checked – the modifier actually results in an equivalent largest width. I can switch it out if you don't mind this turning the commit into only a half refactor/half feature (added smaller container width at smaller screen width).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or, rather, a fix. (;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gythaogg Any more feedback on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koeaw the code changes look fine to me but I couldn't figure out how to test all of the changes; since I've been burnt before by styles losing precedence once they were moved away from inline I want to just do a sanity check.

Is it okay if we sit together so I can use your help to see that the all the moved styles are picked up?

@koeaw koeaw requested a review from gythaogg October 21, 2024 14:59
@koeaw koeaw force-pushed the kk/refactor/inline_styles branch 4 times, most recently from 3b4963b to 6fff8d7 Compare November 11, 2024 12:54
Declare styles for positioning of links and headline text
in app-specific CSS file instead of inline.
Declare styles for additional actions for (entity) object
manipulation – duplication, merging, history – in main CSS
file for app instead of inline.
Declare styles for map for visualising entities
with geocoordinates in existing CSS file for app
instead of inline.
Declare styles for positioning of links and headline text
in app-specific CSS file instead of inline.
Declare styles for overriding Bootstrap defaults in
new external CSS file override_bootstrap.min.css instead
of in an internal stylesheet in a separate template (partial)
whose only purpose is to include styles.
Declare styles for the main modal in the
main CSS file for the app instead of inline.

Closes #1258
@koeaw koeaw force-pushed the kk/refactor/inline_styles branch from 6fff8d7 to 5c66e22 Compare November 11, 2024 13:00
Copy link
Contributor

@gythaogg gythaogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the places (except apis_relations) where the new styles replace inline styles and there is no difference - all the styles are getting applied as they should.

@koeaw koeaw merged commit 559126b into main Nov 11, 2024
13 checks passed
@koeaw koeaw deleted the kk/refactor/inline_styles branch November 11, 2024 13:47
@koeaw
Copy link
Contributor Author

koeaw commented Nov 11, 2024

Thank youuu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move remaining inline styles
3 participants