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

Parser render module #530

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft

Parser render module #530

wants to merge 21 commits into from

Conversation

zakybilfagih
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Dec 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
styled-ppx ⬜️ Ignored (Inspect) Visit Preview Dec 26, 2024 3:20pm

@zakybilfagih zakybilfagih requested a review from davesnx December 26, 2024 15:26
| "or"
| "layer" =>
Error([
"'only', 'not', 'and', 'or', and 'layer' are invalid media types",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yo, give me a proper error message.

can you do a as used and Printf.sprintf "%s is not a valid media type" used?

Comment on lines +282 to +288
let value = {
switch (name) {
| "none"
| "and"
| "not"
| "or" =>
Error(["'none', 'and', 'not', and 'or' are invalid container names"])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's possible that we don't catch those at parse time?

@@ -542,22 +532,28 @@ let handle_tokenizer_error = lexbuf => {
};

let skip_whitespace = ref(false);
let prev_skip_whitespace = ref(false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, I would need an explanation on why previous is needed, when we have skip_ws

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both booleans are needed, I would go with a single ref and a few variants, wdyt?

Inside_media | Inside_selector | Outside_x | etc..

Comment on lines +1 to +3
$ alias run='./Render_test.exe'

$ cat ./test.css | run
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the alias?

$ alias run='./Render_test.exe'

$ cat ./test.css | run
.some-grid{grid:[line1] minmax(20em, max-content) / auto-flow dense 40%;}.a,href > h1,h3[data-foo*=bar]{&::after,href > h1,&:is(h1),&:has(+ :is(h3)){padding:20px 30px calc(20px+30px*(20 * 400/2));}background-image:radial-gradient(circle, #0000 45%, #000f 48%), radial-gradient(ellipse farthest-corner, #fc1c14 20%, #cf15cf 80%);grid-template-columns:[line-name1] 100px [line-name2] repeat(auto-fit, [line-name3 line-name4] 300px) ;}abbr{color:chocolate;}@media (hover: hover) {abbr:hover{color:limegreen;transition-duration:1s;}}@media not all and (hover: hover) {abbr::after{content:" (" attr(title) ")";}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have those tests as "idempotent" and parse-print-parse and compare?

I would prefer to keep separate "features" as separate tests, but a big one is also cool

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the "big" one can be a small tailwind generated file?

Comment on lines +116 to +119
Css_property_parser.Parser.parse(
Css_property_parser.Parser.media_query_list,
prelude,
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I like this parsing

Comment on lines +130 to +133
Styled_ppx_css_parser.Parser_location.update_pos_lnum(
at_rule_prelude_loc,
loc,
),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When have you seen this to be needed? Can add a test for it? ^^

[%expr [%cx "@media (screen and (color)) {}"]],
[%expr CSS.style([|CSS.media({js|(screen and (color))|js}, [||])|])],
"((screen) and (color))",
[%expr [%cx "@media ((screen) and (color)) {}"]],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incorrect, the right way would be

@media screen and (color) {
  color: blue;  
}

Parsing is: @media [media-type] and ([media-feature]) { }

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