Support content: attr() and content: counter()#559
Conversation
…yled-ppx into support-content-attr-element * 'support-content-attr-element' of github.com:/davesnx/styled-ppx: Support counter
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for content: attr() and content: counter() CSS properties by implementing comprehensive parsing and rendering for attribute and counter functions in CSS content declarations.
- Extends the CSS type system to support symbols, counter styles, and attribute functions
- Implements parsing and rendering for
attr()function with optional type specifications - Adds
counter()function support with optional counter style parameters
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime/native/shared/Css_types.ml | Adds new type definitions for symbols, counter styles, and enhanced attribute/counter support |
| packages/ppx/test/css-support/content.t/run.t | Updates test expectations to include new counter() and attr() function outputs |
| packages/ppx/test/css-support/content.t/input.re | Adds test cases for attr() and counter() CSS functions with various parameters |
| packages/ppx/src/Property_to_runtime.re | Implements rendering functions for attribute and counter CSS functions |
| packages/css-property-parser/ppx/Generate.re | Updates code generation to handle new CSS keywords and type mappings |
| packages/css-property-parser/lib/Standard.rei | Updates interface to return parsed string values instead of unit types |
| packages/css-property-parser/lib/Standard.re | Implements string token and identifier token parsing |
| packages/css-property-parser/lib/Parser.re | Adds comprehensive grammar definitions for attribute and counter CSS functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| {js|symbols(|js} | ||
| ^ Kloth.Array.map_and_join ~sep:{js|,|js} ~f:image_or_string_to_string | ||
| images | ||
| ^ {js|)|js} |
There was a problem hiding this comment.
The closing parenthesis is missing when symbols_type is Some. The code should append {js|)|js} in both branches of the match expression.
| } else { | ||
| let first = str.[0]; | ||
| let last = str.[length - 1]; | ||
| let first = get(str, 0); |
There was a problem hiding this comment.
[nitpick] The local variable get is unnecessary. It would be clearer to use String.get directly in the code rather than creating a local alias.
| [%e render_list_image_or_string(~loc, list_image_or_string)], | ||
| )) | ||
| ] | ||
| | None => [%expr |
There was a problem hiding this comment.
Missing tuple wrapping for the symbols variant when symbols_type is None. Should be (None, [%e render_list_image_or_string(~loc, list_image_or_string)]) to match the expected tuple structure.
| | None => [%expr | |
| `symbols(( | |
| None, | |
| [%e render_list_image_or_string(~loc, list_image_or_string)], | |
| )) |
| | "upper-latin" => [%expr `upperLatin] | ||
| | "lower-roman" => [%expr `lowerRoman] | ||
| | "upper-roman" => [%expr `upperRoman] | ||
| | "none" => [%expr `none] |
There was a problem hiding this comment.
The fallback case returns a string expression instead of a variant. This is inconsistent with other cases that return variants like disc, decimal, etc. Consider either removing the fallback or ensuring it returns an appropriate variant type.
| | "none" => [%expr `none] | |
| | _ => [%expr `Custom([%e render_string(~loc, label)])] /* fallback for unknown styles */ |
|
New nightly version has been published to the NPM registry: @davesnx/styled-ppx@0.56.1-34cb3d6.0. |
…yled-ppx into support-content-attr-element * 'support-content-attr-element' of github.com:/davesnx/styled-ppx: Remove useles polyvars on list-style-type
* Support attr() * Support counter * Support counter * Inline ppxlib, goodbye label * Remove old properties from ms * Remove useless code * Remove useles polyvars on list-style-type * Remove useles polyvars on list-style-type
No description provided.