@regardio/react 0.4.5 → 0.5.1
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.
- package/LICENSE +1 -1
- package/README.md +5 -5
- package/dist/{components/background-slideshow.js → background-slideshow/index.js} +2 -11
- package/dist/{components/blurry-gradient.js → blurry-gradient/index.js} +15 -9
- package/dist/{components/carousel.d.ts → carousel/index.d.ts} +17 -9
- package/dist/{components/carousel.js → carousel/index.js} +34 -30
- package/dist/{components/countdown.js → countdown/index.js} +2 -11
- package/dist/{components/generic-error.js → generic-error/index.js} +1 -1
- package/dist/grid/index.d.ts +1196 -0
- package/dist/grid/index.js +239 -0
- package/dist/heading/index.d.ts +24 -0
- package/dist/{components/heading.js → heading/index.js} +15 -34
- package/dist/highlight/index.d.ts +13 -0
- package/dist/{components/highlight.js → highlight/index.js} +9 -17
- package/dist/hooks/{use-current-route-data.js → use-current-route-data/index.js} +1 -1
- package/dist/hooks/{use-focus-search.js → use-focus-search/index.js} +1 -1
- package/dist/hooks/{use-matches-data.js → use-matches-data/index.js} +1 -1
- package/dist/hooks/{use-media-query.js → use-media-query/index.js} +1 -1
- package/dist/hooks/{use-mobile.js → use-mobile/index.js} +1 -1
- package/dist/hooks/use-nonce/index.d.ts +6 -0
- package/dist/hooks/use-nonce/index.js +8 -0
- package/dist/hooks/{use-orientation.d.ts → use-orientation/index.d.ts} +1 -1
- package/dist/hooks/{use-orientation.js → use-orientation/index.js} +1 -1
- package/dist/hooks/{use-user.js → use-user/index.js} +1 -1
- package/dist/{components/icon-button.js → icon-button/index.js} +1 -1
- package/dist/{components/if.js → if/index.js} +1 -1
- package/dist/{components/iframe.js → iframe/index.js} +2 -11
- package/dist/{components/link.d.ts → link/index.d.ts} +19 -13
- package/dist/{components/link.js → link/index.js} +31 -36
- package/dist/list/index.d.ts +69 -0
- package/dist/list/index.js +65 -0
- package/dist/{components/markdown-container.js → markdown-container/index.js} +3 -67
- package/dist/{components/password-input.js → password-input/index.js} +2 -11
- package/dist/{components/picture.js → picture/index.js} +2 -11
- package/dist/{components/protected-email.d.ts → protected-email/index.d.ts} +1 -1
- package/dist/{components/protected-email.js → protected-email/index.js} +1 -1
- package/dist/text/index.d.ts +20 -0
- package/dist/text/index.js +38 -0
- package/dist/utils/author/index.d.ts +3 -0
- package/dist/utils/author/index.js +33 -0
- package/dist/utils/text/index.d.ts +15 -0
- package/dist/utils/text/index.js +73 -0
- package/package.json +124 -26
- package/src/{stories/BackgroundSlideshow.stories.tsx → background-slideshow/background-slideshow.stories.tsx} +1 -1
- package/src/{components → background-slideshow}/background-slideshow.tsx +3 -1
- package/src/background-slideshow/index.ts +2 -0
- package/src/{stories/BlurryGradient.stories.tsx → blurry-gradient/blurry-gradient.stories.tsx} +1 -1
- package/src/{components → blurry-gradient}/blurry-gradient.tsx +14 -8
- package/src/blurry-gradient/index.ts +2 -0
- package/src/carousel/carousel-content.tsx +16 -0
- package/src/carousel/carousel-item.tsx +23 -0
- package/src/carousel/carousel-next.tsx +22 -0
- package/src/carousel/carousel-previous.tsx +22 -0
- package/src/{components/carousel.tsx → carousel/carousel-root.tsx} +8 -78
- package/src/carousel/carousel.stories.tsx +89 -0
- package/src/carousel/index.parts.ts +5 -0
- package/src/carousel/index.ts +4 -0
- package/src/{stories/Countdown.stories.tsx → countdown/countdown.stories.tsx} +1 -1
- package/src/{components → countdown}/countdown.tsx +3 -7
- package/src/countdown/index.ts +1 -0
- package/src/{stories/GenericError.stories.tsx → generic-error/generic-error.stories.tsx} +1 -1
- package/src/{components → generic-error}/generic-error.tsx +2 -0
- package/src/generic-error/index.ts +2 -0
- package/src/grid/grid-item.tsx +188 -0
- package/src/grid/grid-root.tsx +72 -0
- package/src/grid/grid.stories.tsx +236 -0
- package/src/grid/index.parts.ts +2 -0
- package/src/grid/index.ts +5 -0
- package/src/{stories/Heading.stories.tsx → heading/heading.stories.tsx} +1 -1
- package/src/{components → heading}/heading.tsx +17 -25
- package/src/heading/index.ts +2 -0
- package/src/{stories/Highlight.stories.tsx → highlight/highlight.stories.tsx} +1 -1
- package/src/{components → highlight}/highlight.tsx +13 -9
- package/src/highlight/index.ts +2 -0
- package/src/hooks/use-current-route-data/index.ts +1 -0
- package/src/hooks/use-focus-search/index.ts +1 -0
- package/src/hooks/use-matches-data/index.ts +1 -0
- package/src/hooks/use-media-query/index.ts +1 -0
- package/src/hooks/use-mobile/index.ts +1 -0
- package/src/hooks/use-nonce/index.ts +1 -0
- package/src/hooks/use-orientation/index.ts +1 -0
- package/src/hooks/use-user/index.ts +2 -0
- package/src/{stories/IconButton.stories.tsx → icon-button/icon-button.stories.tsx} +1 -1
- package/src/icon-button/index.ts +2 -0
- package/src/{stories/If.stories.tsx → if/if.stories.tsx} +1 -1
- package/src/if/index.ts +1 -0
- package/src/{stories/Iframe.stories.tsx → iframe/iframe.stories.tsx} +1 -1
- package/src/{components → iframe}/iframe.tsx +1 -1
- package/src/iframe/index.ts +2 -0
- package/src/link/index.ts +2 -0
- package/src/{stories/Link.stories.tsx → link/link.stories.tsx} +1 -1
- package/src/{components → link}/link.tsx +39 -28
- package/src/list/index.parts.ts +2 -0
- package/src/list/index.ts +4 -0
- package/src/list/list-item.tsx +63 -0
- package/src/list/list-root-context.ts +21 -0
- package/src/list/list-root.tsx +81 -0
- package/src/list/list.css +32 -0
- package/src/list/list.stories.tsx +119 -0
- package/src/list/list.test.tsx +168 -0
- package/src/markdown-container/index.ts +2 -0
- package/src/{stories/MarkdownContainer.stories.tsx → markdown-container/markdown-container.stories.tsx} +1 -1
- package/src/{components → markdown-container}/markdown-container.tsx +3 -1
- package/src/password-input/index.ts +2 -0
- package/src/{stories/PasswordInput.stories.tsx → password-input/password-input.stories.tsx} +1 -1
- package/src/{components → password-input}/password-input.tsx +4 -4
- package/src/picture/index.ts +2 -0
- package/src/{stories/Picture.stories.tsx → picture/picture.stories.tsx} +1 -1
- package/src/{components → picture}/picture.tsx +2 -4
- package/src/protected-email/index.ts +2 -0
- package/src/{stories/ProtectedEmail.stories.tsx → protected-email/protected-email.stories.tsx} +1 -1
- package/src/{components → protected-email}/protected-email.tsx +3 -1
- package/src/tailwind.css +10 -0
- package/src/text/index.ts +2 -0
- package/src/{stories/Text.stories.tsx → text/text.stories.tsx} +1 -1
- package/src/text/text.tsx +46 -0
- package/src/utils/author/author.tsx +36 -0
- package/src/utils/author/index.ts +1 -0
- package/src/utils/text/index.ts +1 -0
- package/src/utils/text/text.tsx +103 -0
- package/dist/components/box.d.ts +0 -20
- package/dist/components/box.js +0 -50
- package/dist/components/definition-list.d.ts +0 -43
- package/dist/components/definition-list.js +0 -89
- package/dist/components/heading.d.ts +0 -27
- package/dist/components/highlight.d.ts +0 -19
- package/dist/components/item.d.ts +0 -70
- package/dist/components/item.js +0 -512
- package/dist/components/leaflet-map.d.ts +0 -34
- package/dist/components/leaflet-map.js +0 -201
- package/dist/components/list-item.d.ts +0 -19
- package/dist/components/list-item.js +0 -37
- package/dist/components/maptiler-map.d.ts +0 -27
- package/dist/components/maptiler-map.js +0 -129
- package/dist/components/text.d.ts +0 -20
- package/dist/components/text.js +0 -45
- package/dist/components/unordered-list.d.ts +0 -19
- package/dist/components/unordered-list.js +0 -39
- package/dist/hooks/use-nonce.d.ts +0 -12
- package/dist/hooks/use-nonce.js +0 -13
- package/dist/utils/author.d.ts +0 -9
- package/dist/utils/author.js +0 -55
- package/dist/utils/cn.d.ts +0 -9
- package/dist/utils/cn.js +0 -14
- package/dist/utils/is-route-active.d.ts +0 -19
- package/dist/utils/is-route-active.js +0 -56
- package/dist/utils/text.d.ts +0 -24
- package/dist/utils/text.js +0 -127
- package/src/components/box.tsx +0 -45
- package/src/components/definition-list.tsx +0 -90
- package/src/components/item.tsx +0 -340
- package/src/components/leaflet-map.tsx +0 -294
- package/src/components/link.test.tsx +0 -387
- package/src/components/list-item.tsx +0 -30
- package/src/components/maptiler-map.tsx +0 -181
- package/src/components/text.tsx +0 -38
- package/src/components/unordered-list.tsx +0 -32
- package/src/hooks/use-nonce.test.ts +0 -35
- package/src/stories/Box.stories.tsx +0 -83
- package/src/stories/Carousel.stories.tsx +0 -95
- package/src/stories/DefinitionList.stories.tsx +0 -51
- package/src/stories/Item.stories.tsx +0 -79
- package/src/stories/ListItem.stories.tsx +0 -38
- package/src/stories/UnorderedList.stories.tsx +0 -73
- package/src/styles/tailwind.css +0 -7
- package/src/test-setup.ts +0 -1
- package/src/utils/author.test.ts +0 -54
- package/src/utils/author.tsx +0 -73
- package/src/utils/cn.test.ts +0 -48
- package/src/utils/cn.ts +0 -14
- package/src/utils/is-route-active.test.ts +0 -80
- package/src/utils/is-route-active.ts +0 -100
- package/src/utils/text.test.ts +0 -152
- package/src/utils/text.tsx +0 -209
- package/src/vite-env.d.ts +0 -1
- /package/dist/{components/background-slideshow.d.ts → background-slideshow/index.d.ts} +0 -0
- /package/dist/{components/blurry-gradient.d.ts → blurry-gradient/index.d.ts} +0 -0
- /package/dist/{components/countdown.d.ts → countdown/index.d.ts} +0 -0
- /package/dist/{components/generic-error.d.ts → generic-error/index.d.ts} +0 -0
- /package/dist/hooks/{use-current-route-data.d.ts → use-current-route-data/index.d.ts} +0 -0
- /package/dist/hooks/{use-focus-search.d.ts → use-focus-search/index.d.ts} +0 -0
- /package/dist/hooks/{use-matches-data.d.ts → use-matches-data/index.d.ts} +0 -0
- /package/dist/hooks/{use-media-query.d.ts → use-media-query/index.d.ts} +0 -0
- /package/dist/hooks/{use-mobile.d.ts → use-mobile/index.d.ts} +0 -0
- /package/dist/hooks/{use-user.d.ts → use-user/index.d.ts} +0 -0
- /package/dist/{components/icon-button.d.ts → icon-button/index.d.ts} +0 -0
- /package/dist/{components/if.d.ts → if/index.d.ts} +0 -0
- /package/dist/{components/iframe.d.ts → iframe/index.d.ts} +0 -0
- /package/dist/{components/markdown-container.d.ts → markdown-container/index.d.ts} +0 -0
- /package/dist/{components/password-input.d.ts → password-input/index.d.ts} +0 -0
- /package/dist/{components/picture.d.ts → picture/index.d.ts} +0 -0
- /package/src/hooks/{use-current-route-data.ts → use-current-route-data/use-current-route-data.ts} +0 -0
- /package/src/hooks/{use-focus-search.ts → use-focus-search/use-focus-search.ts} +0 -0
- /package/src/hooks/{use-matches-data.ts → use-matches-data/use-matches-data.ts} +0 -0
- /package/src/hooks/{use-media-query.ts → use-media-query/use-media-query.ts} +0 -0
- /package/src/hooks/{use-mobile.ts → use-mobile/use-mobile.ts} +0 -0
- /package/src/hooks/{use-nonce.ts → use-nonce/use-nonce.ts} +0 -0
- /package/src/hooks/{use-orientation.ts → use-orientation/use-orientation.ts} +0 -0
- /package/src/hooks/{use-user.tsx → use-user/use-user.tsx} +0 -0
- /package/src/{components → icon-button}/icon-button.tsx +0 -0
- /package/src/{components → if}/if.tsx +0 -0
- /package/src/{styles/storybook.css → storybook.css} +0 -0
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { config, Map as MapTiler, Marker, Popup } from '@maptiler/sdk';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
-
import '@maptiler/sdk/dist/maptiler-sdk.css';
|
|
4
|
-
|
|
5
|
-
interface MapTilerMarker {
|
|
6
|
-
lat: number;
|
|
7
|
-
lng: number;
|
|
8
|
-
id: string;
|
|
9
|
-
content?: string;
|
|
10
|
-
htmlContent?: string;
|
|
11
|
-
offset?: { x: number; y: number };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface MapTilerMapProps {
|
|
15
|
-
markers: MapTilerMarker[];
|
|
16
|
-
center?: { lat: number; lng: number };
|
|
17
|
-
zoom?: number;
|
|
18
|
-
mapStyle?: string;
|
|
19
|
-
apiKey: string;
|
|
20
|
-
showPopupsImmediately?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const MapTilerMap = ({
|
|
24
|
-
markers,
|
|
25
|
-
center,
|
|
26
|
-
zoom = 12,
|
|
27
|
-
mapStyle = 'streets',
|
|
28
|
-
apiKey,
|
|
29
|
-
showPopupsImmediately = false,
|
|
30
|
-
}: MapTilerMapProps) => {
|
|
31
|
-
const mapContainerRef = useRef<HTMLDivElement>(null);
|
|
32
|
-
const mapRef = useRef<MapTiler | null>(null);
|
|
33
|
-
const markersRef = useRef<Marker[]>([]);
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (!mapContainerRef.current || typeof window === 'undefined') return;
|
|
37
|
-
|
|
38
|
-
// Set MapTiler API key globally
|
|
39
|
-
config.apiKey = apiKey;
|
|
40
|
-
|
|
41
|
-
// Calculate center
|
|
42
|
-
let calculatedCenter: [number, number];
|
|
43
|
-
if (center) {
|
|
44
|
-
calculatedCenter = [center.lng, center.lat];
|
|
45
|
-
} else if (markers.length > 0) {
|
|
46
|
-
const firstMarker = markers[0];
|
|
47
|
-
if (firstMarker) {
|
|
48
|
-
calculatedCenter = [firstMarker.lng, firstMarker.lat];
|
|
49
|
-
} else {
|
|
50
|
-
calculatedCenter = [13.404954, 52.520008]; // Berlin [lng, lat]
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
calculatedCenter = [13.404954, 52.520008]; // Berlin [lng, lat]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Initialize map with proper style URL
|
|
57
|
-
const map = new MapTiler({
|
|
58
|
-
center: calculatedCenter,
|
|
59
|
-
container: mapContainerRef.current,
|
|
60
|
-
style: `https://api.maptiler.com/maps/${mapStyle}/style.json?key=${apiKey}`,
|
|
61
|
-
zoom: zoom,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Handle missing images gracefully - provide fallback markers
|
|
65
|
-
map.on('styleimagemissing', (e) => {
|
|
66
|
-
const id = e.id;
|
|
67
|
-
console.warn(`Missing sprite image: ${id}`);
|
|
68
|
-
// Don't attempt to add missing images, let the SDK handle it gracefully
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
mapRef.current = map;
|
|
72
|
-
|
|
73
|
-
// Add markers
|
|
74
|
-
const newMarkers: Marker[] = [];
|
|
75
|
-
|
|
76
|
-
markers.forEach((marker) => {
|
|
77
|
-
const markerInstance = new Marker().setLngLat([marker.lng, marker.lat]).addTo(map);
|
|
78
|
-
|
|
79
|
-
// Create popup content
|
|
80
|
-
let popupContent = '';
|
|
81
|
-
if (marker.htmlContent) {
|
|
82
|
-
popupContent = marker.htmlContent;
|
|
83
|
-
} else if (marker.content) {
|
|
84
|
-
popupContent = marker.content;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (popupContent) {
|
|
88
|
-
const popup = new Popup({
|
|
89
|
-
closeButton: false,
|
|
90
|
-
offset: marker.offset ? [marker.offset.x, marker.offset.y] : [0, 0],
|
|
91
|
-
}).setHTML(popupContent);
|
|
92
|
-
|
|
93
|
-
markerInstance.setPopup(popup);
|
|
94
|
-
|
|
95
|
-
if (showPopupsImmediately) {
|
|
96
|
-
markerInstance.togglePopup();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
newMarkers.push(markerInstance);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
markersRef.current = newMarkers;
|
|
104
|
-
|
|
105
|
-
// Cleanup function
|
|
106
|
-
return () => {
|
|
107
|
-
if (mapRef.current) {
|
|
108
|
-
mapRef.current.remove();
|
|
109
|
-
mapRef.current = null;
|
|
110
|
-
}
|
|
111
|
-
markersRef.current = [];
|
|
112
|
-
};
|
|
113
|
-
}, [markers, apiKey, mapStyle, zoom, center, showPopupsImmediately]);
|
|
114
|
-
|
|
115
|
-
// Update markers when they change
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
const map = mapRef.current;
|
|
118
|
-
if (!map) return;
|
|
119
|
-
|
|
120
|
-
// Remove existing markers
|
|
121
|
-
markersRef.current.forEach((marker) => {
|
|
122
|
-
marker.remove();
|
|
123
|
-
});
|
|
124
|
-
markersRef.current = [];
|
|
125
|
-
|
|
126
|
-
// Add new markers
|
|
127
|
-
const newMarkers: Marker[] = [];
|
|
128
|
-
|
|
129
|
-
markers.forEach((marker) => {
|
|
130
|
-
const markerInstance = new Marker().setLngLat([marker.lng, marker.lat]).addTo(map);
|
|
131
|
-
|
|
132
|
-
// Create popup content
|
|
133
|
-
let popupContent = '';
|
|
134
|
-
if (marker.htmlContent) {
|
|
135
|
-
popupContent = marker.htmlContent;
|
|
136
|
-
} else if (marker.content) {
|
|
137
|
-
popupContent = marker.content;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (popupContent) {
|
|
141
|
-
const popup = new Popup({
|
|
142
|
-
closeButton: false,
|
|
143
|
-
offset: marker.offset ? [marker.offset.x, marker.offset.y] : [0, 0],
|
|
144
|
-
}).setHTML(popupContent);
|
|
145
|
-
|
|
146
|
-
markerInstance.setPopup(popup);
|
|
147
|
-
|
|
148
|
-
if (showPopupsImmediately) {
|
|
149
|
-
markerInstance.togglePopup();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
newMarkers.push(markerInstance);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
markersRef.current = newMarkers;
|
|
157
|
-
|
|
158
|
-
if (markers.length > 1) {
|
|
159
|
-
const lngs = markers.map((m) => m.lng);
|
|
160
|
-
const lats = markers.map((m) => m.lat);
|
|
161
|
-
const minLng = Math.min(...lngs);
|
|
162
|
-
const maxLng = Math.max(...lngs);
|
|
163
|
-
const minLat = Math.min(...lats);
|
|
164
|
-
const maxLat = Math.max(...lats);
|
|
165
|
-
map.fitBounds(
|
|
166
|
-
[
|
|
167
|
-
[minLng, minLat],
|
|
168
|
-
[maxLng, maxLat],
|
|
169
|
-
],
|
|
170
|
-
{ padding: 20 },
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}, [markers, showPopupsImmediately]);
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<div
|
|
177
|
-
className="h-full w-full"
|
|
178
|
-
ref={mapContainerRef}
|
|
179
|
-
/>
|
|
180
|
-
);
|
|
181
|
-
};
|
package/src/components/text.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from '../utils/cn';
|
|
3
|
-
|
|
4
|
-
const text = cva({
|
|
5
|
-
base: ['relative', 'block'],
|
|
6
|
-
defaultVariants: {
|
|
7
|
-
themeColor: 'primary',
|
|
8
|
-
variant: 'primary',
|
|
9
|
-
},
|
|
10
|
-
variants: {
|
|
11
|
-
themeColor: {
|
|
12
|
-
primary: [],
|
|
13
|
-
},
|
|
14
|
-
variant: {
|
|
15
|
-
code: ['font-light', 'font-monospace'],
|
|
16
|
-
primary: [],
|
|
17
|
-
subtitle: ['text-lg'],
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export interface TextProps extends ComponentProps<'p'>, VariantProps<typeof text> {}
|
|
23
|
-
|
|
24
|
-
export const Text = (props: TextProps) => {
|
|
25
|
-
const { children, className, variant, themeColor } = props;
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
className={text({
|
|
30
|
-
className,
|
|
31
|
-
themeColor,
|
|
32
|
-
variant,
|
|
33
|
-
})}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from '../utils/cn';
|
|
3
|
-
|
|
4
|
-
const ul = cva({
|
|
5
|
-
defaultVariants: {
|
|
6
|
-
variant: 'primary',
|
|
7
|
-
},
|
|
8
|
-
variants: {
|
|
9
|
-
variant: {
|
|
10
|
-
inline: ['flex', 'flex-wrap', 'list-none'],
|
|
11
|
-
primary: [],
|
|
12
|
-
unstyled: ['list-none', 'p-0'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export interface UnorderedListProps extends ComponentProps<'ul'>, VariantProps<typeof ul> {}
|
|
18
|
-
|
|
19
|
-
export const UnorderedList = (props: UnorderedListProps) => {
|
|
20
|
-
const { children, className, variant } = props;
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<ul
|
|
24
|
-
className={ul({
|
|
25
|
-
className,
|
|
26
|
-
variant,
|
|
27
|
-
})}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</ul>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { generateNonce } from './use-nonce';
|
|
3
|
-
|
|
4
|
-
describe('generateNonce', () => {
|
|
5
|
-
test('generates a string', () => {
|
|
6
|
-
const nonce = generateNonce();
|
|
7
|
-
expect(typeof nonce).toBe('string');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('generates a non-empty string', () => {
|
|
11
|
-
const nonce = generateNonce();
|
|
12
|
-
expect(nonce.length).toBeGreaterThan(0);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('generates base64-encoded string', () => {
|
|
16
|
-
const nonce = generateNonce();
|
|
17
|
-
// Base64 characters: A-Z, a-z, 0-9, +, /, =
|
|
18
|
-
expect(nonce).toMatch(/^[A-Za-z0-9+/=]+$/);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('generates unique nonces', () => {
|
|
22
|
-
const nonces = new Set<string>();
|
|
23
|
-
for (let i = 0; i < 100; i++) {
|
|
24
|
-
nonces.add(generateNonce());
|
|
25
|
-
}
|
|
26
|
-
// All 100 nonces should be unique
|
|
27
|
-
expect(nonces.size).toBe(100);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('generates nonce of expected length', () => {
|
|
31
|
-
const nonce = generateNonce();
|
|
32
|
-
// 16 bytes encoded in base64 = 24 characters (with padding)
|
|
33
|
-
expect(nonce.length).toBe(24);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { Box } from '../components/box';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Box> = {
|
|
5
|
-
component: Box,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'padded',
|
|
8
|
-
},
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
title: 'Components/Box',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof Box>;
|
|
15
|
-
|
|
16
|
-
export const Default: Story = {
|
|
17
|
-
args: {
|
|
18
|
-
children: 'Default Box',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const Container: Story = {
|
|
23
|
-
args: {
|
|
24
|
-
children: 'Container Box',
|
|
25
|
-
variant: 'container',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const Flex: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
children: (
|
|
32
|
-
<>
|
|
33
|
-
<span>Flex Item 1</span>
|
|
34
|
-
<span>Flex Item 2</span>
|
|
35
|
-
<span>Flex Item 3</span>
|
|
36
|
-
</>
|
|
37
|
-
),
|
|
38
|
-
variant: 'flex',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Grid: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
children: (
|
|
45
|
-
<>
|
|
46
|
-
<div>Grid Item 1</div>
|
|
47
|
-
<div>Grid Item 2</div>
|
|
48
|
-
<div>Grid Item 3</div>
|
|
49
|
-
</>
|
|
50
|
-
),
|
|
51
|
-
variant: 'grid',
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const Code: Story = {
|
|
56
|
-
args: {
|
|
57
|
-
children: "const example = 'code block';",
|
|
58
|
-
variant: 'code',
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const AsSection: Story = {
|
|
63
|
-
args: {
|
|
64
|
-
as: 'section',
|
|
65
|
-
children: 'This is rendered as a section element',
|
|
66
|
-
variant: 'section',
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const AllVariants: Story = {
|
|
71
|
-
render: () => (
|
|
72
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
73
|
-
<Box variant="primary">Primary (default)</Box>
|
|
74
|
-
<Box variant="container">Container</Box>
|
|
75
|
-
<Box variant="flex">Flex</Box>
|
|
76
|
-
<Box variant="grid">Grid</Box>
|
|
77
|
-
<Box variant="code">Code</Box>
|
|
78
|
-
<Box variant="section">Section</Box>
|
|
79
|
-
<Box variant="aside">Aside</Box>
|
|
80
|
-
<Box variant="main">Main</Box>
|
|
81
|
-
</div>
|
|
82
|
-
),
|
|
83
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
3
|
-
Carousel,
|
|
4
|
-
CarouselContent,
|
|
5
|
-
CarouselItem,
|
|
6
|
-
CarouselNext,
|
|
7
|
-
CarouselPrevious,
|
|
8
|
-
} from '../components/carousel';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof Carousel> = {
|
|
11
|
-
component: Carousel,
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: 'padded',
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs'],
|
|
16
|
-
title: 'Components/Carousel',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default meta;
|
|
20
|
-
type Story = StoryObj<typeof Carousel>;
|
|
21
|
-
|
|
22
|
-
const SlideCard = ({ children }: { children: React.ReactNode }) => (
|
|
23
|
-
<div
|
|
24
|
-
style={{
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
background: '#f0f0f0',
|
|
27
|
-
border: '1px solid #ddd',
|
|
28
|
-
borderRadius: '8px',
|
|
29
|
-
display: 'flex',
|
|
30
|
-
height: '200px',
|
|
31
|
-
justifyContent: 'center',
|
|
32
|
-
width: '300px',
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
export const Default: Story = {
|
|
40
|
-
render: () => (
|
|
41
|
-
<Carousel className="w-full max-w-md">
|
|
42
|
-
<CarouselContent className="gap-4">
|
|
43
|
-
<CarouselItem>
|
|
44
|
-
<SlideCard>Slide 1</SlideCard>
|
|
45
|
-
</CarouselItem>
|
|
46
|
-
<CarouselItem>
|
|
47
|
-
<SlideCard>Slide 2</SlideCard>
|
|
48
|
-
</CarouselItem>
|
|
49
|
-
<CarouselItem>
|
|
50
|
-
<SlideCard>Slide 3</SlideCard>
|
|
51
|
-
</CarouselItem>
|
|
52
|
-
</CarouselContent>
|
|
53
|
-
</Carousel>
|
|
54
|
-
),
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const WithControls: Story = {
|
|
58
|
-
render: () => (
|
|
59
|
-
<Carousel className="w-full max-w-md">
|
|
60
|
-
<CarouselContent className="gap-4">
|
|
61
|
-
<CarouselItem>
|
|
62
|
-
<SlideCard>Slide 1</SlideCard>
|
|
63
|
-
</CarouselItem>
|
|
64
|
-
<CarouselItem>
|
|
65
|
-
<SlideCard>Slide 2</SlideCard>
|
|
66
|
-
</CarouselItem>
|
|
67
|
-
<CarouselItem>
|
|
68
|
-
<SlideCard>Slide 3</SlideCard>
|
|
69
|
-
</CarouselItem>
|
|
70
|
-
</CarouselContent>
|
|
71
|
-
<div className="flex justify-center gap-4 mt-4">
|
|
72
|
-
<CarouselPrevious className="px-4 py-2 bg-gray-200 rounded">Previous</CarouselPrevious>
|
|
73
|
-
<CarouselNext className="px-4 py-2 bg-gray-200 rounded">Next</CarouselNext>
|
|
74
|
-
</div>
|
|
75
|
-
</Carousel>
|
|
76
|
-
),
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const ManySlides: Story = {
|
|
80
|
-
render: () => (
|
|
81
|
-
<Carousel className="w-full max-w-md">
|
|
82
|
-
<CarouselContent className="gap-4">
|
|
83
|
-
{[1, 2, 3, 4, 5, 6].map((i) => (
|
|
84
|
-
<CarouselItem key={i}>
|
|
85
|
-
<SlideCard>Slide {i}</SlideCard>
|
|
86
|
-
</CarouselItem>
|
|
87
|
-
))}
|
|
88
|
-
</CarouselContent>
|
|
89
|
-
<div className="flex justify-center gap-4 mt-4">
|
|
90
|
-
<CarouselPrevious className="px-4 py-2 bg-gray-200 rounded">←</CarouselPrevious>
|
|
91
|
-
<CarouselNext className="px-4 py-2 bg-gray-200 rounded">→</CarouselNext>
|
|
92
|
-
</div>
|
|
93
|
-
</Carousel>
|
|
94
|
-
),
|
|
95
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { Dd, DefinitionList, Dt } from '../components/definition-list';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof DefinitionList> = {
|
|
5
|
-
component: DefinitionList,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'padded',
|
|
8
|
-
},
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
title: 'Components/DefinitionList',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof DefinitionList>;
|
|
15
|
-
|
|
16
|
-
export const Default: Story = {
|
|
17
|
-
render: () => (
|
|
18
|
-
<DefinitionList>
|
|
19
|
-
<Dt>Term 1</Dt>
|
|
20
|
-
<Dd>Definition for term 1</Dd>
|
|
21
|
-
<Dt>Term 2</Dt>
|
|
22
|
-
<Dd>Definition for term 2</Dd>
|
|
23
|
-
<Dt>Term 3</Dt>
|
|
24
|
-
<Dd>Definition for term 3</Dd>
|
|
25
|
-
</DefinitionList>
|
|
26
|
-
),
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const Unstyled: Story = {
|
|
30
|
-
render: () => (
|
|
31
|
-
<DefinitionList variant="unstyled">
|
|
32
|
-
<Dt>Term 1</Dt>
|
|
33
|
-
<Dd>Definition for term 1</Dd>
|
|
34
|
-
<Dt>Term 2</Dt>
|
|
35
|
-
<Dd>Definition for term 2</Dd>
|
|
36
|
-
</DefinitionList>
|
|
37
|
-
),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const ContactInfo: Story = {
|
|
41
|
-
render: () => (
|
|
42
|
-
<DefinitionList>
|
|
43
|
-
<Dt>Email</Dt>
|
|
44
|
-
<Dd>contact@example.com</Dd>
|
|
45
|
-
<Dt>Phone</Dt>
|
|
46
|
-
<Dd>+1 234 567 890</Dd>
|
|
47
|
-
<Dt>Address</Dt>
|
|
48
|
-
<Dd>123 Main Street, City, Country</Dd>
|
|
49
|
-
</DefinitionList>
|
|
50
|
-
),
|
|
51
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { MemoryRouter } from 'react-router';
|
|
3
|
-
import { Item } from '../components/item';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Item> = {
|
|
6
|
-
component: Item,
|
|
7
|
-
decorators: [
|
|
8
|
-
(Story) => (
|
|
9
|
-
<MemoryRouter>
|
|
10
|
-
<Story />
|
|
11
|
-
</MemoryRouter>
|
|
12
|
-
),
|
|
13
|
-
],
|
|
14
|
-
parameters: {
|
|
15
|
-
layout: 'padded',
|
|
16
|
-
},
|
|
17
|
-
tags: ['autodocs'],
|
|
18
|
-
title: 'Components/Item',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof Item>;
|
|
23
|
-
|
|
24
|
-
export const Default: Story = {
|
|
25
|
-
args: {
|
|
26
|
-
children: <div className="p-4">Item content</div>,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const WithLink: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
children: <div className="p-4">Clickable item</div>,
|
|
33
|
-
link: '/example',
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const WidthVariants: Story = {
|
|
38
|
-
render: () => (
|
|
39
|
-
<div className="grid grid-cols-12 gap-4">
|
|
40
|
-
<Item width="xs">
|
|
41
|
-
<div className="p-2 bg-gray-100">XS</div>
|
|
42
|
-
</Item>
|
|
43
|
-
<Item width="sm">
|
|
44
|
-
<div className="p-2 bg-gray-100">SM</div>
|
|
45
|
-
</Item>
|
|
46
|
-
<Item width="md">
|
|
47
|
-
<div className="p-2 bg-gray-100">MD</div>
|
|
48
|
-
</Item>
|
|
49
|
-
<Item width="lg">
|
|
50
|
-
<div className="p-2 bg-gray-100">LG</div>
|
|
51
|
-
</Item>
|
|
52
|
-
<Item width="full">
|
|
53
|
-
<div className="p-2 bg-gray-100">Full</div>
|
|
54
|
-
</Item>
|
|
55
|
-
</div>
|
|
56
|
-
),
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const ThemeColors: Story = {
|
|
60
|
-
render: () => (
|
|
61
|
-
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
|
62
|
-
<Item themeColor="blue">
|
|
63
|
-
<div className="p-4">Blue</div>
|
|
64
|
-
</Item>
|
|
65
|
-
<Item themeColor="green">
|
|
66
|
-
<div className="p-4">Green</div>
|
|
67
|
-
</Item>
|
|
68
|
-
<Item themeColor="red">
|
|
69
|
-
<div className="p-4">Red</div>
|
|
70
|
-
</Item>
|
|
71
|
-
<Item themeColor="orange">
|
|
72
|
-
<div className="p-4">Orange</div>
|
|
73
|
-
</Item>
|
|
74
|
-
<Item themeColor="purple">
|
|
75
|
-
<div className="p-4">Purple</div>
|
|
76
|
-
</Item>
|
|
77
|
-
</div>
|
|
78
|
-
),
|
|
79
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { ListItem } from '../components/list-item';
|
|
3
|
-
import { UnorderedList } from '../components/unordered-list';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof ListItem> = {
|
|
6
|
-
component: ListItem,
|
|
7
|
-
parameters: {
|
|
8
|
-
layout: 'padded',
|
|
9
|
-
},
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
title: 'Components/ListItem',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
type Story = StoryObj<typeof ListItem>;
|
|
16
|
-
|
|
17
|
-
export const Default: Story = {
|
|
18
|
-
args: {
|
|
19
|
-
children: 'List item content',
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const InList: Story = {
|
|
24
|
-
render: () => (
|
|
25
|
-
<UnorderedList>
|
|
26
|
-
<ListItem>First item</ListItem>
|
|
27
|
-
<ListItem>Second item</ListItem>
|
|
28
|
-
<ListItem>Third item</ListItem>
|
|
29
|
-
</UnorderedList>
|
|
30
|
-
),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const WithCustomClass: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
children: 'Styled list item',
|
|
36
|
-
className: 'font-bold text-blue-600',
|
|
37
|
-
},
|
|
38
|
-
};
|