@krrli/cm-designsystem 1.32.1 → 1.32.2

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 (180) hide show
  1. package/dist/assets/fallback.png.js +4 -0
  2. package/dist/cm-designsystem.css +1944 -1
  3. package/dist/components/accessible-button/AccessibleButton.js +29 -11
  4. package/dist/components/avatar/Avatar.js +91 -65
  5. package/dist/components/branding/BrandingGallery.js +212 -145
  6. package/dist/components/branding/app-icon-gradient.svg.js +4 -0
  7. package/dist/components/branding/app-icon-white.svg.js +4 -0
  8. package/dist/components/branding/hover-logo-default.svg.js +4 -0
  9. package/dist/components/branding/hover-logo-hovered.svg.js +4 -0
  10. package/dist/components/branding/logo-inline-gradient.svg.js +4 -0
  11. package/dist/components/branding/logo-inline-violet.svg.js +4 -0
  12. package/dist/components/branding/logo-inline-white.svg.js +4 -0
  13. package/dist/components/branding/logo-stacked-gradient.svg.js +4 -0
  14. package/dist/components/branding/logo-stacked-violet.svg.js +4 -0
  15. package/dist/components/branding/logo-stacked-white.svg.js +4 -0
  16. package/dist/components/branding/superzeichen.svg.js +4 -0
  17. package/dist/components/button/Button.js +61 -55
  18. package/dist/components/color/ColorDoc.js +26 -7
  19. package/dist/components/file-upload/FileUpload.js +129 -66
  20. package/dist/components/form/Form.js +33 -26
  21. package/dist/components/icon-button/IconButton.js +33 -29
  22. package/dist/components/icons/IconBase.js +21 -6
  23. package/dist/components/icons/generated/ArrowDown.js +15 -4
  24. package/dist/components/icons/generated/ArrowLeft.js +15 -4
  25. package/dist/components/icons/generated/ArrowRight.js +15 -4
  26. package/dist/components/icons/generated/ArrowUp.js +15 -4
  27. package/dist/components/icons/generated/Calendar.js +15 -4
  28. package/dist/components/icons/generated/Cancel.js +12 -4
  29. package/dist/components/icons/generated/Checkmark.js +12 -4
  30. package/dist/components/icons/generated/Edit.js +9 -4
  31. package/dist/components/icons/generated/Eye.js +15 -4
  32. package/dist/components/icons/generated/Fullscreen.js +9 -4
  33. package/dist/components/icons/generated/HeartFilled.js +15 -4
  34. package/dist/components/icons/generated/HeartOutline.js +15 -4
  35. package/dist/components/icons/generated/Location.js +15 -4
  36. package/dist/components/icons/generated/LogOut.js +12 -4
  37. package/dist/components/icons/generated/Mumble.js +13 -4
  38. package/dist/components/icons/generated/Profile.js +12 -4
  39. package/dist/components/icons/generated/ReplyFilled.js +15 -4
  40. package/dist/components/icons/generated/ReplyOutline.js +15 -4
  41. package/dist/components/icons/generated/Repost.js +15 -4
  42. package/dist/components/icons/generated/Send.js +15 -4
  43. package/dist/components/icons/generated/Settings.js +15 -4
  44. package/dist/components/icons/generated/Share.js +12 -4
  45. package/dist/components/icons/generated/Time.js +12 -4
  46. package/dist/components/icons/generated/Upload.js +21 -4
  47. package/dist/components/input/Input.js +67 -41
  48. package/dist/components/like-toggle/LikeToggle.js +203 -176
  49. package/dist/components/logo-link/LogoLink.js +56 -34
  50. package/dist/components/modal/Modal.js +66 -50
  51. package/dist/components/navi-button/NaviButton.js +42 -30
  52. package/dist/components/navi-user-button/NaviUserButton.js +39 -29
  53. package/dist/components/round-button/RoundButton.js +39 -29
  54. package/dist/components/tabs/TabItem.js +11 -8
  55. package/dist/components/tabs/Tabs.js +74 -59
  56. package/dist/components/text-link/TextLink.js +14 -11
  57. package/dist/components/textarea/Textarea.js +57 -41
  58. package/dist/components/timed-button/TimedButton.js +116 -102
  59. package/dist/components/toggle/Toggle.js +91 -62
  60. package/dist/components/typography/AccessibleTypography.js +12 -9
  61. package/dist/components/typography/Heading.js +13 -9
  62. package/dist/components/typography/Label.js +13 -9
  63. package/dist/components/typography/Paragraph.js +13 -9
  64. package/dist/components/typography/Placeholder.js +13 -9
  65. package/dist/components/typography/ValidationMessage.js +14 -9
  66. package/dist/components/typography/styles.js +53 -46
  67. package/dist/compositions/image-banner/ImageBanner.js +53 -45
  68. package/dist/compositions/image-upload-modal/ImageUploadModal.js +44 -20
  69. package/dist/compositions/post/Post.js +81 -26
  70. package/dist/compositions/post-base/PostBase.js +23 -24
  71. package/dist/compositions/post-creator/PostCreator.js +72 -24
  72. package/dist/compositions/profile-banner/ProfileBanner.js +71 -21
  73. package/dist/compositions/profile-banner-image/ProfileBannerImage.js +60 -52
  74. package/dist/compositions/profile-banner-info/ProfileBannerInfo.js +72 -40
  75. package/dist/compositions/response/Response.js +63 -19
  76. package/dist/compositions/response-creator/ResponseCreator.js +67 -23
  77. package/dist/compositions/user-info/UserInfo.js +71 -52
  78. package/dist/compositions/user-recommendation/UserRecommendation.js +58 -30
  79. package/dist/index.js +129 -4
  80. package/package.json +14 -12
  81. package/dist/components/accessible-button/AccessibleButton.d.ts +0 -32
  82. package/dist/components/accessible-button/AccessibleButton.test.d.ts +0 -1
  83. package/dist/components/accessible-button/AccessibleButton.test.js +0 -28
  84. package/dist/components/avatar/Avatar.d.ts +0 -118
  85. package/dist/components/branding/BrandingGallery.d.ts +0 -1
  86. package/dist/components/button/Button.d.ts +0 -66
  87. package/dist/components/button/Button.test.d.ts +0 -1
  88. package/dist/components/button/Button.test.js +0 -30
  89. package/dist/components/color/ColorDoc.d.ts +0 -4
  90. package/dist/components/file-upload/FileUpload.d.ts +0 -83
  91. package/dist/components/form/Form.d.ts +0 -54
  92. package/dist/components/icon-button/IconButton.d.ts +0 -69
  93. package/dist/components/icon-button/IconButton.test.d.ts +0 -1
  94. package/dist/components/icon-button/IconButton.test.js +0 -22
  95. package/dist/components/icons/IconBase.d.ts +0 -5
  96. package/dist/components/icons/generated/ArrowDown.d.ts +0 -3
  97. package/dist/components/icons/generated/ArrowLeft.d.ts +0 -3
  98. package/dist/components/icons/generated/ArrowRight.d.ts +0 -3
  99. package/dist/components/icons/generated/ArrowUp.d.ts +0 -3
  100. package/dist/components/icons/generated/Calendar.d.ts +0 -3
  101. package/dist/components/icons/generated/Cancel.d.ts +0 -3
  102. package/dist/components/icons/generated/Checkmark.d.ts +0 -3
  103. package/dist/components/icons/generated/Edit.d.ts +0 -3
  104. package/dist/components/icons/generated/Eye.d.ts +0 -3
  105. package/dist/components/icons/generated/Fullscreen.d.ts +0 -3
  106. package/dist/components/icons/generated/HeartFilled.d.ts +0 -3
  107. package/dist/components/icons/generated/HeartOutline.d.ts +0 -3
  108. package/dist/components/icons/generated/Location.d.ts +0 -3
  109. package/dist/components/icons/generated/LogOut.d.ts +0 -3
  110. package/dist/components/icons/generated/Mumble.d.ts +0 -3
  111. package/dist/components/icons/generated/Profile.d.ts +0 -3
  112. package/dist/components/icons/generated/ReplyFilled.d.ts +0 -3
  113. package/dist/components/icons/generated/ReplyOutline.d.ts +0 -3
  114. package/dist/components/icons/generated/Repost.d.ts +0 -3
  115. package/dist/components/icons/generated/Send.d.ts +0 -3
  116. package/dist/components/icons/generated/Settings.d.ts +0 -3
  117. package/dist/components/icons/generated/Share.d.ts +0 -3
  118. package/dist/components/icons/generated/Time.d.ts +0 -3
  119. package/dist/components/icons/generated/Upload.d.ts +0 -3
  120. package/dist/components/icons/generated/index.d.ts +0 -24
  121. package/dist/components/icons/generated/index.js +0 -24
  122. package/dist/components/index.d.ts +0 -27
  123. package/dist/components/index.js +0 -27
  124. package/dist/components/input/Input.d.ts +0 -61
  125. package/dist/components/like-toggle/LikeToggle.d.ts +0 -97
  126. package/dist/components/like-toggle/LikeToggle.test.d.ts +0 -1
  127. package/dist/components/like-toggle/LikeToggle.test.js +0 -35
  128. package/dist/components/logo-link/LogoLink.d.ts +0 -11
  129. package/dist/components/modal/Modal.d.ts +0 -75
  130. package/dist/components/modal/Modal.test.d.ts +0 -1
  131. package/dist/components/modal/Modal.test.js +0 -24
  132. package/dist/components/navi-button/NaviButton.d.ts +0 -49
  133. package/dist/components/navi-button/NaviButton.test.d.ts +0 -1
  134. package/dist/components/navi-button/NaviButton.test.js +0 -22
  135. package/dist/components/navi-user-button/NaviUserButton.d.ts +0 -44
  136. package/dist/components/round-button/RoundButton.d.ts +0 -44
  137. package/dist/components/round-button/RoundButton.test.d.ts +0 -1
  138. package/dist/components/round-button/RoundButton.test.js +0 -22
  139. package/dist/components/tabs/TabItem.d.ts +0 -11
  140. package/dist/components/tabs/Tabs.d.ts +0 -67
  141. package/dist/components/tabs/Tabs.test.d.ts +0 -1
  142. package/dist/components/tabs/Tabs.test.js +0 -61
  143. package/dist/components/text-link/TextLink.d.ts +0 -9
  144. package/dist/components/text-link/TextLink.test.d.ts +0 -1
  145. package/dist/components/text-link/TextLink.test.js +0 -14
  146. package/dist/components/textarea/Textarea.d.ts +0 -48
  147. package/dist/components/timed-button/TimedButton.d.ts +0 -79
  148. package/dist/components/timed-button/TimedButton.test.d.ts +0 -1
  149. package/dist/components/timed-button/TimedButton.test.js +0 -36
  150. package/dist/components/toggle/Toggle.d.ts +0 -62
  151. package/dist/components/toggle/Toggle.test.d.ts +0 -1
  152. package/dist/components/toggle/Toggle.test.js +0 -93
  153. package/dist/components/typography/AccessibleTypography.d.ts +0 -33
  154. package/dist/components/typography/Heading.d.ts +0 -24
  155. package/dist/components/typography/Label.d.ts +0 -22
  156. package/dist/components/typography/Paragraph.d.ts +0 -22
  157. package/dist/components/typography/Placeholder.d.ts +0 -17
  158. package/dist/components/typography/ValidationMessage.d.ts +0 -22
  159. package/dist/components/typography/styles.d.ts +0 -74
  160. package/dist/compositions/image-banner/ImageBanner.d.ts +0 -54
  161. package/dist/compositions/image-upload-modal/ImageUploadModal.d.ts +0 -15
  162. package/dist/compositions/index.d.ts +0 -11
  163. package/dist/compositions/index.js +0 -11
  164. package/dist/compositions/post/Post.d.ts +0 -75
  165. package/dist/compositions/post-base/PostBase.d.ts +0 -41
  166. package/dist/compositions/post-creator/PostCreator.d.ts +0 -69
  167. package/dist/compositions/profile-banner/ProfileBanner.d.ts +0 -82
  168. package/dist/compositions/profile-banner-image/ProfileBannerImage.d.ts +0 -54
  169. package/dist/compositions/profile-banner-info/ProfileBannerInfo.d.ts +0 -92
  170. package/dist/compositions/response/Response.d.ts +0 -75
  171. package/dist/compositions/response-creator/ResponseCreator.d.ts +0 -63
  172. package/dist/compositions/user-info/UserInfo.d.ts +0 -75
  173. package/dist/compositions/user-recommendation/UserRecommendation.d.ts +0 -63
  174. package/dist/favicon.svg +0 -18
  175. package/dist/index.cjs.js +0 -50
  176. package/dist/index.d.ts +0 -3
  177. package/dist/index.es.js +0 -8343
  178. package/dist/logo-inline-gradient.svg +0 -43
  179. package/dist/setupTests.d.ts +0 -1
  180. package/dist/setupTests.js +0 -7
@@ -1,57 +1,65 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as AspectRatio from "@radix-ui/react-aspect-ratio";
3
3
  import { useState } from "react";
4
- import { cn, tv } from "tailwind-variants";
5
- import { Edit } from "../../components/icons/generated";
4
+ import { tv, cn } from "tailwind-variants";
5
+ import { Edit } from "../../components/icons/generated/Edit.js";
6
6
  const ProfileBannerImageStyles = tv({
7
- slots: {
8
- base: ["w-170", "h-80"],
9
- image: [
10
- "h-full",
11
- "w-full",
12
- "cursor-pointer",
13
- "rounded-2xl",
14
- "object-cover",
15
- ],
16
- overlay: [
17
- "group",
18
- "absolute",
19
- "flex",
20
- "items-center",
21
- "justify-center",
22
- "text-white",
23
- "inset-0",
24
- "bg-violet-600/0",
25
- "hover:bg-violet-600/50",
26
- "transition",
27
- "duration-500",
28
- "ease-in-out",
29
- ],
30
- icon: [
31
- "w-8",
32
- "h-8",
33
- "opacity-0",
34
- "group-hover:opacity-100",
35
- "transition",
36
- "duration-500",
37
- "rotate-15",
38
- "group-hover:rotate-0",
39
- ],
40
- },
41
- variants: {
42
- isFallback: {
43
- true: { image: ["bg-violet-200"] },
44
- },
45
- },
7
+ slots: {
8
+ base: ["w-170", "h-80"],
9
+ image: [
10
+ "h-full",
11
+ "w-full",
12
+ "cursor-pointer",
13
+ "rounded-2xl",
14
+ "object-cover"
15
+ ],
16
+ overlay: [
17
+ "group",
18
+ "absolute",
19
+ "flex",
20
+ "items-center",
21
+ "justify-center",
22
+ "text-white",
23
+ "inset-0",
24
+ "bg-violet-600/0",
25
+ "hover:bg-violet-600/50",
26
+ "transition",
27
+ "duration-500",
28
+ "ease-in-out"
29
+ ],
30
+ icon: [
31
+ "w-8",
32
+ "h-8",
33
+ "opacity-0",
34
+ "group-hover:opacity-100",
35
+ "transition",
36
+ "duration-500",
37
+ "rotate-15",
38
+ "group-hover:rotate-0"
39
+ ]
40
+ },
41
+ variants: {
42
+ isFallback: {
43
+ true: { image: ["bg-violet-200"] }
44
+ }
45
+ }
46
46
  });
47
- /**
48
- * ProfileBannerImage component
49
- *
50
- * Displays a banner image with a fixed aspect ratio (17:8) and an optional overlay icon.
51
- * If the image fails to load, a fallback element is displayed instead.
52
- */
53
- export const ProfileBannerImage = (props) => {
54
- const { base, image, overlay, icon } = ProfileBannerImageStyles(props);
55
- const [src, setSrc] = useState(props.src);
56
- return (_jsx("div", { className: base(), children: src ? (_jsxs(AspectRatio.Root, { ratio: 17 / 8, children: [_jsx("img", { className: image(), src: src, alt: props.alt, onError: () => setSrc("") }), _jsx("button", { className: cn(image(), overlay()), onClick: props.onClick, children: _jsx(Edit, { className: icon() }) })] })) : (_jsx("div", { className: image({ isFallback: true }) })) }));
47
+ const ProfileBannerImage = (props) => {
48
+ const { base, image, overlay, icon } = ProfileBannerImageStyles(props);
49
+ const [src, setSrc] = useState(props.src);
50
+ return /* @__PURE__ */ jsx("div", { className: base(), children: src ? /* @__PURE__ */ jsxs(AspectRatio.Root, { ratio: 17 / 8, children: [
51
+ /* @__PURE__ */ jsx(
52
+ "img",
53
+ {
54
+ className: image(),
55
+ src,
56
+ alt: props.alt,
57
+ onError: () => setSrc("")
58
+ }
59
+ ),
60
+ /* @__PURE__ */ jsx("button", { className: cn(image(), overlay()), onClick: props.onClick, children: /* @__PURE__ */ jsx(Edit, { className: icon() }) })
61
+ ] }) : /* @__PURE__ */ jsx("div", { className: image({ isFallback: true }) }) });
62
+ };
63
+ export {
64
+ ProfileBannerImage
57
65
  };
@@ -1,47 +1,79 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { tv } from "tailwind-variants";
3
- import { IconButton } from "../../components/icon-button/IconButton";
4
- import { Profile, Location, Calendar, Settings, } from "../../components/icons/generated";
5
- import { Label } from "../../components/typography/Label";
3
+ import { IconButton } from "../../components/icon-button/IconButton.js";
4
+ import { Label } from "../../components/typography/Label.js";
5
+ import { Settings } from "../../components/icons/generated/Settings.js";
6
+ import { Location } from "../../components/icons/generated/Location.js";
7
+ import { Calendar } from "../../components/icons/generated/Calendar.js";
8
+ import { Profile } from "../../components/icons/generated/Profile.js";
6
9
  const profileBannerInfoStyles = tv({
7
- slots: {
8
- base: ["flex", "flex-col", "gap-2", "items-start"],
9
- title: ["flex", "gap-1", "items-center", "**:cursor-pointer"],
10
- icon: ["text-violet-600", "-mt-0.5"],
11
- displayName: ["text-slate-900"],
12
- detailInfo: ["flex", "gap-4"],
13
- secondaryInfo: ["text-slate-500"],
14
- },
10
+ slots: {
11
+ base: ["flex", "flex-col", "gap-2", "items-start"],
12
+ title: ["flex", "gap-1", "items-center", "**:cursor-pointer"],
13
+ icon: ["text-violet-600", "-mt-0.5"],
14
+ displayName: ["text-slate-900"],
15
+ detailInfo: ["flex", "gap-4"],
16
+ secondaryInfo: ["text-slate-500"]
17
+ }
15
18
  });
16
19
  function timeSince(timestamp) {
17
- const now = new Date();
18
- const past = timestamp instanceof Date ? timestamp : new Date(timestamp);
19
- const diffMs = now.getTime() - past.getTime();
20
- const seconds = Math.floor(diffMs / 1000);
21
- const minutes = Math.floor(seconds / 60);
22
- const hours = Math.floor(minutes / 60);
23
- const days = Math.floor(hours / 24);
24
- const months = Math.floor(days / 30); // approximate
25
- const years = Math.floor(days / 365); // approximate
26
- if (years > 0)
27
- return years === 1 ? "1 year" : `${years} years`;
28
- if (months > 0)
29
- return months === 1 ? "1 month" : `${months} months`;
30
- if (days > 0)
31
- return days === 1 ? "1 day" : `${days} days`;
32
- if (hours > 0)
33
- return hours === 1 ? "1 hour" : `${hours} hours`;
34
- if (minutes > 0)
35
- return minutes === 1 ? "1 minute" : `${minutes} minutes`;
36
- return seconds <= 1 ? "just now" : `${seconds} seconds`;
20
+ const now = /* @__PURE__ */ new Date();
21
+ const past = timestamp instanceof Date ? timestamp : new Date(timestamp);
22
+ const diffMs = now.getTime() - past.getTime();
23
+ const seconds = Math.floor(diffMs / 1e3);
24
+ const minutes = Math.floor(seconds / 60);
25
+ const hours = Math.floor(minutes / 60);
26
+ const days = Math.floor(hours / 24);
27
+ const months = Math.floor(days / 30);
28
+ const years = Math.floor(days / 365);
29
+ if (years > 0) return years === 1 ? "1 year" : `${years} years`;
30
+ if (months > 0) return months === 1 ? "1 month" : `${months} months`;
31
+ if (days > 0) return days === 1 ? "1 day" : `${days} days`;
32
+ if (hours > 0) return hours === 1 ? "1 hour" : `${hours} hours`;
33
+ if (minutes > 0) return minutes === 1 ? "1 minute" : `${minutes} minutes`;
34
+ return seconds <= 1 ? "just now" : `${seconds} seconds`;
37
35
  }
38
36
  const memberSincePrefix = "Member since ";
39
- /**
40
- * ProfileBannerInfo Component
41
- *
42
- * Renders profile information used in a user profile banner
43
- */
44
- export const ProfileBannerInfo = (props) => {
45
- const { base, title, icon, displayName, detailInfo, secondaryInfo } = profileBannerInfoStyles(props);
46
- return (_jsxs("div", { className: base(), children: [_jsxs("div", { className: title(), children: [_jsx("button", { onClick: props.onProfileClick, className: displayName(), children: _jsx(Label, { size: "xl", children: props.displayName }) }), props.isCurrentUser && (_jsx("button", { onClick: props.onSettingsClick, children: _jsx(Settings, { className: icon() }) }))] }), _jsxs("div", { className: detailInfo(), children: [_jsx(IconButton, { intent: "secondary", icon: Profile, onClick: props.onProfileClick, children: props.userName }), _jsx(IconButton, { intent: "primary", icon: Location, onClick: props.onProfileClick, className: secondaryInfo(), children: props.location }), _jsx(IconButton, { intent: "primary", icon: Calendar, onClick: props.onProfileClick, className: secondaryInfo(), children: memberSincePrefix + timeSince(props.joinedTimestamp) })] })] }));
37
+ const ProfileBannerInfo = (props) => {
38
+ const { base, title, icon, displayName, detailInfo, secondaryInfo } = profileBannerInfoStyles(props);
39
+ return /* @__PURE__ */ jsxs("div", { className: base(), children: [
40
+ /* @__PURE__ */ jsxs("div", { className: title(), children: [
41
+ /* @__PURE__ */ jsx("button", { onClick: props.onProfileClick, className: displayName(), children: /* @__PURE__ */ jsx(Label, { size: "xl", children: props.displayName }) }),
42
+ props.isCurrentUser && /* @__PURE__ */ jsx("button", { onClick: props.onSettingsClick, children: /* @__PURE__ */ jsx(Settings, { className: icon() }) })
43
+ ] }),
44
+ /* @__PURE__ */ jsxs("div", { className: detailInfo(), children: [
45
+ /* @__PURE__ */ jsx(
46
+ IconButton,
47
+ {
48
+ intent: "secondary",
49
+ icon: Profile,
50
+ onClick: props.onProfileClick,
51
+ children: props.userName
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ IconButton,
56
+ {
57
+ intent: "primary",
58
+ icon: Location,
59
+ onClick: props.onProfileClick,
60
+ className: secondaryInfo(),
61
+ children: props.location
62
+ }
63
+ ),
64
+ /* @__PURE__ */ jsx(
65
+ IconButton,
66
+ {
67
+ intent: "primary",
68
+ icon: Calendar,
69
+ onClick: props.onProfileClick,
70
+ className: secondaryInfo(),
71
+ children: memberSincePrefix + timeSince(props.joinedTimestamp)
72
+ }
73
+ )
74
+ ] })
75
+ ] });
76
+ };
77
+ export {
78
+ ProfileBannerInfo
47
79
  };
@@ -1,23 +1,67 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { tv } from "tailwind-variants";
3
- import { LikeToggle, Paragraph, TimedButton, Toggle } from "../../components";
4
- import { Share } from "../../components/icons/generated";
5
- import { ImageBanner } from "../image-banner/ImageBanner";
6
- import { PostBase } from "../post-base/PostBase";
7
- import { UserInfo } from "../user-info/UserInfo";
3
+ import { ImageBanner } from "../image-banner/ImageBanner.js";
4
+ import { PostBase } from "../post-base/PostBase.js";
5
+ import { UserInfo } from "../user-info/UserInfo.js";
6
+ import { Paragraph } from "../../components/typography/Paragraph.js";
7
+ import { Toggle } from "../../components/toggle/Toggle.js";
8
+ import { LikeToggle } from "../../components/like-toggle/LikeToggle.js";
9
+ import { TimedButton } from "../../components/timed-button/TimedButton.js";
10
+ import { Share } from "../../components/icons/generated/Share.js";
8
11
  const ResponseStyles = tv({
9
- slots: {
10
- base: [],
11
- content: ["flex", "flex-col", "gap-4"],
12
- text: ["text-slate-900"],
13
- action: ["flex", "gap-10", "justify-start", "-ml-3"],
14
- },
12
+ slots: {
13
+ base: [],
14
+ content: ["flex", "flex-col", "gap-4"],
15
+ text: ["text-slate-900"],
16
+ action: ["flex", "gap-10", "justify-start", "-ml-3"]
17
+ }
15
18
  });
16
- /**
17
- * Detailed Response component displaying user info, text content,
18
- * optional image, and action buttons (comment, like, share).
19
- */
20
- export const Response = (props) => {
21
- const { base, content, text, action } = ResponseStyles(props);
22
- return (_jsx(PostBase, { className: base(), children: _jsxs("div", { className: content(), children: [_jsx(UserInfo, { size: "sm", src: props.src, displayName: props.displayName, userName: props.userName, timestamp: props.timestamp, onClick: props.onAvatarClick }), _jsx(Paragraph, { size: "md", className: text(), children: props.text }), props.imageSrc && (_jsx(ImageBanner, { src: props.imageSrc, alt: props.imageAlt ?? "", onClick: () => { } })), _jsxs("div", { className: action(), children: [_jsx(Toggle, { ariaLabel: "Comment", labelText: "Comment", onToggle: props.onCommentClick }), _jsx(LikeToggle, { onLikeChange: props.onLikeClick }), _jsx(TimedButton, { icon: Share, label: "Copy Link", labelActive: "Link copied", onClick: props.onShareClick })] })] }) }));
19
+ const Response = (props) => {
20
+ const { base, content, text, action } = ResponseStyles(props);
21
+ return /* @__PURE__ */ jsx(PostBase, { className: base(), children: /* @__PURE__ */ jsxs("div", { className: content(), children: [
22
+ /* @__PURE__ */ jsx(
23
+ UserInfo,
24
+ {
25
+ size: "sm",
26
+ src: props.src,
27
+ displayName: props.displayName,
28
+ userName: props.userName,
29
+ timestamp: props.timestamp,
30
+ onClick: props.onAvatarClick
31
+ }
32
+ ),
33
+ /* @__PURE__ */ jsx(Paragraph, { size: "md", className: text(), children: props.text }),
34
+ props.imageSrc && /* @__PURE__ */ jsx(
35
+ ImageBanner,
36
+ {
37
+ src: props.imageSrc,
38
+ alt: props.imageAlt ?? "",
39
+ onClick: () => {
40
+ }
41
+ }
42
+ ),
43
+ /* @__PURE__ */ jsxs("div", { className: action(), children: [
44
+ /* @__PURE__ */ jsx(
45
+ Toggle,
46
+ {
47
+ ariaLabel: "Comment",
48
+ labelText: "Comment",
49
+ onToggle: props.onCommentClick
50
+ }
51
+ ),
52
+ /* @__PURE__ */ jsx(LikeToggle, { onLikeChange: props.onLikeClick }),
53
+ /* @__PURE__ */ jsx(
54
+ TimedButton,
55
+ {
56
+ icon: Share,
57
+ label: "Copy Link",
58
+ labelActive: "Link copied",
59
+ onClick: props.onShareClick
60
+ }
61
+ )
62
+ ] })
63
+ ] }) });
64
+ };
65
+ export {
66
+ Response
23
67
  };
@@ -1,28 +1,72 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { Form } from "@radix-ui/react-form";
3
- import { useRef, useState } from "react";
3
+ import { useState, useRef } from "react";
4
4
  import { tv } from "tailwind-variants";
5
- import { Button, Textarea } from "../../components";
6
- import { Send, Upload } from "../../components/icons/generated";
7
- import { ImageUploadModal, } from "../image-upload-modal/ImageUploadModal";
8
- import { PostBase } from "../post-base/PostBase";
9
- import { UserInfo } from "../user-info/UserInfo";
5
+ import { ImageUploadModal } from "../image-upload-modal/ImageUploadModal.js";
6
+ import { PostBase } from "../post-base/PostBase.js";
7
+ import { UserInfo } from "../user-info/UserInfo.js";
8
+ import { Textarea } from "../../components/textarea/Textarea.js";
9
+ import { Button } from "../../components/button/Button.js";
10
+ import { Upload } from "../../components/icons/generated/Upload.js";
11
+ import { Send } from "../../components/icons/generated/Send.js";
10
12
  const ResponseCreatorStyles = tv({
11
- slots: {
12
- content: ["flex", "flex-col", "gap-4", "w-full"],
13
- input: ["w-full", "h-40"],
14
- action: ["flex", "gap-4"],
15
- },
13
+ slots: {
14
+ content: ["flex", "flex-col", "gap-4", "w-full"],
15
+ input: ["w-full", "h-40"],
16
+ action: ["flex", "gap-4"]
17
+ }
16
18
  });
17
- /**
18
- * ResponseCreator component
19
- *
20
- * Renders a Response creation component.
21
- */
22
- export const ResponseCreator = (props) => {
23
- const { content, input, action } = ResponseCreatorStyles(props);
24
- const [file, setFile] = useState(null);
25
- const [text, setText] = useState("");
26
- const imageUploadModalRef = useRef(null);
27
- return (_jsxs(_Fragment, { children: [_jsx(PostBase, { children: _jsxs(Form, { className: content(), children: [_jsx(UserInfo, { displayName: props.displayName, onClick: props.onAvatarClick, size: "sm", src: props.src, userName: props.userName }), _jsx("div", { className: input(), children: _jsx(Textarea, { name: "post", placeholder: "Your opinion matters!", onChange: setText }) }), _jsxs("div", { className: action(), children: [_jsx(Button, { intent: "primary", size: "md", icon: Upload, onClick: () => imageUploadModalRef.current?.openModal(true), children: "Picture upload" }), _jsx(Button, { intent: "secondary", size: "md", icon: Send, onClick: () => props.onSendClick(text, file), children: "Send" })] })] }) }), _jsx(ImageUploadModal, { ref: imageUploadModalRef, onFileChange: setFile })] }));
19
+ const ResponseCreator = (props) => {
20
+ const { content, input, action } = ResponseCreatorStyles(props);
21
+ const [file, setFile] = useState(null);
22
+ const [text, setText] = useState("");
23
+ const imageUploadModalRef = useRef(null);
24
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
25
+ /* @__PURE__ */ jsx(PostBase, { children: /* @__PURE__ */ jsxs(Form, { className: content(), children: [
26
+ /* @__PURE__ */ jsx(
27
+ UserInfo,
28
+ {
29
+ displayName: props.displayName,
30
+ onClick: props.onAvatarClick,
31
+ size: "sm",
32
+ src: props.src,
33
+ userName: props.userName
34
+ }
35
+ ),
36
+ /* @__PURE__ */ jsx("div", { className: input(), children: /* @__PURE__ */ jsx(
37
+ Textarea,
38
+ {
39
+ name: "post",
40
+ placeholder: "Your opinion matters!",
41
+ onChange: setText
42
+ }
43
+ ) }),
44
+ /* @__PURE__ */ jsxs("div", { className: action(), children: [
45
+ /* @__PURE__ */ jsx(
46
+ Button,
47
+ {
48
+ intent: "primary",
49
+ size: "md",
50
+ icon: Upload,
51
+ onClick: () => imageUploadModalRef.current?.openModal(true),
52
+ children: "Picture upload"
53
+ }
54
+ ),
55
+ /* @__PURE__ */ jsx(
56
+ Button,
57
+ {
58
+ intent: "secondary",
59
+ size: "md",
60
+ icon: Send,
61
+ onClick: () => props.onSendClick(text, file),
62
+ children: "Send"
63
+ }
64
+ )
65
+ ] })
66
+ ] }) }),
67
+ /* @__PURE__ */ jsx(ImageUploadModal, { ref: imageUploadModalRef, onFileChange: setFile })
68
+ ] });
69
+ };
70
+ export {
71
+ ResponseCreator
28
72
  };
@@ -1,60 +1,79 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { tv } from "tailwind-variants";
3
- import { Avatar } from "../../components/avatar/Avatar";
4
- import { IconButton } from "../../components/icon-button/IconButton";
5
- import { Profile, Time } from "../../components/icons/generated";
6
- import { Label } from "../../components/typography/Label";
3
+ import { Avatar } from "../../components/avatar/Avatar.js";
4
+ import { IconButton } from "../../components/icon-button/IconButton.js";
5
+ import { Label } from "../../components/typography/Label.js";
6
+ import { Profile } from "../../components/icons/generated/Profile.js";
7
+ import { Time } from "../../components/icons/generated/Time.js";
7
8
  const userInfoStyles = tv({
8
- slots: {
9
- base: ["flex", "gap-2", "items-center"],
10
- userInfo: ["flex", "flex-col", "gap-2", "justify-center", "items-start"],
11
- displayName: ["text-slate-900", "**:cursor-pointer"],
12
- detailInfo: ["flex", "flex", "gap-4"],
13
- timeInfo: ["text-slate-500"],
14
- },
9
+ slots: {
10
+ base: ["flex", "gap-2", "items-center"],
11
+ userInfo: ["flex", "flex-col", "gap-2", "justify-center", "items-start"],
12
+ displayName: ["text-slate-900", "**:cursor-pointer"],
13
+ detailInfo: ["flex", "flex", "gap-4"],
14
+ timeInfo: ["text-slate-500"]
15
+ }
15
16
  });
16
17
  function timeSince(timestamp) {
17
- const now = new Date();
18
- const past = timestamp instanceof Date ? timestamp : new Date(timestamp);
19
- const diffMs = now.getTime() - past.getTime();
20
- const seconds = Math.floor(diffMs / 1000);
21
- const minutes = Math.floor(seconds / 60);
22
- const hours = Math.floor(minutes / 60);
23
- const days = Math.floor(hours / 24);
24
- const months = Math.floor(days / 30); // approximate
25
- const years = Math.floor(days / 365); // approximate
26
- if (years > 0)
27
- return years === 1 ? "1 year ago" : `${years} years ago`;
28
- if (months > 0)
29
- return months === 1 ? "1 month ago" : `${months} months ago`;
30
- if (days > 0)
31
- return days === 1 ? "1 day ago" : `${days} days ago`;
32
- if (hours > 0)
33
- return hours === 1 ? "1 hour ago" : `${hours} hours ago`;
34
- if (minutes > 0)
35
- return minutes === 1 ? "1 minute ago" : `${minutes} minutes ago`;
36
- return seconds <= 1 ? "just now" : `${seconds} seconds ago`;
18
+ const now = /* @__PURE__ */ new Date();
19
+ const past = timestamp instanceof Date ? timestamp : new Date(timestamp);
20
+ const diffMs = now.getTime() - past.getTime();
21
+ const seconds = Math.floor(diffMs / 1e3);
22
+ const minutes = Math.floor(seconds / 60);
23
+ const hours = Math.floor(minutes / 60);
24
+ const days = Math.floor(hours / 24);
25
+ const months = Math.floor(days / 30);
26
+ const years = Math.floor(days / 365);
27
+ if (years > 0) return years === 1 ? "1 year ago" : `${years} years ago`;
28
+ if (months > 0) return months === 1 ? "1 month ago" : `${months} months ago`;
29
+ if (days > 0) return days === 1 ? "1 day ago" : `${days} days ago`;
30
+ if (hours > 0) return hours === 1 ? "1 hour ago" : `${hours} hours ago`;
31
+ if (minutes > 0)
32
+ return minutes === 1 ? "1 minute ago" : `${minutes} minutes ago`;
33
+ return seconds <= 1 ? "just now" : `${seconds} seconds ago`;
37
34
  }
38
35
  function getLabelSize(size) {
39
- switch (size) {
40
- case "sm":
41
- return "md";
42
- case "md":
43
- return "lg";
44
- case "lg":
45
- return "xl";
46
- default:
47
- return "md";
48
- }
36
+ switch (size) {
37
+ case "sm":
38
+ return "md";
39
+ case "md":
40
+ return "lg";
41
+ case "lg":
42
+ return "xl";
43
+ default:
44
+ return "md";
45
+ }
49
46
  }
50
- /**
51
- * UserInfo Component
52
- *
53
- * Displays a user avatar, display name, username, and a timestamp indicating
54
- * when an activity occurred. The entire component acts as an interactive button
55
- * and includes keyboard accessibility using `Enter` and `Space`.
56
- */
57
- export const UserInfo = (props) => {
58
- const { base, userInfo, displayName, detailInfo, timeInfo } = userInfoStyles(props);
59
- return (_jsxs("div", { className: base(), children: [props.src && (_jsx(Avatar, { alt: "Profile", size: "sm", src: props.src, onAvatarClick: props.onClick })), _jsxs("div", { className: userInfo(), children: [_jsx("button", { onClick: props.onClick, className: displayName(), children: _jsx(Label, { size: getLabelSize(props.size), children: props.displayName }) }), _jsxs("div", { className: detailInfo(), children: [_jsx(IconButton, { intent: "secondary", icon: Profile, onClick: props.onClick, children: props.userName }), props.timestamp && (_jsx(IconButton, { intent: "primary", icon: Time, className: timeInfo(), onClick: props.onClick, children: timeSince(props.timestamp) }))] })] })] }));
47
+ const UserInfo = (props) => {
48
+ const { base, userInfo, displayName, detailInfo, timeInfo } = userInfoStyles(props);
49
+ return /* @__PURE__ */ jsxs("div", { className: base(), children: [
50
+ props.src && /* @__PURE__ */ jsx(
51
+ Avatar,
52
+ {
53
+ alt: "Profile",
54
+ size: "sm",
55
+ src: props.src,
56
+ onAvatarClick: props.onClick
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxs("div", { className: userInfo(), children: [
60
+ /* @__PURE__ */ jsx("button", { onClick: props.onClick, className: displayName(), children: /* @__PURE__ */ jsx(Label, { size: getLabelSize(props.size), children: props.displayName }) }),
61
+ /* @__PURE__ */ jsxs("div", { className: detailInfo(), children: [
62
+ /* @__PURE__ */ jsx(IconButton, { intent: "secondary", icon: Profile, onClick: props.onClick, children: props.userName }),
63
+ props.timestamp && /* @__PURE__ */ jsx(
64
+ IconButton,
65
+ {
66
+ intent: "primary",
67
+ icon: Time,
68
+ className: timeInfo(),
69
+ onClick: props.onClick,
70
+ children: timeSince(props.timestamp)
71
+ }
72
+ )
73
+ ] })
74
+ ] })
75
+ ] });
76
+ };
77
+ export {
78
+ UserInfo
60
79
  };