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

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 (175) hide show
  1. package/astro.config.ts +10 -2
  2. package/example.svelte +0 -0
  3. package/package.json +12 -7
  4. package/parent.svelte +0 -0
  5. package/pnpm-lock.yaml +301 -35
  6. package/src/App.svelte +0 -0
  7. package/src/blocks/Products.astro +53 -72
  8. package/src/components/Card.astro +2 -2
  9. package/src/components/Cart.astro +12 -3
  10. package/src/components/CartAdd.svelte +76 -0
  11. package/src/components/CartCheckout.svelte +58 -0
  12. package/src/components/CartForm.astro +87 -88
  13. package/src/components/CartForm.svelte +130 -0
  14. package/src/components/CartList.astro +84 -79
  15. package/src/components/CartList.svelte +88 -0
  16. package/src/components/CartQuantity.svelte +81 -0
  17. package/src/components/CartSummary.astro +8 -94
  18. package/src/components/CartTotal.svelte +15 -0
  19. package/src/components/Dialog.astro +1 -0
  20. package/src/components/Drawer.astro +1 -0
  21. package/src/components/Gallery.astro +3 -1
  22. package/src/components/Header.astro +2 -0
  23. package/src/components/Image.astro +2 -2
  24. package/src/components/Input.astro +17 -9
  25. package/src/components/ProductCard.astro +52 -0
  26. package/src/components/Prose.astro +1 -1
  27. package/src/components/Search.astro +106 -43
  28. package/src/components/Section.astro +11 -269
  29. package/src/components/Select.astro +1 -0
  30. package/src/components/_CartList backup.astro +125 -0
  31. package/src/components/_CartList copy.astro +213 -0
  32. package/src/components/_CartListSimple.astro +148 -0
  33. package/src/content/categories/mugs.md +7 -0
  34. package/src/content/config.ts +24 -4
  35. package/src/content/{pages/docs → docs}/_internationalization.mdx +0 -1
  36. package/src/content/{pages/docs → docs}/_using-blocks.mdx +0 -1
  37. package/src/content/{pages/docs → docs}/_using-presets.mdx +0 -1
  38. package/src/content/{pages/docs → docs}/blocks.mdx +0 -1
  39. package/src/content/{pages/docs → docs}/collections/images.mdx +3 -2
  40. package/src/content/{pages/docs → docs}/collections/pages.mdx +0 -1
  41. package/src/content/{pages/docs → docs}/collections/presets.mdx +0 -1
  42. package/src/content/{pages/docs → docs}/collections.mdx +0 -1
  43. package/src/content/{pages/docs → docs}/components/_card.mdx +0 -2
  44. package/src/content/{pages/docs → docs}/components/_dialog.mdx +0 -2
  45. package/src/content/{pages/docs → docs}/components/_drawer.mdx +0 -2
  46. package/src/content/{pages/docs → docs}/components/_localeswitcher.mdx +0 -2
  47. package/src/content/{pages/docs → docs}/components/_switch.mdx +0 -2
  48. package/src/content/{pages/docs → docs}/components/_tagline.mdx +0 -2
  49. package/src/content/{pages/docs → docs}/components/_toggle.mdx +0 -2
  50. package/src/content/{pages/docs → docs}/components/avatar.mdx +0 -2
  51. package/src/content/{pages/docs → docs}/components/badge.mdx +0 -2
  52. package/src/content/{pages/docs → docs}/components/badges.mdx +0 -2
  53. package/src/content/{pages/docs → docs}/components/button.mdx +0 -2
  54. package/src/content/{pages/docs → docs}/components/buttons.mdx +0 -2
  55. package/src/content/{pages/docs → docs}/components/channel.mdx +0 -2
  56. package/src/content/{pages/docs → docs}/components/channels.mdx +0 -2
  57. package/src/content/{pages/docs → docs}/components/checkbox.mdx +0 -2
  58. package/src/content/{pages/docs → docs}/components/code.mdx +0 -2
  59. package/src/content/{pages/docs → docs}/components/heading.mdx +0 -2
  60. package/src/content/{pages/docs → docs}/components/icon.mdx +0 -2
  61. package/src/content/{pages/docs → docs}/components/image.mdx +0 -2
  62. package/src/content/{pages/docs → docs}/components/input.mdx +0 -2
  63. package/src/content/{pages/docs → docs}/components/label.mdx +0 -2
  64. package/src/content/{pages/docs → docs}/components/lead.mdx +0 -2
  65. package/src/content/{pages/docs → docs}/components/link.mdx +0 -2
  66. package/src/content/{pages/docs → docs}/components/links.mdx +0 -2
  67. package/src/content/{pages/docs → docs}/components/list.mdx +0 -2
  68. package/src/content/{pages/docs → docs}/components/logo.mdx +0 -2
  69. package/src/content/{pages/docs → docs}/components/menu.mdx +0 -2
  70. package/src/content/{pages/docs → docs}/components/paragraph.mdx +0 -2
  71. package/src/content/{pages/docs → docs}/components/prose.mdx +0 -2
  72. package/src/content/{pages/docs → docs}/components/rating.mdx +0 -2
  73. package/src/content/{pages/docs → docs}/components/section.mdx +0 -2
  74. package/src/content/{pages/docs → docs}/components/select.mdx +0 -2
  75. package/src/content/{pages/docs → docs}/components/social.mdx +0 -2
  76. package/src/content/{pages/docs → docs}/components/socials.mdx +0 -2
  77. package/src/content/{pages/docs → docs}/components/switch.mdx +0 -2
  78. package/src/content/{pages/docs → docs}/components/table.mdx +0 -2
  79. package/src/content/{pages/docs → docs}/components/tagline.mdx +0 -2
  80. package/src/content/{pages/docs → docs}/components/textarea.mdx +0 -2
  81. package/src/content/{pages/docs → docs}/components/themer.mdx +0 -2
  82. package/src/content/{pages/docs → docs}/components.mdx +0 -1
  83. package/src/content/{pages/docs → docs}/customization.mdx +0 -1
  84. package/src/content/{pages/docs → docs}/frameworks.mdx +0 -1
  85. package/src/content/{pages/docs → docs}/generating-pages.mdx +0 -1
  86. package/src/content/{pages/docs → docs}/index.mdx +0 -1
  87. package/src/content/{pages/docs → docs}/installation.mdx +0 -1
  88. package/src/content/{pages/docs → docs}/layouts.mdx +0 -1
  89. package/src/content/layouts/base.yml +101 -0
  90. package/src/content/layouts/docs.yml +70 -0
  91. package/src/content/pages/blocks/_categories.mdx +0 -2
  92. package/src/content/pages/blocks/_footer.mdx +0 -2
  93. package/src/content/pages/blocks/_header.mdx +0 -2
  94. package/src/content/pages/blocks/_jobs.mdx +0 -2
  95. package/src/content/pages/blocks/_prices.mdx +0 -2
  96. package/src/content/pages/blocks/_product.mdx +0 -2
  97. package/src/content/pages/blocks/_products.mdx +0 -2
  98. package/src/content/pages/blocks/_stats.mdx +0 -2
  99. package/src/content/pages/blocks/banner.mdx +0 -2
  100. package/src/content/pages/blocks/colleagues.mdx +0 -2
  101. package/src/content/pages/blocks/contact.mdx +0 -2
  102. package/src/content/pages/blocks/content.mdx +0 -2
  103. package/src/content/pages/blocks/cta.mdx +0 -2
  104. package/src/content/pages/blocks/features.mdx +0 -2
  105. package/src/content/pages/blocks/hero.mdx +0 -2
  106. package/src/content/pages/blocks/intro.mdx +0 -2
  107. package/src/content/pages/blocks/posts.mdx +0 -2
  108. package/src/content/pages/blocks/reviews.mdx +0 -2
  109. package/src/content/pages/index.mdx +0 -2
  110. package/src/content/pages/showcase/anti-slip-profiles.md +2 -2
  111. package/src/content/pages/showcase/fulldev-ui.md +1 -1
  112. package/src/content/pages/showcase/lavis-detailing.md +1 -1
  113. package/src/content/pages/showcase/leren-trainingsacteren.md +1 -1
  114. package/src/content/pages/showcase/miele-witgoedcenter-amsterdam.md +1 -1
  115. package/src/content/pages/showcase/sloepverhuur-bolsward.md +1 -1
  116. package/src/content/pages/showcase/stark-vulcanising-products.md +1 -1
  117. package/src/content/pages/showcase/the-gym-haren.md +1 -1
  118. package/src/content/pages/showcase/van-dillen-antieke-bouwmaterialen.md +1 -1
  119. package/src/content/pages/showcase.mdx +0 -1
  120. package/src/content/products/product.md +20 -0
  121. package/src/env.d.ts +1 -0
  122. package/src/integration/index.ts +20 -8
  123. package/src/layouts/CategoryLayout.astro +12 -17
  124. package/src/layouts/DocLayout.astro +17 -0
  125. package/src/layouts/Layout.astro +11 -40
  126. package/src/layouts/PageLayout.astro +6 -12
  127. package/src/layouts/PostLayout.astro +6 -12
  128. package/src/layouts/ProductLayout.astro +28 -33
  129. package/src/pages/[...category].astro +17 -0
  130. package/src/pages/[...doc].astro +17 -0
  131. package/src/pages/[...page].astro +6 -25
  132. package/src/pages/[...post].astro +17 -0
  133. package/src/pages/[...product].astro +17 -0
  134. package/src/pages/test.astro +1 -16
  135. package/src/schemas/archive/_pageSchema.ts +94 -0
  136. package/src/schemas/categorySchema.ts +16 -0
  137. package/src/schemas/components/banner.ts +3 -0
  138. package/src/schemas/components/card.ts +1 -1
  139. package/src/schemas/components/footer.ts +1 -0
  140. package/src/schemas/components/header.ts +1 -0
  141. package/src/schemas/components/link.ts +21 -14
  142. package/src/schemas/components/section.ts +2 -0
  143. package/src/schemas/components/sections.ts +1 -1
  144. package/src/schemas/components/sidebar.ts +1 -0
  145. package/src/schemas/components/subheader.ts +1 -0
  146. package/src/schemas/components/writeup.ts +1 -1
  147. package/src/schemas/docSchema.ts +10 -0
  148. package/src/schemas/fields/categories.ts +3 -0
  149. package/src/schemas/fields/description.ts +3 -0
  150. package/src/schemas/fields/href.ts +3 -0
  151. package/src/schemas/fields/image.ts +24 -0
  152. package/src/schemas/fields/images.ts +4 -0
  153. package/src/schemas/fields/order.ts +3 -0
  154. package/src/schemas/fields/price.ts +3 -0
  155. package/src/schemas/fields/products.ts +5 -0
  156. package/src/schemas/fields/seo.ts +12 -0
  157. package/src/schemas/fields/soldout.ts +3 -0
  158. package/src/schemas/{components/price.ts → fields/title.ts} +1 -1
  159. package/src/schemas/fields/variants.ts +3 -0
  160. package/src/schemas/layoutSchema.ts +28 -0
  161. package/src/schemas/pageSchema.ts +12 -86
  162. package/src/schemas/postSchema.ts +16 -0
  163. package/src/schemas/productSchema.ts +22 -0
  164. package/src/stores/cart.svelte.ts +79 -0
  165. package/src/stores/cart.ts +59 -6
  166. package/src/utils/formatEntries.ts +8 -0
  167. package/src/utils/formatEntry.ts +29 -0
  168. package/src/utils/getHref.ts +22 -0
  169. package/svelte.config.js +5 -0
  170. package/src/content/presets/base.yml +0 -100
  171. package/src/content/presets/docs.yml +0 -6
  172. package/src/schemas/components/images.ts +0 -4
  173. package/src/schemas/presetSchema.ts +0 -3
  174. package/src/schemas/utils/categories.ts +0 -3
  175. package/src/schemas/utils/navigation.ts +0 -8
@@ -7,3 +7,4 @@ export default z
7
7
  })
8
8
  .partial()
9
9
  .passthrough()
10
+ .optional()
@@ -1,8 +1,8 @@
1
1
  import { z } from 'astro:content'
2
+ import price from '../fields/price'
2
3
  import badge from './badge'
3
4
  import heading from './heading'
4
5
  import list from './list'
5
- import price from './price'
6
6
  import rating from './rating'
7
7
  import tagline from './tagline'
8
8
  import text from './text'
@@ -0,0 +1,10 @@
1
+ import { z } from 'astro:content'
2
+ import title from 'fulldev-ui/schemas/fields/title'
3
+
4
+ export const docSchema = z
5
+ .object({
6
+ title,
7
+ })
8
+ .strict()
9
+
10
+ export type DocSchema = z.infer<typeof docSchema>
@@ -0,0 +1,3 @@
1
+ import pathSchema from '../utils/pathSchema'
2
+
3
+ export default pathSchema('categories').array().optional()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.string().optional()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.string().optional()
@@ -0,0 +1,24 @@
1
+ import { reference, z } from 'astro:content'
2
+
3
+ const imagePath = z.preprocess((data: unknown) => {
4
+ if (typeof data === 'string') {
5
+ return data.split('/').pop()
6
+ }
7
+ return data
8
+ }, reference('images').optional())
9
+
10
+ export default z.union([imagePath, z.object({}).passthrough()]).pipe(
11
+ z
12
+ .object({
13
+ id: z
14
+ .string()
15
+ .refine(async (data) => await reference('images').parseAsync(data)),
16
+ src: z.string(),
17
+ alt: z.string(),
18
+ width: z.number(),
19
+ height: z.number(),
20
+ })
21
+ .partial()
22
+ .passthrough()
23
+ .optional()
24
+ )
@@ -0,0 +1,4 @@
1
+ import { z } from 'astro:content'
2
+ import image from '../components/image'
3
+
4
+ export default z.array(image).optional()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.number().optional()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.number().optional()
@@ -0,0 +1,5 @@
1
+ import { reference, z } from 'astro:content'
2
+
3
+ export const productsSchema = reference('products').array().optional()
4
+
5
+ export type ProductReferences = z.infer<typeof productsSchema>
@@ -0,0 +1,12 @@
1
+ import { z } from 'astro:content'
2
+ import image from 'fulldev-ui/schemas/components/image'
3
+ import description from 'fulldev-ui/schemas/fields/description'
4
+ import title from 'fulldev-ui/schemas/fields/title'
5
+
6
+ export default z
7
+ .object({
8
+ title: title.optional(),
9
+ description,
10
+ image,
11
+ })
12
+ .optional()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.boolean().optional()
@@ -1,3 +1,3 @@
1
1
  import { z } from 'astro:content'
2
2
 
3
- export default z.number()
3
+ export default z.string()
@@ -0,0 +1,3 @@
1
+ import { z } from 'astro:content'
2
+
3
+ export default z.record(z.string(), z.string().array()).optional()
@@ -0,0 +1,28 @@
1
+ import { z } from 'astro:content'
2
+ import banner from 'fulldev-ui/schemas/components/banner'
3
+ import footer from 'fulldev-ui/schemas/components/footer'
4
+ import header from 'fulldev-ui/schemas/components/header'
5
+ import sidebar from 'fulldev-ui/schemas/components/sidebar'
6
+ import subheader from 'fulldev-ui/schemas/components/subheader'
7
+ import seo from './fields/seo'
8
+
9
+ export const layoutSchema = z
10
+ .object({
11
+ theme: z.any(),
12
+ code: z
13
+ .object({
14
+ head: z.string().optional(),
15
+ body: z.string().optional(),
16
+ })
17
+ .optional(),
18
+ seo,
19
+ banner,
20
+ header,
21
+ subheader,
22
+ footer,
23
+ sidebar,
24
+ })
25
+ .strict()
26
+ .nullable()
27
+
28
+ export type LayoutSchema = z.infer<typeof layoutSchema>
@@ -1,94 +1,20 @@
1
- import { getEntries, getEntry, z } from 'astro:content'
2
- import { assign } from 'radash'
3
- import footer from './components/footer'
4
- import header from './components/header'
5
- import image from './components/image'
6
- import images from './components/images'
7
- import price from './components/price'
8
- import section from './components/section'
1
+ import { z } from 'astro:content'
2
+ import title from 'fulldev-ui/schemas/fields/title'
9
3
  import sections from './components/sections'
10
- import sidebar from './components/sidebar'
11
- import subheader from './components/subheader'
12
- import toc from './components/toc'
13
- import categories from './utils/categories'
14
- import component from './utils/component'
15
- import navigation from './utils/navigation'
16
- import pathSchema from './utils/pathSchema'
4
+ import description from './fields/description'
5
+ import href from './fields/href'
6
+ import image from './fields/image'
7
+ import seo from './fields/seo'
17
8
 
18
- export const i18n = z
9
+ export const pageSchema = z
19
10
  .object({
20
- i18n: pathSchema('pages').optional(),
21
- })
22
- .passthrough()
23
- .transform(async ({ i18n, ...rest }) => {
24
- if (!i18n) return rest
25
- const entry = await getEntry(i18n)
26
- const merged = assign(entry.data, rest) as typeof rest
27
- return merged as typeof rest
28
- })
29
-
30
- export const presets = z
31
- .object({
32
- presets: z.array(pathSchema('presets')).optional(),
33
- })
34
- .passthrough()
35
- .transform(async ({ presets, ...rest }) => {
36
- let mergedData = {}
37
-
38
- const baseEntry = await getEntry('presets', 'base')
39
- mergedData = assign(mergedData, baseEntry?.data || {})
40
-
41
- if (presets) {
42
- const entries = await getEntries(presets)
43
- entries.forEach(
44
- (preset: any) => (mergedData = assign(mergedData, preset.data))
45
- )
46
- }
47
-
48
- mergedData = assign(mergedData, rest)
49
- return mergedData as typeof rest
50
- })
51
-
52
- export const page = z
53
- .object({
54
- component,
55
- categories,
56
- order: z.number().optional(),
57
- theme: z.enum(['light', 'dark', 'system']),
58
- lang: z.string(),
59
- seo: z
60
- .object({
61
- title: z.string().optional(),
62
- description: z.string().optional(),
63
- })
64
- .optional(),
65
- title: z.string(),
66
- description: z.string().optional(),
67
- paragraph: z.string().optional(),
11
+ seo,
12
+ title,
13
+ description,
68
14
  image,
69
- images,
70
- section,
71
15
  sections,
72
- footer,
73
- header,
74
- sidebar,
75
- subheader,
76
- navigation,
77
- toc,
78
- price,
79
- code: z.any(),
80
- sizes: z.any(),
81
- banner: z.any(),
82
- _schema: z.any(),
83
- uitverkocht: z.any(),
84
- rating: z.any(),
85
- variants: z.any(),
86
- heading: z.any(),
87
- href: z.any(),
88
- next: z.any(),
89
- prev: z.any(),
16
+ href,
90
17
  })
91
- .partial()
92
18
  .strict()
93
19
 
94
- export default i18n.pipe(presets).pipe(page)
20
+ export type PageSchema = z.infer<typeof pageSchema>
@@ -0,0 +1,16 @@
1
+ import { z } from 'astro:content'
2
+ import image from 'fulldev-ui/schemas/components/image'
3
+ import sections from 'fulldev-ui/schemas/components/sections'
4
+ import description from 'fulldev-ui/schemas/fields/description'
5
+ import title from 'fulldev-ui/schemas/fields/title'
6
+
7
+ export const postSchema = z
8
+ .object({
9
+ title,
10
+ description,
11
+ image,
12
+ sections,
13
+ })
14
+ .strict()
15
+
16
+ export type PostSchema = z.infer<typeof postSchema>
@@ -0,0 +1,22 @@
1
+ import { z } from 'astro:content'
2
+ import categories from 'fulldev-ui/schemas/fields/categories'
3
+ import description from 'fulldev-ui/schemas/fields/description'
4
+ import images from 'fulldev-ui/schemas/fields/images'
5
+ import title from 'fulldev-ui/schemas/fields/title'
6
+ import order from './fields/order'
7
+ import price from './fields/price'
8
+ import soldout from './fields/soldout'
9
+ import variants from './fields/variants'
10
+
11
+ export const productSchema = z.object({
12
+ soldout,
13
+ order,
14
+ title,
15
+ description,
16
+ price,
17
+ categories,
18
+ images,
19
+ variants,
20
+ })
21
+
22
+ export type ProductSchema = z.infer<typeof productSchema>
@@ -0,0 +1,79 @@
1
+ import { derived, writable } from 'svelte/store'
2
+
3
+ export type CartItem = {
4
+ uid: string
5
+ quantity: number
6
+ slug: string
7
+ title: string
8
+ price?: number | undefined
9
+ image?: string | undefined
10
+ variants?:
11
+ | {
12
+ [k: string]: string | undefined
13
+ }
14
+ | undefined
15
+ }
16
+
17
+ export type Cart = CartItem[]
18
+
19
+ const isServer = import.meta.env.SSR
20
+ const storageJson = !isServer && localStorage.getItem('cart')
21
+ const storageData = storageJson ? JSON.parse(storageJson) : []
22
+
23
+ export const cart = writable<Cart>(storageData)
24
+
25
+ cart.subscribe((newCart) => {
26
+ if (isServer) return
27
+ const json = JSON.stringify(newCart)
28
+ localStorage.setItem('cart', json)
29
+ })
30
+
31
+ export const getUid = (
32
+ slug: CartItem['slug'],
33
+ variants?: CartItem['variants']
34
+ ) => (variants ? `${slug}-${Object.values(variants)?.join('-')}` : slug)
35
+
36
+ export const getItemIndex = (currentCart: Cart, uid: CartItem['uid']) => {
37
+ const index = currentCart.findIndex((i) => i.uid === uid)
38
+ if (index === -1) throw new Error(`Item with uid ${uid} not found`)
39
+ return index
40
+ }
41
+
42
+ export const addItem = (item: CartItem) =>
43
+ cart.update((currentCart) => [...currentCart, item])
44
+
45
+ export const removeItem = (uid: CartItem['uid']) =>
46
+ cart.update((currentCart) => {
47
+ const index = getItemIndex(currentCart, uid)
48
+ currentCart.splice(index, 1)
49
+ return [...currentCart]
50
+ })
51
+
52
+ export const updateQuantity = (
53
+ uid: CartItem['uid'],
54
+ quantity: CartItem['quantity']
55
+ ) =>
56
+ cart.update((currentCart) => {
57
+ const index = getItemIndex(currentCart, uid)
58
+ if (currentCart[index]) currentCart[index].quantity = quantity
59
+ return [...currentCart]
60
+ })
61
+
62
+ export const openCart = () => {
63
+ const cartDialog = document.querySelector('dialog#cart')
64
+ if (cartDialog instanceof HTMLDialogElement) cartDialog.showModal()
65
+ }
66
+
67
+ export const closeCart = () => {
68
+ const cartDialog = document.querySelector('dialog#cart')
69
+ if (cartDialog instanceof HTMLDialogElement) cartDialog.close()
70
+ }
71
+
72
+ export const totalPrice = derived(cart, ($cart) => {
73
+ console.log('DERIVED', $cart)
74
+ return $cart.length
75
+ // return $cart.reduce(
76
+ // (acc, item) => acc + (item.price || 0) * (item.quantity || 0),
77
+ // 0
78
+ // )
79
+ })
@@ -1,23 +1,76 @@
1
1
  import { persistentAtom } from '@nanostores/persistent'
2
2
  import { computed } from 'nanostores'
3
3
 
4
- // type Item = CollectionEntry<'products'>['data'] & {
5
- // quantity: number
6
- // }
4
+ type Item = {
5
+ slug: string
6
+ title: string
7
+ price: number
8
+ image: string
9
+ quantity: number
10
+ variants: string[]
11
+ }
7
12
 
8
- type Item = any
13
+ type Cart = Item[] | []
9
14
 
10
- export const $cart = persistentAtom<Item[] | []>('cart', [], {
15
+ export const $cart = persistentAtom<Cart>('cart', [], {
11
16
  encode: JSON.stringify,
12
17
  decode: JSON.parse,
13
18
  })
14
19
 
15
- // export const cartIsOpen = atom(false)
20
+ // for svelte files
21
+ export const cart = $cart
22
+
23
+ export const getCart = () => $cart.get()
24
+
25
+ export const setCart = (cart: Cart) => $cart.set(cart)
26
+
27
+ export const removeItem = (slug: string) => {
28
+ const currentCart = getCart()
29
+ const newCart = [...currentCart]
30
+ const index = currentCart.findIndex((item) => item.slug === slug)
31
+ newCart.splice(index, 1)
32
+ $cart.set(newCart)
33
+ }
34
+
35
+ export const addItem = (item: Item) => {
36
+ const currentCart = getCart()
37
+ const newCart = [...currentCart]
38
+ const index = currentCart.findIndex(
39
+ (i) => i.slug === item.slug && i.variants.join() === item.variants.join()
40
+ )
41
+ if (index === -1) newCart.push(item)
42
+ else {
43
+ let newItem = { ...newCart[index] } as Item
44
+ newItem.quantity += item.quantity
45
+ newCart[index] = newItem
46
+ }
47
+ setCart(newCart)
48
+ }
49
+
50
+ export const updateQuantity = (slug: string, quantity: number) => {
51
+ const currentCart = getCart()
52
+ const newCart = [...currentCart]
53
+ const index = currentCart.findIndex((item) => item.slug === slug)
54
+ let newItem = { ...newCart[index] } as Item
55
+ newItem.quantity = quantity
56
+ newCart[index] = newItem
57
+ setCart(newCart)
58
+ }
16
59
 
17
60
  export const $totalPrice = computed($cart, ($cart) =>
18
61
  $cart.reduce((a, b) => +a + b.price * b.quantity, 0)
19
62
  )
20
63
 
64
+ export const openCart = () => {
65
+ const cartDialog = document.querySelector('dialog#cart')
66
+ if (cartDialog instanceof HTMLDialogElement) cartDialog.showModal()
67
+ }
68
+
69
+ export const closeCart = () => {
70
+ const cartDialog = document.querySelector('dialog#cart')
71
+ if (cartDialog instanceof HTMLDialogElement) cartDialog.close()
72
+ }
73
+
21
74
  // export const totalQuantity = computed(cart, ($cart) =>
22
75
  // $cart.reduce((a, b) => +a + b.quantity, 0)
23
76
  // )
@@ -0,0 +1,8 @@
1
+ import type { CollectionEntry } from 'astro:content'
2
+ import { formatEntry } from './formatEntry'
3
+
4
+ export const formatEntries = (
5
+ entries: CollectionEntry<
6
+ 'categories' | 'docs' | 'pages' | 'posts' | 'products'
7
+ >[]
8
+ ) => entries.map(formatEntry)
@@ -0,0 +1,29 @@
1
+ import type { CollectionEntry, ContentCollectionKey } from 'astro:content'
2
+
3
+ const routes: {
4
+ [key in ContentCollectionKey]: string
5
+ } = {
6
+ categories: 'categorieen',
7
+ docs: 'docs',
8
+ pages: '',
9
+ posts: 'blog',
10
+ products: 'producten',
11
+ }
12
+
13
+ export const formatEntry = ({
14
+ data,
15
+ slug,
16
+ ...rest
17
+ }: CollectionEntry<ContentCollectionKey>) => {
18
+ let href
19
+ if (slug !== 'index') href = `/${routes[rest.collection]}/${slug}/`
20
+
21
+ href?.replace('//', '/')
22
+
23
+ return {
24
+ href,
25
+ slug,
26
+ ...rest,
27
+ ...data,
28
+ }
29
+ }
@@ -0,0 +1,22 @@
1
+ import type { CollectionEntry, ContentCollectionKey } from 'astro:content'
2
+
3
+ const routes: {
4
+ [key in ContentCollectionKey]: string
5
+ } = {
6
+ categories: 'categorieen',
7
+ docs: 'docs',
8
+ pages: '',
9
+ posts: 'blog',
10
+ products: 'producten',
11
+ }
12
+
13
+ export function getHref(
14
+ collection: ContentCollectionKey,
15
+ slug: CollectionEntry<ContentCollectionKey>['slug']
16
+ ) {
17
+ let href
18
+ if (slug === 'index') href = `/`
19
+ else if (slug) href = `/${routes[collection]}/${slug}/`
20
+ href = href?.replace('//', '/')
21
+ return href
22
+ }
@@ -0,0 +1,5 @@
1
+ import { vitePreprocess } from '@astrojs/svelte';
2
+
3
+ export default {
4
+ preprocess: vitePreprocess(),
5
+ }
@@ -1,100 +0,0 @@
1
- theme: system
2
-
3
- seo:
4
- image: /images/og-image.png
5
-
6
- code:
7
- head: |
8
- <script is:inline>
9
- !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
10
- posthog.init('phc_mVacbe8Xydu0UZlh4bNw5EGisvzyRcpqXEEuEEp5lOY',{api_host:'https://eu.i.posthog.com', person_profiles: 'identified_only' // or 'always' to create profiles for anonymous users as well
11
- })
12
- </script>
13
-
14
- navigation:
15
- themer: true
16
- header: true
17
- company: Fulldev UI
18
- logo: favicon.svg
19
- links:
20
- - text: Docs
21
- href: /docs/
22
- - text: Components
23
- href: /docs/components/badge/
24
- - text: Blocks
25
- href: /docs/blocks/banner/
26
- - showcase
27
-
28
- socials:
29
- - https://github.com/fulldotdev/ui
30
- - https://discord.gg/vXZqMbadm8
31
-
32
- menu:
33
- - heading: Get Started
34
- links:
35
- - docs
36
- - docs/installation
37
- - docs/customization
38
- - docs/frameworks
39
- - docs/components
40
- - docs/collections
41
- - heading: Collections
42
- links:
43
- - docs/collections/pages
44
- - docs/collections/presets
45
- - docs/collections/images
46
- - heading: Components
47
- links:
48
- - docs/components/avatar
49
- - docs/components/badge
50
- - docs/components/badges
51
- - docs/components/button
52
- - docs/components/buttons
53
- # - docs/components/card
54
- # - docs/components/cards
55
- # - docs/components/cart
56
- # - docs/components/cart-form
57
- # - docs/components/cart-list
58
- # - docs/components/cart-summary
59
- - docs/components/channel
60
- - docs/components/channels
61
- - docs/components/checkbox
62
- - docs/components/code
63
- # - docs/components/dialog
64
- # - docs/components/drawer
65
- # - docs/components/element
66
- # - docs/components/footer
67
- # - docs/components/form
68
- # - docs/components/head
69
- # - docs/components/header
70
- - docs/components/heading
71
- - docs/components/icon
72
- - docs/components/image
73
- - docs/components/input
74
- - docs/components/label
75
- - docs/components/lead
76
- - docs/components/link
77
- - docs/components/links
78
- - docs/components/list
79
- # - docs/components/locale-switcher
80
- - docs/components/logo
81
- - docs/components/menu
82
- - docs/components/paragraph
83
- # - docs/components/price
84
- - docs/components/prose
85
- - docs/components/rating
86
- # - docs/components/search
87
- # - docs/components/section
88
- # - docs/components/sections
89
- - docs/components/select
90
- # - docs/components/sidebar
91
- - docs/components/social
92
- - docs/components/socials
93
- - docs/components/switch
94
- # - docs/components/table
95
- - docs/components/tagline
96
- # - docs/components/text
97
- - docs/components/textarea
98
- - docs/components/themer
99
- # - docs/components/toc
100
- # - docs/components/writeup
@@ -1,6 +0,0 @@
1
- navigation:
2
- sidebar: true
3
- header: false
4
- toc: 'On this page'
5
- next: true
6
- prev: true
@@ -1,4 +0,0 @@
1
- import { z } from 'astro:content'
2
- import image from './image'
3
-
4
- export default z.array(image)
@@ -1,3 +0,0 @@
1
- import { page } from './pageSchema'
2
-
3
- export default page
@@ -1,3 +0,0 @@
1
- import pathSchema from './pathSchema'
2
-
3
- export default pathSchema('pages').array().optional()
@@ -1,8 +0,0 @@
1
- import { z } from 'astro:content'
2
- import header from '../components/header'
3
- import sidebar from '../components/sidebar'
4
-
5
- export default sidebar.merge(header).extend({
6
- header: z.boolean().optional(),
7
- sidebar: z.boolean().optional(),
8
- })