-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Added Padding extraction functions: top(@pad) right(@pad) bottom(@pad) left(@pad) #1112
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
Conversation
…values from a variable
…x" - (improved comment)
@agatronic @MatthewDL @gustavohenke Open for discussion: The current implementation has the Naming suggestions for the single function:
I like |
In addition to extracting from margin & padding shorthand
I actually think this use-case is as valid as the margin & padding use-case, so I will soon perform the refactoring, unless I hear any objections? |
Your patch is using tabs instead of spaces, you probably want to check that. What about a simpler, index-based approach? |
@ricardobeat , the "index based approach" was already discussed in #1100... @scottrippey, And, no mather the approach you use, it would be useful for many dimension extracting:
|
@ricardobeat Re: tabs vs spaces: The first commit was with tabs, but I "normalized whitespace" and fixed the mistake ... did you spot any other mistakes I might have missed? @gustavohenke Earlier, @agatronic said "I considered 1 function better than 4 (more succinct). " So I'll refactor accordingly. If it's just 1 function, then it'll be a piece of cake to implement support for more mapping parameters:
I need help with 2 important design decisions, though:
|
Please wait to see if we get some more feedback from @MatthewDL and if he really doesn't like it we'll discuss with @cloudhead |
@agatronic I'll wait to hear from those gentlemen :) |
I agree that if we cannot know what kind of value we are extracting, then allowing naming like "top", "left", etc. is inappropriate and adds bloat. If this is essentially to pull a sub-value from a space-separated shorthand variable, it's probably a tiny addition. We already do magic with making an argument collection space separated, so this seems like a nice inverse. (That is, you could / should be able to do So, kill off the keywords, and it seems fine. I like "extract" better than "pick". CSS uses 1-based indexes (nth-child), so I'm inclined that way as well. @agatronic Agree with that? |
To further clarify, I'm 100% against adding a slew of extraction functions. That's a pile of unnecessary confusion for what should be a very small feature, if it exists at all. extract() or nothing. |
@gustavohenke discussion was moved here, and the consensus on #1100 was that supporting keywords is too much bloat. That's why I suggested the simpler index-based implementation. Adding a 30-line method seems like overkill. Btw, wouldn't |
@MatthewDL You certainly have good points. The index-based part is just 2 lines of code. The keyword-based approach (including the extra shorthand logic) was starting to get out-of-hand. LESS currently doesn't "understand" CSS this way, it just "builds" CSS, so maybe that's the reason why this feels out-of-place. I liked the semantics of |
I liked being able to pass TRLB, but it did suffer terribly from the potential of not working for some sets of properties in the future. I thought that bad side was worth the niceness of it, but I'm willing to conceded, espescially since the original proposer doesn't mind.
I'd rather say what would a less user expect it to be.. 0 based or 1 based? Personally I'd expect it 0-based. |
Most of my design decisions were based on the readability of the LESS. Since @pad is not an array, nor a list ... it is a group of values, and I would verbally reference those values as "1st, 2nd, 3rd, etc" |
Ok, 1-based it is. |
Just one thing: I would have expected the syntax to be |
From memory, the contrast function is like that. First, pass in the vars, then the numerical value of threshold. |
It's the standard order in most languages, since at the moment you want to add a 2nd argument you get a mess: |
lets swap them round raised #1119 so I don't forget |
Ok, good points, |
yes, I rebased the pull and pushed your commits together as it didn't make sense to have so many commits for what ended up being so tiny. Sorry if that messes with your history! |
I'm new to collaborating via Git & GitHub, so I need to learn how to squash commits, rebase, pull upstream, etc... |
I've implemented these functions.
Please see #1100 for use cases and more info.