-
Notifications
You must be signed in to change notification settings - Fork 292
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
Migrate SCSS variables to CSS3 to enable auto dark and more features #429
Conversation
5b08590
to
c8d9c63
Compare
Good work
Hmm I'd rather apply it to the body since there's only supposed to be "1 true stylesheet" for kint in a page. Are there any fancy frontend systems you know of that could break that? (ie. react) I'll review this today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resources/sass/original.scss
Outdated
@@ -1,27 +1,30 @@ | |||
@import "base"; | |||
|
|||
:root { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are specific to original
I deliberately didn't bother putting them in variables. Maybe 1 and 2 should be since they're used more than once...
In that case what do you think of naming them --gradient-start
/--gradient-end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I just named them color1
and color2
as a temporary placeholder.
I prefer to use gradient-start
and gradient-end
, just that since there are two gradients used here, maybe they can be named primary-gradient-[start|end]
and secondary-gradient-[start|end]
, I just didn't know which was which when I did it.
Alternatively, would be to make the entire gradient a variable instead. Then, instead of using CSS to apply them to the elements in question, the newly created --background-image
variable can be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 gradients but color3
color4
and highlight-color
are only used once so you might as well make them literals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main purpose for using vars instead of literals is being able to override them in the TBA dark theme variant of this theme.
Good call, so setting the theme to an alias
If a request from React is made to a PHP backend (e.g. Using Axiom), then it's most likely a "fetch" type request (à la ajax) and won't be directly rendered in the page. There is one problem that comes to mind, which is that we will need to declare our styles as |
c8d9c63
to
8c1a9dd
Compare
Yeah but you can't set a class on the body from kint in PHP, would have to be in JS. I can imagine different dumps with the light and dark version toggling the class on the body which is not what we want I presume. Maybe it should be a class like |
If I am not mistaken, the folder functionality already makes use of JS, right? If so, it makes sense for PHP to set the
I wouldn't say that it would make sense, but I believe if the user can set the theme to be anything for each individual dump, it would make sense that they could also turn the dark mode on/off by specifying another "theme alias". In conclusion, this makes more sense to me when I think about it, rather than setting
Quite right, the closest thing I can imagine is having a parent I guess functionality speaking, it doesn't make sense to have per-dump dark control, so a "global" dark mode control approach would've been nice. But technically speaking, setting it on the whole page doesn't make sense, and setting it on each individual dump makes more sense. |
Yeah that's exactly what I meant. Let's go with that (I can work on the php/js side) once this migration is done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't press the big green button
@DRSDavidSoft any movement on this? 8.4 is now scheduled to release on the 21st so we have a little under 2 weeks. I'd like to push an RC by the end of this weekend, but I still have more changes to make before then. If you can't make it by then just take your time and we'll aim for 6.1 |
@jnvsor I was just a bit busy at work, if possible I would like to focus the PR only at migrating the variables for now to keep it simpler and allow us the time for it to be merged in If so, can you please make a list of the changes that I need to apply for this PR to be merged? That would help me prioritize the changes as well as allowing #428 to be implemented in a later PR that will be based on this one. |
Yeah that works for me I'll just resolve everything and make a new review then |
resources/sass/aante-dark.scss
Outdated
|
||
$variable-type-color: invert(#06f); | ||
$variable-type-color-hover: invert(#f00); | ||
:root { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put vars in .kint-rich (In all scss files)
In most children extending _base they already have a .kint-rich block so merge them rather than duplicating them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied this change, although I believe there could be some benefits for using the :root
space, particularly if we use a short and concise prefix such as --kt-
.
Would you prefer the following declarations? Otherwise, I'll put the variables in .kint-rich
as requested.
:root {
--kt-variable-type-color: ...
--kt-variable-type-color-hover: ...
}
This would allow the users to easily override Kint themes using custom values later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah just leave it in .kint-rich
- it's just as hard for a user to write
.kint-rich {
--variable-type-color: #F00;
}
As
:root {
--kt--variable-type-color: #F00;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what I mean is the ability to override the variable, but sure, I submitted the PR using the .kint-rich
instead of :root
Note: using the .kint-rich
approach, the user have to supply a more qualifying css selector in order to override their variables. e.g. add kint-custom
class to the body, then insert overriding vars as .kint-custom .kint-rich
, hopefully I was able to demonstrate my point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also do this with :root .kint-rich
without touching the HTML, but even with that it's not a downgrade.
Before you had to style individual elements since you didn't have access to variables at all. Now you can still do it without more specific selectors if you make sure your css comes after kints (Which is admittedly pretty hard to do but easy enough for actual kint themes)
background: { | ||
color: #ccc; | ||
image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="%23FFF" d="M0 0h1v2h1V1H0z"/></svg>'); | ||
size: if($color_size >= 30, 30px, 100%); | ||
size: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these changes won't break some layouts but I'll merge them first and test them myself later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why the new approach would break anything, but we could also go this route as well:
size: min(30px, 100%)
which has the same effect.
Alternatively, if you found a breaking change with either of these CSS-only implementations, we can revert back to the SCSS solution.
8c1a9dd
to
8595632
Compare
I'm off to work now, I'll review tweak and merge later today |
8595632
to
7b0b042
Compare
There's a few small things but I'll just take care of them here. For now could you hold off on making any more changes until I've pushed? Otherwise we're just going to cause conflicts |
Merged in 63fcf33 with some tweaks after that. The CSS could really use some love. I noticed the Anyway I'll leave CSS here and push rc1 when I'm done with my changes |
Description
This is a preliminary PR to address #428. Changes so far include:
Converted all SCSS variables to CSS variables instead where required (no scss variable remained after this change)
Drop IE support (eliminating the need for base64 encoding of SVG images, reducing both file clutter and size)
General cleanup to improve consistency across themes
Note: This PR currently doesn't introduce visual changes. If there are any differences from the previous styles, please flag them. I’ve reviewed this but would appreciate a thorough check.
Additional Requests:
I used
d($_SERVER);
to verify theme consistency. But it might not output use of all the Kint features, so could you please prepare a script for me that would make use of all the Kint features for a detailed comparison between the previous and old styles?For theme files, we currently have separate files for
solarized-light
andsolarized-dark
. Ideally, we should consolidate to a singlesolarized.css
file with color variables adaptable to both themes. Users might prefer explicitly setting light or dark themes, though, and we should avoid disrupting existing user settings. I propose a “theme alias” feature in Kint, mapping old themes to a unified auto theme while applyingkint-dark
orkint-light
classes as appropriate. This would allow us to ship just one file instead of three. Let me know if you agree, and I’ll work on a PR.Once decisions are finalized, another PR could be opened to refresh theme colors using professionally curated palettes in preparation for the Kint 6 release.
Theme Variable Enhancements
Simplification and Consistency
@media (prefers-color-scheme: dark)
query)The changes will help in maintaining a consistent design and make future modifications more straightforward.
Tests
Verified the produced
css
in the compiled directory against the older versions by setting the following:To ensure new styles exactly match previous themes.