@rimelight/ui 0.0.7 → 0.0.9

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.
@@ -1,107 +0,0 @@
1
- ---
2
- import Carousel from "@rimelight/ui/components/carousel/Carousel.astro";
3
- import CarouselPrevious from "@rimelight/ui/components/carousel/CarouselPrevious.astro";
4
- import CarouselNext from "@rimelight/ui/components/carousel/CarouselNext.astro";
5
- import type { HTMLAttributes } from "astro/types";
6
- import type { EmblaOptionsType } from "embla-carousel";
7
-
8
- export interface ExtendedCarouselProps extends HTMLAttributes<"div"> {
9
- opts?: EmblaOptionsType;
10
- orientation?: "horizontal" | "vertical";
11
- showDots?: boolean;
12
- }
13
- type Props = ExtendedCarouselProps;
14
-
15
- const { opts = {}, orientation = "horizontal", showDots = true, class: className, ...rest } = Astro.props;
16
-
17
- // Default loop to true for ExtendedCarousel
18
- const carouselOpts: EmblaOptionsType = {
19
- loop: true,
20
- ...opts
21
- };
22
- ---
23
-
24
- <Carousel
25
- opts={carouselOpts}
26
- orientation={orientation}
27
- class:list={["extended-carousel group/extended-carousel", className]}
28
- {...rest}
29
- data-extended-carousel
30
- autoInit={false}
31
- >
32
- <slot />
33
-
34
- <div class="hidden md:block">
35
- <CarouselPrevious class="-left-12 opacity-50 hover:opacity-100 transition-opacity" />
36
- <CarouselNext class="-right-12 opacity-50 hover:opacity-100 transition-opacity" />
37
- </div>
38
-
39
- {showDots && (
40
- <div class="carousel-pagination absolute bottom-8 left-1/2 -translate-x-1/2 z-10 flex justify-center items-center gap-1.5" data-slot="pagination">
41
- {/* Dots injected by script */}
42
- </div>
43
- )}
44
- </Carousel>
45
-
46
- <script>
47
- import { initCarousel } from "@rimelight/ui/components/carousel/carousel-script.ts";
48
-
49
- const setupExtendedCarousels = () => {
50
- const extendedCarousels = document.querySelectorAll('[data-extended-carousel]') as NodeListOf<HTMLElement>;
51
-
52
- extendedCarousels.forEach((carousel) => {
53
- // Avoid double-initialization
54
- if (carousel.dataset.extendedInitialized === "true") return;
55
- carousel.dataset.extendedInitialized = "true";
56
-
57
- // Initialize the underlying Starwind carousel
58
- // Passing autoInit={false} to the component means we handle init here
59
- const manager = initCarousel(carousel);
60
- if (!manager) return;
61
-
62
- const api = manager.api;
63
- const pagination = carousel.querySelector('[data-slot="pagination"]');
64
-
65
- if (pagination) {
66
- const scrollSnaps = api.scrollSnapList();
67
- const dots: HTMLButtonElement[] = [];
68
-
69
- // Clear existing (useful for handle re-init cases)
70
- pagination.innerHTML = '';
71
-
72
- scrollSnaps.forEach((_: number, index: number) => {
73
- const dot = document.createElement('button');
74
- dot.className = 'size-4 rounded-full bg-border transition-all hover:bg-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary h-4 cursor-pointer';
75
- dot.setAttribute('aria-label', `Go to slide ${index + 1}`);
76
- dot.addEventListener('click', () => api.scrollTo(index));
77
- pagination.appendChild(dot);
78
- dots.push(dot);
79
- });
80
-
81
- const updateDots = () => {
82
- const selectedIndex = api.selectedScrollSnap();
83
- dots.forEach((dot, index) => {
84
- if (index === selectedIndex) {
85
- dot.classList.add('bg-primary');
86
- dot.classList.remove('bg-border');
87
- } else {
88
- dot.classList.remove('bg-primary');
89
- dot.classList.add('bg-border');
90
- }
91
- });
92
- };
93
-
94
- api.on('select', updateDots);
95
- api.on('init', updateDots);
96
- api.on('reInit', updateDots);
97
-
98
- updateDots();
99
- }
100
- });
101
- };
102
-
103
- // Run on load and after Astro page swaps
104
- document.addEventListener("DOMContentLoaded", setupExtendedCarousels);
105
- document.addEventListener("astro:after-swap", setupExtendedCarousels);
106
- </script>
107
-
@@ -1,26 +0,0 @@
1
- ---
2
- export interface FormattedDateProps {
3
- date?: Date | undefined;
4
- locale?: string;
5
- }
6
- type Props = FormattedDateProps;
7
-
8
- const {
9
- date,
10
- locale = Astro.locals.astroI18n?.locale || "en-US"
11
- } = Astro.props;
12
- ---
13
-
14
- {
15
- date && (
16
- <time datetime={date.toISOString()}>
17
- {
18
- date.toLocaleDateString(locale, {
19
- year: 'numeric',
20
- month: 'short',
21
- day: 'numeric',
22
- })
23
- }
24
- </time>
25
- )
26
- }
@@ -1,24 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from 'astro/types';
3
-
4
- export interface HeaderLinkProps extends HTMLAttributes<"a"> {}
5
- type Props = HeaderLinkProps;
6
-
7
- const { href, class: className, ...props } = Astro.props;
8
- const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, '');
9
- const subpath = pathname.match(/[^/]+/g);
10
- const isActive = href === pathname || href === '/' + (subpath?.[0] || '');
11
- ---
12
-
13
- <a
14
- href={href}
15
- class:list={[
16
- className,
17
- "inline-block no-underline",
18
- { "font-bold underline active": isActive }
19
- ]}
20
- {...props}
21
- >
22
- <slot />
23
- </a>
24
-
@@ -1,197 +0,0 @@
1
- ---
2
- import { Image } from "astro:assets";
3
- import { scv } from "css-variants";
4
- import type { CollectionEntry } from "astro:content";
5
- import Separator from "@rimelight/ui/components/separator/Separator.astro";
6
- import Avatar from "@rimelight/ui/components/avatar/Avatar.astro";
7
- import AvatarImage from "@rimelight/ui/components/avatar/AvatarImage.astro";
8
- import avatarAsset from "../assets/team/Daniel-Marchi_0000_00.webp";
9
-
10
- // Support both Astro content collections and CMS documents
11
- export type CMSProjectDocument = {
12
- _id: string;
13
- slug?: string;
14
- title: string;
15
- description?: string;
16
- heroImage?: string;
17
- publishedDate?: string | Date | null;
18
- featured?: boolean;
19
- tags?: string[] | Record<string, unknown> | null;
20
- _updatedAt?: string;
21
- _createdAt?: string;
22
- };
23
-
24
- export interface ProjectPostProps extends NonNullable<Parameters<typeof projectPostVariants>[0]> {
25
- project: CollectionEntry<"projects"> | CMSProjectDocument;
26
- class?: string;
27
- showImage?: boolean;
28
- separator?: boolean;
29
- /** Translations for the component */
30
- t?: {
31
- latest_badge?: string;
32
- view_project?: string;
33
- };
34
- /** The current locale for formatting and links */
35
- locale?: string;
36
- }
37
-
38
- type Props = ProjectPostProps;
39
-
40
- const projectPostVariants = scv({
41
- slots: [
42
- "root",
43
- "imageWrapper",
44
- "image",
45
- "content",
46
- "title",
47
- "description",
48
- "footer",
49
- "authorGroup",
50
- "author",
51
- "link",
52
- "badge",
53
- "featuredBadge"
54
- ],
55
- base: {
56
- root: "group flex transition-all duration-300 w-full",
57
- imageWrapper: "relative overflow-hidden ring-1 ring-border shadow-sm shrink-0 bg-muted isolate",
58
- image: "absolute inset-0 h-full w-full !object-cover transition-transform duration-500 group-hover:scale-105 block",
59
- content: "flex flex-col flex-1",
60
- title: "font-heading font-bold tracking-tight text-pretty group-hover:text-primary transition-colors",
61
- description: "text-muted-foreground line-clamp-2 text-base text-pretty",
62
- footer: "mt-auto flex items-end justify-end w-full",
63
- authorGroup: "flex flex-col gap-5xs text-xs font-medium text-muted-foreground",
64
- author: "font-bold text-foreground",
65
- link: "inline-flex items-center gap-5xs text-sm font-semibold hover:underline decoration-primary underline-offset-4",
66
- badge: "px-2xs py-6xs rounded-full bg-muted text-muted-foreground text-[10px] font-bold uppercase tracking-wider",
67
- featuredBadge: "absolute top-3 left-3 z-20 flex items-center gap-5xs px-3xs py-5xs rounded-full bg-primary text-primary-foreground text-[10px] font-bold uppercase tracking-wider shadow-lg ring-1 ring-white/20",
68
- },
69
- variants: {
70
- variant: {
71
- flat: {
72
- root: "flex-col md:flex-row gap-3xl md:gap-4xl items-stretch py-4xl first:pt-0 last:pb-0 text-left",
73
- imageWrapper: "w-full md:w-5/12 aspect-video self-stretch rounded-3xl shrink-0 shadow-none ring-0",
74
- content: "gap-2xl justify-center items-start text-left",
75
- title: "text-xl",
76
- description: "text-base",
77
- },
78
- card: {
79
- root: "flex-col bg-muted/20 p-2xl rounded-3xl border border-border/50 hover:bg-muted/40 hover:shadow-2xl hover:-translate-y-1 gap-2xl text-left items-stretch",
80
- imageWrapper: "w-full aspect-video rounded-2xl shadow-lg",
81
- title: "text-xl",
82
- content: "gap-2xl text-left items-start",
83
- },
84
- },
85
- },
86
- defaultVariants: {
87
- variant: "flat",
88
- },
89
- });
90
-
91
- const {
92
- project,
93
- variant,
94
- class: className,
95
- showImage = true,
96
- separator = false,
97
- t: tProp,
98
- locale = Astro.locals.astroI18n?.locale || "en"
99
- } = Astro.props;
100
-
101
- const t = {
102
- latest_badge: tProp?.latest_badge || (Astro.locals.astroI18n ? Astro.locals.astroI18n.t("projects.latest_badge") : "Latest"),
103
- view_project: tProp?.view_project || (Astro.locals.astroI18n ? Astro.locals.astroI18n.t("projects.view_project") : "View Project"),
104
- };
105
-
106
- // Detect if this is a CMS document or Astro content entry
107
- const isCMSDocument = "_id" in project && !("id" in project);
108
-
109
- // Extract fields based on source type
110
- const projectTitle = isCMSDocument ? project.title : (project as CollectionEntry<"projects">).data.title;
111
- const projectDescription = isCMSDocument ? project.description : (project as CollectionEntry<"projects">).data.description;
112
- const projectImage = isCMSDocument ? project.heroImage : (project as CollectionEntry<"projects">).data.heroImage;
113
- const projectFeatured = isCMSDocument ? (project.featured ?? false) : (project as CollectionEntry<"projects">).data.featured;
114
- const projectTags = isCMSDocument ? (project.tags || []) : ((project as CollectionEntry<"projects">).data.tags || []);
115
-
116
- // Handle date formatting
117
- const rawDate = isCMSDocument ? (project.publishedDate || project._createdAt) : (project as CollectionEntry<"projects">).data.publishedDate;
118
- const d = rawDate ? new Date(rawDate) : null;
119
- const formattedDate = d && !isNaN(d.getTime())
120
- ? new Intl.DateTimeFormat(locale, {
121
- dateStyle: "medium",
122
- }).format(d)
123
- : "";
124
-
125
- // Get slug from CMS or Astro content
126
- const projectSlug = isCMSDocument
127
- ? (project.slug || "")
128
- : (project as CollectionEntry<"projects">).id.replace(/^(en|pt|de|es|ja)\//, "");
129
-
130
- const { root, imageWrapper, image, content, title, description, footer, authorGroup, author, link, badge, featuredBadge } = projectPostVariants({ variant });
131
- ---
132
-
133
- <div class="flex flex-col w-full">
134
- <a href={Astro.locals.astroI18n ? Astro.locals.astroI18n.l(`/projects/${projectSlug}`) : `/${locale}/projects/${projectSlug}`} class:list={[root, className]}>
135
- {showImage && (
136
- <div class={imageWrapper}>
137
- {projectFeatured && (
138
- <div class={featuredBadge}>
139
- <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>
140
- {t.latest_badge}
141
- </div>
142
- )}
143
- {projectImage && (
144
- <Image
145
- src={projectImage as any}
146
- alt={projectTitle}
147
- width={800}
148
- height={450}
149
- class={image}
150
- loading="lazy"
151
- decoding="async"
152
- />
153
- )}
154
- </div>
155
- )}
156
-
157
- <div class={content}>
158
- <h3 class={title}>
159
- {projectTitle}
160
- </h3>
161
-
162
- <div class="flex items-center gap-3xs mt-3xs">
163
- <Avatar size="sm" variant="primary">
164
- <AvatarImage image={avatarAsset} alt="Daniel Marchi" />
165
- </Avatar>
166
- <div class={authorGroup}>
167
- <span class={author}>Daniel Marchi</span>
168
- <div class="flex items-center gap-3xs">
169
- <span>{formattedDate}</span>
170
- <div class="flex flex-wrap gap-5xs ml-3xs">
171
- {Array.isArray(projectTags) && projectTags.map((tag: string) => (
172
- <span class={badge}>{tag}</span>
173
- ))}
174
- </div>
175
- </div>
176
- </div>
177
- </div>
178
-
179
- <p class={description}>
180
- {projectDescription}
181
- </p>
182
-
183
- <div class={footer}>
184
- <span class={link}>
185
- {t.view_project}
186
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="transition-transform group-hover:translate-x-1"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>
187
- </span>
188
- </div>
189
- </div>
190
- </a>
191
-
192
- {separator && (
193
- <div class="py-4xl last:hidden">
194
- <Separator />
195
- </div>
196
- )}
197
- </div>
@@ -1,3 +0,0 @@
1
- ---
2
-
3
- ---
@@ -1 +0,0 @@
1
- export * from "@nuxt/ui"