Skip to content

WIP: Multiple media queries - #27

Open
peterramsing wants to merge 2 commits into
ryanbahniuk:masterfrom
peterramsing:multiple-media-queries
Open

WIP: Multiple media queries#27
peterramsing wants to merge 2 commits into
ryanbahniuk:masterfrom
peterramsing:multiple-media-queries

Conversation

@peterramsing

Copy link
Copy Markdown
Contributor

For fixing #25

@ryanbahniuk I created this PR so that I can get some input on if I'm tackling this the right way. I'm not overly familiar with the AST syntax or how you have these test set up. I now have a test failing and am experimenting on getting it to pass but I'm certainly not familiar with this type of code (and am loving the challenge for sure!).

So, if you see this going completely off base or if I'm working in the wrong areas just let me know. I'll just keep working and ping you if I have any specific questions.

I'll update this PR description when it's no long a WIP

This adds css in JSON format to the media query test file that will
allow testing against it in order to realize finding multiple
media queries.

This also adds a failing test to try and specifically search for a media query.
I did some more Google searching after the previous commit and found a generator
for the AST version of the CSS. I went ahead and created a vanilla CSS version
for future use and included it in the project. I also updated the mistakes I
had made when trying to make the AST version of the CSS by hand. This includes
those fixes as well.
@ryanbahniuk

Copy link
Copy Markdown
Owner

This looks like its on the right path. I would change the parsers#findMedia function to take a second argument which is the specific rule that it searches for. The existing method should then still return the first match, failing your added integration test, and you can work towards changing the internals of that method to match the new test. There is also a unit test for that parser method, but I would start with the integration test as you have here.

FYI, this is a good resource for working with CSS ASTs:
http://iamdustan.com/reworkcss_ast_explorer/

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

Successfully merging this pull request may close these issues.

2 participants