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

Support moar properties #509

Merged
merged 35 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5d13486
game save 1
zakybilfagih Aug 19, 2024
dd70e86
game save 2
zakybilfagih Aug 19, 2024
84fc381
game save 3
zakybilfagih Aug 20, 2024
4e3fe60
game save 4
zakybilfagih Aug 20, 2024
4fbdcd3
game save 5
zakybilfagih Aug 20, 2024
7bb2429
grid auto flow interpolation
zakybilfagih Aug 21, 2024
8c3848a
game save 6
zakybilfagih Aug 21, 2024
7343471
game save 7
zakybilfagih Aug 21, 2024
e0c2500
game save 8
zakybilfagih Aug 21, 2024
fcc0b59
misc promote
zakybilfagih Aug 21, 2024
78962d5
remove nested value module include
zakybilfagih Aug 21, 2024
3408e25
cleanup transform origin
zakybilfagih Aug 22, 2024
10014e4
add more props
zakybilfagih Aug 22, 2024
b77c095
add Fun.id to Kloth
zakybilfagih Aug 24, 2024
a14ef9b
Merge branch 'main' into unsupported-values
zakybilfagih Jan 30, 2025
97a5e88
Merge branch 'main' into unsupported-values
zakybilfagih Jan 30, 2025
d811766
fix: typo translateProperty on scaleProperty
zakybilfagih Jan 30, 2025
b6934db
chore: add back fill
zakybilfagih Jan 30, 2025
912fa98
chore: move BgPosition module into BackgroundPosition
zakybilfagih Jan 31, 2025
2df5969
chore: update snapshot test for scaleProperty
zakybilfagih Jan 31, 2025
9537cb7
fix: render background position
zakybilfagih Jan 31, 2025
37dd14b
chore: make transition property a string, update how shorthand proper…
zakybilfagih Feb 1, 2025
8f151b6
fixes and new stuff
zakybilfagih Feb 3, 2025
b59bf36
chore: support bg size
zakybilfagih Feb 3, 2025
77659b4
chore: flatten display module and run make fmt
zakybilfagih Feb 3, 2025
f3447e0
Merge branch 'main' into unsupported-values
zakybilfagih Feb 4, 2025
e61ca38
chore: remove redundant exception pattern
zakybilfagih Feb 4, 2025
e6dd076
feat: better invalid_value error message
zakybilfagih Feb 4, 2025
35b4b08
chore: promote test
zakybilfagih Feb 4, 2025
461f435
feat: add impossible state exception
zakybilfagih Feb 4, 2025
2e1110c
chore: fix scale property pattern match
zakybilfagih Feb 4, 2025
2674fdb
feat: background-repeat multiple value support
zakybilfagih Feb 4, 2025
259ee3f
chore: promote test
zakybilfagih Feb 4, 2025
285d8a2
chore: handle one arg for list values
zakybilfagih Feb 4, 2025
c3bd24a
chore: remove redundant impossible state
zakybilfagih Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions packages/css-property-parser/lib/Parser.re
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ and bg_layer = [%value.rec
"<bg-image> || <bg-position> [ '/' <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>"
]
and bg_position = [%value.rec
"'left' | 'center' | 'right' | 'top' | 'bottom' | <extended-length> | <extended-percentage> | [ 'left' | 'center' | 'right' | <extended-length> | <extended-percentage> ] [ 'top' | 'center' | 'bottom' | <extended-length> | <extended-percentage> ] | [ 'center' | [ 'left' | 'right' ] [ <extended-length> | <extended-percentage> ]? ] && [ 'center' | [ 'top' | 'bottom' ] [ <extended-length> | <extended-percentage> ]? ]"
"[ 'left' | 'center' | 'right' | 'top' | 'bottom' | <length-percentage> ]
| [ 'left' | 'center' | 'right' | <length-percentage> ] [ 'top' | 'center' | 'bottom' | <length-percentage> ]
| [ 'center' | [ 'left' | 'right' ] <length-percentage>? ] && [ 'center' | [ 'top' | 'bottom' ] <length-percentage>? ]"
]
/* one_bg_size isn't part of the spec, helps us with Type generation */
and one_bg_size = [%value.rec
Expand Down Expand Up @@ -443,7 +445,7 @@ and gradient = [%value.rec
"<linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <-legacy-gradient>"
]
and grid_line = [%value.rec
"'auto' | <custom-ident> | <integer> && [ <custom-ident> ]? | 'span' && [ <integer> || <custom-ident> ]"
"<custom-ident-without-span-or-auto> | <integer> && [ <custom-ident-without-span-or-auto> ]? | 'span' && [ <integer> || <custom-ident-without-span-or-auto> ] | 'auto'"
]
and historical_lig_values = [%value.rec
"'historical-ligatures' | 'no-historical-ligatures'"
Expand Down Expand Up @@ -551,7 +553,10 @@ and paint = [%value.rec
"'none' | <color> | <url> [ 'none' | <color> ]? | 'context-fill' | 'context-stroke' | <interpolation>"
]
and position = [%value.rec
"[ 'left' | 'center' | 'right' ] || [ 'top' | 'center' | 'bottom' ] | [ 'left' | 'center' | 'right' | <extended-length> | <extended-percentage> ] [ 'top' | 'center' | 'bottom' | <extended-length> | <extended-percentage> ]? | [ 'left' | 'right' ] [<extended-length> | <extended-percentage>] && [ 'top' | 'bottom' ] [<extended-length> | <extended-percentage>]"
"[ 'left' | 'center' | 'right' | 'top' | 'bottom' | <length-percentage> ]
| [ 'left' | 'center' | 'right' ] && [ 'top' | 'center' | 'bottom' ]
| [ 'left' | 'center' | 'right' | <length-percentage> ] [ 'top' | 'center' | 'bottom' | <length-percentage> ]
| [ [ 'left' | 'right' ] <length-percentage> ] && [ [ 'top' | 'bottom' ] <length-percentage> ]"
]
and positive_integer = [%value.rec "<integer>"]
and property__moz_appearance = [%value.rec
Expand Down Expand Up @@ -1107,7 +1112,7 @@ and property_font_stretch = [%value.rec "<font-stretch-absolute>"]
and property_font_style = [%value.rec
"'normal' | 'italic' | 'oblique' | <interpolation> | [ 'oblique' <extended-angle> ]?"
]
and property_font_synthesis = [%value.rec "'none' | 'weight' || 'style'"]
and property_font_synthesis = [%value.rec "'none' | [ 'weight' || 'style' || 'small-caps' || 'position' ]"]
and property_font_synthesis_weight = [%value.rec "'auto' | 'none'"]
and property_font_synthesis_style = [%value.rec "'auto' | 'none'"]
and property_font_synthesis_small_caps = [%value.rec "'auto' | 'none'"]
Expand Down Expand Up @@ -1144,11 +1149,13 @@ and property_gap = [%value.rec "<'row-gap'> [ <'column-gap'> ]?"]
and property_glyph_orientation_horizontal = [%value.rec "<extended-angle>"]
and property_glyph_orientation_vertical = [%value.rec "<extended-angle>"]
and property_grid = [%value.rec
"<'grid-template'> | <'grid-template-rows'> '/' [ 'auto-flow' && [ 'dense' ]? ] [ <'grid-auto-columns'> ]? | [ 'auto-flow' && [ 'dense' ]? ] [ <'grid-auto-rows'> ]? '/' <'grid-template-columns'>"
"<'grid-template'>
| <'grid-template-rows'> '/' [ 'auto-flow' && [ 'dense' ]? ] [ <'grid-auto-columns'> ]?
| [ 'auto-flow' && [ 'dense' ]? ] [ <'grid-auto-rows'> ]? '/' <'grid-template-columns'>"
]
and property_grid_area = [%value.rec "<grid-line> [ '/' <grid-line> ]{0,3}"]
and property_grid_auto_columns = [%value.rec "[ <track-size> ]+"]
and property_grid_auto_flow = [%value.rec "[ 'row' | 'column' ] || 'dense'"]
and property_grid_auto_flow = [%value.rec "[ [ 'row' | 'column' ] || 'dense' ] | <interpolation>"]
and property_grid_auto_rows = [%value.rec "[ <track-size> ]+"]
and property_grid_column = [%value.rec "<grid-line> [ '/' <grid-line> ]?"]
and property_grid_column_end = [%value.rec "<grid-line>"]
Expand All @@ -1168,12 +1175,12 @@ and property_grid_row_start = [%value.rec "<grid-line>"]
and property_grid_template = [%value.rec
"'none' | <'grid-template-rows'> '/' <'grid-template-columns'> | [ [ <line-names> ]? <string> [ <track-size> ]? [ <line-names> ]? ]+ [ '/' <explicit-track-list> ]?"
]
and property_grid_template_areas = [%value.rec "'none' | [ <string> ]+"]
and property_grid_template_areas = [%value.rec "'none' | [ <string> | <interpolation> ]+"]
and property_grid_template_columns = [%value.rec
"'none' | <track-list> | <auto-track-list> | 'subgrid' [ <line-name-list> ]? | <interpolation>"
"'none' | <track-list> | <auto-track-list> | 'subgrid' [ <line-name-list> ]? | 'masonry' | <interpolation>"
]
and property_grid_template_rows = [%value.rec
"'none' | <track-list> | <auto-track-list> | 'subgrid' [ <line-name-list> ]? | <interpolation>"
"'none' | <track-list> | <auto-track-list> | 'subgrid' [ <line-name-list> ]? | 'masonry' | <interpolation>"
]
and property_hanging_punctuation = [%value.rec
"'none' | 'first' || [ 'force-end' | 'allow-end' ] || 'last'"
Expand Down Expand Up @@ -1313,6 +1320,7 @@ and property_mask_position = [%value.rec "[ <position> ]#"]
and property_mask_repeat = [%value.rec "[ <repeat-style> ]#"]
and property_mask_size = [%value.rec "[ <bg-size> ]#"]
and property_mask_type = [%value.rec "'luminance' | 'alpha'"]
and property_masonry_auto_flow = [%value.rec "[ 'pack' | 'next' ] || [ 'definite-first' | 'ordered' ]"]
and property_max_block_size = [%value.rec "<'max-width'>"]
and property_max_height = [%value.rec
"'auto' | <extended-length> | <extended-percentage> | 'min-content' | 'max-content' | 'fit-content' | fit-content( <extended-length> | <extended-percentage> )"
Expand Down Expand Up @@ -1407,19 +1415,18 @@ and property_overflow_anchor = [%value.rec "'auto' | 'none'"]
and property_overflow_block = [%value.rec
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto' | <interpolation>"
]
and property_overflow_clip_box = [%value.rec "'padding-box' | 'content-box'"]
and property_overflow_clip_margin = [%value.rec "<box> || <extended-length>"]
and property_overflow_clip_margin = [%value.rec "<visual-box> || <extended-length>"]
and property_overflow_inline = [%value.rec
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto' | <interpolation>"
]
and property_overflow_wrap = [%value.rec
"'normal' | 'break-word' | 'anywhere'"
]
and property_overflow_x = [%value.rec
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto'"
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto' | <interpolation>"
]
and property_overflow_y = [%value.rec
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto'"
"'visible' | 'hidden' | 'clip' | 'scroll' | 'auto' | <interpolation>"
]
and property_overscroll_behavior = [%value.rec
"[ 'contain' | 'none' | 'auto' ]{1,2}"
Expand Down Expand Up @@ -1512,7 +1519,7 @@ and property_ruby_merge = [%value.rec "'separate' | 'collapse' | 'auto'"]
and property_ruby_position = [%value.rec
"'over' | 'under' | 'inter-character'"
]
and property_scale = [%value.rec "'none' | [ <number> ]{1,3}"]
and property_scale = [%value.rec "'none' | [ <number-percentage> ]{1,3}"]
and property_scroll_behavior = [%value.rec "'auto' | 'smooth'"]
and property_scroll_margin = [%value.rec "[ <extended-length> ]{1,4}"]
and property_scroll_margin_block = [%value.rec "[ <extended-length> ]{1,2}"]
Expand Down Expand Up @@ -1635,7 +1642,7 @@ and property_text_combine_upright = [%value.rec
"'none' | 'all' | 'digits' [ <integer> ]?"
]
and property_text_decoration = [%value.rec
"[ <'text-decoration-line'>] [<'text-decoration-style'>]? [<'text-decoration-color'>]?"
"<'text-decoration-color'> || <'text-decoration-style'> || <'text-decoration-thickness'> || <'text-decoration-line'>"
]
and property_text_justify_trim = [%value.rec "'none' | 'all' | 'auto'"]
and property_text_kashida = [%value.rec
Expand All @@ -1647,7 +1654,7 @@ and property_text_decoration_color = [%value.rec "<color>"]
/* and this definition has changed from the origianl, it might be a bug on the spec or our Generator,
but simplifying to "|" simplifies it and solves the bug */
and property_text_decoration_line = [%value.rec
"'none' | <interpolation> | [ 'underline' | 'overline' | 'line-through' | 'blink' ]{1,2}"
"'none' | <interpolation> | [ 'underline' || 'overline' || 'line-through' || 'blink' ]"
]
and property_text_decoration_skip = [%value.rec
"'none' | 'objects' || [ 'spaces' | 'leading-spaces' || 'trailing-spaces' ] || 'edges' || 'box-decoration'"
Expand Down Expand Up @@ -1717,20 +1724,22 @@ and property_transform_box = [%value.rec
"'content-box' | 'border-box' | 'fill-box' | 'stroke-box' | 'view-box'"
]
and property_transform_origin = [%value.rec
"<extended-length> | <extended-percentage> | 'left' | 'center' | 'right' | 'top' | 'bottom' | [ [ <extended-length> | <extended-percentage> | 'left' | 'center' | 'right' ] && [ <extended-length> | <extended-percentage> | 'top' | 'center' | 'bottom' ] ] [ <extended-length> ]?"
"[ 'left' | 'center' | 'right' | 'top' | 'bottom' | <length-percentage> ]
| [ 'left' | 'center' | 'right' | <length-percentage> ] [ 'top' | 'center' | 'bottom' | <length-percentage> ] <length>?
| [[ 'center' | 'left' | 'right' ] && [ 'center' | 'top' | 'bottom' ]] <length>? "
]
and property_transform_style = [%value.rec "'flat' | 'preserve-3d'"]
and property_transition = [%value.rec
"[ <single-transition> | <single-transition-no-interp> ]# | <interpolation>"
"[ <single-transition> | <single-transition-no-interp> ]#"
]
and property_transition_delay = [%value.rec "[ <extended-time> ]#"]
and property_transition_duration = [%value.rec "[ <extended-time> ]#"]
and property_transition_property = [%value.rec
"'none' | [ <single-transition-property> ]#"
"[ <single-transition-property> ]# | 'none'"
]
and property_transition_timing_function = [%value.rec "[ <timing-function> ]#"]
and property_translate = [%value.rec
"'none' | <extended-length> | <extended-percentage> [ <extended-length> | <extended-percentage> [ <extended-length> ]? ]?"
"'none' | <length-percentage> [ <length-percentage> <length>? ]?"
]
and property_unicode_bidi = [%value.rec
"'normal' | 'embed' | 'isolate' | 'bidi-override' | 'isolate-override' | 'plaintext' | '-moz-isolate' | '-moz-isolate-override' | '-moz-plaintext' | '-webkit-isolate'"
Expand Down Expand Up @@ -1848,7 +1857,8 @@ and single_transition_no_interp = [%value.rec
"[ <single-transition-property-no-interp> | 'none' ] || <extended-time-no-interp> || <timing-function-no-interp> || <extended-time-no-interp>"
]
and single_transition = [%value.rec
"[ [<single-transition-property> | 'none'] <extended-time> ]
"[<single-transition-property> | 'none']
| [ [<single-transition-property> | 'none'] <extended-time> ]
| [ [<single-transition-property> | 'none'] <extended-time> <timing-function> ]
| [ [<single-transition-property> | 'none'] <extended-time> <timing-function> <extended-time> ]"
]
Expand Down Expand Up @@ -1955,6 +1965,7 @@ and type_selector = [%value.rec "<wq-name> | [ <ns-prefix> ]? '*'"]
and viewport_length = [%value.rec
"'auto' | <extended-length> | <extended-percentage>"
]
and visual_box = [%value.rec "'content-box' | 'padding-box' | 'border-box'"]
and wq_name = [%value.rec "[ <ns-prefix> ]? <ident-token>"]
and x = [%value.rec "<number>"]
and y = [%value.rec "<number>"];
Expand Down Expand Up @@ -3041,6 +3052,7 @@ let check_map =
("property-mask-repeat", check(property_mask_repeat)),
("property-mask-size", check(property_mask_size)),
("property-mask-type", check(property_mask_type)),
("property-masonry-auto-flow", check(property_masonry_auto_flow)),
("property-max-block-size", check(property_max_block_size)),
("property-max-height", check(property_max_height)),
("property-max-inline-size", check(property_max_inline_size)),
Expand Down Expand Up @@ -3070,7 +3082,6 @@ let check_map =
("property-overflow", check(property_overflow)),
("property-overflow-anchor", check(property_overflow_anchor)),
("property-overflow-block", check(property_overflow_block)),
("property-overflow-clip-box", check(property_overflow_clip_box)),
("property-overflow-clip-margin", check(property_overflow_clip_margin)),
("property-overflow-inline", check(property_overflow_inline)),
("property-overflow-wrap", check(property_overflow_wrap)),
Expand Down
12 changes: 12 additions & 0 deletions packages/css-property-parser/lib/Standard.re
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ let flex_value =
| _ => Error(["expected flex_value"]),
);

let custom_ident_without_span_or_auto =
token(
fun
| IDENT("auto")
| STRING("auto")
| IDENT("span")
| STRING("span") => Error(["custom ident cannot be span or auto"])
| IDENT(string) => Ok(string)
| STRING(string) => Ok(string)
| _ => Error(["expected an identifier"]),
);

// TODO: workarounds
let invalid = expect(STRING("not-implemented"));
let attr_name = invalid;
Expand Down
1 change: 1 addition & 0 deletions packages/css-property-parser/lib/Standard.rei
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ let css_wide_keywords:
Rule.rule([> | `Inherit | `Initial | `Revert | `RevertLayer | `Unset]);

let custom_ident: Rule.rule(string);
let custom_ident_without_span_or_auto: Rule.rule(string);

let dashed_ident: Rule.rule(string);

Expand Down
1 change: 1 addition & 0 deletions packages/css-property-parser/ppx/Generate.re
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ module Make = (Builder: Ppxlib.Ast_builder.S) => {
type_("percentage", [%type: float]),
type_("ident", [%type: string]),
type_("custom_ident", [%type: string]),
type_("custom_ident_without_span_or_auto", [%type: string]),
// abstract_type("string"), already represented by OCaml string type
type_("url", [%type: string]),
type_("hex_color", [%type: string]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module Types = {
and percentage = float
and ident = string
and custom_ident = string
and custom_ident_without_span_or_auto = string
and url = string
and hex_color = string
and interpolation = list(string)
Expand Down
Loading
Loading