@eldrajs/theme-cli 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/manifest.json +160 -132
  4. package/template/.eldra/previews.json +35 -35
  5. package/template/blocks/announcement-bar/preview.png +0 -0
  6. package/template/blocks/article/preview.png +0 -0
  7. package/template/blocks/article-list/preview.png +0 -0
  8. package/template/blocks/breadcrumbs/preview.png +0 -0
  9. package/template/blocks/cart/preview.png +0 -0
  10. package/template/blocks/collection-grid/preview.png +0 -0
  11. package/template/blocks/collection-header/preview.png +0 -0
  12. package/template/blocks/contact/preview.png +0 -0
  13. package/template/blocks/cta/preview.png +0 -0
  14. package/template/blocks/faq/preview.png +0 -0
  15. package/template/blocks/feature-grid/preview.png +0 -0
  16. package/template/blocks/footer/preview.png +0 -0
  17. package/template/blocks/form/preview.png +0 -0
  18. package/template/blocks/gallery/preview.png +0 -0
  19. package/template/blocks/hero/preview.png +0 -0
  20. package/template/blocks/image/preview.png +0 -0
  21. package/template/blocks/logo-cloud/preview.png +0 -0
  22. package/template/blocks/navigation/Block.vue +54 -11
  23. package/template/blocks/navigation/__tests__/Block.spec.ts +91 -8
  24. package/template/blocks/navigation/block.json +11 -3
  25. package/template/blocks/navigation/mock.json +134 -129
  26. package/template/blocks/navigation/preview.png +0 -0
  27. package/template/blocks/newsletter/preview.png +0 -0
  28. package/template/blocks/order-status/preview.png +0 -0
  29. package/template/blocks/pricing-table/preview.png +0 -0
  30. package/template/blocks/product-carousel/preview.png +0 -0
  31. package/template/blocks/product-detail/preview.png +0 -0
  32. package/template/blocks/quote/preview.png +0 -0
  33. package/template/blocks/rich-text/preview.png +0 -0
  34. package/template/blocks/search/preview.png +0 -0
  35. package/template/blocks/split-content/preview.png +0 -0
  36. package/template/blocks/stats/preview.png +0 -0
  37. package/template/blocks/tabs/preview.png +0 -0
  38. package/template/blocks/team/preview.png +0 -0
  39. package/template/blocks/testimonials/preview.png +0 -0
  40. package/template/blocks/timeline/preview.png +0 -0
  41. package/template/blocks/trust-strip/preview.png +0 -0
  42. package/template/blocks/video-embed/preview.png +0 -0
  43. package/template/blocks/wishlist/preview.png +0 -0
  44. package/template/package.json +1 -1
  45. package/template/public/images/bowl.webp +0 -0
  46. package/template/test/prerenderFailure.spec.ts +4 -3
  47. package/template/test/previewParity.browser.spec.ts +1152 -0
  48. package/template/test/starter.spec.ts +6 -1
  49. package/template/test/support/previewParity.ts +302 -0
  50. package/template/test/support/previewParityContent.ts +726 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,7 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - The scaffolded starter's header declares menu sections and product/collection cards on its `links` field and draws them (WS-1362): a mega panel column of cards, each a picture at 4:3, a title and a price. Its `navigation` block is version 5 with a `groupsToSections` migration, and its mock is sections; deploying it needs a cms-service that has `groupsToSections`, so deploy the platform first.
8
9
  - The starter template builds its pages in the store's default currency (`commerce.defaultCurrency`), and never offers the store's own currency once the store turned it off; a cart left in that currency moves to the default, and a business customer's cart stays in ISK (`currency.keepOwnCurrency()` for a theme with business sign-in) (WS-1399).
9
10
  - `eldra-theme types` asks the gateway for the `declare module '@eldrajs/sdk'` augmentation and
10
11
  writes it with the CMS types, so `product.extensions` is typed through the SDK's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-cli",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "CLI for Eldra themes: init from the starter, scaffold blocks, validate, generate types, deploy a static build to Eldra.",
5
5
  "keywords": [
6
6
  "cli",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "citty": "^0.1.6",
44
44
  "tar": "^7.4.3",
45
- "@eldrajs/theme-core": "^0.3.6",
46
- "@eldrajs/vite-plugin-theme": "^0.3.6"
45
+ "@eldrajs/theme-core": "^0.4.0",
46
+ "@eldrajs/vite-plugin-theme": "^0.4.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "execa": "^9.5.2"
@@ -3745,7 +3745,7 @@
3745
3745
  "description": "The store's top bar: brand, primary links with optional mega-menus, search, cart and one call to action.",
3746
3746
  "icon": "layout-navbar",
3747
3747
  "category": "structure",
3748
- "version": 4,
3748
+ "version": 5,
3749
3749
  "groups": [
3750
3750
  {
3751
3751
  "groupId": "brand",
@@ -3796,6 +3796,14 @@
3796
3796
  "label": "ctaLabel"
3797
3797
  }
3798
3798
  ]
3799
+ },
3800
+ {
3801
+ "version": 5,
3802
+ "groupsToSections": [
3803
+ {
3804
+ "field": "links"
3805
+ }
3806
+ ]
3799
3807
  }
3800
3808
  ],
3801
3809
  "fields": [
@@ -3844,7 +3852,7 @@
3844
3852
  "name": "Links",
3845
3853
  "type": "list",
3846
3854
  "groupId": "navigation",
3847
- "helpText": "Primary links. 3 to 6 recommended; more than 6 may overflow at 64–80rem. Give a link children to turn it into a mega-menu: consecutive children sharing the same Group form one column, in order — up to 4 groups × 8 links.",
3855
+ "helpText": "Primary links. 3 to 6 recommended; more than 6 may overflow at 64–80rem. Give a link a panel to turn it into a mega-menu: up to 4 columns, each with a heading, its links and a See all link. A column can hold up to 2 product or collection cards, a picture with a title and a price.",
3848
3856
  "metadata": {
3849
3857
  "item": {
3850
3858
  "fieldId": "link",
@@ -3852,7 +3860,22 @@
3852
3860
  "type": "link",
3853
3861
  "localized": true,
3854
3862
  "metadata": {
3855
- "tree": true,
3863
+ "tree": {
3864
+ "depth": 2,
3865
+ "sections": {
3866
+ "max": 4,
3867
+ "headingLink": true,
3868
+ "seeAll": true
3869
+ },
3870
+ "cards": {
3871
+ "kinds": [
3872
+ "product",
3873
+ "collection"
3874
+ ],
3875
+ "max": 2,
3876
+ "aspect": "4:3"
3877
+ }
3878
+ },
3856
3879
  "kinds": [
3857
3880
  "product",
3858
3881
  "collection",
@@ -3939,114 +3962,117 @@
3939
3962
  "slug": "knitwear"
3940
3963
  },
3941
3964
  "label": "Knitwear",
3942
- "children": [
3943
- {
3944
- "kind": "collection",
3945
- "target": {
3946
- "_type": "collection",
3947
- "slug": "womens-sweaters"
3948
- },
3949
- "group": "Women",
3950
- "label": "Sweaters"
3951
- },
3952
- {
3953
- "kind": "collection",
3954
- "target": {
3955
- "_type": "collection",
3956
- "slug": "womens-cardigans"
3957
- },
3958
- "group": "Women",
3959
- "label": "Cardigans"
3960
- },
3961
- {
3962
- "kind": "collection",
3963
- "target": {
3964
- "_type": "collection",
3965
- "slug": "scarves-wraps"
3966
- },
3967
- "group": "Women",
3968
- "label": "Scarves & wraps"
3969
- },
3965
+ "sections": [
3970
3966
  {
3971
- "kind": "collection",
3972
- "target": {
3973
- "_type": "collection",
3974
- "slug": "hats-gloves"
3975
- },
3976
- "group": "Women",
3977
- "label": "Hats & gloves"
3978
- },
3979
- {
3980
- "kind": "collection",
3981
- "target": {
3982
- "_type": "collection",
3983
- "slug": "mens-sweaters"
3984
- },
3985
- "group": "Men",
3986
- "label": "Sweaters"
3987
- },
3988
- {
3989
- "kind": "collection",
3990
- "target": {
3991
- "_type": "collection",
3992
- "slug": "mens-cardigans"
3993
- },
3994
- "group": "Men",
3995
- "label": "Cardigans"
3996
- },
3997
- {
3998
- "kind": "collection",
3999
- "target": {
4000
- "_type": "collection",
4001
- "slug": "mens-scarves"
4002
- },
4003
- "group": "Men",
4004
- "label": "Scarves"
4005
- },
4006
- {
4007
- "kind": "collection",
4008
- "target": {
4009
- "_type": "collection",
4010
- "slug": "socks"
4011
- },
4012
- "group": "Men",
4013
- "label": "Socks"
4014
- },
4015
- {
4016
- "kind": "collection",
4017
- "target": {
4018
- "_type": "collection",
4019
- "slug": "merino-essentials"
4020
- },
4021
- "group": "Collections",
4022
- "label": "Merino essentials"
4023
- },
4024
- {
4025
- "kind": "collection",
4026
- "target": {
4027
- "_type": "collection",
4028
- "slug": "heavy-winter-knits"
4029
- },
4030
- "group": "Collections",
4031
- "label": "Heavy winter knits"
3967
+ "heading": "Women",
3968
+ "links": [
3969
+ {
3970
+ "kind": "collection",
3971
+ "target": {
3972
+ "_type": "collection",
3973
+ "slug": "womens-sweaters"
3974
+ },
3975
+ "label": "Sweaters"
3976
+ },
3977
+ {
3978
+ "kind": "collection",
3979
+ "target": {
3980
+ "_type": "collection",
3981
+ "slug": "womens-cardigans"
3982
+ },
3983
+ "label": "Cardigans"
3984
+ },
3985
+ {
3986
+ "kind": "collection",
3987
+ "target": {
3988
+ "_type": "collection",
3989
+ "slug": "scarves-wraps"
3990
+ },
3991
+ "label": "Scarves & wraps"
3992
+ },
3993
+ {
3994
+ "kind": "collection",
3995
+ "target": {
3996
+ "_type": "collection",
3997
+ "slug": "hats-gloves"
3998
+ },
3999
+ "label": "Hats & gloves"
4000
+ }
4001
+ ]
4032
4002
  },
4033
4003
  {
4034
- "kind": "collection",
4035
- "target": {
4036
- "_type": "collection",
4037
- "slug": "undyed-wool"
4038
- },
4039
- "group": "Collections",
4040
- "label": "Undyed wool"
4004
+ "heading": "Men",
4005
+ "links": [
4006
+ {
4007
+ "kind": "collection",
4008
+ "target": {
4009
+ "_type": "collection",
4010
+ "slug": "mens-sweaters"
4011
+ },
4012
+ "label": "Sweaters"
4013
+ },
4014
+ {
4015
+ "kind": "collection",
4016
+ "target": {
4017
+ "_type": "collection",
4018
+ "slug": "mens-cardigans"
4019
+ },
4020
+ "label": "Cardigans"
4021
+ },
4022
+ {
4023
+ "kind": "collection",
4024
+ "target": {
4025
+ "_type": "collection",
4026
+ "slug": "mens-scarves"
4027
+ },
4028
+ "label": "Scarves"
4029
+ },
4030
+ {
4031
+ "kind": "collection",
4032
+ "target": {
4033
+ "_type": "collection",
4034
+ "slug": "socks"
4035
+ },
4036
+ "label": "Socks"
4037
+ }
4038
+ ]
4041
4039
  },
4042
4040
  {
4043
- "kind": "collection",
4044
- "target": {
4045
- "_type": "collection",
4046
- "slug": "knitwear"
4047
- },
4048
- "group": "Collections",
4049
- "label": "Shop all knitwear"
4041
+ "heading": "Collections",
4042
+ "links": [
4043
+ {
4044
+ "kind": "collection",
4045
+ "target": {
4046
+ "_type": "collection",
4047
+ "slug": "merino-essentials"
4048
+ },
4049
+ "label": "Merino essentials"
4050
+ },
4051
+ {
4052
+ "kind": "collection",
4053
+ "target": {
4054
+ "_type": "collection",
4055
+ "slug": "heavy-winter-knits"
4056
+ },
4057
+ "label": "Heavy winter knits"
4058
+ },
4059
+ {
4060
+ "kind": "collection",
4061
+ "target": {
4062
+ "_type": "collection",
4063
+ "slug": "undyed-wool"
4064
+ },
4065
+ "label": "Undyed wool"
4066
+ },
4067
+ {
4068
+ "kind": "collection",
4069
+ "target": {
4070
+ "_type": "collection",
4071
+ "slug": "knitwear"
4072
+ },
4073
+ "label": "Shop all knitwear"
4074
+ }
4075
+ ]
4050
4076
  }
4051
4077
  ]
4052
4078
  },
@@ -4057,33 +4083,35 @@
4057
4083
  "slug": "ceramics"
4058
4084
  },
4059
4085
  "label": "Ceramics",
4060
- "children": [
4086
+ "sections": [
4061
4087
  {
4062
- "kind": "collection",
4063
- "target": {
4064
- "_type": "collection",
4065
- "slug": "plates"
4066
- },
4067
- "group": "Tableware",
4068
- "label": "Plates"
4069
- },
4070
- {
4071
- "kind": "collection",
4072
- "target": {
4073
- "_type": "collection",
4074
- "slug": "bowls"
4075
- },
4076
- "group": "Tableware",
4077
- "label": "Bowls"
4078
- },
4079
- {
4080
- "kind": "collection",
4081
- "target": {
4082
- "_type": "collection",
4083
- "slug": "mugs-cups"
4084
- },
4085
- "group": "Tableware",
4086
- "label": "Mugs & cups"
4088
+ "heading": "Tableware",
4089
+ "links": [
4090
+ {
4091
+ "kind": "collection",
4092
+ "target": {
4093
+ "_type": "collection",
4094
+ "slug": "plates"
4095
+ },
4096
+ "label": "Plates"
4097
+ },
4098
+ {
4099
+ "kind": "collection",
4100
+ "target": {
4101
+ "_type": "collection",
4102
+ "slug": "bowls"
4103
+ },
4104
+ "label": "Bowls"
4105
+ },
4106
+ {
4107
+ "kind": "collection",
4108
+ "target": {
4109
+ "_type": "collection",
4110
+ "slug": "mugs-cups"
4111
+ },
4112
+ "label": "Mugs & cups"
4113
+ }
4114
+ ]
4087
4115
  }
4088
4116
  ]
4089
4117
  },
@@ -1,37 +1,37 @@
1
1
  {
2
- "announcement-bar": "c9afe3ca53192bd788e724048eb4fa66bbff19d93f1fefbc63aa4e396b1a1f71",
3
- "article": "46689140a4cc1e04b70bfa1c69fc8ac2ae8e5b0ce669e7a2c23157bb2ac79876",
4
- "article-list": "c99dbf56425ed57161d348b28f67a23dcb609d9cf9b602da2995baea584070d6",
5
- "breadcrumbs": "db7e456eec13ac6e6688fcd67b12cec63ffd876defdebd3085f28fdb5d8d6206",
6
- "cart": "ce507a5b1961646df5292f308a287732d13205ac9e32afddfc7d10fb4369cd98",
7
- "collection-grid": "9c4603f5de2891b3f066c0532bbb480003f7eb2ee1834475e2bd2097f149d57d",
8
- "collection-header": "e0f8c97068a4cfd20585d7c055244a1e078f52d9a6eef59373b09dfde7337bdc",
9
- "contact": "c8e558e99456095a7b3a0eb6baa06aa4ba2d246839bae123d769c88b8958ada8",
10
- "cta": "bb97e5de236bc8fb46bfd7fc8ac80a8b3167a21fa90dd2b728d843f72fc0e421",
11
- "faq": "5f9b2fbd25c28048d2f5c36c2fd2855f76011597bf1aa75e81e1316753a7eeba",
12
- "feature-grid": "5019b8af23b77e0cd1360dd021287923c462e26b42e065886c03fb111929dda0",
13
- "footer": "6dcbe2f7349c0a4dd51b47746c5f69466fa17cfefa63ee92e13e06be03c2c0a4",
14
- "form": "6ec0407c114b5de4490d9f691b13cab3657e3fcbf7e37ed20a7f86fce4c1c24e",
15
- "gallery": "d3fa5b835a1707e607410f7ca8e245c13ba4c8bc69b4c84485cc80b6d336f921",
16
- "hero": "62c6ad62978389ae977db134e7277b410e57f1143832013e97e1db820d114987",
17
- "image": "4b0bc804f063d947099f950bd0c09b98a07ea63f45ddfde51c9cd356c8c09587",
18
- "logo-cloud": "7e946206faffab98d73d692f326bc79f4100c6e4892eb63ed69ee61032545042",
19
- "navigation": "12363a34c5fd3593d91a912ba43352edb9347b1fda7e6b903baa2c39b0470682",
20
- "newsletter": "5718d21c8c234534ac97a911989fea31fbe7a7ffcdbf9069a290954476ecf386",
21
- "order-status": "1a7b4d108117fe7c67789adf9b55796364c16ab9c8f5ab652ac40d6c49d6f80e",
22
- "pricing-table": "43b16d3abea292d7878a2a2f86dc35a6a069d9fb934bdb601305ee9731afe020",
23
- "product-carousel": "70cc990a853c3ac33394e26cf071966ce2ce2c58e7254b5650f83c25b1402fa2",
24
- "product-detail": "3979ef86314e70d970befe738f1792888b2919055801539d5506f5f3f874de86",
25
- "quote": "d771f4097ca14d70320c90fd88c54d980a996c1fe43a4448ab10f89c2bfe6d3d",
26
- "rich-text": "6062e831392f12e805968882a0edbfde00dfd1296d00395a3e9a27492a242118",
27
- "search": "30c9627f44da0c88f289d63de62e639ed7553cea079dac5cbe5010acf058229a",
28
- "split-content": "a10b26c39b12e350ac1a16521c13bdd9ec0baf7581fc7fa1e1c8263307efc2c2",
29
- "stats": "22bbd1d98024ef1f2cf2e969fbe070bfda2b316d9319009721c6189384c7a43c",
30
- "tabs": "3f054548e97dac4f6f69782824abb020e191e28c229ed560f366651cd55dd2cf",
31
- "team": "532e5965c859aa33844e228f9be6329e635ecfa8cb5e1bd2af261b337377b593",
32
- "testimonials": "ce60546dba65fefea8403ede13b9b590ebf7650976b09cb5b1d0f4ca4b365c20",
33
- "timeline": "bfb25e247819c632e5f6e6ed79340f1ad54cd103883d0238e1ed6db94b4c5ca8",
34
- "trust-strip": "337c79080c4af9f784e151b6221ab21e63b4324de75b266c5f6af6f15964eb5d",
35
- "video-embed": "ff21253e4ad5abcc6d4b34ae930068f2493b1c404ab42608799dd70ce2c4481f",
36
- "wishlist": "a5994d9744219233dfa0ab5932507bb4a57599e1113466e759661074f7c16341"
2
+ "announcement-bar": "cb5f0c03d3ff5a608408dd73caae60d673528ba57cca559292c0217f5b55371e",
3
+ "article": "287384ce10758a8ca3019f0331cb51c392da915886b4ac67cb599c7743bd4e83",
4
+ "article-list": "aca0382d44cbd9b3989634bd863fe55e088cf617959e38dda9ee0c0ca17f7b68",
5
+ "breadcrumbs": "9537ded283e8a2fbc3ad9ae0d330e6ada4f18bcf59dd8f3f7a495bdbaf3501fc",
6
+ "cart": "701e89e63820b14a9fa5e3a2da9e9efd55fc151d5165a278dd9ab4971473dc2a",
7
+ "collection-grid": "1182dab25ac153ccc773b858c55264734f24c557c0ca1a70b90337cad17104e1",
8
+ "collection-header": "427a6703c5cc6c1a10632034f946f1bc79fd9ff99d107e26dac87d163068f78d",
9
+ "contact": "52d9c46ee78b5ad97cb85b063cbee8b878829468a3ec168c74195f18d4ff739e",
10
+ "cta": "692e6279827b7def0b4e38451c121059941a6bbf82ac8d75dd2d399abdc81169",
11
+ "faq": "eb07354f72cdc53484db949de18d4de609a720dda49169e8f12d4b49ed867060",
12
+ "feature-grid": "f80baa8c92a3e54a37683385995bcc2af4d5a8b8ee26fd9f6370b3f2b40b1409",
13
+ "footer": "9556050d0adde3ba38ba29a96efb3b381348f6a2447fa81a881663fd0cf6b70a",
14
+ "form": "75e0c7c42e701bd0c477df33b6604b318bf14e4ba860e25cf2dc498242a76e81",
15
+ "gallery": "aa7603b38a2fc91f362700ff4fc6e6a85095ef9542efcef69cf36e92e6ab9a63",
16
+ "hero": "5784dafe38c860aa48f7efaa60829af12cc98fab24eff6afe535742a79e445bb",
17
+ "image": "d05e60073be042bd55ed2243efff806e411263e45aea79c20c25318c655d9bf7",
18
+ "logo-cloud": "8c08fb404c587f419d8914e29bd520f4f4faedd3c9a23cdd33b31602b75dfce0",
19
+ "navigation": "7db1b690f9f9043626e8d917a9d3b602b5facc44e23e301961bd80df15875fd8",
20
+ "newsletter": "a1bcec0a512f8fcee3b8e92b1146fdbb99620625cdcc6b4a8715047f8775d892",
21
+ "order-status": "cdd505d94b2650d00548dd798fc16d4de466d24b68c18107c88134b96c5d4d5f",
22
+ "pricing-table": "e807254da0b2ff76f2a66ba2143f15244998ee911d47c3dc5d27dbdcfc3240ca",
23
+ "product-carousel": "3ffe2cb752712b40e2d721b1132c30e0bd5104fc0e1879d38d657bdad40a50cf",
24
+ "product-detail": "ef517359eff04b1303d69dffa04e4f06016dd5a06a4a4d39422300b16851a4d0",
25
+ "quote": "f5a205b691285faa47981418b5668c6b33f9d6426b8d63c153be209ca2151281",
26
+ "rich-text": "b37d0b974a66e417550eccbc3151fd70e7b58c80f62756231fe0c93228f8ffa2",
27
+ "search": "530a23a1108914114ed89b41d0153364e3b77c383c4e4900b6704ea007e0868f",
28
+ "split-content": "d211565a4765c12d6b99a1988e0494f3276cb00967f72f4f16b2620cd690342a",
29
+ "stats": "83bf41b6d029bfbcf662e5d151a4a38847cc7027eb399d722f97aa0eb88fef10",
30
+ "tabs": "575f13a6abd1f5e161f2b4ca0789ff8b662f1bf1faff7b1ce32c4731c434a535",
31
+ "team": "42ee4e323e80b821c5371d6d04f478de80b14b147bd9d6d854bfcb348c54e613",
32
+ "testimonials": "5f974a9b8294389276c4905b92b626b20d5bd561de0b01d0a3fe35970b29312c",
33
+ "timeline": "c058a395bb86d9cabb7cb9a40e8ee2f8ca0928b147745e025208197c42a23be3",
34
+ "trust-strip": "f2ac93c745c109060209430c8bd8b6b74a53c25eda0d6227057fa801fc1784e8",
35
+ "video-embed": "c1c3ee4da01b70aac86d371bcf488e7dea8a08e30d42ffde19904cf48f43dad6",
36
+ "wishlist": "aed7dd39c1190c5fb286b2ab2dcded2dff7d3bb21ecd85d5c1e74016c62c6335"
37
37
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -2,6 +2,7 @@
2
2
  /** Header (design spec 2); apiId stays `navigation`. Layout: docs/starter-kit.md, "The header". */
3
3
  import { computed, onMounted, ref, watchEffect } from 'vue';
4
4
  import { useEldraLink, useEldraLocale } from '@eldrajs/theme-vue';
5
+ import type { ResolvedLink, ResolvedSection } from '@eldrajs/theme-vue';
5
6
  import {
6
7
  Badge,
7
8
  Button,
@@ -15,7 +16,9 @@ import {
15
16
  } from '@eldrajs/ui';
16
17
  import type {
17
18
  NavMenuItem,
19
+ NavMenuLink,
18
20
  NavMenuPart,
21
+ NavMenuSection,
19
22
  SearchResultItem,
20
23
  SearchResults,
21
24
  UiMessages,
@@ -31,6 +34,7 @@ import { isInternalHref, SEARCH_PATH } from '../../app/utils/links';
31
34
  import { useMoney } from '../../app/storefront/money';
32
35
  import type { StorefrontSearchResponse } from '../../app/storefront/types';
33
36
  import MenuLink from './parts/MenuLink.vue';
37
+ import blockJson from './block.json';
34
38
 
35
39
  const props = defineProps<{ entry: EldraBlockEntry<'navigation'> }>();
36
40
  const { data } = useBlockData(props, 'navigation');
@@ -65,11 +69,50 @@ const links = computed(() =>
65
69
  })
66
70
  );
67
71
 
68
- /** A parent with children is a disclosure, so its own destination moves to the panel's "View all". */
72
+ /**
73
+ * The picture crop of a menu card: the `aspect` this block's own `links` field declares in
74
+ * `cards`, so the declaration and the drawing cannot drift. `NavMenu` falls back to 4:3 on a
75
+ * value that is not `width:height`.
76
+ */
77
+ const cardAspect = (
78
+ blockJson.fields.find((field) => field.fieldId === 'links') as
79
+ | { metadata?: { item?: { metadata?: { tree?: { cards?: { aspect?: string } } } } } }
80
+ | undefined
81
+ )?.metadata?.item?.metadata?.tree?.cards?.aspect;
82
+
83
+ /** A resolved link as the menu draws it, `display` and `card` (child and section links only) kept. */
84
+ function toNavLink(link: ResolvedLink): NavMenuLink {
85
+ return {
86
+ label: link.label,
87
+ href: link.href,
88
+ newTab: link.newTab,
89
+ group: link.group,
90
+ current: isCurrent(link.href),
91
+ display: link.display,
92
+ card: link.card,
93
+ };
94
+ }
95
+
96
+ function toNavSection(section: ResolvedSection): NavMenuSection {
97
+ return {
98
+ heading: section.heading,
99
+ headingLink: section.headingLink === null ? null : toNavLink(section.headingLink),
100
+ display: section.display,
101
+ links: section.links.map(toNavLink),
102
+ seeAll: section.seeAll === null ? null : toNavLink(section.seeAll),
103
+ };
104
+ }
105
+
106
+ /**
107
+ * A parent with a panel is a disclosure, so its own destination moves to the panel's "View all". The
108
+ * panel is its `sections` when the site served them (this block declares them), else its `children`
109
+ * grouped by their `group`, which is what a menu stored before sections existed still is.
110
+ */
69
111
  const navItems = computed<NavMenuItem[]>(() =>
70
112
  links.value.map((link) => {
113
+ const sections = link.sections ?? [];
71
114
  const children = link.children.filter((child) => child.label !== null);
72
- if (children.length === 0) {
115
+ if (sections.length === 0 && children.length === 0) {
73
116
  return {
74
117
  label: link.label,
75
118
  href: link.href,
@@ -80,13 +123,9 @@ const navItems = computed<NavMenuItem[]>(() =>
80
123
  return {
81
124
  label: link.label,
82
125
  layout: 'mega',
83
- children: children.map((child) => ({
84
- label: child.label,
85
- href: child.href,
86
- newTab: child.newTab,
87
- group: child.group,
88
- current: isCurrent(child.href),
89
- })),
126
+ ...(sections.length > 0
127
+ ? { sections: sections.map(toNavSection) }
128
+ : { children: children.map(toNavLink) }),
90
129
  };
91
130
  })
92
131
  );
@@ -668,8 +707,11 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
668
707
  panel: 'pt-0',
669
708
  content:
670
709
  'rounded-none rounded-b-lg border-t-0 bg-(--eldra-header-surface) shadow-(--eldra-shadow-float) @wide:p-8',
671
- columns: 'grid-cols-12 gap-6',
672
- group: 'col-span-3',
710
+ // Twelve columns, a link column three of them. A panel with a cards column is laid out in equal
711
+ // tracks instead: a link column is one, the cards column spans two (the design's ~1.7x).
712
+ columns:
713
+ 'grid-cols-12 gap-6 data-cards:grid-flow-col data-cards:auto-cols-fr data-cards:grid-cols-none',
714
+ group: 'col-span-3 [[data-cards]>&]:col-span-1 [[data-cards]>&[data-cards]]:col-span-2',
673
715
  footer: 'justify-end',
674
716
  drawerLink: 'font-heading text-xl font-semibold',
675
717
  drawerTrigger: 'font-heading text-xl font-semibold',
@@ -730,6 +772,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
730
772
  :collapse-below="variant === 'minimal' ? 'always' : '@content'"
731
773
  open-on-hover
732
774
  :link-as="MenuLink"
775
+ :card-aspect="cardAspect"
733
776
  :messages="navMenuMessages"
734
777
  class="static contents"
735
778
  :classes="navMenuClasses"