-
Notifications
You must be signed in to change notification settings - Fork 2
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
CSS properties order #4
Comments
I normally don't write the rules in alphabetical order, I usually write the rules in blocks: flex rules, height width rules, color rules, etc. I write the rules that are related at the same time. And then I run a function to sort by alphabetical order, to match the current guides. I believe we should at least give this a try in one project. |
@groupbuddies/developers we'll need everyone's feedback on this. |
What has changed since the conclusions in the trello card? Only flexbox, or is there any new argument for or against this ordering? |
I agree that semantically ordering is better than alphabetical ordering. I also don't think my opinion has changed that much since we last discussed this Did this fail just due to not getting updates, or was there any other reason for giving up at the time? |
I think it's safe to say that a lot has changed since last time. At least some people did even more investigation, and in general, almost everyone did level up on css. Previously the rule was discarded because @ronaldofs said he already tried this and there was no point in doing it. But a lot has improved on our way of doing css since then. And there are a lot more arguments for this improvement. I hope everyone thinks for a while, before rejecting this improvement. I don't think an argument is necessary if all of us look at the way we program in other languages and apply the same rules to css. |
What new arguments are there? |
I would rather know everyone's opinion on this first. I already know that me, @azevedo-252 and @naps62 agree with this improvement, what about @ronaldofs and @joaojusto ? |
I would like to try this in one project to. It may seem strange and I recognize that will take a bit of time and effort to get it right but it makes more sense than the alphabetical order. |
I believe this is only a matter of style, not an improvement. But I don't want to be the only opposition on this if you know it's the best way to do that (whatever 'best' means). Side note: |
@ronaldofs how do you organize your methods in a class? |
@gabrielpoca usually: public then private; init and constructors on top; and organized by usage (not having methods call methods yet to be defined). |
But hey, I said I don't mind to order css props with a chosen and defined order. Let's do it. |
Quoting idiomatic-css "Larger teams may prefer the simplicity and ease-of-maintenance that comes with alphabetical ordering.", are there opinions on this sentence? |
Do you consider css to be more like a config file instead of a programming language? |
I consider it more as "config" than "real programming". |
Before anything else, I still haven't updated anything on the trello card, I just reopened this issue in order to generate discussion. The refactor still needs to happen. @naps62 it failed due to a mix or "forgetness" and not having a clear unanimous approval. @ronaldofs "I believe this is only a matter of style" The ordering between related groups, indeed is "decided" by us and may look random (even though it has a logic, which I still need to write down, sorry about that). Nevertheless, the actual property grouping cannot be labeled as random since it represents some semantic function on the browser. That, I find hard to reason against, since I see no profit in seeing a layout rule followed by a coloring rule and then another layout rule. It's an attempt on a separation of concerns. Anyway I would strive for at least having some well defined property groupings (the inner ordering may be alphabetical or some other logic we're comfortable with, eg: some logic that the W3c specs may have defined, some personal preference, ...). In another note, it is possible and will probably be my next "endeavor" having a tool and/or some sort of linter for ordering/warning about these sorting errors. |
@azevedo-252 The problem I have with the approach is the overhead of conforming to a non-obvious organization. You need to think how to order every time you'd write new declarations. |
For me, it's the same as if you said something like: |
Why do you think is necessary to order methods and variables and everything, but css is just a bag of things? I get the feeling you're not thinking this through. Or at least not really writing enough css to feel the pain or to recognize the patterns in the way you write css. Maybe we need to agree first if css if a configuration file or a programming language? |
@gabrielpoca that's even more philosophical :D I do understand this is only a problem for some because we look at what CSS is differently. Right now I'm trying to collect more logical (spec wise) reasons for grouping certain properties... Hope it will be useful for making things easier to grasp |
Do you have any specific order for variables in let's say a constructor? I don't. Or when I do it's alphabetical, because it just doesn't matter and it's easier this way. What I do, is try to follow SRP (especially) and other patterns, so that everything that's there is related to a single purpose and thus making the order irrelevant. As for methods, they are organized in a way they should be read, if they call each other, if they don't interact with each other, the order has no relevance. In terms of CSS I agree with @azevedo-252 that we should try to follow SRP, with componentization, Sass variables and the such. So, as much as possible separate layout from coloring, for example, thus making the number of rules per selector so small that the order is (debatably) irrelevant. In sum, having little methods and classes make the order pretty much irrelevant in my experience with most programming language. With CSS I believe the same applies if we have small components and selectors. |
@gabrielpoca for me it's more config/stylesheet than algorithmic/programming |
@ronaldofs (link removed, blue pen) |
Your public methods go on top, private on bottom. The only thing this rules have in common is that they improve readability. You had to learn the rules. They don't come naturally. Why do you consider that these rules are necessary, but css properties can go alphabetical, when you normally write related properties at the same time? |
@zamith I was referring to components with separate layout from aspect. |
Public methods go on top and private on the bottom in ruby, because after the Instance variables and class variables most likely will have to be defined in different places or else it won't work. And as for empty lines to improve readability we also do that in CSS. As @ronaldofs has stated, I don't really see this as an improvement, as much as a style change. And I haven't experienced this order to be more readable. Actually, if we don't have more than 6 or 7 rules per selector (which is pretty much what we have), I think order has no effect on readability at all. This is obviously my opinion, but if we do agree in an order, whatever it may be, I intend to follow it in every project (unless experimenting something well documented on the research board). That for me is the most important thing. Much more important than this ordering issue. |
@zamith yes, I do try to group instance variables declarations according to their responsibility, or context. In ruby that doesn't apply too much, since we don't declare them, but a simple example that is language agnostic is this:
vs
Width and Height are two things that go together like bread and butter, so seeing a Is there a strict, definable order for how we would declare them? I don't think so. But for me, alphabetical and random are pretty much the same here SRP is a good principle, but it can only go so far. And saying that with SRP makes the order irrelevant is an exaggeration, IMO |
@naps62 I get your point, but I think your example is a bit biased, because there are some attributes that are usually coupled to each other, such as Generally speaking, I do think order does not really matter. As for CSS, those are the two rules I think have a stronger gravitational pull to be together. Most of the others I understand that they have some relation, like |
@naps62 I agree and I believe everyone does the same. Those guidelines are pretty much standard for "good development". It's a pain having to work/move/refactor related variables that are set apart from each other. I feel no pain trying to grasp alphabetically ordered style declarations. I would feel pain having to keep a specific order of groups of properties. Actually, I can give a similar case: @gabrielpoca asked me why I aligned variable initialization or key/value pairs as it was extra work for no gain (I thought it improved readability) ... and indeed I was wasting my time. So I stopped worrying and now I'm happier 😃
|
@ronaldofs You can find a lot of examples in our easyPaperRebelz repo. If i'm not wrong there isn't a component that mixes structure with skin (unless it has some well defined reason), much less a single class (if you don't care about the notion of component). Other than that, having too many properties under a class is usually a bad sign. But when/if you do have I can't say that the order is irrelevant. It's a matter of how you organize things in your head and seeing unrelated things together does make you make wrong assumptions. I'm still trying to figure out arguments that can convince you but it's getting harder. As I write this I thought of another one: |
This has already been talked about. It was an issue in this repo as well but got deleted probably when this repo stopped being a fork.
It has a trello card.
@gabrielpoca and I still believe this could have a revamp even in the actual properties order which might be "outdated" and missing some properties like those from the flexbox module.
The reasons are stated in the trello card, but for us the main reason for not liking the current order (alphabetical) is because it's not logical, even though it's an alphabetical order it feels random. It doesn't translate the "semanticness" of a ruleset.
The text was updated successfully, but these errors were encountered: