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

column-offset function #525

Open
xaddict opened this issue Mar 8, 2017 · 5 comments
Open

column-offset function #525

xaddict opened this issue Mar 8, 2017 · 5 comments

Comments

@xaddict
Copy link

xaddict commented Mar 8, 2017

I'm looking for an easy way to calculate just the offset of a column (think of bootstrap's col-sm-offset-3).

column-width(3/12) + column-gutter(1/12) would be an easy way to calculate this but both of those functions return a string.

To get rid of the string I need the following code:
$offset3: to-number(str-slice(column-width(3/12), 0, -2)) + $gutter + unquote("%");

where to-number is an annoying helper function just to get the percentage string to be recognised as a float.

Is there any way column-width and column-gutter can be modified to only return a float?

@corysimmons
Copy link
Contributor

You're trying to get column-width + column-gutter? Or do you need half a gutter?

I think we could add something like span-width to do this.

@corysimmons
Copy link
Contributor

I'd also heavily suggest you check out postcss-ant. It was specifically developed to get whatever sizes you could possibly imagine in an intuitive way.

For instance, here is a column, column + 1/2 gutter, column + full gutter: https://codepen.io/corysimmons/pen/dvNNbj?editors=1100

@xaddict
Copy link
Author

xaddict commented Mar 8, 2017 via email

@xaddict
Copy link
Author

xaddict commented Mar 8, 2017 via email

@corysimmons
Copy link
Contributor

Sorry, I hate, and have hated, LESS' syntax so I never ported Jeet to it.

Why would you need the full gutter? span() works by getting half gutter. I see a case for span-column() being introduced, but think your need might be too fringe to warrant more API.

So far as postcss-ant, if you're already into a project, then I wouldn't migrate, but for future projects you should really look into it. It works with any preprocessor (i.e. LESS) or even vanilla CSS.

I think wrapping what you're trying to do in a function is your best bet for now: https://codepen.io/corysimmons/pen/bqgrqo?editors=1100

And this should serve as a lesson that Sass, and other preprocessors, are grossly underpowered. I think they should be used for syntax sugar, but for libs, or anything custom, PostCSS is king.

@pixeldesu Thoughts on this issue?

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

No branches or pull requests

2 participants