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

Feature debug #31

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Feature debug #31

wants to merge 15 commits into from

Conversation

willemvb
Copy link
Contributor

Proof of concept for #24 with an $av-enable-debug flag to show the current breakpoint.

@colourgarden
Copy link
Owner

Hi @willemvb. Thanks for submitting.

My original proof of concept worked in a similar way using the content property on a pseudo element but the problem I encountered is that, by default at least, Avalanche has breakpoints that overlap each other.

For example, if the viewport is 700px wide then it falls under the 'handheld', 'handheld-and-up' AND 'portable' breakpoints. Because 'portable' is last in the list (and so the generated code comes after the others) that is the one that gets shown but I really think that ALL applicable breakpoints should be shown.

I haven't been able to come up with a workaround for this as yet. Maybe we try and list all the breakpoints somehow and then highlight the 'active' ones? Not sure how this could be accomplished though.

Tom

@willemvb
Copy link
Contributor Author

willemvb commented Dec 12, 2016

Hey Tom,

thanks for reviewing. I have the habit of not letting media queries overlap, but you're absolutely right: it should combine all breakpoints one way or another. I think a CSS only solution is doable if we generate combinations of media queries, and set the content property accordingly to the combination of keys. The more complex combinations should come last to overwrite the simpler ones.

The difficulty lies in the combination of queries: they can have and & or conditions, different media-types, ... Some sort of deconstruction of the original media queries is needed here.

I made a new proof in Sassmeister http://www.sassmeister.com/gist/bcdff07e684a1f64d880f4d85207c5a5

Possibly not the shortest version, I tried to keep it readable. Might need a lot of real-life testing, and only handles screen, print media types for now.

@colourgarden
Copy link
Owner

I've revisited this a couple of times but still haven't been able to come up with a satisfactory solution. I think using the content property on :before is the correct way to go and I tried to work with CSS custom properties to see if I could concatenate the breakpoint aliases but custom properties don't really inherit. Feels like there should be a way to achieve this...

@willemvb
Copy link
Contributor Author

Hey Tom,

I pushed a small demo to this branch /demo/index.html to see overlapping queries in action.

To fix the overlapping mediaqueries, I needed to make all possible combinations for all mediaqueries and fill out the content property accordingly for each combination.

This is, unfortunately, not that straight-forward, the result is quite some code :)

To test yourself:

  • npm install
  • Adapt /demo/style/scss
  • Compile with npm run demo
  • Refresh /demo/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants