@factorialco/f0-react-native 0.19.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.
Files changed (310) hide show
  1. package/README.md +54 -0
  2. package/package.json +84 -0
  3. package/src/components/Activity/ActivityItem/__snapshots__/index.spec.tsx.snap +62 -0
  4. package/src/components/Activity/ActivityItem/index.spec.tsx +103 -0
  5. package/src/components/Activity/ActivityItem/index.tsx +90 -0
  6. package/src/components/Avatars/Avatar.tsx +56 -0
  7. package/src/components/Avatars/BaseAvatar/index.tsx +126 -0
  8. package/src/components/Avatars/BaseAvatar/utils.ts +73 -0
  9. package/src/components/Avatars/CompanyAvatar/__snapshots__/index.spec.tsx.snap +25 -0
  10. package/src/components/Avatars/CompanyAvatar/index.spec.tsx +11 -0
  11. package/src/components/Avatars/CompanyAvatar/index.tsx +36 -0
  12. package/src/components/Avatars/DateAvatar/__snapshots__/index.spec.tsx.snap +18 -0
  13. package/src/components/Avatars/DateAvatar/index.spec.tsx +12 -0
  14. package/src/components/Avatars/DateAvatar/index.tsx +22 -0
  15. package/src/components/Avatars/EmojiAvatar/__snapshots__/index.spec.tsx.snap +37 -0
  16. package/src/components/Avatars/EmojiAvatar/index.spec.tsx +15 -0
  17. package/src/components/Avatars/EmojiAvatar/index.tsx +37 -0
  18. package/src/components/Avatars/FileAvatar/__snapshots__/index.spec.tsx.snap +261 -0
  19. package/src/components/Avatars/FileAvatar/index.spec.tsx +43 -0
  20. package/src/components/Avatars/FileAvatar/index.tsx +117 -0
  21. package/src/components/Avatars/FileAvatar/utils.ts +103 -0
  22. package/src/components/Avatars/IconAvatar/__snapshots__/index.spec.tsx.snap +256 -0
  23. package/src/components/Avatars/IconAvatar/index.spec.tsx +16 -0
  24. package/src/components/Avatars/IconAvatar/index.tsx +31 -0
  25. package/src/components/Avatars/ModuleAvatar/index.tsx +106 -0
  26. package/src/components/Avatars/ModuleAvatar/modules.ts +64 -0
  27. package/src/components/Avatars/PersonAvatar/__snapshots__/index.spec.tsx.snap +25 -0
  28. package/src/components/Avatars/PersonAvatar/index.spec.tsx +13 -0
  29. package/src/components/Avatars/PersonAvatar/index.tsx +38 -0
  30. package/src/components/Avatars/TeamAvatar/__snapshots__/index.spec.tsx.snap +25 -0
  31. package/src/components/Avatars/TeamAvatar/index.spec.tsx +11 -0
  32. package/src/components/Avatars/TeamAvatar/index.tsx +36 -0
  33. package/src/components/Avatars/exports.ts +9 -0
  34. package/src/components/Avatars/types.ts +15 -0
  35. package/src/components/Badge/index.tsx +47 -0
  36. package/src/components/Button/__snapshots__/index.spec.tsx.snap +517 -0
  37. package/src/components/Button/index.spec.tsx +124 -0
  38. package/src/components/Button/index.tsx +233 -0
  39. package/src/components/Counter/__snapshots__/index.spec.tsx.snap +113 -0
  40. package/src/components/Counter/index.spec.tsx +53 -0
  41. package/src/components/Counter/index.tsx +59 -0
  42. package/src/components/ExampleComponent.tsx +22 -0
  43. package/src/components/Icon/README.md +63 -0
  44. package/src/components/Icon/__tests__/Icon.spec.tsx +35 -0
  45. package/src/components/Icon/index.tsx +85 -0
  46. package/src/components/Navigation/PageHeader/__snapshots__/index.spec.tsx.snap +242 -0
  47. package/src/components/Navigation/PageHeader/index.spec.tsx +198 -0
  48. package/src/components/Navigation/PageHeader/index.tsx +53 -0
  49. package/src/components/OneChip/__snapshots__/index.spec.tsx.snap +366 -0
  50. package/src/components/OneChip/index.spec.tsx +69 -0
  51. package/src/components/OneChip/index.tsx +89 -0
  52. package/src/components/OnePreset/__snapshots__/index.spec.tsx.snap +149 -0
  53. package/src/components/OnePreset/index.spec.tsx +46 -0
  54. package/src/components/OnePreset/index.tsx +36 -0
  55. package/src/components/Tags/AlertTab/__snapshots__/index.spec.tsx.snap +292 -0
  56. package/src/components/Tags/AlertTab/index.spec.tsx +18 -0
  57. package/src/components/Tags/AlertTab/index.tsx +61 -0
  58. package/src/components/Tags/BaseTag/index.tsx +64 -0
  59. package/src/components/Tags/DotTag/__snapshots__/index.spec.tsx.snap +1081 -0
  60. package/src/components/Tags/DotTag/index.spec.tsx +14 -0
  61. package/src/components/Tags/DotTag/index.tsx +54 -0
  62. package/src/components/Tags/RawTag/__snapshots__/index.spec.tsx.snap +213 -0
  63. package/src/components/Tags/RawTag/index.spec.tsx +19 -0
  64. package/src/components/Tags/RawTag/index.tsx +41 -0
  65. package/src/components/Tags/Tag.tsx +32 -0
  66. package/src/components/Tags/exports.ts +3 -0
  67. package/src/components/__tests__/ExampleComponent.spec.tsx +16 -0
  68. package/src/components/experimental/Lists/DataList/ItemContainer.tsx +74 -0
  69. package/src/components/experimental/Lists/DataList/actions/CopyAction.tsx +72 -0
  70. package/src/components/experimental/Lists/DataList/actions/GenericAction.tsx +37 -0
  71. package/src/components/experimental/Lists/DataList/index.tsx +186 -0
  72. package/src/components/experimental/Lists/DetailsItem/__snapshots__/index.spec.tsx.snap +759 -0
  73. package/src/components/experimental/Lists/DetailsItem/index.spec.tsx +81 -0
  74. package/src/components/experimental/Lists/DetailsItem/index.tsx +68 -0
  75. package/src/components/experimental/Lists/DetailsItemsList/__snapshots__/index.spec.tsx.snap +671 -0
  76. package/src/components/experimental/Lists/DetailsItemsList/index.spec.tsx +73 -0
  77. package/src/components/experimental/Lists/DetailsItemsList/index.tsx +52 -0
  78. package/src/icons/app/AcademicCap.tsx +31 -0
  79. package/src/icons/app/Add.tsx +21 -0
  80. package/src/icons/app/Ai.tsx +24 -0
  81. package/src/icons/app/Alert.tsx +16 -0
  82. package/src/icons/app/AlertCircle.tsx +19 -0
  83. package/src/icons/app/AlertCircleLine.tsx +17 -0
  84. package/src/icons/app/AlignTextCenter.tsx +21 -0
  85. package/src/icons/app/AlignTextJustify.tsx +21 -0
  86. package/src/icons/app/AlignTextLeft.tsx +21 -0
  87. package/src/icons/app/AlignTextRight.tsx +21 -0
  88. package/src/icons/app/Appearance.tsx +33 -0
  89. package/src/icons/app/Archive.tsx +21 -0
  90. package/src/icons/app/ArchiveOpen.tsx +21 -0
  91. package/src/icons/app/ArrowCycle.tsx +27 -0
  92. package/src/icons/app/ArrowDown.tsx +27 -0
  93. package/src/icons/app/ArrowLeft.tsx +21 -0
  94. package/src/icons/app/ArrowRight.tsx +21 -0
  95. package/src/icons/app/ArrowUp.tsx +21 -0
  96. package/src/icons/app/Bank.tsx +20 -0
  97. package/src/icons/app/BarGraph.tsx +21 -0
  98. package/src/icons/app/Bell.tsx +24 -0
  99. package/src/icons/app/Bold.tsx +23 -0
  100. package/src/icons/app/BookOpen.tsx +21 -0
  101. package/src/icons/app/Briefcase.tsx +18 -0
  102. package/src/icons/app/Bucket.tsx +23 -0
  103. package/src/icons/app/Building.tsx +25 -0
  104. package/src/icons/app/Bullet.tsx +19 -0
  105. package/src/icons/app/Calculator.tsx +17 -0
  106. package/src/icons/app/Calendar.tsx +21 -0
  107. package/src/icons/app/CalendarArrowDown.tsx +21 -0
  108. package/src/icons/app/CalendarArrowLeft.tsx +21 -0
  109. package/src/icons/app/CalendarArrowRight.tsx +21 -0
  110. package/src/icons/app/CameraPlus.tsx +22 -0
  111. package/src/icons/app/ChartLine.tsx +26 -0
  112. package/src/icons/app/ChartPie.tsx +25 -0
  113. package/src/icons/app/Check.tsx +21 -0
  114. package/src/icons/app/CheckCircle.tsx +21 -0
  115. package/src/icons/app/CheckCircleLine.tsx +22 -0
  116. package/src/icons/app/CheckDouble.tsx +21 -0
  117. package/src/icons/app/ChevronDown.tsx +21 -0
  118. package/src/icons/app/ChevronLeft.tsx +21 -0
  119. package/src/icons/app/ChevronRight.tsx +21 -0
  120. package/src/icons/app/ChevronUp.tsx +21 -0
  121. package/src/icons/app/Circle.tsx +16 -0
  122. package/src/icons/app/Clock.tsx +22 -0
  123. package/src/icons/app/Code.tsx +21 -0
  124. package/src/icons/app/Coffee.tsx +24 -0
  125. package/src/icons/app/Comment.tsx +19 -0
  126. package/src/icons/app/Completed.tsx +21 -0
  127. package/src/icons/app/CreditCard.tsx +21 -0
  128. package/src/icons/app/Cross.tsx +21 -0
  129. package/src/icons/app/CrossedCircle.tsx +21 -0
  130. package/src/icons/app/Crown.tsx +21 -0
  131. package/src/icons/app/Delete.tsx +21 -0
  132. package/src/icons/app/Deny.tsx +21 -0
  133. package/src/icons/app/Desktop.tsx +26 -0
  134. package/src/icons/app/DollarBill.tsx +22 -0
  135. package/src/icons/app/DottedCircle.tsx +16 -0
  136. package/src/icons/app/Download.tsx +21 -0
  137. package/src/icons/app/DropdownDefault.tsx +25 -0
  138. package/src/icons/app/DropdownOpen.tsx +25 -0
  139. package/src/icons/app/Ellipsis.tsx +36 -0
  140. package/src/icons/app/EllipsisHorizontal.tsx +18 -0
  141. package/src/icons/app/Envelope.tsx +21 -0
  142. package/src/icons/app/EnvelopeOpen.tsx +23 -0
  143. package/src/icons/app/Exit.tsx +21 -0
  144. package/src/icons/app/ExternalLink.tsx +21 -0
  145. package/src/icons/app/EyeInvisible.tsx +26 -0
  146. package/src/icons/app/EyeVisible.tsx +21 -0
  147. package/src/icons/app/FaceNegative.tsx +21 -0
  148. package/src/icons/app/FaceNeutral.tsx +21 -0
  149. package/src/icons/app/FacePositive.tsx +21 -0
  150. package/src/icons/app/FaceSuperNegative.tsx +21 -0
  151. package/src/icons/app/FaceSuperPositive.tsx +21 -0
  152. package/src/icons/app/Feed.tsx +21 -0
  153. package/src/icons/app/File.tsx +21 -0
  154. package/src/icons/app/FileFilled.tsx +21 -0
  155. package/src/icons/app/Filter.tsx +19 -0
  156. package/src/icons/app/Flag.tsx +21 -0
  157. package/src/icons/app/Folder.tsx +19 -0
  158. package/src/icons/app/Folders.tsx +24 -0
  159. package/src/icons/app/Globe.tsx +26 -0
  160. package/src/icons/app/Graph.tsx +26 -0
  161. package/src/icons/app/Handshake.tsx +29 -0
  162. package/src/icons/app/Heading1.tsx +21 -0
  163. package/src/icons/app/Heading2.tsx +21 -0
  164. package/src/icons/app/Heading3.tsx +21 -0
  165. package/src/icons/app/Heart.tsx +21 -0
  166. package/src/icons/app/HoldHeart.tsx +21 -0
  167. package/src/icons/app/Home.tsx +20 -0
  168. package/src/icons/app/Hub.tsx +51 -0
  169. package/src/icons/app/Image.tsx +21 -0
  170. package/src/icons/app/InProgressTask.tsx +17 -0
  171. package/src/icons/app/Inbox.tsx +26 -0
  172. package/src/icons/app/Info.tsx +21 -0
  173. package/src/icons/app/InfoCircle.tsx +21 -0
  174. package/src/icons/app/InfoCircleLine.tsx +28 -0
  175. package/src/icons/app/Italic.tsx +21 -0
  176. package/src/icons/app/Kanban.tsx +21 -0
  177. package/src/icons/app/Laptop.tsx +20 -0
  178. package/src/icons/app/LayersFront.tsx +26 -0
  179. package/src/icons/app/Lightbulb.tsx +26 -0
  180. package/src/icons/app/Link.tsx +25 -0
  181. package/src/icons/app/LinkRemove.tsx +20 -0
  182. package/src/icons/app/List.tsx +25 -0
  183. package/src/icons/app/LockLocked.tsx +21 -0
  184. package/src/icons/app/LockUnlocked.tsx +21 -0
  185. package/src/icons/app/LogoAvatar.tsx +23 -0
  186. package/src/icons/app/LogoEruditai.tsx +19 -0
  187. package/src/icons/app/LogoTravelperk.tsx +27 -0
  188. package/src/icons/app/Masonry.tsx +19 -0
  189. package/src/icons/app/Maximize.tsx +21 -0
  190. package/src/icons/app/Megaphone.tsx +21 -0
  191. package/src/icons/app/Menu.tsx +21 -0
  192. package/src/icons/app/MessageFrown.tsx +25 -0
  193. package/src/icons/app/MessageHeart.tsx +25 -0
  194. package/src/icons/app/Messages.tsx +21 -0
  195. package/src/icons/app/Microphone.tsx +26 -0
  196. package/src/icons/app/MicrophoneNegative.tsx +26 -0
  197. package/src/icons/app/Minimize.tsx +21 -0
  198. package/src/icons/app/Minus.tsx +21 -0
  199. package/src/icons/app/Mobile.tsx +21 -0
  200. package/src/icons/app/Money.tsx +26 -0
  201. package/src/icons/app/MoneyBag.tsx +24 -0
  202. package/src/icons/app/MoveDown.tsx +44 -0
  203. package/src/icons/app/MoveTop.tsx +34 -0
  204. package/src/icons/app/MoveUp.tsx +42 -0
  205. package/src/icons/app/Office.tsx +31 -0
  206. package/src/icons/app/OlList.tsx +21 -0
  207. package/src/icons/app/PalmTree.tsx +20 -0
  208. package/src/icons/app/Paperclip.tsx +20 -0
  209. package/src/icons/app/PartiallyCompleted.tsx +21 -0
  210. package/src/icons/app/PauseCircle.tsx +21 -0
  211. package/src/icons/app/Pencil.tsx +21 -0
  212. package/src/icons/app/People.tsx +27 -0
  213. package/src/icons/app/Person.tsx +22 -0
  214. package/src/icons/app/Phone.tsx +20 -0
  215. package/src/icons/app/Pin.tsx +22 -0
  216. package/src/icons/app/PixBrazil.tsx +19 -0
  217. package/src/icons/app/Placeholder.tsx +21 -0
  218. package/src/icons/app/Plane.tsx +21 -0
  219. package/src/icons/app/Plus.tsx +21 -0
  220. package/src/icons/app/Present.tsx +31 -0
  221. package/src/icons/app/Printer.tsx +26 -0
  222. package/src/icons/app/Proyector.tsx +22 -0
  223. package/src/icons/app/Question.tsx +22 -0
  224. package/src/icons/app/Quote.tsx +21 -0
  225. package/src/icons/app/Reaction.tsx +32 -0
  226. package/src/icons/app/Receipt.tsx +20 -0
  227. package/src/icons/app/Record.tsx +17 -0
  228. package/src/icons/app/RemoveFavorite.tsx +21 -0
  229. package/src/icons/app/Replace.tsx +21 -0
  230. package/src/icons/app/Reset.tsx +27 -0
  231. package/src/icons/app/Rocket.tsx +26 -0
  232. package/src/icons/app/Salad.tsx +21 -0
  233. package/src/icons/app/Save.tsx +27 -0
  234. package/src/icons/app/Schedule.tsx +32 -0
  235. package/src/icons/app/Search.tsx +17 -0
  236. package/src/icons/app/SearchPerson.tsx +24 -0
  237. package/src/icons/app/Settings.tsx +20 -0
  238. package/src/icons/app/Share.tsx +27 -0
  239. package/src/icons/app/Sliders.tsx +22 -0
  240. package/src/icons/app/SolidPause.tsx +19 -0
  241. package/src/icons/app/SolidPlay.tsx +19 -0
  242. package/src/icons/app/SolidStop.tsx +19 -0
  243. package/src/icons/app/Sort.tsx +21 -0
  244. package/src/icons/app/Sparkles.tsx +25 -0
  245. package/src/icons/app/Spinner.tsx +20 -0
  246. package/src/icons/app/Split.tsx +21 -0
  247. package/src/icons/app/Star.tsx +21 -0
  248. package/src/icons/app/StarFilled.tsx +19 -0
  249. package/src/icons/app/Strikethrough.tsx +21 -0
  250. package/src/icons/app/Suitcase.tsx +22 -0
  251. package/src/icons/app/Table.tsx +21 -0
  252. package/src/icons/app/Target.tsx +31 -0
  253. package/src/icons/app/TextSize.tsx +21 -0
  254. package/src/icons/app/Timer.tsx +27 -0
  255. package/src/icons/app/Underline.tsx +26 -0
  256. package/src/icons/app/Upload.tsx +21 -0
  257. package/src/icons/app/Video.tsx +23 -0
  258. package/src/icons/app/VideoRecorder.tsx +31 -0
  259. package/src/icons/app/VideoRecorderNegative.tsx +22 -0
  260. package/src/icons/app/Wallet.tsx +26 -0
  261. package/src/icons/app/Warning.tsx +21 -0
  262. package/src/icons/app/WhatsappChat.tsx +23 -0
  263. package/src/icons/app/Windows.tsx +21 -0
  264. package/src/icons/app/index.ts +186 -0
  265. package/src/icons/index.ts +5 -0
  266. package/src/icons/modules/Benefits.tsx +25 -0
  267. package/src/icons/modules/Calendar.tsx +21 -0
  268. package/src/icons/modules/Cards.tsx +25 -0
  269. package/src/icons/modules/ClockIn.tsx +21 -0
  270. package/src/icons/modules/Discover.tsx +25 -0
  271. package/src/icons/modules/Documents.tsx +19 -0
  272. package/src/icons/modules/Engagement.tsx +21 -0
  273. package/src/icons/modules/Finance.tsx +21 -0
  274. package/src/icons/modules/Goals.tsx +19 -0
  275. package/src/icons/modules/Home.tsx +19 -0
  276. package/src/icons/modules/Hub.tsx +20 -0
  277. package/src/icons/modules/Inbox.tsx +19 -0
  278. package/src/icons/modules/Kudos.tsx +19 -0
  279. package/src/icons/modules/MyDocuments.tsx +21 -0
  280. package/src/icons/modules/Organization.tsx +19 -0
  281. package/src/icons/modules/Overviews.tsx +23 -0
  282. package/src/icons/modules/Payroll.tsx +25 -0
  283. package/src/icons/modules/Performance.tsx +19 -0
  284. package/src/icons/modules/Profile.tsx +19 -0
  285. package/src/icons/modules/Projects.tsx +21 -0
  286. package/src/icons/modules/Recruitment.tsx +21 -0
  287. package/src/icons/modules/Reports.tsx +21 -0
  288. package/src/icons/modules/Sales.tsx +27 -0
  289. package/src/icons/modules/Settings.tsx +21 -0
  290. package/src/icons/modules/Shifts.tsx +27 -0
  291. package/src/icons/modules/Social.tsx +21 -0
  292. package/src/icons/modules/Software.tsx +19 -0
  293. package/src/icons/modules/Spaces.tsx +21 -0
  294. package/src/icons/modules/Spending.tsx +21 -0
  295. package/src/icons/modules/Tasks.tsx +21 -0
  296. package/src/icons/modules/TimeOff.tsx +21 -0
  297. package/src/icons/modules/TimeTracking.tsx +25 -0
  298. package/src/icons/modules/Trainings.tsx +19 -0
  299. package/src/icons/modules/Treasury.tsx +19 -0
  300. package/src/icons/modules/Workflows.tsx +19 -0
  301. package/src/icons/modules/index.ts +35 -0
  302. package/src/icons/types.ts +9 -0
  303. package/src/index.ts +18 -0
  304. package/src/lib/date.ts +102 -0
  305. package/src/lib/emojis.tsx +47 -0
  306. package/src/lib/iconWithClassName.ts +17 -0
  307. package/src/lib/text.ts +31 -0
  308. package/src/lib/utils.ts +6 -0
  309. package/src/ui/avatar.tsx +113 -0
  310. package/tailwind.config.ts +19 -0
@@ -0,0 +1,36 @@
1
+ import { ComponentProps } from "react";
2
+ import { BaseAvatar } from "../BaseAvatar";
3
+ import { AvatarBadge } from "../types";
4
+
5
+ type BaseAvatarProps = ComponentProps<typeof BaseAvatar>;
6
+
7
+ type Props = {
8
+ name: string;
9
+ src?: string;
10
+ size?: BaseAvatarProps["size"];
11
+ badge?: AvatarBadge;
12
+ } & Pick<BaseAvatarProps, "aria-label" | "aria-labelledby">;
13
+
14
+ export const CompanyAvatar = ({
15
+ name,
16
+ src,
17
+ size,
18
+ "aria-label": ariaLabel,
19
+ "aria-labelledby": ariaLabelledby,
20
+ badge,
21
+ }: Props) => {
22
+ return (
23
+ <BaseAvatar
24
+ type="base"
25
+ name={name}
26
+ src={src}
27
+ size={size}
28
+ color="viridian"
29
+ aria-label={ariaLabel}
30
+ aria-labelledby={ariaLabelledby}
31
+ badge={badge}
32
+ />
33
+ );
34
+ };
35
+
36
+ CompanyAvatar.displayName = "CompanyAvatar";
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DateAvatar Snapshot 1`] = `
4
+ <View
5
+ className="flex h-10 w-10 flex-col items-center justify-center rounded border border-solid border-f1-border-secondary bg-f1-background-inverse-secondary"
6
+ >
7
+ <Text
8
+ className="pt-0.5 text-xs font-semibold uppercase leading-3 text-f1-special-highlight dark:text-f1-foreground-inverse-secondary"
9
+ >
10
+ Jan
11
+ </Text>
12
+ <Text
13
+ className="flex items-center justify-center text-lg font-medium leading-tight text-f1-foreground"
14
+ >
15
+ 1
16
+ </Text>
17
+ </View>
18
+ `;
@@ -0,0 +1,12 @@
1
+ import { render } from "@testing-library/react-native";
2
+ import React from "react";
3
+ import { DateAvatar } from "./";
4
+
5
+ describe("DateAvatar", () => {
6
+ it("Snapshot", () => {
7
+ const fixedDate = new Date("2025-01-01T00:00:00Z");
8
+ const { toJSON } = render(<DateAvatar date={fixedDate} />);
9
+
10
+ expect(toJSON()).toMatchSnapshot();
11
+ });
12
+ });
@@ -0,0 +1,22 @@
1
+ import { View, Text } from "react-native";
2
+ import { getAbbreviateMonth, getDayOfMonth } from "../../../lib/date";
3
+
4
+ type Props = {
5
+ date: Date;
6
+ };
7
+
8
+ export const DateAvatar = ({ date }: Props) => {
9
+ const dateDay = getDayOfMonth(date);
10
+ const month = getAbbreviateMonth(date);
11
+
12
+ return (
13
+ <View className="flex h-10 w-10 flex-col items-center justify-center rounded border border-solid border-f1-border-secondary bg-f1-background-inverse-secondary">
14
+ <Text className="pt-0.5 text-xs font-semibold uppercase leading-3 text-f1-special-highlight dark:text-f1-foreground-inverse-secondary">
15
+ {month}
16
+ </Text>
17
+ <Text className="flex items-center justify-center text-lg font-medium leading-tight text-f1-foreground">
18
+ {dateDay}
19
+ </Text>
20
+ </View>
21
+ );
22
+ };
@@ -0,0 +1,37 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`EmojiAvatar Snapshot - different sizes text emoji and diferent size 1`] = `
4
+ <View
5
+ className="w-6 h-6 rounded-sm flex aspect-square items-center justify-center border border-solid border-f1-border-secondary bg-f1-background dark:bg-f1-background-inverse-secondary"
6
+ >
7
+ <Text
8
+ className="text-xs"
9
+ >
10
+ test
11
+ </Text>
12
+ </View>
13
+ `;
14
+
15
+ exports[`EmojiAvatar Snapshot - different sizes text emoji and diferent size 2`] = `
16
+ <View
17
+ className="w-9 h-9 rounded-md flex aspect-square items-center justify-center border border-solid border-f1-border-secondary bg-f1-background dark:bg-f1-background-inverse-secondary"
18
+ >
19
+ <Text
20
+ className="text-sm"
21
+ >
22
+ test
23
+ </Text>
24
+ </View>
25
+ `;
26
+
27
+ exports[`EmojiAvatar Snapshot - different sizes text emoji and diferent size 3`] = `
28
+ <View
29
+ className="w-10 h-10 rounded-lg flex aspect-square items-center justify-center border border-solid border-f1-border-secondary bg-f1-background dark:bg-f1-background-inverse-secondary"
30
+ >
31
+ <Text
32
+ className="text-md"
33
+ >
34
+ test
35
+ </Text>
36
+ </View>
37
+ `;
@@ -0,0 +1,15 @@
1
+ import { render } from "@testing-library/react-native";
2
+ import React from "react";
3
+ import { EmojiAvatar } from "./";
4
+
5
+ describe("EmojiAvatar", () => {
6
+ it("Snapshot - different sizes text emoji and diferent size", () => {
7
+ const sizes = ["sm", "md", "lg"] as const;
8
+
9
+ sizes.forEach((size) => {
10
+ const { toJSON } = render(<EmojiAvatar emoji="test" size={size} />);
11
+
12
+ expect(toJSON()).toMatchSnapshot();
13
+ });
14
+ });
15
+ });
@@ -0,0 +1,37 @@
1
+ import { View } from "react-native";
2
+ import { EmojiImage } from "../../../lib/emojis";
3
+ import { cn } from "../../../lib/utils";
4
+
5
+ type Props = {
6
+ emoji: string;
7
+ size?: "sm" | "md" | "lg";
8
+ className?: string;
9
+ };
10
+
11
+ const sizes = {
12
+ sm: "w-6 h-6 rounded-sm",
13
+ md: "w-9 h-9 rounded-md",
14
+ lg: "w-10 h-10 rounded-lg",
15
+ };
16
+
17
+ const emojiSize = {
18
+ sm: { icon: "w-4 h-4", text: "text-xs" },
19
+ md: { icon: "w-5 h-5", text: "text-sm" },
20
+ lg: { icon: "w-6 h-6", text: "text-md" },
21
+ } as const;
22
+
23
+ export const EmojiAvatar = ({ emoji, size = "md", className }: Props) => {
24
+ return (
25
+ <View
26
+ className={cn(
27
+ className,
28
+ sizes[size],
29
+ "flex aspect-square items-center justify-center border border-solid border-f1-border-secondary bg-f1-background dark:bg-f1-background-inverse-secondary",
30
+ )}
31
+ >
32
+ <EmojiImage emoji={emoji} size={emojiSize[size]} />
33
+ </View>
34
+ );
35
+ };
36
+
37
+ EmojiAvatar.displayName = "EmojiAvatar";
@@ -0,0 +1,261 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`FileAvatar Snapshot - different file types 1`] = `
4
+ <View
5
+ className="inline-flex "
6
+ >
7
+ <View
8
+ className="h-fit w-fit"
9
+ >
10
+ <View
11
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
12
+ >
13
+ <Text
14
+ className="font-semibold text-sm text-f1-foreground-accent"
15
+ >
16
+ PDF
17
+ </Text>
18
+ </View>
19
+ </View>
20
+ </View>
21
+ `;
22
+
23
+ exports[`FileAvatar Snapshot - different file types 2`] = `
24
+ <View
25
+ className="inline-flex "
26
+ >
27
+ <View
28
+ className="h-fit w-fit"
29
+ >
30
+ <View
31
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
32
+ >
33
+ <Text
34
+ className="font-semibold text-sm text-f1-foreground-info"
35
+ >
36
+ IMG
37
+ </Text>
38
+ </View>
39
+ </View>
40
+ </View>
41
+ `;
42
+
43
+ exports[`FileAvatar Snapshot - different file types 3`] = `
44
+ <View
45
+ className="inline-flex "
46
+ >
47
+ <View
48
+ className="h-fit w-fit"
49
+ >
50
+ <View
51
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
52
+ >
53
+ <Text
54
+ className="font-semibold text-sm text-f1-foreground-info"
55
+ >
56
+ DOC
57
+ </Text>
58
+ </View>
59
+ </View>
60
+ </View>
61
+ `;
62
+
63
+ exports[`FileAvatar Snapshot - different file types 4`] = `
64
+ <View
65
+ className="inline-flex "
66
+ >
67
+ <View
68
+ className="h-fit w-fit"
69
+ >
70
+ <View
71
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
72
+ >
73
+ <Text
74
+ className="font-semibold text-sm text-f1-foreground-positive"
75
+ >
76
+ XLS
77
+ </Text>
78
+ </View>
79
+ </View>
80
+ </View>
81
+ `;
82
+
83
+ exports[`FileAvatar Snapshot - different file types 5`] = `
84
+ <View
85
+ className="inline-flex "
86
+ >
87
+ <View
88
+ className="h-fit w-fit"
89
+ >
90
+ <View
91
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
92
+ >
93
+ <Text
94
+ className="font-semibold text-sm text-f1-foreground-warning"
95
+ >
96
+ PPT
97
+ </Text>
98
+ </View>
99
+ </View>
100
+ </View>
101
+ `;
102
+
103
+ exports[`FileAvatar Snapshot - different file types 6`] = `
104
+ <View
105
+ className="inline-flex "
106
+ >
107
+ <View
108
+ className="h-fit w-fit"
109
+ >
110
+ <View
111
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
112
+ >
113
+ <Text
114
+ className="font-semibold text-sm text-f1-foreground-secondary"
115
+ >
116
+ TXT
117
+ </Text>
118
+ </View>
119
+ </View>
120
+ </View>
121
+ `;
122
+
123
+ exports[`FileAvatar Snapshot - different file types 7`] = `
124
+ <View
125
+ className="inline-flex "
126
+ >
127
+ <View
128
+ className="h-fit w-fit"
129
+ >
130
+ <View
131
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
132
+ >
133
+ <Text
134
+ className="font-semibold text-sm text-f1-foreground-info"
135
+ >
136
+ VID
137
+ </Text>
138
+ </View>
139
+ </View>
140
+ </View>
141
+ `;
142
+
143
+ exports[`FileAvatar Snapshot - different file types 8`] = `
144
+ <View
145
+ className="inline-flex "
146
+ >
147
+ <View
148
+ className="h-fit w-fit"
149
+ >
150
+ <View
151
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
152
+ >
153
+ <Text
154
+ className="font-semibold text-sm text-f1-foreground-accent"
155
+ >
156
+ AUD
157
+ </Text>
158
+ </View>
159
+ </View>
160
+ </View>
161
+ `;
162
+
163
+ exports[`FileAvatar Snapshot - different file types 9`] = `
164
+ <View
165
+ className="inline-flex "
166
+ >
167
+ <View
168
+ className="h-fit w-fit"
169
+ >
170
+ <View
171
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
172
+ >
173
+ <Text
174
+ className="font-semibold text-sm text-f1-foreground-warning"
175
+ >
176
+ ZIP
177
+ </Text>
178
+ </View>
179
+ </View>
180
+ </View>
181
+ `;
182
+
183
+ exports[`FileAvatar Snapshot - different file types 10`] = `
184
+ <View
185
+ className="inline-flex "
186
+ >
187
+ <View
188
+ className="h-fit w-fit"
189
+ >
190
+ <View
191
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
192
+ >
193
+ <Text
194
+ className="font-semibold text-sm text-f1-foreground-positive"
195
+ >
196
+ CSV
197
+ </Text>
198
+ </View>
199
+ </View>
200
+ </View>
201
+ `;
202
+
203
+ exports[`FileAvatar Snapshot - different file types 11`] = `
204
+ <View
205
+ className="inline-flex "
206
+ >
207
+ <View
208
+ className="h-fit w-fit"
209
+ >
210
+ <View
211
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
212
+ >
213
+ <Text
214
+ className="font-semibold text-sm text-f1-foreground-accent"
215
+ >
216
+ HTM
217
+ </Text>
218
+ </View>
219
+ </View>
220
+ </View>
221
+ `;
222
+
223
+ exports[`FileAvatar Snapshot - different file types 12`] = `
224
+ <View
225
+ className="inline-flex "
226
+ >
227
+ <View
228
+ className="h-fit w-fit"
229
+ >
230
+ <View
231
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
232
+ >
233
+ <Text
234
+ className="font-semibold text-sm text-f1-foreground-secondary"
235
+ >
236
+ MD
237
+ </Text>
238
+ </View>
239
+ </View>
240
+ </View>
241
+ `;
242
+
243
+ exports[`FileAvatar Snapshot - different file types 13`] = `
244
+ <View
245
+ className="inline-flex "
246
+ >
247
+ <View
248
+ className="h-fit w-fit"
249
+ >
250
+ <View
251
+ className="flex shrink-0 items-center justify-center overflow-hidden text-center font-semibold w-8 h-8 rounded border border-solid border-f1-border-secondary bg-f1-background"
252
+ >
253
+ <Text
254
+ className="font-semibold text-sm text-f1-foreground"
255
+ >
256
+ FIL
257
+ </Text>
258
+ </View>
259
+ </View>
260
+ </View>
261
+ `;
@@ -0,0 +1,43 @@
1
+ import { render } from "@testing-library/react-native";
2
+ import React from "react";
3
+ import { FileAvatar } from "./";
4
+
5
+ describe("FileAvatar", () => {
6
+ it("Snapshot - different file types", () => {
7
+ const fileTypes = [
8
+ { name: "document.pdf", type: "application/pdf" },
9
+ { name: "image.jpg", type: "image/jpeg" },
10
+ {
11
+ name: "document.docx",
12
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
13
+ },
14
+ {
15
+ name: "spreadsheet.xlsx",
16
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
17
+ },
18
+ {
19
+ name: "presentation.pptx",
20
+ type: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
21
+ },
22
+ { name: "text.txt", type: "text/plain" },
23
+ { name: "video.mp4", type: "video/mp4" },
24
+ { name: "audio.mp3", type: "audio/mpeg" },
25
+ { name: "archive.zip", type: "application/zip" },
26
+ { name: "data.csv", type: "csv" },
27
+ { name: "webpage.html", type: "html" },
28
+ { name: "readme.md", type: "markdown" },
29
+ { name: "unknown.xyz", type: "undefined" },
30
+ ];
31
+
32
+ fileTypes.map((fileType, index) => {
33
+ const { toJSON } = render(
34
+ <FileAvatar
35
+ key={index}
36
+ file={new File([""], fileType.name, { type: fileType.type })}
37
+ />,
38
+ );
39
+
40
+ expect(toJSON()).toMatchSnapshot();
41
+ });
42
+ });
43
+ });
@@ -0,0 +1,117 @@
1
+ import { ComponentProps, useMemo } from "react";
2
+ import { Text } from "react-native";
3
+ import { FileLike, getFileTypeInfo } from "./utils";
4
+ import { Avatar } from "../../../ui/avatar";
5
+ import { cn } from "../../../lib/utils";
6
+ import { BaseAvatar } from "../BaseAvatar";
7
+ import { AvatarBadge } from "../types";
8
+ import { ModuleAvatar, ModuleAvatarProps } from "../ModuleAvatar";
9
+ import { Badge, BadgeProps } from "../../Badge";
10
+ import { View } from "react-native";
11
+ import { getInitials } from "../BaseAvatar/utils";
12
+
13
+ type BaseAvatarProps = ComponentProps<typeof BaseAvatar>;
14
+
15
+ type Props = {
16
+ file: FileLike;
17
+ className?: string;
18
+ size?: BaseAvatarProps["size"];
19
+ badge?: AvatarBadge;
20
+ };
21
+
22
+ const textSizes = {
23
+ xsmall: "text-xs",
24
+ small: "text-xs",
25
+ medium: "text-sm",
26
+ large: "text-md",
27
+ xlarge: "text-2xl",
28
+ };
29
+
30
+ const getAvatarSize = (
31
+ size: BaseAvatarProps["size"],
32
+ ): ModuleAvatarProps["size"] | undefined => {
33
+ const sizeMap: Partial<
34
+ Record<
35
+ Exclude<BaseAvatarProps["size"], undefined>,
36
+ ModuleAvatarProps["size"]
37
+ >
38
+ > = {
39
+ xlarge: "lg",
40
+ large: "md",
41
+ small: "sm",
42
+ } as const;
43
+
44
+ return size && sizeMap[size] ? sizeMap[size] : sizeMap.small;
45
+ };
46
+
47
+ const getBadgeSize = (
48
+ size: BaseAvatarProps["size"],
49
+ ): BadgeProps["size"] | undefined => {
50
+ const sizeMap: Partial<
51
+ Record<Exclude<BaseAvatarProps["size"], undefined>, BadgeProps["size"]>
52
+ > = {
53
+ xlarge: "lg",
54
+ large: "md",
55
+ small: "sm",
56
+ } as const;
57
+
58
+ return size && sizeMap[size] ? sizeMap[size] : sizeMap.small;
59
+ };
60
+ export const FileAvatar = ({
61
+ file,
62
+ className,
63
+ size = "medium",
64
+ badge,
65
+ ...props
66
+ }: Props) => {
67
+ const { type: fileType, color: fileColor } = getFileTypeInfo(file);
68
+ const initials = getInitials(fileType, size, true);
69
+ const badgeSize = getBadgeSize(size);
70
+ const moduleAvatarSize = getAvatarSize(size);
71
+ const badgeContent = useMemo(
72
+ () =>
73
+ badge ? (
74
+ <>
75
+ {badge.type === "module" && (
76
+ <ModuleAvatar module={badge.module} size={moduleAvatarSize} />
77
+ )}
78
+ {badge.type !== "module" && (
79
+ <Badge type={badge.type} icon={badge.icon} size={badgeSize} />
80
+ )}
81
+ </>
82
+ ) : null,
83
+ [badge, badgeSize, moduleAvatarSize],
84
+ );
85
+
86
+ return (
87
+ <View
88
+ className={`inline-flex ${badge && badge.type === "module" ? "p-[3px]" : ""}`}
89
+ >
90
+ <View className="h-fit w-fit">
91
+ <Avatar
92
+ size={size}
93
+ className={cn(
94
+ "border border-solid border-f1-border-secondary bg-f1-background",
95
+ className,
96
+ )}
97
+ {...props}
98
+ >
99
+ <Text
100
+ className={cn(
101
+ "font-semibold text-f1-foreground-inverse/90",
102
+ textSizes[size],
103
+ fileColor,
104
+ )}
105
+ >
106
+ {initials}
107
+ </Text>
108
+ </Avatar>
109
+ </View>
110
+ {badge && (
111
+ <View className="absolute -bottom-0.5 -right-0.5">{badgeContent}</View>
112
+ )}
113
+ </View>
114
+ );
115
+ };
116
+
117
+ FileAvatar.displayName = "FileAvatar";