fulldev-ui 0.6.0-beta.2 → 0.6.0-beta.3

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 (183) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/Banner1.astro +35 -0
  3. package/src/blocks/Contact1.astro +92 -0
  4. package/src/blocks/Cta1.astro +72 -0
  5. package/src/blocks/Feature1.astro +67 -0
  6. package/src/blocks/Footer.astro +47 -54
  7. package/src/blocks/Header1.astro +192 -0
  8. package/src/blocks/Hero1.astro +74 -0
  9. package/src/blocks/Intro1.astro +56 -0
  10. package/src/blocks/Products1.astro +90 -0
  11. package/src/blocks/{Hero.astro → _Hero.astro} +7 -6
  12. package/src/components/Badge.astro +10 -18
  13. package/src/components/Banner.astro +26 -0
  14. package/src/components/Block.astro +49 -0
  15. package/src/components/Blocks.astro +26 -0
  16. package/src/components/Button.astro +10 -23
  17. package/src/components/Card.astro +8 -150
  18. package/src/components/Cart.astro +1 -0
  19. package/src/components/CartSummary.astro +3 -3
  20. package/src/components/Channel.astro +5 -14
  21. package/src/components/Container.astro +25 -0
  22. package/src/components/Drawer.astro +57 -118
  23. package/src/components/DrawerOld.astro +143 -0
  24. package/src/components/Element.astro +2 -0
  25. package/src/components/Form.astro +5 -3
  26. package/src/components/Head.astro +18 -32
  27. package/src/components/Header.astro +8 -105
  28. package/src/components/Heading.astro +29 -70
  29. package/src/components/Icon.astro +6 -4
  30. package/src/components/Link.astro +12 -18
  31. package/src/components/Logo.astro +31 -18
  32. package/src/components/Navigation.astro +39 -0
  33. package/src/components/Panel.astro +25 -0
  34. package/src/components/Paragraph.astro +24 -7
  35. package/src/components/Price.astro +4 -4
  36. package/src/components/Prose.astro +41 -132
  37. package/src/components/Rating.astro +24 -75
  38. package/src/components/Search.astro +4 -3
  39. package/src/components/Section.astro +20 -29
  40. package/src/components/Sidebar.astro +44 -64
  41. package/src/components/Social.astro +9 -2
  42. package/src/components/Tagline.astro +21 -31
  43. package/src/components/Toc.astro +12 -3
  44. package/src/components/_Author.astro +90 -0
  45. package/src/components/_Header.astro +129 -0
  46. package/src/components/_Prose copy.astro +172 -0
  47. package/src/components/_Sidebar copy.astro +87 -0
  48. package/src/content/categories/category.md +7 -0
  49. package/src/content/config.ts +7 -8
  50. package/src/content/docs/components/text.mdx +47 -0
  51. package/src/content/docs/components.mdx +1 -4
  52. package/src/content/docs/index.mdx +1 -4
  53. package/src/content/layouts/base.yml +41 -80
  54. package/src/content/layouts/docs.yml +2 -70
  55. package/src/content/pages/index.mdx +17 -25
  56. package/src/content/{categories/mugs.md → posts/post.md} +1 -1
  57. package/src/content/products/product.md +3 -3
  58. package/src/css/theme.css +2 -0
  59. package/src/images/favicon/android-chrome-192x192.png +0 -0
  60. package/src/images/favicon/android-chrome-512x512.png +0 -0
  61. package/src/images/favicon/apple-touch-icon.png +0 -0
  62. package/src/images/favicon/browserconfig.xml +9 -0
  63. package/src/images/favicon/favicon-16x16.png +0 -0
  64. package/src/images/favicon/favicon-32x32.png +0 -0
  65. package/src/images/favicon/favicon-48x48.png +0 -0
  66. package/src/images/favicon/favicon.ico +0 -0
  67. package/src/images/favicon/favicon.svg +16 -0
  68. package/src/images/favicon/manifest.webmanifest +30 -0
  69. package/src/images/favicon/mstile-150x150.png +0 -0
  70. package/src/images/favicon/safari-pinned-tab.svg +16 -0
  71. package/src/images/favicon/yandex-browser-50x50.png +0 -0
  72. package/src/images/favicon/yandex-browser-manifest.json +9 -0
  73. package/src/integration/index.ts +10 -1
  74. package/src/layouts/CategoryLayout.astro +16 -9
  75. package/src/layouts/DocLayout.astro +49 -7
  76. package/src/layouts/Layout.astro +55 -27
  77. package/src/layouts/PageLayout.astro +12 -5
  78. package/src/layouts/PostLayout.astro +7 -5
  79. package/src/layouts/ProductLayout.astro +12 -7
  80. package/src/pages/test.astro +7 -1
  81. package/src/schemas/blocks/banner.ts +10 -0
  82. package/src/schemas/blocks/categories.ts +14 -0
  83. package/src/schemas/blocks/contact.ts +18 -0
  84. package/src/schemas/blocks/cta.ts +18 -0
  85. package/src/schemas/blocks/feature.ts +18 -0
  86. package/src/schemas/blocks/hero.ts +20 -0
  87. package/src/schemas/blocks/intro.ts +16 -0
  88. package/src/schemas/blocks/products.ts +14 -0
  89. package/src/schemas/categorySchema.ts +8 -8
  90. package/src/schemas/components/avatar.ts +4 -1
  91. package/src/schemas/components/badge.ts +16 -11
  92. package/src/schemas/components/block.ts +18 -0
  93. package/src/schemas/components/button.ts +13 -19
  94. package/src/schemas/components/channel.ts +15 -9
  95. package/src/schemas/components/footer.ts +15 -14
  96. package/src/schemas/components/head.ts +17 -0
  97. package/src/schemas/components/header.ts +19 -16
  98. package/src/schemas/components/heading.ts +7 -1
  99. package/src/schemas/components/icon.ts +7 -1
  100. package/src/schemas/components/image.ts +17 -14
  101. package/src/schemas/components/link.ts +10 -16
  102. package/src/schemas/components/logo.ts +12 -2
  103. package/src/schemas/components/menu.ts +11 -13
  104. package/src/schemas/components/navigation.ts +10 -0
  105. package/src/schemas/components/paragraph.ts +9 -0
  106. package/src/schemas/components/price.ts +9 -0
  107. package/src/schemas/components/rating.ts +8 -13
  108. package/src/schemas/components/sidebar.ts +14 -12
  109. package/src/schemas/components/social.ts +16 -1
  110. package/src/schemas/components/tagline.ts +7 -1
  111. package/src/schemas/docSchema.ts +6 -2
  112. package/src/schemas/imageSchema.ts +30 -1
  113. package/src/schemas/layoutSchema.ts +14 -20
  114. package/src/schemas/pageSchema.ts +9 -12
  115. package/src/schemas/postSchema.ts +6 -8
  116. package/src/schemas/productSchema.ts +18 -18
  117. package/src/types/global-props.ts +0 -9
  118. package/src/types/{virtual-modules.d.ts → virtual.d.ts} +1 -1
  119. package/src/utils/getHref.ts +3 -2
  120. package/tsconfig.json +1 -3
  121. package/example.svelte +0 -0
  122. package/parent.svelte +0 -0
  123. package/src/App.svelte +0 -0
  124. package/src/blocks/Banner.astro +0 -35
  125. package/src/blocks/Categories.astro +0 -12
  126. package/src/blocks/Colleagues.astro +0 -12
  127. package/src/blocks/Contact.astro +0 -117
  128. package/src/blocks/Content.astro +0 -130
  129. package/src/blocks/Cta.astro +0 -13
  130. package/src/blocks/Excerpt.astro +0 -12
  131. package/src/blocks/Features.astro +0 -11
  132. package/src/blocks/Header.astro +0 -7
  133. package/src/blocks/Intro.astro +0 -101
  134. package/src/blocks/Jobs.astro +0 -12
  135. package/src/blocks/Posts.astro +0 -11
  136. package/src/blocks/Prices.astro +0 -24
  137. package/src/blocks/Product.astro +0 -89
  138. package/src/blocks/Products.astro +0 -101
  139. package/src/blocks/Reviews.astro +0 -12
  140. package/src/blocks/_Contact.astro +0 -112
  141. package/src/components/CartForm.astro +0 -120
  142. package/src/components/CartList.astro +0 -122
  143. package/src/components/Lead.astro +0 -46
  144. package/src/components/ProductCard.astro +0 -52
  145. package/src/components/Text.astro +0 -43
  146. package/src/components/Writeup.astro +0 -108
  147. package/src/components/_CartList backup.astro +0 -125
  148. package/src/components/_CartList copy.astro +0 -213
  149. package/src/components/_CartListSimple.astro +0 -148
  150. package/src/components/sections.astro +0 -28
  151. package/src/content/docs/components/lead.mdx +0 -49
  152. package/src/content/docs/components/paragraph.mdx +0 -49
  153. package/src/loaders/imageLoader.ts +0 -26
  154. package/src/schemas/archive/_pageSchema.ts +0 -94
  155. package/src/schemas/components/avatars.ts +0 -4
  156. package/src/schemas/components/banner.ts +0 -3
  157. package/src/schemas/components/buttons.ts +0 -4
  158. package/src/schemas/components/card.ts +0 -43
  159. package/src/schemas/components/cards.ts +0 -4
  160. package/src/schemas/components/channels.ts +0 -4
  161. package/src/schemas/components/global.ts +0 -16
  162. package/src/schemas/components/links.ts +0 -4
  163. package/src/schemas/components/list.ts +0 -3
  164. package/src/schemas/components/section.ts +0 -17
  165. package/src/schemas/components/sections.ts +0 -3
  166. package/src/schemas/components/socials.ts +0 -4
  167. package/src/schemas/components/subheader.ts +0 -10
  168. package/src/schemas/components/text.ts +0 -3
  169. package/src/schemas/components/themer.ts +0 -3
  170. package/src/schemas/components/toc.ts +0 -3
  171. package/src/schemas/components/writeup.ts +0 -20
  172. package/src/schemas/fields/categories.ts +0 -3
  173. package/src/schemas/fields/description.ts +0 -3
  174. package/src/schemas/fields/href.ts +0 -3
  175. package/src/schemas/fields/image.ts +0 -24
  176. package/src/schemas/fields/images.ts +0 -4
  177. package/src/schemas/fields/order.ts +0 -3
  178. package/src/schemas/fields/price.ts +0 -3
  179. package/src/schemas/fields/products.ts +0 -5
  180. package/src/schemas/fields/seo.ts +0 -12
  181. package/src/schemas/fields/soldout.ts +0 -3
  182. package/src/schemas/fields/title.ts +0 -3
  183. package/src/schemas/fields/variants.ts +0 -3
@@ -1,11 +0,0 @@
1
- ---
2
- import Section from 'fulldev-ui/components/Section.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <Section
8
- class:list="features"
9
- structure="stack"
10
- {...rest}
11
- />
@@ -1,7 +0,0 @@
1
- ---
2
- import HeaderComponent from 'fulldev-ui/components/Header.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <HeaderComponent {...rest} />
@@ -1,101 +0,0 @@
1
- ---
2
- import type { ComponentProps, HTMLAttributes, HTMLTag } from 'astro/types'
3
- import Badge from 'fulldev-ui/components/Badge.astro'
4
- import Breadcrumb from 'fulldev-ui/components/Breadcrumb.astro'
5
- import Buttons from 'fulldev-ui/components/Buttons.astro'
6
- import Element from 'fulldev-ui/components/Element.astro'
7
- import Heading from 'fulldev-ui/components/Heading.astro'
8
- import Image from 'fulldev-ui/components/Image.astro'
9
- import Lead from 'fulldev-ui/components/Lead.astro'
10
- import Paragraph from 'fulldev-ui/components/Paragraph.astro'
11
- import Rating from 'fulldev-ui/components/Rating.astro'
12
- import Tagline from 'fulldev-ui/components/Tagline.astro'
13
-
14
- interface Props extends HTMLAttributes<'section'> {
15
- rating?: ComponentProps<typeof Rating> | undefined
16
- badge?: ComponentProps<typeof Badge> | undefined
17
- tagline?: ComponentProps<typeof Tagline>['text']
18
- heading?: ComponentProps<typeof Heading>['text']
19
- lead?: ComponentProps<typeof Lead>['text']
20
- paragraph?: ComponentProps<typeof Paragraph>['text']
21
- buttons?: ComponentProps<typeof Buttons>['buttons']
22
- image?: ComponentProps<typeof Image>['id']
23
- level?: ComponentProps<typeof Heading>['level']
24
- as?: HTMLTag
25
- size?: 'sm' | 'md' | 'lg' | undefined
26
- variant?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined
27
- }
28
-
29
- const {
30
- as = 'section',
31
- size = 'lg',
32
- variant = 1,
33
- level = 1,
34
- slug,
35
- rating,
36
- tagline,
37
- badge,
38
- heading,
39
- lead,
40
- paragraph,
41
- buttons,
42
- image,
43
- ...rest
44
- } = Astro.props
45
- ---
46
-
47
- <Element
48
- class:list="intro"
49
- {as}
50
- {size}
51
- {variant}
52
- {...rest}
53
- >
54
- <Element class:list="intro-container">
55
- <Element class:list="intro-content">
56
- <!-- <Breadcrumb {slug} /> -->
57
- <Heading
58
- text={heading}
59
- as="h1"
60
- level={3}
61
- {size}
62
- />
63
- <Paragraph
64
- text={paragraph}
65
- {size}
66
- />
67
- </Element>
68
- <slot />
69
- </Element>
70
- </Element>
71
-
72
- <style is:global>
73
- @layer fulldev {
74
- .intro {
75
- @apply relative w-full;
76
-
77
- .intro-container {
78
- @apply flex h-full w-full flex-col;
79
- }
80
-
81
- .intro-content {
82
- @apply flex max-w-screen-md flex-col gap-6;
83
- }
84
-
85
- &.dark {
86
- @apply bg-background;
87
- }
88
-
89
- /* Background left */
90
- &.variant-1 {
91
- .intro-container {
92
- @apply container justify-center py-16;
93
- }
94
-
95
- .intro-image {
96
- @apply absolute inset-0 h-full w-full object-cover opacity-30;
97
- }
98
- }
99
- }
100
- }
101
- </style>
@@ -1,12 +0,0 @@
1
- ---
2
- import Section from 'fulldev-ui/components/Section.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <Section
8
- class:list="jobs"
9
- structure="grid"
10
- panel
11
- {...rest}
12
- />
@@ -1,11 +0,0 @@
1
- ---
2
- import Section from 'fulldev-ui/components/Section.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <Section
8
- class:list="posts"
9
- structure="grid"
10
- {...rest}
11
- />
@@ -1,24 +0,0 @@
1
- ---
2
- import Section from 'fulldev-ui/components/Section.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <Section
8
- class:list="prices"
9
- structure="stack"
10
- panel
11
- {...rest}
12
- />
13
-
14
- <style is:global >
15
- @layer fulldev {
16
- .prices {
17
- .card {
18
- .wrap {
19
- margin-top: auto;
20
- }
21
- }
22
- }
23
- }
24
- </style>
@@ -1,89 +0,0 @@
1
- <!-- ---
2
- import { getImage } from 'astro:assets'
3
- import CartForm from 'fulldev-ui/components/CartForm.astro'
4
- import Element from 'fulldev-ui/components/Element.astro'
5
- import Gallery from 'fulldev-ui/components/Gallery.astro'
6
- import Heading from 'fulldev-ui/components/Heading.astro'
7
- import List from 'fulldev-ui/components/List.astro'
8
- import Paragraph from 'fulldev-ui/components/Paragraph.astro'
9
-
10
- const {
11
- as = 'section',
12
- size = 'md',
13
- variant = 1,
14
- level = 1,
15
- heading,
16
- paragraph,
17
- title,
18
- list,
19
- price,
20
- images,
21
- text,
22
- subheading,
23
- variants,
24
- button,
25
- description,
26
- form,
27
- uitverkocht,
28
- ...rest
29
- } = Astro.props
30
-
31
- const slug = Astro.url.pathname.replace(/^\/|\/$/g, '') || 'index'
32
- const imageId = images?.[0]?.id
33
- const src = `/src/images/${imageId}`
34
- const allImages = import.meta.glob<{ default: ImageMetadata }>('/src/images/*')
35
- const foundImage = allImages[src]
36
- const gotImage =
37
- imageId && (await getImage({ src: foundImage ? foundImage() : src }))
38
- ---
39
-
40
- <Element
41
- class:list="product"
42
- {as}
43
- {size}
44
- {...rest}
45
- >
46
- <Element class:list="product-container">
47
- <Gallery {images} />
48
- <Element class:list="product-segment">
49
- <Element class:list="product-content">
50
- <Heading
51
- {level}
52
- text={heading || title}
53
- />
54
- <Paragraph text={paragraph || description} />
55
- <List items={list} />
56
- </Element>
57
- <CartForm
58
- soldout={uitverkocht}
59
- image={gotImage?.src}
60
- {title}
61
- {price}
62
- {slug}
63
- {variants}
64
- />
65
- </Element>
66
- </Element>
67
- </Element>
68
-
69
- <style is:global>
70
- .product {
71
- @apply relative w-full;
72
-
73
- .product-container {
74
- @apply container flex h-full w-full flex-col gap-16 py-8 lg:grid lg:grid-cols-[3fr_2fr];
75
- }
76
-
77
- .product-segment {
78
- @apply z-10 flex flex-col items-start gap-8;
79
- }
80
-
81
- .product-content {
82
- @apply flex max-w-screen-md flex-col gap-6;
83
- }
84
-
85
- &.dark {
86
- @apply bg-background;
87
- }
88
- }
89
- </style> -->
@@ -1,101 +0,0 @@
1
- ---
2
- import type { ComponentProps, HTMLAttributes } from 'astro/types'
3
- import type { CollectionEntry } from 'astro:content'
4
- import Button from 'fulldev-ui/components/Button.astro'
5
- import Buttons from 'fulldev-ui/components/Buttons.astro'
6
- import Element from 'fulldev-ui/components/Element.astro'
7
- import Heading from 'fulldev-ui/components/Heading.astro'
8
- import Image from 'fulldev-ui/components/Image.astro'
9
- import Price from 'fulldev-ui/components/Price.astro'
10
-
11
- interface Props extends HTMLAttributes<'section'> {
12
- heading?: ComponentProps<typeof Heading>['text']
13
- button?: ComponentProps<typeof Buttons> | undefined
14
- products?: CollectionEntry<'products'>[]
15
- }
16
-
17
- const { heading, button, products, ...rest } = Astro.props
18
- ---
19
-
20
- <Element
21
- class:list="products"
22
- if={products?.length}
23
- as="section"
24
- {...rest}
25
- >
26
- <Element class:list="products-container">
27
- <Element class:list="products-segment">
28
- <Heading
29
- level={2}
30
- size="sm"
31
- text={heading}
32
- />
33
- <Button
34
- variant="ghost"
35
- size="sm"
36
- {...button}
37
- />
38
- </Element>
39
- <Element class:list="products-cards">
40
- {
41
- products?.map(({ slug, data }) => (
42
- <Element
43
- class:list="products-card"
44
- as="a"
45
- href={`/producten/${slug}/`}
46
- >
47
- <Image
48
- class:list="products-card-image"
49
- {...data.images?.[0]}
50
- />
51
- <Element class:list="products-card-content">
52
- <Heading
53
- as="h3"
54
- level={5}
55
- size={'sm'}
56
- text={data.title}
57
- />
58
- <Price value={data.price} />
59
- </Element>
60
- </Element>
61
- ))
62
- }
63
- </Element>
64
- </Element>
65
- </Element>
66
-
67
- <style is:global>
68
- @layer fulldev {
69
- .products {
70
- @apply relative w-full py-16;
71
-
72
- .products-container {
73
- @apply container flex flex-col gap-8;
74
- }
75
-
76
- .products-segment {
77
- @apply flex items-center justify-between gap-8;
78
- }
79
-
80
- .products-cards {
81
- @apply grid grid-cols-2 items-start gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6;
82
- }
83
-
84
- .products-card {
85
- @apply relative flex flex-col gap-3;
86
-
87
- &:hover > .image {
88
- @apply opacity-75 transition-opacity;
89
- }
90
-
91
- .image {
92
- @apply rounded-md border;
93
- }
94
- }
95
-
96
- .products-card-content {
97
- @apply flex h-full flex-col gap-2;
98
- }
99
- }
100
- }
101
- </style>
@@ -1,12 +0,0 @@
1
- ---
2
- import Section from 'fulldev-ui/components/Section.astro'
3
-
4
- const { ...rest } = Astro.props
5
- ---
6
-
7
- <Section
8
- class:list="reviews"
9
- structure="masonry"
10
- panel
11
- {...rest}
12
- />
@@ -1,112 +0,0 @@
1
- ---
2
- import Button from 'fulldev-ui/components/Button.astro'
3
- import Buttons from 'fulldev-ui/components/Buttons.astro'
4
- import Channels from 'fulldev-ui/components/Channels.astro'
5
- import Element from 'fulldev-ui/components/Element.astro'
6
- import Form from 'fulldev-ui/components/Form.astro'
7
- import Heading from 'fulldev-ui/components/Heading.astro'
8
- import Image from 'fulldev-ui/components/Image.astro'
9
- import Input from 'fulldev-ui/components/Input.astro'
10
- import Section from 'fulldev-ui/components/Section.astro'
11
- import Socials from 'fulldev-ui/components/Socials.astro'
12
- import Tagline from 'fulldev-ui/components/Tagline.astro'
13
- import Text from 'fulldev-ui/components/Text.astro'
14
- import Textarea from 'fulldev-ui/components/Textarea.astro'
15
-
16
- const {
17
- heading,
18
- form,
19
- text,
20
- tagline,
21
- googleMaps,
22
- buttons,
23
- socials,
24
- position,
25
- image,
26
- channels,
27
- level = 1,
28
- ...rest
29
- } = Astro.props
30
- ---
31
-
32
- <Section
33
- class:list="contact"
34
- structure="split"
35
- {...rest}
36
- >
37
- <Element class:list="column">
38
- <Tagline text={tagline} />
39
- <Heading
40
- size={'sm'}
41
- level={level}
42
- text={heading}
43
- />
44
- <Text text={text} />
45
- <Buttons {buttons} />
46
- <Channels {channels} />
47
- <Socials {socials} />
48
- <Form
49
- action="/thank-you"
50
- method="POST"
51
- >
52
- {
53
- form.fields.map((field: any) => {
54
- if (field.type === 'textarea') {
55
- return (
56
- <Textarea
57
- label={field.label}
58
- id={field.name}
59
- name={field.name}
60
- required={field.required}
61
- />
62
- )
63
- }
64
- return (
65
- <Input
66
- label={field.label}
67
- id={field.name}
68
- name={field.name}
69
- type={field.type}
70
- required={field.required}
71
- />
72
- )
73
- })
74
- }
75
- <Button
76
- type="submit"
77
- variant="primary"
78
- text={form.button}
79
- />
80
- </Form>
81
- </Element>
82
-
83
- <Image
84
- {position}
85
- {...image}
86
- />
87
- </Section>
88
-
89
- <style is:global>
90
- @layer fulldev {
91
- .oldcontact {
92
- .column {
93
- display: flex;
94
- flex-direction: column;
95
- align-items: flex-start;
96
- }
97
-
98
- > .column {
99
- gap: var(--space-5);
100
- }
101
-
102
- .channel + .channel {
103
- margin-top: var(--space-3) !important;
104
- }
105
-
106
- .socials {
107
- display: flex;
108
- gap: var(--space-2);
109
- }
110
- }
111
- }
112
- </style>
@@ -1,120 +0,0 @@
1
- ---
2
- import type { CollectionEntry } from 'astro:content'
3
- import Button from 'fulldev-ui/components/Button.astro'
4
- import Input from 'fulldev-ui/components/Input.astro'
5
- import Select from 'fulldev-ui/components/Select.astro'
6
- import { capitalize } from 'radash'
7
- import { scope } from 'simple:scope'
8
- import Element from './Element.astro'
9
- import Form from './Form.astro'
10
- import Price from './Price.astro'
11
-
12
- interface Props {
13
- product: CollectionEntry<'products'>
14
- }
15
-
16
- const { slug, data } = Astro.props.product
17
-
18
- const src = data.images?.[0]?.src || `/${data.images?.[0]?.id}`
19
- ---
20
-
21
- <RootElement data={{ variants: Object.keys(data.variants || {}) }}>
22
- <Form
23
- class:list="cart-form"
24
- data-target={scope('form')}
25
- >
26
- <Input
27
- name="slug"
28
- type="hidden"
29
- value={slug}
30
- />
31
- <Input
32
- name="title"
33
- type="hidden"
34
- value={data.title}
35
- />
36
- <Input
37
- name="price"
38
- type="hidden"
39
- value={data.price}
40
- />
41
- <Input
42
- name="image"
43
- type="hidden"
44
- value={Astro.site && (Astro.site.href + src).replace('//', '/')}
45
- />
46
- {
47
- Object.entries(data.variants ?? {}).map(([key, options]) => (
48
- <Select
49
- name={key}
50
- label={capitalize(key)}
51
- name={key}
52
- options={options}
53
- disabled={data.soldout}
54
- />
55
- ))
56
- }
57
- <Price value={data.price} />
58
- <Element class:list="inputs">
59
- <Input
60
- class:list="quantity-input"
61
- name="quantity"
62
- type="number"
63
- min={1}
64
- value={1}
65
- />
66
- <Button
67
- variant="primary"
68
- type="submit"
69
- class="cart-add"
70
- text={data.soldout ? 'Uitverkocht' : 'Toevoegen aan winkelwagen'}
71
- disabled={data.soldout}
72
- />
73
- </Element>
74
- </Form>
75
- </RootElement>
76
-
77
- <script>
78
- import { addItem, openCart } from 'fulldev-ui/stores/cart.ts'
79
-
80
- RootElement.ready(($, ctx) => {
81
- $('form').addEventListener('submit', async (e) => {
82
- if (!(e.target instanceof HTMLFormElement)) return
83
- e.preventDefault()
84
-
85
- const formData = new FormData(e.target)
86
- const object = Object.fromEntries(formData.entries())
87
- const formatted = {
88
- slug: String(object['slug']),
89
- title: String(object['title']),
90
- price: Number(object['price']),
91
- quantity: Number(object['quantity']),
92
- image: String(object['image']),
93
- variants: ctx.data.variants.map((key: string) => object[key]),
94
- }
95
-
96
- addItem(formatted)
97
- openCart()
98
- })
99
- })
100
- </script>
101
-
102
- <style is:global>
103
- @layer fulldev {
104
- .cart-form {
105
- @apply flex flex-col gap-4;
106
-
107
- .inputs {
108
- @apply flex gap-2;
109
- }
110
-
111
- .quantity-input {
112
- @apply w-16;
113
- }
114
-
115
- .price-input {
116
- @apply hidden;
117
- }
118
- }
119
- }
120
- </style>