fulldev-ui 0.5.0-beta.4 → 0.5.0-beta.6

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 (60) hide show
  1. package/CONTRIBUTING.md +10 -4
  2. package/astro.config.ts +0 -2
  3. package/package.json +4 -2
  4. package/pnpm-lock.yaml +31 -69
  5. package/src/blocks/Banner.astro +2 -1
  6. package/src/blocks/Excerpt.astro +14 -0
  7. package/src/blocks/Product.astro +51 -22
  8. package/src/components/Card.astro +1 -1
  9. package/src/components/Cart.astro +36 -0
  10. package/src/components/CartForm.astro +121 -0
  11. package/src/components/CartList.astro +134 -0
  12. package/src/components/CartSummary.astro +146 -0
  13. package/src/components/Drawer.astro +119 -52
  14. package/src/components/Footer.astro +4 -0
  15. package/src/components/Form.astro +49 -0
  16. package/src/components/Header.astro +14 -12
  17. package/src/components/Input.astro +6 -0
  18. package/src/components/Menu.astro +56 -0
  19. package/src/components/Price.astro +7 -11
  20. package/src/components/Search.astro +1 -4
  21. package/src/components/Section.astro +2 -0
  22. package/src/components/Sidebar.astro +61 -111
  23. package/src/components/ThemeSelect.astro +3 -0
  24. package/src/components/Toc.astro +36 -94
  25. package/src/components/experimental/Form.astro +29 -5
  26. package/src/components/experimental/Gallery.astro +50 -126
  27. package/src/components/experimental/Prose.astro +32 -0
  28. package/src/content/pages/base/select.mdx +0 -8
  29. package/src/content/pages/base/textarea.mdx +0 -5
  30. package/src/content/pages/blocks/_product.mdx +73 -2
  31. package/src/content/pages/index.mdx +0 -2
  32. package/src/content/pages/layouts/_layout.mdx +8 -15
  33. package/src/content/pages/layouts/docslayout.mdx +10 -1
  34. package/src/content/pages/overview/components.mdx +5 -0
  35. package/src/content/pages/overview/content-collections.mdx +139 -0
  36. package/src/content/pages/overview/installation.mdx +25 -26
  37. package/src/content/pages/overview/introduction.mdx +16 -10
  38. package/src/content/pages/overview/theming.mdx +69 -0
  39. package/src/content/pages/schemas/page.mdx +6 -0
  40. package/src/content/presets/base.yml +57 -43
  41. package/src/content/presets/blocks.yml +0 -3
  42. package/src/content/presets/docs.yml +1 -61
  43. package/src/env.d.ts +1 -1
  44. package/src/layouts/Layout.astro +28 -14
  45. package/src/layouts/PostLayout.astro +24 -0
  46. package/src/layouts/ProductLayout.astro +5 -2
  47. package/src/schemas/components/header.ts +7 -9
  48. package/src/schemas/components/menu.ts +13 -0
  49. package/src/schemas/components/sidebar.ts +15 -0
  50. package/src/schemas/components/toc.ts +3 -0
  51. package/src/schemas/pageSchema.ts +54 -30
  52. package/src/schemas/presetSchema.ts +2 -32
  53. package/src/schemas/utils/navigation.ts +3 -53
  54. package/src/stores/cart.ts +23 -0
  55. package/src/utils/cart.ts +36 -0
  56. package/tsconfig.json +1 -3
  57. package/src/components/experimental/GalleryVertical.astro +0 -161
  58. package/src/content/pages/overview/content-layer.mdx +0 -128
  59. package/src/content/pages/overview/customization.mdx +0 -83
  60. /package/src/types/{global-props.d.ts → global-props.ts} +0 -0
@@ -1,54 +1,4 @@
1
- // import { z } from 'astro:content'
2
- // import button from '../components/button'
3
- // import buttons from '../components/buttons'
4
- // import heading from '../components/heading'
5
- // import logo from '../components/logo'
1
+ import header from '../components/header'
2
+ import sidebar from '../components/sidebar'
6
3
 
7
- // export default z.object({
8
- // logo,
9
- // buttons: z.array(
10
- // button.or(
11
- // z.object({
12
- // heading,
13
- // buttons,
14
- // })
15
- // )
16
- // ),
17
- // })
18
-
19
- import { z } from 'astro:content'
20
- import logo from '../components/logo'
21
- import pathSchema from '../utils/pathSchema'
22
-
23
- const button = pathSchema('pages').or(
24
- z
25
- .object({
26
- text: z.string(),
27
- href: z.string(),
28
- heading: z.never(),
29
- buttons: z.never(),
30
- })
31
- .partial()
32
- .passthrough()
33
- )
34
-
35
- const group = z
36
- .object({
37
- heading: z.string(),
38
- buttons: z.array(button),
39
- text: z.never(),
40
- href: z.never(),
41
- })
42
- .partial()
43
- .passthrough()
44
-
45
- export default z
46
- .object({
47
- logo,
48
- search: z.boolean(),
49
- sidebar: z.boolean(),
50
- toc: z.boolean(),
51
- buttons: z.array(button.or(group)),
52
- })
53
- .partial()
54
- .passthrough()
4
+ export default sidebar.merge(header)
@@ -0,0 +1,23 @@
1
+ import { persistentAtom } from '@nanostores/persistent'
2
+ import { computed } from 'nanostores'
3
+
4
+ // type Item = CollectionEntry<'products'>['data'] & {
5
+ // quantity: number
6
+ // }
7
+
8
+ type Item = any
9
+
10
+ export const $cart = persistentAtom<Item[] | []>('cart', [], {
11
+ encode: JSON.stringify,
12
+ decode: JSON.parse,
13
+ })
14
+
15
+ // export const cartIsOpen = atom(false)
16
+
17
+ export const $totalPrice = computed($cart, ($cart) =>
18
+ $cart.reduce((a, b) => +a + b.price * b.quantity, 0)
19
+ )
20
+
21
+ // export const totalQuantity = computed(cart, ($cart) =>
22
+ // $cart.reduce((a, b) => +a + b.quantity, 0)
23
+ // )
@@ -0,0 +1,36 @@
1
+ // import Stripe from 'stripe'
2
+
3
+ // const stripe = new Stripe(import.meta.env.STRIPE_SECRET_KEY)
4
+
5
+ const slugify = (input: string): string => {
6
+ return input
7
+ .toLowerCase()
8
+ .replace(/[^a-z0-9]+/g, '-')
9
+ .replace(/^-+|-+$/g, '')
10
+ }
11
+
12
+ export const generateProductId = (
13
+ slug: string,
14
+ variants?: string[] | undefined
15
+ ): string => {
16
+ const slugified = slugify(slug)
17
+
18
+ if (variants && variants.length > 0)
19
+ return `${slugified}--${variants.map((variant) => slugify(variant)).join('--')}`
20
+
21
+ return slugified
22
+ }
23
+
24
+ export const generateProductName = (
25
+ title: string,
26
+ variants?: string[] | undefined
27
+ ): string => {
28
+ if (variants && variants.length > 0)
29
+ return `${title} / ${variants.join(' / ')}`
30
+
31
+ return title
32
+ }
33
+
34
+ export const formatPrice = (price: number): string => {
35
+ return `€${price?.toFixed(2).replace('.', ',')}`
36
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "extends": "astro/tsconfigs/strictest",
3
+ "include": ["src", "astro.config.ts"],
3
4
  "compilerOptions": {
4
5
  "baseUrl": ".",
5
6
  "paths": {
@@ -8,7 +9,4 @@
8
9
  ]
9
10
  }
10
11
  },
11
- "exclude": [
12
- "dist"
13
- ]
14
12
  }
@@ -1,161 +0,0 @@
1
- ---
2
- import Icon from 'fulldev-ui/components/Icon.astro'
3
- import Image from 'fulldev-ui/components/Image.astro'
4
-
5
- const { images, direction } = Astro.props
6
- ---
7
-
8
- <script>
9
- const carousel = document.querySelector('.gallery .large-carousel')
10
- const icon = document.querySelector('.gallery .icon')
11
- const smallImages = document.querySelectorAll('.gallery .small-image')
12
-
13
- carousel &&
14
- icon?.addEventListener('click', () => {
15
- const carouselWidth = (carousel as HTMLElement).offsetWidth
16
- const currentScroll = carousel.scrollLeft
17
- const maxScroll = carousel.scrollWidth - carouselWidth
18
-
19
- let scrollAmount = currentScroll + carouselWidth
20
- if (scrollAmount > maxScroll) {
21
- scrollAmount = 0 // Reset to beginning if we're at the end
22
- }
23
-
24
- carousel.scrollTo({
25
- left: scrollAmount,
26
- behavior: 'smooth',
27
- })
28
- })
29
-
30
- carousel &&
31
- smallImages.forEach((image, i) => {
32
- image.addEventListener('click', () => {
33
- const imageWidth = (carousel as HTMLElement).offsetWidth
34
- carousel.scrollTo({
35
- left: i * imageWidth,
36
- behavior: 'smooth',
37
- })
38
- })
39
- })
40
- </script>
41
-
42
- <div
43
- class:list={[
44
- 'full',
45
- 'gallery',
46
- {
47
- [`direction-${direction}`]: direction,
48
- },
49
- ]}
50
- >
51
- <div class="large-container">
52
- <div class="large-carousel">
53
- {
54
- images?.map((image: any) => (
55
- <Image
56
- class="large-image"
57
- src={image}
58
- />
59
- ))
60
- }
61
- </div>
62
- {
63
- images?.length > 1 && (
64
- <Icon
65
- class="icon"
66
- name="swipe-left"
67
- />
68
- )
69
- }
70
- </div>
71
- <div class="small-carousel">
72
- {
73
- images?.length > 1 &&
74
- images.map((image: any) => (
75
- <Image
76
- class="small-image"
77
- src={image}
78
- />
79
- ))
80
- }
81
- </div>
82
- </div>
83
-
84
- <style is:global lang="scss">
85
- .gallery {
86
- display: flex;
87
- position: relative;
88
- flex-direction: column;
89
- gap: var(--space-1);
90
-
91
- .large-container {
92
- display: flex;
93
- justify-content: space-between;
94
- align-items: center;
95
-
96
- &:hover .icon {
97
- opacity: 1;
98
- }
99
-
100
- .icon {
101
- position: absolute;
102
- right: var(--space-3);
103
- opacity: 0.5;
104
- animation: swipe-icon 1.6s ease-in-out infinite;
105
- transition: opacity 0.2s ease-in-out;
106
- font-size: calc(var(--text-2) * 1.7);
107
- }
108
-
109
- @keyframes swipe-icon {
110
- 0%,
111
- 100% {
112
- right: var(--space-3);
113
- }
114
- 50% {
115
- right: calc(var(--space-3) * 2);
116
- }
117
- }
118
- }
119
-
120
- .small-carousel,
121
- .large-carousel {
122
- --column-width: 100%;
123
- display: flex;
124
- position: relative;
125
- flex-direction: row;
126
- align-items: flex-start;
127
- gap: var(--space-4);
128
-
129
- box-sizing: border-box;
130
- padding-bottom: var(--space-4);
131
- width: 100%;
132
- overflow-x: auto;
133
- scroll-behavior: smooth;
134
- scroll-snap-type: x mandatory;
135
-
136
- > .root {
137
- flex-grow: 0;
138
- flex-shrink: 0;
139
- width: var(--column-width);
140
- scroll-snap-align: center;
141
- }
142
-
143
- &.position-inset {
144
- margin-right: calc(var(--inner-x) * -1);
145
- margin-left: calc(var(--inner-x) * -1);
146
- padding-right: var(--inner-x);
147
- padding-left: var(--inner-x);
148
- width: calc(100% + var(--inner-x) * 2);
149
- }
150
- }
151
-
152
- .small-carousel {
153
- --column-width: var(--space-7);
154
- }
155
-
156
- .small-image:hover {
157
- opacity: 0.8;
158
- cursor: pointer;
159
- }
160
- }
161
- </style>
@@ -1,128 +0,0 @@
1
- ---
2
- presets: [docs]
3
- title: Content Layer
4
- ---
5
-
6
- import Link from 'fulldev-ui/components/Link.astro'
7
-
8
- # Content Layer
9
-
10
- We utilize <Link href="https://docs.astro.build/docs/guides/content-collections/">Astro's Content Layer</Link> to create entire websites using just content files and our components.
11
-
12
- ## Starter Template
13
-
14
- This is the recommended way to get started with our content layer integration. We've created a <Link href="https://github.com/fulldotdev/starter/tree/main">starter template</Link> with examples of everything you need to get started.
15
-
16
- ## Manual Setup
17
-
18
- To get started with the manual setup, you need to install the <Link href="/overview/installation/">integration</Link> and add `injectRoutes: true` to your `astro.config.ts` file, see <Link href="#folder-structure">file structure</Link> below for more information on how this generates a site using content files.
19
-
20
- ```ts
21
- import { defineConfig } from 'astro/config'
22
- import fulldev from 'fulldev-ui/integration'
23
-
24
- // https://astro.build/config
25
- export default defineConfig({
26
- integrations: [
27
- fulldev({
28
- // other options
29
- injectRoutes: true,
30
- }),
31
- ],
32
- })
33
- ```
34
-
35
- ## Folder Structure
36
-
37
- ```
38
- .
39
- ├── src/
40
- │ ├── blocks/
41
- │ │ └── ...
42
- │ ├── components/
43
- │ │ └── ...
44
- │ ├── layouts/
45
- │ │ └── ...
46
- │ ├── assets/
47
- │ │ └── ...
48
- │ ├── content/
49
- │ │ ├── pages/
50
- │ │ │ └── ...
51
- │ │ ├── records/
52
- │ │ │ └── ...
53
- │ │ │ └── ...
54
- │ │ ├── presets/
55
- │ │ │ ├── base.yml
56
- │ │ │ └── ...
57
- │ │ └── ...
58
- │ ├── css/
59
- │ │ ├── custom.css
60
- │ │ └── ...
61
- ├── public/
62
- │ └── ...
63
- └──
64
- ```
65
-
66
- - **/src/**: The main source directory containing all the core files of the project.
67
- - **/blocks/**: Contains reusable block components that can be composed to build pages (Custom or overwrites existing fulldev-ui blocks)
68
- - **/components/**: Houses individual UI components used throughout the project (Custom or overwrites existing fulldev-ui components)
69
- - **/layouts/**: Contains layout components used to structure pages (Custom or overwrites existing fulldev-ui layouts)
70
- - **/assets/**: Contains assets like images, fonts, etc.
71
- - **/content/**: Stores content-related files:
72
- - **pages/**: Contains markdown or MDX files for individual pages.
73
- - **records/**: Contains markdown or MDX files for content collections. Nested in directories by collection name.
74
- - **/presets/**: Includes configuration files for various settings like the sidebar.
75
- - **/css/**: Contains global CSS files and styles.
76
-
77
- ### File Structure
78
-
79
- Each file has a few frontmatter objects that are important to know about. Seo has priority over title and description, however title and description is used in multiple places like a card.
80
-
81
- ```md
82
- ---
83
- seo:
84
- title: Page Title
85
- description: This is my page description
86
- image: /image.jpg # Open Graph Image
87
-
88
- title: Page Title
89
- description: This is my page description
90
- ---
91
- ```
92
-
93
- For all objects avaliable in the Content Layer, see the <Link href="/schemas/page/">schemas</Link>.
94
-
95
- ### Image Alt collection
96
-
97
- To create yml records for images, you can simply add `generateImageEntries: true` to the integration setup. This will generate a yml file in the **src/assets/** directory with the image alt text pre set to the unslugged filename which can be customized. If turned on the Image component will automatically use these records for the alt text of local images.
98
-
99
- ```ts
100
- import { defineConfig } from 'astro/config'
101
- import fulldev from 'fulldev-ui/integration'
102
-
103
- // https://astro.build/config
104
- export default defineConfig({
105
- integrations: [
106
- fulldev({
107
- // other options
108
- generateImageEntries: true,
109
- }),
110
- ],
111
- })
112
- ```
113
-
114
- ## i18n
115
-
116
- Getting started with i18n is easy, you can easily add additional languages by creating a new folder in the **content/pages** directory and adding your content files in the new language.
117
-
118
- ```
119
- .
120
- ├── src/
121
- │ ├── content/
122
- │ │ ├── pages/
123
- │ │ │ ├── index.md
124
- │ │ │ ├── nl/
125
- │ │ │ │ └── index.md
126
- │ │ │ └── de/
127
- │ │ │ │ └── index.md
128
- ```
@@ -1,83 +0,0 @@
1
- ---
2
- presets: [docs]
3
- title: Customization
4
- ---
5
-
6
- import Link from 'fulldev-ui/components/Link.astro'
7
-
8
- # Customization
9
-
10
- ## Colors
11
-
12
- The color theme is inspired by and compatible with <Link href="https://www.radix-ui.com/colors">Radix Colors.</Link>
13
-
14
- ### Automatic setup
15
-
16
- With the fulldev-ui integration you can easily set a theme and generate a radix color palette. See the <Link href="/overview/installation/">installation page</Link> to get started with the integration.
17
-
18
- ### Manual setup
19
-
20
- You can define a `base` and a `brand` theme, both with 12 steps and 1 contrast step for text on step 9. For a detailed explanation see <Link href="https://www.radix-ui.com/colors/docs/palette-composition/understanding-the-scale">this page</Link>.
21
-
22
- ```css
23
- :root,
24
- .theme-light {
25
- --base-1: ;
26
- --base-2: ;
27
- --base-3: ;
28
- --base-4: ;
29
- --base-5: ;
30
- --base-6: ;
31
- --base-7: ;
32
- --base-8: ;
33
- --base-9: ;
34
- --base-10: ;
35
- --base-11: ;
36
- --base-12: ;
37
- --base-contrast: ;
38
-
39
- --brand-1: ;
40
- --brand-2: ;
41
- --brand-3: ;
42
- --brand-4: ;
43
- --brand-5: ;
44
- --brand-6: ;
45
- --brand-7: ;
46
- --brand-8: ;
47
- --brand-9: ;
48
- --brand-10: ;
49
- --brand-11: ;
50
- --brand-12: ;
51
- --brand-contrast: ;
52
- }
53
- ```
54
-
55
- ### Dark theme
56
-
57
- Dark mode is set via a simple `.theme-dark` class.
58
-
59
- If you want to use a dark theme by default, remove the `:root` selector from the light theme and add it to the dark theme.
60
-
61
- Components in Fulldev UI that support theme switching have the `theme` prop available, which adds either the `theme-dark` or `theme-light` class
62
-
63
- ```css
64
- .theme-dark {
65
- /* Same variables here as above */
66
- }
67
- ```
68
-
69
- ## Radius
70
-
71
- The `--border-radius` variable is a multiplier applied to all radius values. The default value is `1`.
72
-
73
- ```css
74
- :root {
75
- --border-radius: 1;
76
- }
77
- ```
78
-
79
- ## Other
80
-
81
- Since Fulldev UI uses just regular CSS with low specificity, you can customize anything else using custom CSS.
82
-
83
- We plan to add more customization via variables later.