123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522(** Alignment utilities for flexbox and grid layouts
What's included:
- `justify-*` - Justify content, items, and self alignment.
- `items-*` - Align items in flex/grid containers.
- `content-*` - Align content in flex/grid containers.
- `self-*` - Align self in flex/grid items.
- `place-*` - Shorthand for align and justify.
What's not:
- Advanced grid alignment features not covered by basic flex/grid alignment.
- `-safe` on any position but `center` and `end`: Tailwind offers the
overflow-position suffix on those two alone, in every family.
Parsing contract (`of_string`):
- Accepts ["justify"; ...], ["items"; ...], ["content"; ...], ["self"; ...],
["place"; ...]. Unknown tokens yield `Error (`Msg "Not an alignment
utility")`. *)moduleCss=Cascade.CssmoduleHandler=structopenStyleopenCsstypet=|(* Justify content *)Justify_start|Justify_end|Justify_center|Justify_between|Justify_around|Justify_evenly|Justify_normal|Justify_stretch|Justify_center_safe|Justify_end_safe|(* Align items *)Items_start|Items_end|Items_center|Items_baseline|Items_stretch|Items_baseline_last|Items_center_safe|Items_end_safe|(* Align content *)Content_start|Content_end|Content_center|Content_between|Content_around|Content_evenly|Content_stretch|Content_baseline|Content_normal|Content_center_safe|Content_end_safe|(* Align self *)Self_auto|Self_start|Self_end|Self_center|Self_baseline|Self_baseline_last|Self_stretch|Self_center_safe|Self_end_safe|(* Justify items *)Justify_items_start|Justify_items_end|Justify_items_center|Justify_items_normal|Justify_items_stretch|Justify_items_center_safe|Justify_items_end_safe|(* Justify self *)Justify_self_auto|Justify_self_start|Justify_self_end|Justify_self_center|Justify_self_stretch|Justify_self_center_safe|Justify_self_end_safe|(* Place content *)Place_content_start|Place_content_end|Place_content_center|Place_content_between|Place_content_around|Place_content_evenly|Place_content_stretch|Place_content_baseline|Place_content_center_safe|Place_content_end_safe|(* Place items *)Place_items_start|Place_items_end|Place_items_center|Place_items_stretch|Place_items_baseline|Place_items_center_safe|Place_items_end_safe|(* Place self *)Place_self_auto|Place_self_start|Place_self_end|Place_self_center|Place_self_stretch|Place_self_center_safe|Place_self_end_safeletname="alignment"(* Same priority as gap (15), differentiated by suborder: - Container
alignment: suborder 0-999 (before gap's 25000+) - Self alignment: suborder
50000+ (after gap) *)(* Same priority as gap; comes after flex_props *)letpriority_=17letjustify_start=style[justify_contentFlex_start]letjustify_end=style[justify_contentFlex_end]letjustify_center=style[justify_contentCenter]letjustify_between=style[justify_contentSpace_between]letjustify_around=style[justify_contentSpace_around]letjustify_evenly=style[justify_contentSpace_evenly]letjustify_normal=style[justify_contentNormal]letjustify_stretch=style[justify_contentStretch]letjustify_center_safe=style[justify_contentSafe_center]letjustify_end_safe=style[justify_contentSafe_flex_end]letitems_start=style[align_itemsFlex_start]letitems_end=style[align_itemsFlex_end]letitems_center=style[align_itemsCenter]letitems_baseline=style[align_itemsBaseline]letitems_stretch=style[align_itemsStretch]letitems_baseline_last=style[align_itemsLast_baseline]letitems_center_safe=style[align_itemsSafe_center]letitems_end_safe=style[align_itemsSafe_flex_end]letcontent_start=style[align_contentFlex_start]letcontent_end=style[align_contentFlex_end]letcontent_center=style[align_contentCenter]letcontent_between=style[align_contentSpace_between]letcontent_around=style[align_contentSpace_around]letcontent_evenly=style[align_contentSpace_evenly]letcontent_stretch=style[align_contentStretch]letcontent_baseline=style[align_contentBaseline]letcontent_normal=style[align_contentNormal]letcontent_center_safe=style[align_contentSafe_center]letcontent_end_safe=style[align_contentSafe_flex_end]letself_auto=style[align_selfAuto]letself_start=style[align_selfFlex_start]letself_end=style[align_selfFlex_end]letself_center=style[align_selfCenter]letself_baseline=style[align_selfBaseline]letself_baseline_last=style[align_selfLast_baseline]letself_stretch=style[align_selfStretch]letself_center_safe=style[align_selfSafe_center]letself_end_safe=style[align_selfSafe_flex_end]letjustify_items_start=style[justify_itemsStart]letjustify_items_end=style[justify_itemsEnd]letjustify_items_center=style[justify_itemsCenter]letjustify_items_stretch=style[justify_itemsStretch]letjustify_items_normal=style[justify_itemsNormal]letjustify_items_center_safe=style[justify_itemsSafe_center]letjustify_items_end_safe=style[justify_itemsSafe_end]letjustify_self_auto=style[justify_selfAuto]letjustify_self_start=style[justify_selfFlex_start]letjustify_self_end=style[justify_selfFlex_end]letjustify_self_center=style[justify_selfCenter]letjustify_self_stretch=style[justify_selfStretch]letjustify_self_center_safe=style[justify_selfSafe_center]letjustify_self_end_safe=style[justify_selfSafe_flex_end]letplace_content_start=style[place_contentStart]letplace_content_end=style[place_contentEnd]letplace_content_center=style[place_contentCenter]letplace_content_between=style[place_contentSpace_between]letplace_content_around=style[place_contentSpace_around]letplace_content_evenly=style[place_contentSpace_evenly]letplace_content_stretch=style[place_contentStretch]letplace_content_baseline=style[place_content(Align_justify(Baseline,Start))]letplace_content_center_safe=style[place_contentSafe_center]letplace_content_end_safe=style[place_contentSafe_end]letplace_items_start=style[place_itemsStart]letplace_items_end=style[place_itemsEnd]letplace_items_center=style[place_itemsCenter]letplace_items_stretch=style[place_itemsStretch_stretch]letplace_items_baseline=style[place_itemsBaseline]letplace_items_center_safe=style[place_itemsCenter_safe]letplace_items_end_safe=style[place_itemsEnd_safe]letplace_self_auto=style[place_self(Auto,Auto)]letplace_self_start=style[place_self(Start,Start)]letplace_self_end=style[place_self(End,End)]letplace_self_center=style[place_self(Center,Center)]letplace_self_stretch=style[place_self(Stretch,Stretch)]letplace_self_center_safe=style[place_self(Safe_center,Safe_center)]letplace_self_end_safe=style[place_self(Safe_end,Safe_end)](* Class name, style and cascade suborder of one utility. Written as a match
rather than a lookup table: a constructor added to [t] without an entry
here is a compile error, not a [Not_found] raised out of [to_class] partway
through rendering a sheet. *)letdata:t->string*Style.t*int=function(* Justify content *)|Justify_start->("justify-start",justify_start,58)|Justify_end->("justify-end",justify_end,54)|Justify_center->("justify-center",justify_center,52)|Justify_between->("justify-between",justify_between,51)|Justify_around->("justify-around",justify_around,50)|Justify_evenly->("justify-evenly",justify_evenly,56)|Justify_normal->("justify-normal",justify_normal,57)|Justify_stretch->("justify-stretch",justify_stretch,59)|Justify_center_safe->("justify-center-safe",justify_center_safe,53)|Justify_end_safe->("justify-end-safe",justify_end_safe,55)(* Align items *)|Items_start->("items-start",items_start,36)|Items_end->("items-end",items_end,34)|Items_center->("items-center",items_center,32)|Items_baseline->("items-baseline",items_baseline,30)|Items_stretch->("items-stretch",items_stretch,38)|Items_baseline_last->("items-baseline-last",items_baseline_last,31)|Items_center_safe->("items-center-safe",items_center_safe,33)|Items_end_safe->("items-end-safe",items_end_safe,35)(* Align content *)|Content_start->("content-start",content_start,29)|Content_end->("content-end",content_end,25)|Content_center->("content-center",content_center,23)|Content_between->("content-between",content_between,22)|Content_around->("content-around",content_around,20)|Content_evenly->("content-evenly",content_evenly,27)|Content_stretch->("content-stretch",content_stretch,30)|Content_baseline->("content-baseline",content_baseline,21)|Content_normal->("content-normal",content_normal,28)|Content_center_safe->("content-center-safe",content_center_safe,24)|Content_end_safe->("content-end-safe",content_end_safe,26)(* Align self *)|Self_auto->("self-auto",self_auto,76010)|Self_start->("self-start",self_start,76017)|Self_end->("self-end",self_end,76015)|Self_center->("self-center",self_center,76013)|Self_baseline->("self-baseline",self_baseline,76011)|Self_baseline_last->("self-baseline-last",self_baseline_last,76012)|Self_stretch->("self-stretch",self_stretch,76019)|Self_center_safe->("self-center-safe",self_center_safe,76014)|Self_end_safe->("self-end-safe",self_end_safe,76016)(* Justify items *)|Justify_items_start->("justify-items-start",justify_items_start,74)|Justify_items_end->("justify-items-end",justify_items_end,72)|Justify_items_center->("justify-items-center",justify_items_center,70)|Justify_items_stretch->("justify-items-stretch",justify_items_stretch,75)|Justify_items_normal->("justify-items-normal",justify_items_normal,73)|Justify_items_center_safe->("justify-items-center-safe",justify_items_center_safe,71)|Justify_items_end_safe->("justify-items-end-safe",justify_items_end_safe,73)(* Justify self *)|Justify_self_auto->("justify-self-auto",justify_self_auto,76030)|Justify_self_start->("justify-self-start",justify_self_start,76035)|Justify_self_end->("justify-self-end",justify_self_end,76033)|Justify_self_center->("justify-self-center",justify_self_center,76031)|Justify_self_stretch->("justify-self-stretch",justify_self_stretch,76037)|Justify_self_center_safe->("justify-self-center-safe",justify_self_center_safe,76032)|Justify_self_end_safe->("justify-self-end-safe",justify_self_end_safe,76034)(* Place content *)|Place_content_start->("place-content-start",place_content_start,8)|Place_content_end->("place-content-end",place_content_end,5)|Place_content_center->("place-content-center",place_content_center,3)|Place_content_between->("place-content-between",place_content_between,2)|Place_content_around->("place-content-around",place_content_around,0)|Place_content_evenly->("place-content-evenly",place_content_evenly,7)|Place_content_stretch->("place-content-stretch",place_content_stretch,10)|Place_content_baseline->("place-content-baseline",place_content_baseline,1)|Place_content_center_safe->("place-content-center-safe",place_content_center_safe,4)|Place_content_end_safe->("place-content-end-safe",place_content_end_safe,6)(* Place items *)|Place_items_start->("place-items-start",place_items_start,15)|Place_items_end->("place-items-end",place_items_end,13)|Place_items_center->("place-items-center",place_items_center,11)|Place_items_stretch->("place-items-stretch",place_items_stretch,17)|Place_items_baseline->("place-items-baseline",place_items_baseline,10)|Place_items_center_safe->("place-items-center-safe",place_items_center_safe,12)|Place_items_end_safe->("place-items-end-safe",place_items_end_safe,14)(* Place self *)|Place_self_auto->("place-self-auto",place_self_auto,76000)|Place_self_start->("place-self-start",place_self_start,76005)|Place_self_end->("place-self-end",place_self_end,76003)|Place_self_center->("place-self-center",place_self_center,76001)|Place_self_stretch->("place-self-stretch",place_self_stretch,76006)|Place_self_center_safe->("place-self-center-safe",place_self_center_safe,76002)|Place_self_end_safe->("place-self-end-safe",place_self_end_safe,76004)(* Every constructor, for the class-name lookup. A missing entry costs a class
that no longer parses, which the round-trip test reports. *)letall=[(* Justify content *)Justify_start;Justify_end;Justify_center;Justify_between;Justify_around;Justify_evenly;Justify_normal;Justify_stretch;Justify_center_safe;Justify_end_safe;(* Align items *)Items_start;Items_end;Items_center;Items_baseline;Items_stretch;Items_baseline_last;Items_center_safe;Items_end_safe;(* Align content *)Content_start;Content_end;Content_center;Content_between;Content_around;Content_evenly;Content_stretch;Content_baseline;Content_normal;Content_center_safe;Content_end_safe;(* Align self *)Self_auto;Self_start;Self_end;Self_center;Self_baseline;Self_baseline_last;Self_stretch;Self_center_safe;Self_end_safe;(* Justify items *)Justify_items_start;Justify_items_end;Justify_items_center;Justify_items_stretch;Justify_items_normal;Justify_items_center_safe;Justify_items_end_safe;(* Justify self *)Justify_self_auto;Justify_self_start;Justify_self_end;Justify_self_center;Justify_self_stretch;Justify_self_center_safe;Justify_self_end_safe;(* Place content *)Place_content_start;Place_content_end;Place_content_center;Place_content_between;Place_content_around;Place_content_evenly;Place_content_stretch;Place_content_baseline;Place_content_center_safe;Place_content_end_safe;(* Place items *)Place_items_start;Place_items_end;Place_items_center;Place_items_stretch;Place_items_baseline;Place_items_center_safe;Place_items_end_safe;(* Place self *)Place_self_auto;Place_self_start;Place_self_end;Place_self_center;Place_self_stretch;Place_self_center_safe;Place_self_end_safe;]letto_classt=letcls,_,_=datatinclsletto_style_themet=let_,s,_=datatinsletsubordert=let_,_,o=datatinoletof_class_map=List.map(funt->(to_classt,t))allletof_class_themecls=matchList.assoc_optclsof_class_mapwith|Somet->Okt|None->Error(`Msg"Not an alignment utility")letexamples=[Justify_start;Justify_items_start;Justify_self_start;Items_start;Content_start;Self_start;Place_content_center;Place_items_start;Place_self_auto;]endopenHandlermoduleUtility_factory=Utility.Make(Handler)(** Register alignment handler with Utility system *)(** Public API *)letutility=Utility_factory.v(** {1 Justify Content Utilities} *)letjustify_start=utilityJustify_startletjustify_end=utilityJustify_endletjustify_center=utilityJustify_centerletjustify_between=utilityJustify_betweenletjustify_around=utilityJustify_aroundletjustify_evenly=utilityJustify_evenly(** {1 Align Items Utilities} *)letitems_start=utilityItems_startletitems_end=utilityItems_endletitems_center=utilityItems_centerletitems_baseline=utilityItems_baselineletitems_stretch=utilityItems_stretch(** {1 Align Content Utilities} *)letcontent_start=utilityContent_startletcontent_end=utilityContent_endletcontent_center=utilityContent_centerletcontent_between=utilityContent_betweenletcontent_around=utilityContent_aroundletcontent_evenly=utilityContent_evenlyletcontent_stretch=utilityContent_stretchletcontent_baseline=utilityContent_baselineletcontent_normal=utilityContent_normalletcontent_center_safe=utilityContent_center_safeletcontent_end_safe=utilityContent_end_safe(** {1 Align Self Utilities} *)letself_auto=utilitySelf_autoletself_start=utilitySelf_startletself_end=utilitySelf_endletself_center=utilitySelf_centerletself_baseline=utilitySelf_baselineletself_stretch=utilitySelf_stretch(** {1 Justify Items Utilities} *)letjustify_items_start=utilityJustify_items_startletjustify_items_end=utilityJustify_items_endletjustify_items_center=utilityJustify_items_centerletjustify_items_stretch=utilityJustify_items_stretchletjustify_items_normal=utilityJustify_items_normalletjustify_items_center_safe=utilityJustify_items_center_safeletjustify_items_end_safe=utilityJustify_items_end_safe(** {1 Justify Self Utilities} *)letjustify_self_auto=utilityJustify_self_autoletjustify_self_start=utilityJustify_self_startletjustify_self_end=utilityJustify_self_endletjustify_self_center=utilityJustify_self_centerletjustify_self_stretch=utilityJustify_self_stretch(** {1 Place Content Utilities} *)letplace_content_start=utilityPlace_content_startletplace_content_end=utilityPlace_content_endletplace_content_center=utilityPlace_content_centerletplace_content_between=utilityPlace_content_betweenletplace_content_around=utilityPlace_content_aroundletplace_content_evenly=utilityPlace_content_evenlyletplace_content_stretch=utilityPlace_content_stretch(** {1 Place Items Utilities} *)letplace_items_start=utilityPlace_items_startletplace_items_end=utilityPlace_items_endletplace_items_center=utilityPlace_items_centerletplace_items_stretch=utilityPlace_items_stretchletplace_items_baseline=utilityPlace_items_baselineletplace_items_center_safe=utilityPlace_items_center_safeletplace_items_end_safe=utilityPlace_items_end_safe(** {1 Place Self Utilities} *)letplace_self_auto=utilityPlace_self_autoletplace_self_start=utilityPlace_self_startletplace_self_end=utilityPlace_self_endletplace_self_center=utilityPlace_self_centerletplace_self_stretch=utilityPlace_self_stretchletplace_self_center_safe=utilityPlace_self_center_safeletplace_self_end_safe=utilityPlace_self_end_safe