-
Notifications
You must be signed in to change notification settings - Fork 304
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
Feature request: Option syntax for .user.css files which keeps CSS valid and future-proof #314
Comments
There's a wiki link in the manager. I'm sure one of the usercss gurus here will respond, but in the meantime, I figured I'd point you in the right direction. |
@narcolepticinsomniac Hahaha, I was confused by the lack of numbers on the wiki tab header — thought it's empty. 😆 OK, read the docs. Now it makes sense. Updated the original post and adjusted the feature request. |
You have leave out the On that same page is another example of the same style using the stylus preprocessor - https://gist.github.com/Mottie/82de0c2956b31d9a34c2e49ffbd4d444#file-github-selected-tab-color-user-css If you need an |
Thanks for the Point-out. I was looking for just that, more complete, working examples. Helped a lot, thank you. |
While I have someone on the phone... is there a location for editing and saving the default userscript header added to new files? I thought I read there was, looked but haven't found it or info yet. Thanks. |
Create a basic template, then leave the |
Thank you. Looking now. |
Hmm, it doesn't seem to be working anymore. |
@Mottie If I understand correctly, I have to choose between:
(1 and 2 differ only in the way a file is coded, the preprocessor is actually the same.) The problem is, there's no option to have valid CSS + CSS variables + conditional blocks. The way I see it, it is the most clean option and should be used by default. Addition of at-rule syntax to defaut/USO preprocessor is guaranteed to not break anything. Considering almost everything is already implemented (if statements, CSS parsing), adding a new syntax shouldn't be difficult. I guess I can make a pull request myself. |
I'm confused, how does valid CSS include conditional blocks? The USO preprocessor can only use conditional blocks within the We're not using SASS or LESS because the libraries to parse CSS are ginormous; and the Stylus preprocessor appears to be adequate for what you need. So, why are you compelled to need a new |
I'm not against the idea 😸 , but I don't have the final say in the decision. And to answer the other questions:
Yes, including a duplicate default within the Our implementation does support the freestyler extension's method of setting advanced options.
Stylus has a vastly improved and updated version of the style editor - you can still use the same workflow. Edit the style in a separate window and then saving the changes will automatically update the userstyle in any targeted tabs.
That would be difficult since Stylish doesn't support option modification from within the extension - but I haven't checked the latest update. It would be nice to have a standard, but there are too many maintained and un-maintained style extensions out there to try to coordinate. Adding a
Please do, we're always looking to get help from more contributors! |
@Mottie My proposal is a valid CSS proprietery extension. If you add it, nothing breaks, a valid CSS file remains a valid CSS file — that's what I mean by valid extension. It's just another conditional block like The reason I want it is that currently, if I need conditional blocks, I have to choose between two options:
The way I see it, adding prefixed
|
I'm not writing styles as epic as GitHub-Dark, which heavily rely on configuration, so I can afford to say in the description something like: "When installed, you get all options set to default. If you want to configure the style, use Stylus extension or edit variables manually." (I already use CSS variables heavily.) It also kinda opens a possibility for converting between formats automatically. Having all information in one file is the first step, valid CSS simplifies it. At one point I'll probably write a user script which converts user.css to USO when copy-pasted to userstyles.org's textbox (that would put strict limitations on if statements, but can be done). |
That would disable updates for this style because it'll be considered locally modified and we protect local modifications for the obvious reason of protecting them. So I'm not sure this entire idea is worth implementing. Or do you mean Stylus will act as a preprocessor to compile the style code to use variables customized in the style config dialog? But then it'll suffer from the same predicament you cited as a SERIOUS PROBLEM - it needs a preprocessor. |
@tophf File extensions and vendor CSS prefixes aren't exactly related, so there's no conflict. It can be kinda confusing though, I agree. I just wanted something short, related to Stylus-as-addon, yet generic enough and related to styles in general. "Styl" seemed like a good candidate. Browsers use company and web engine names as prefixes. What's "OpenStyles" which is used as a company name on GitHub? So... Let's see what options we have.
If
Yes. The .user.css files using this syntax should work correctly in any extension, but will have additional config functionality in Stylus. (And if a user decides to, they can manually edit a style, losing update functionality — some websites are updated once in a decade, so it isn't that bad actually.) Hmm, need to test userstyles.org's parser. It failed parsing advanced |
What about |
@tophf That would violate the standard. |
|
Would this also include an implementation of |
@tophf This prefix is supposed to identify the vendor, not just be something random. It's also supposed to be applied to all extensions of the vendor, so if any other CSS syntax specific to Stylus / user styles is invented later, the same prefix should be used. It doesn't have to be a real word. Compare to @Mottie CSS at-rule syntax doesn't allow multiple at-rule sections to be combined, AFAIK. That's not a problem though, you can always just negate the condition. I think most of the uses should be equality tests |
I'd vote for |
@Mottie Let's imagine we want to add another two rules to Stylus some time later: Would Would Ideally, we want a prefix which is tied to user styles in general. This is why I lean towards P. S. Yup, there are only two hard things in Computer Science. 😆 |
|
I don't think it is worth re-inventing another preprocessor just because we want to make the code compatible with other CSS parsers.
I suggest creating a build tool that can extract CSS variables from usercss header and inject them to the usercss file to create a standalone version. Note that the standalone version might not work after Firefox 61 since the built-in
|
Intro
I love the new syntax for .user.css files which was introduced in #134 (Install styles from *.user.css file). It solves two major problems with styles on userstyles.org:
However, it suffers from a serious problem: just like option syntax from userstyles.org, it forces developers to write files which rely on preprocessors, while pure CSS is often sufficient and doesn't require any specific software.
Feature request: @if
While
@var
introduces CSS variables, its current functionality is lacking as it only allows using variable values in property values (and calculating new values usingcalc
). Theif
statement is completely missing, but it's crucial for customizable themes.I propose adding a new pure CSS syntax for if:
@-styl-if (nav-pos == 'bottom')
. Reasons:-styl-
prefix.As a result, any conforming CSS parser from the past, present or future, will correctly skip this as an unrecognized at-rule, while parsers supporting it will provide new functionality — this is what at-rules are designed for.
Question: Pure CSS @var
The original proposal suggests that CSS variables are introduced, but all later examples rely on Stylus preprocessor. Without relying on any preprocessors, I could write the following:
This way, CSS file works correctly both as a stanalone file and with GUI support. I don't like value duplication, but can live with it I guess, given the benefits. Is that the correct appoach?
Question: Workflow
While I'v been using user styles for ages and have written more than a hundred of them, I'm still new to sharing them and try to find a sensible workflow. So far, I've been using Stylish for editing styles and to see changes while I edit the file, then copy-paste the whole text to userstyles.org. I try to find a sensible way to add options to the styles which doesn't ruin the workflow and turn it into an error-prone mess, but I don't see any.
Ideally, I'd like to write pure CSS, with support for options in all user style extensions, as well as easily update online versions. And advice?
(Currently stuck on Firefox 56.)
The text was updated successfully, but these errors were encountered: