1 import clsx from "clsx"
2 import { HeadlineTags } from "docs-ui"
3 import HomepageWhatsNewRow from "./Row"
4 import { MAX_WHATS_NEW_ITEMS, whatsNewItems, WhatsNewItem } from "./data"
5
6 const getPriority = (item: WhatsNewItem) => {
7 if (item.comingSoon) {
8 return 0
9 }
10
11 return item.earlyAccess ? 1 : 2
12 }
13
14 const sortItems = (a: WhatsNewItem, b: WhatsNewItem) => {
15 const priorityDiff = getPriority(a) - getPriority(b)
16 if (priorityDiff !== 0) {
17 return priorityDiff
18 }
19
20 return (b.date ?? "").localeCompare(a.date ?? "")
21 }
22
23 const HomepageWhatsNewSection = () => {
24 const items = [...whatsNewItems].sort(sortItems).slice(0, MAX_WHATS_NEW_ITEMS)
25
26 return (
27 <div
28 className={clsx(
29 "w-full flex flex-col md:flex-row",
30 "border-b border-medusa-border-base"
31 )}
32 >
33 <div
34 className={clsx(
35 "p-2 w-full md:w-1/3 flex flex-col justify-center gap-0.75",
36 "bg-medusa-bg-component",
37 "border-b border-medusa-border-base md:border-b-0 md:border-r"
38 )}
39 >
40 <HeadlineTags tags={["What's New"]} className="!justify-start" />
41 <h2 className="text-h1 text-medusa-fg-base">
42 New features, releases, and guides.
43 </h2>
44 <p className="txt-large text-medusa-fg-base">
45 Learn more about what we&apos;re shipping.
46 </p>
47 </div>
48 <div className="w-full md:w-2/3 flex flex-col">
49 {items.map((item, index) => (
50 <HomepageWhatsNewRow
51 key={index}
52 item={item}
53 position={index}
54 isLast={index === items.length - 1}
55 />
56 ))}
57 </div>
58 </div>
59 )
60 }
61
62 export default HomepageWhatsNewSection