Skip to content

Commit a9bd6d8

Browse files
committed
v1.15.0
1 parent 073eb9d commit a9bd6d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+909
-95
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.15.0
4+
5+
### Minor Changes
6+
7+
- feat(Timeline): add color depends on state
8+
39
## 1.14.6
410

511
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flowbite-svelte",
3-
"version": "1.14.6",
3+
"version": "1.15.0",
44
"description": "Flowbite components for Svelte",
55
"main": "dist/index.js",
66
"author": {

src/lib/timeline/TimelineItem.svelte

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@
55
import clsx from "clsx";
66
import { getTheme, warnThemeDeprecation } from "$lib/theme/themeUtils";
77
8-
let { children, orientationSlot, title, date, dateFormat = "month-year", svgClass, liClass, divClass, timeClass, h3Class, class: className, classes, ...restProps }: TimelineItemProps = $props();
8+
let { children, orientationSlot, title, date, dateFormat = "month-year", color = "primary", isLast = false, svgClass, liClass, divClass, timeClass, h3Class, connectorClass, datePrefix, class: className, classes, ...restProps }: TimelineItemProps = $props();
99
1010
warnThemeDeprecation(
1111
"TimelineItem",
12-
{ svgClass, liClass, divClass, timeClass, h3Class },
12+
{ svgClass, liClass, divClass, timeClass, h3Class, connectorClass },
1313
{
1414
liClass: "class",
1515
svgClass: "svg",
1616
divClass: "div",
1717
timeClass: "time",
18-
h3Class: "h3"
18+
h3Class: "h3",
19+
connectorClass: "connector"
1920
}
2021
);
22+
2123
const styling = $derived({
2224
svg: svgClass,
2325
div: divClass,
2426
time: timeClass,
25-
h3: h3Class
27+
h3: h3Class,
28+
connector: connectorClass
2629
});
2730
2831
const theme = getTheme("timelineItem");
29-
3032
let order = getContext<TimelineVariants["order"]>("order");
3133
32-
const { base, div, time, h3, svg } = $derived(timelineItem({ order }));
34+
const { base, div, time, h3, svg, connector } = $derived(timelineItem({ order, color, isLast }));
3335
3436
function formatDisplayDate(dateStr: string, format: DateFormat) {
3537
const date = new Date(dateStr);
@@ -61,6 +63,11 @@
6163
</script>
6264

6365
<li {...restProps} class={base({ class: clsx(theme?.base, className ?? liClass) })}>
66+
<!-- Individual connector line for vertical/activity layouts -->
67+
{#if !isLast && (order === "vertical" || order === "activity")}
68+
<div class={connector({ class: clsx(theme?.connector, styling.connector) })} aria-hidden="true"></div>
69+
{/if}
70+
6471
{#if order !== "default"}
6572
{#if orientationSlot && (order === "vertical" || order === "horizontal")}
6673
{@render orientationSlot()}
@@ -73,9 +80,11 @@
7380
{/if}
7481
{:else if date}
7582
<time datetime={date} class={time({ class: clsx(theme?.time, styling.time) })}>
83+
{datePrefix}
7684
{formatDisplayDate(date, dateFormat)}
7785
</time>
7886
{/if}
87+
7988
{#if title}
8089
<h3 class={h3({ class: clsx(theme?.h3, styling.h3) })}>
8190
{title}
@@ -84,7 +93,8 @@
8493

8594
{#if order !== "default"}
8695
{#if date}
87-
<time datetime={date} class={time({ class: clsx(theme?.time, timeClass) })}>
96+
<time datetime={date} class={time({ class: clsx(theme?.time, styling.time) })}>
97+
{datePrefix}
8898
{formatDisplayDate(date, dateFormat)}
8999
</time>
90100
{/if}
@@ -97,18 +107,22 @@
97107
@component
98108
[Go to docs](https://flowbite-svelte.com/)
99109
## Type
100-
[TimelineItemProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L1816)
110+
[TimelineItemProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L1818)
101111
## Props
102112
@prop children
103113
@prop orientationSlot
104114
@prop title
105115
@prop date
106116
@prop dateFormat = "month-year"
117+
@prop color = "primary"
118+
@prop isLast = false
107119
@prop svgClass
108120
@prop liClass
109121
@prop divClass
110122
@prop timeClass
111123
@prop h3Class
124+
@prop connectorClass
125+
@prop datePrefix
112126
@prop class: className
113127
@prop classes
114128
@prop ...restProps

src/lib/timeline/theme.ts

Lines changed: 206 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,58 @@ export const groupItem = tv({
4545
}
4646
});
4747

48+
const colorVariants = {
49+
primary: {
50+
dot: "bg-primary-200 dark:bg-primary-900",
51+
ring: "ring-white dark:ring-gray-900",
52+
icon: "text-primary-600 dark:text-primary-400",
53+
connector: "border-primary-200 dark:border-primary-700"
54+
},
55+
green: {
56+
dot: "bg-green-200 dark:bg-green-900",
57+
ring: "ring-white dark:ring-gray-900",
58+
icon: "text-green-600 dark:text-green-400",
59+
connector: "border-green-200 dark:border-green-700"
60+
},
61+
orange: {
62+
dot: "bg-orange-200 dark:bg-orange-900",
63+
ring: "ring-white dark:ring-gray-900",
64+
icon: "text-orange-600 dark:text-orange-400",
65+
connector: "border-orange-200 dark:border-orange-700"
66+
},
67+
red: {
68+
dot: "bg-red-200 dark:bg-red-900",
69+
ring: "ring-white dark:ring-gray-900",
70+
icon: "text-red-600 dark:text-red-400",
71+
connector: "border-red-200 dark:border-red-700"
72+
},
73+
blue: {
74+
dot: "bg-blue-200 dark:bg-blue-900",
75+
ring: "ring-white dark:ring-gray-900",
76+
icon: "text-blue-600 dark:text-blue-400",
77+
connector: "border-blue-200 dark:border-blue-700"
78+
},
79+
purple: {
80+
dot: "bg-purple-200 dark:bg-purple-900",
81+
ring: "ring-white dark:ring-gray-900",
82+
icon: "text-purple-600 dark:text-purple-400",
83+
connector: "border-purple-200 dark:border-purple-700"
84+
},
85+
gray: {
86+
dot: "bg-gray-200 dark:bg-gray-700",
87+
ring: "ring-white dark:ring-gray-900",
88+
icon: "text-gray-600 dark:text-gray-400",
89+
connector: "border-gray-200 dark:border-gray-700"
90+
}
91+
};
92+
4893
export const timeline = tv({
4994
variants: {
5095
order: {
5196
group: "p-5 mb-4 bg-gray-50 rounded-lg border border-gray-100 dark:bg-gray-800 dark:border-gray-700",
5297
horizontal: "sm:flex",
53-
activity: "relative border-s border-gray-200 dark:border-gray-700",
54-
vertical: "relative border-s border-gray-200 dark:border-gray-700",
98+
activity: "relative",
99+
vertical: "relative",
55100
default: "relative border-s border-gray-200 dark:border-gray-700"
56101
}
57102
},
@@ -62,25 +107,27 @@ export const timeline = tv({
62107

63108
export const timelineItem = tv({
64109
slots: {
65-
base: "",
110+
base: "relative",
66111
div: "",
67112
time: "",
68113
h3: "",
69-
svg: "w-3 h-3 text-primary-600 dark:text-primary-400"
114+
svg: "w-4 h-4",
115+
connector: "absolute top-6 left-3 w-px h-full"
70116
},
71117
variants: {
72118
order: {
73119
default: {
74120
base: "mb-10 ms-4",
75-
div: "absolute w-3 h-3 bg-gray-200 rounded-full mt-1.5 -start-1.5 border border-white dark:border-gray-900 dark:bg-gray-700",
121+
div: "absolute w-3 h-3 bg-gray-200 rounded-full mt-1.5 -left-1.5 border border-white dark:border-gray-900 dark:bg-gray-700",
76122
time: "mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500",
77123
h3: "text-lg font-semibold text-gray-900 dark:text-white"
78124
},
79125
vertical: {
80-
base: "mb-10 ms-6",
81-
div: "flex absolute -start-3 justify-center items-center w-6 h-6 bg-primary-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-primary-900",
82-
time: "mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500",
83-
h3: "flex items-center mb-1 text-lg font-semibold text-gray-900 dark:text-white"
126+
base: "mb-10 ms-6 relative",
127+
div: "flex absolute -left-4 top-1.5 justify-center items-center w-6 h-6 rounded-full ring-8",
128+
time: "mb-1 pl-4 text-sm font-normal leading-none text-gray-400 dark:text-gray-500",
129+
h3: "flex ml-4 items-center mb-1 text-lg font-semibold text-gray-900 dark:text-white",
130+
connector: "absolute top-7 -left-1.5 w-px h-full"
84131
},
85132
horizontal: {
86133
base: "relative mb-6 sm:mb-0",
@@ -89,20 +136,166 @@ export const timelineItem = tv({
89136
h3: "text-lg font-semibold text-gray-900 dark:text-white"
90137
},
91138
activity: {
92-
base: "mb-10 ms-6",
93-
div: "flex absolute -start-3 justify-center items-center w-6 h-6 bg-primary-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-primary-900",
139+
base: "mb-10 ms-6 relative",
140+
div: "flex absolute -left-4 top-1.5 justify-center items-center w-6 h-6 rounded-full ring-8",
94141
time: "mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500",
95-
h3: "text-lg font-semibold text-gray-900 dark:text-white"
142+
h3: "text-lg font-semibold text-gray-900 dark:text-white",
143+
connector: "absolute top-7 -left-4 w-px h-full"
96144
},
97145
group: {
98146
base: "",
99147
div: "p-5 mb-4 bg-gray-50 rounded-lg border border-gray-100 dark:bg-gray-800 dark:border-gray-700",
100148
time: "text-lg font-semibold text-gray-900 dark:text-white",
101149
h3: "text-lg font-semibold text-gray-900 dark:text-white"
102150
}
151+
},
152+
color: {
153+
primary: {},
154+
green: {},
155+
orange: {},
156+
red: {},
157+
blue: {},
158+
purple: {},
159+
gray: {}
160+
},
161+
isLast: {
162+
true: {},
163+
false: {}
103164
}
104165
},
166+
compoundVariants: [
167+
// Vertical color variants
168+
{
169+
order: "vertical",
170+
color: "primary",
171+
class: {
172+
div: colorVariants.primary.dot + " " + colorVariants.primary.ring,
173+
svg: colorVariants.primary.icon,
174+
connector: "bg-primary-200 dark:bg-primary-700"
175+
}
176+
},
177+
{
178+
order: "vertical",
179+
color: "green",
180+
class: {
181+
div: colorVariants.green.dot + " " + colorVariants.green.ring,
182+
svg: colorVariants.green.icon,
183+
connector: "bg-green-200 dark:bg-green-700"
184+
}
185+
},
186+
{
187+
order: "vertical",
188+
color: "orange",
189+
class: {
190+
div: colorVariants.orange.dot + " " + colorVariants.orange.ring,
191+
svg: colorVariants.orange.icon,
192+
connector: "bg-orange-200 dark:bg-orange-700"
193+
}
194+
},
195+
{
196+
order: "vertical",
197+
color: "red",
198+
class: {
199+
div: colorVariants.red.dot + " " + colorVariants.red.ring,
200+
svg: colorVariants.red.icon,
201+
connector: "bg-red-200 dark:bg-red-700"
202+
}
203+
},
204+
{
205+
order: "vertical",
206+
color: "blue",
207+
class: {
208+
div: colorVariants.blue.dot + " " + colorVariants.blue.ring,
209+
svg: colorVariants.blue.icon,
210+
connector: "bg-blue-200 dark:bg-blue-700"
211+
}
212+
},
213+
{
214+
order: "vertical",
215+
color: "purple",
216+
class: {
217+
div: colorVariants.purple.dot + " " + colorVariants.purple.ring,
218+
svg: colorVariants.purple.icon,
219+
connector: "bg-purple-200 dark:bg-purple-700"
220+
}
221+
},
222+
{
223+
order: "vertical",
224+
color: "gray",
225+
class: {
226+
div: colorVariants.gray.dot + " " + colorVariants.gray.ring,
227+
svg: colorVariants.gray.icon,
228+
connector: "bg-gray-200 dark:bg-gray-700"
229+
}
230+
},
231+
// Horizontal color variants
232+
{
233+
order: "horizontal",
234+
color: "primary",
235+
class: {
236+
div: colorVariants.primary.dot + " " + colorVariants.primary.ring,
237+
svg: colorVariants.primary.icon
238+
}
239+
},
240+
{
241+
order: "horizontal",
242+
color: "green",
243+
class: {
244+
div: colorVariants.green.dot + " " + colorVariants.green.ring,
245+
svg: colorVariants.green.icon
246+
}
247+
},
248+
{
249+
order: "horizontal",
250+
color: "orange",
251+
class: {
252+
div: colorVariants.orange.dot + " " + colorVariants.orange.ring,
253+
svg: colorVariants.orange.icon
254+
}
255+
},
256+
{
257+
order: "horizontal",
258+
color: "red",
259+
class: {
260+
div: colorVariants.red.dot + " " + colorVariants.red.ring,
261+
svg: colorVariants.red.icon
262+
}
263+
},
264+
{
265+
order: "horizontal",
266+
color: "blue",
267+
class: {
268+
div: colorVariants.blue.dot + " " + colorVariants.blue.ring,
269+
svg: colorVariants.blue.icon
270+
}
271+
},
272+
{
273+
order: "horizontal",
274+
color: "purple",
275+
class: {
276+
div: colorVariants.purple.dot + " " + colorVariants.purple.ring,
277+
svg: colorVariants.purple.icon
278+
}
279+
},
280+
{
281+
order: "horizontal",
282+
color: "gray",
283+
class: {
284+
div: colorVariants.gray.dot + " " + colorVariants.gray.ring,
285+
svg: colorVariants.gray.icon
286+
}
287+
},
288+
// Hide connector on last item
289+
{
290+
isLast: true,
291+
class: {
292+
connector: "hidden"
293+
}
294+
}
295+
],
105296
defaultVariants: {
106-
order: "default"
297+
order: "default",
298+
color: "primary",
299+
isLast: false
107300
}
108301
});

src/lib/toast/Toast.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
@component
6262
[Go to docs](https://flowbite-svelte.com/)
6363
## Type
64-
[ToastProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L1830)
64+
[ToastProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L1836)
6565
## Props
6666
@prop children
6767
@prop icon

0 commit comments

Comments
 (0)