@fibery/ui-kit 1.37.0 → 1.38.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 (194) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/config/jest/testFrameworkSetup.js +1 -1
  3. package/package.json +20 -16
  4. package/src/abbreviate-name.ts +42 -0
  5. package/src/actions-menu/actions-menu-item.tsx +32 -11
  6. package/src/actions-menu/actions-menu-props.tsx +5 -0
  7. package/src/actions-menu/actions-menu-sub-command-menu.tsx +7 -4
  8. package/src/actions-menu/actions-menu-sub-menu.tsx +9 -3
  9. package/src/actions-menu/actions-menu.tsx +28 -9
  10. package/src/actions-menu/context-actions-menu.tsx +22 -0
  11. package/src/actions-panel.tsx +12 -2
  12. package/src/animated-height-container.tsx +24 -5
  13. package/src/antd/ant-upload.tsx +1 -1
  14. package/src/antd/input.tsx +4 -0
  15. package/src/avatar.tsx +1 -27
  16. package/src/axis-header.tsx +136 -76
  17. package/src/box.tsx +1 -1
  18. package/src/breadcrumb.tsx +78 -0
  19. package/src/button/actions-button-compact.tsx +4 -1
  20. package/src/button/base-button.tsx +7 -3
  21. package/src/button/button-group.tsx +1 -1
  22. package/src/button/button.tsx +33 -1
  23. package/src/button/icon-button.tsx +10 -1
  24. package/src/button/select-button.tsx +4 -0
  25. package/src/card-container.tsx +10 -6
  26. package/src/checkbox.tsx +17 -0
  27. package/src/collapsible-section.tsx +3 -1
  28. package/src/color-picker/swatch.tsx +1 -0
  29. package/src/command-menu/index.tsx +3 -3
  30. package/src/context-menu/index.tsx +10 -1
  31. package/src/date-picker/autocomplete.tsx +11 -5
  32. package/src/date-picker/date-range-input.tsx +5 -1
  33. package/src/date-picker/date-range-picker-popup-content.tsx +31 -13
  34. package/src/date-picker/date-range-picker.tsx +6 -3
  35. package/src/date-picker/relative-date-picker.tsx +6 -2
  36. package/src/date-picker/single-date-input.tsx +5 -1
  37. package/src/date-picker/single-date-picker.tsx +8 -5
  38. package/src/date-picker/styles.ts +52 -26
  39. package/src/date-picker/types.ts +3 -1
  40. package/src/day-select/day-select.tsx +21 -75
  41. package/src/day-select/iso-week-day-select.tsx +1 -1
  42. package/src/day-select/mount-day-select.tsx +2 -2
  43. package/src/day-select/week-day-select.tsx +1 -5
  44. package/src/design-system.ts +45 -12
  45. package/src/dropdown-menu/index.tsx +19 -2
  46. package/src/emoji-picker/app-icon-picker.tsx +6 -4
  47. package/src/emoji-picker/emoji-picker-preview-footer.tsx +5 -1
  48. package/src/emoji-picker/emoji-picker.tsx +3 -0
  49. package/src/emoji-picker/emoji.tsx +5 -3
  50. package/src/emoji-picker/icon-emoji-picker.tsx +10 -1
  51. package/src/emoji-picker/primitives/emoji.tsx +49 -51
  52. package/src/emoji-picker/primitives/footer.tsx +5 -0
  53. package/src/emoji-picker/primitives/search.tsx +8 -0
  54. package/src/emoji-picker/primitives/skin-tone.tsx +12 -1
  55. package/src/emoji-picker/use-responsive-emoji-size.ts +11 -0
  56. package/src/emoji-picker/utils/emoji-set.ts +2 -1
  57. package/src/empty-state/empty-state.tsx +6 -0
  58. package/src/fibermoji-placeholder.tsx +1 -27
  59. package/src/field-icon.tsx +4 -1
  60. package/src/file-item-2.tsx +408 -0
  61. package/src/file-item.tsx +215 -47
  62. package/src/header-layout.tsx +11 -0
  63. package/src/html-styles.ts +21 -4
  64. package/src/icons/ast/ActivityFilled.ts +8 -0
  65. package/src/icons/ast/AiAssistantFilled.ts +8 -0
  66. package/src/icons/ast/Back.ts +1 -1
  67. package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
  68. package/src/icons/ast/DateRange.ts +1 -1
  69. package/src/icons/ast/EntityCreateFilled.ts +8 -0
  70. package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
  71. package/src/icons/ast/ExtensionFiles.ts +1 -1
  72. package/src/icons/ast/FileUpload.ts +1 -1
  73. package/src/icons/ast/GlobeUnpublish.ts +8 -0
  74. package/src/icons/ast/HomeFilled.ts +8 -0
  75. package/src/icons/ast/KeyboardHideDown.ts +8 -0
  76. package/src/icons/ast/LayoutMultiple.ts +8 -0
  77. package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
  78. package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
  79. package/src/icons/ast/SearchFilled.ts +8 -0
  80. package/src/icons/ast/SettingsFilled.ts +8 -0
  81. package/src/icons/ast/SlideMenuFilled.ts +8 -0
  82. package/src/icons/ast/SwitchToMention.ts +8 -0
  83. package/src/icons/ast/SwitchToText.ts +8 -0
  84. package/src/icons/ast/SwitchToWidget.ts +8 -0
  85. package/src/icons/ast/TypeDate.ts +1 -1
  86. package/src/icons/ast/ViewGallery.ts +8 -0
  87. package/src/icons/ast/index.tsx +16 -0
  88. package/src/icons/react/ActivityFilled.tsx +13 -0
  89. package/src/icons/react/AiAssistantFilled.tsx +13 -0
  90. package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
  91. package/src/icons/react/EntityCreateFilled.tsx +13 -0
  92. package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
  93. package/src/icons/react/GlobeUnpublish.tsx +13 -0
  94. package/src/icons/react/HomeFilled.tsx +13 -0
  95. package/src/icons/react/KeyboardHideDown.tsx +13 -0
  96. package/src/icons/react/LayoutMultiple.tsx +13 -0
  97. package/src/icons/react/SearchFilled.tsx +13 -0
  98. package/src/icons/react/SettingsFilled.tsx +13 -0
  99. package/src/icons/react/SlideMenuFilled.tsx +13 -0
  100. package/src/icons/react/SwitchToMention.tsx +13 -0
  101. package/src/icons/react/SwitchToText.tsx +13 -0
  102. package/src/icons/react/SwitchToWidget.tsx +13 -0
  103. package/src/icons/react/ViewGallery.tsx +13 -0
  104. package/src/icons/react/index.tsx +16 -0
  105. package/src/icons/svg/activity-filled.svg +4 -0
  106. package/src/icons/svg/ai-assistant-filled.svg +3 -0
  107. package/src/icons/svg/back.svg +3 -1
  108. package/src/icons/svg/collapse-all-horizontal.svg +3 -0
  109. package/src/icons/svg/date-range.svg +3 -3
  110. package/src/icons/svg/entity-create-filled.svg +4 -0
  111. package/src/icons/svg/expand-all-horizontal.svg +3 -0
  112. package/src/icons/svg/extension/files.svg +3 -1
  113. package/src/icons/svg/file-upload.svg +3 -6
  114. package/src/icons/svg/globe-unpublish.svg +4 -0
  115. package/src/icons/svg/home-filled.svg +3 -0
  116. package/src/icons/svg/keyboard-hide-down.svg +1 -0
  117. package/src/icons/svg/layout-multiple.svg +3 -0
  118. package/src/icons/svg/richeditor/history/redo.svg +3 -2
  119. package/src/icons/svg/richeditor/history/undo.svg +3 -2
  120. package/src/icons/svg/search-filled.svg +3 -0
  121. package/src/icons/svg/settings-filled.svg +3 -0
  122. package/src/icons/svg/slide-menu-filled.svg +1 -0
  123. package/src/icons/svg/switch-to-mention.svg +3 -0
  124. package/src/icons/svg/switch-to-text.svg +4 -0
  125. package/src/icons/svg/switch-to-widget.svg +4 -0
  126. package/src/icons/svg/type/date.svg +3 -2
  127. package/src/icons/svg/view-gallery.svg +4 -0
  128. package/src/images-gallery/images-gallery-fall-through-provider.tsx +11 -0
  129. package/src/images-gallery/images-gallery.tsx +257 -0
  130. package/src/images-gallery/zoom.tsx +123 -0
  131. package/src/images-gallery-2/images-gallery-2.tsx +442 -0
  132. package/src/images-gallery-2/slide-buttons.tsx +230 -0
  133. package/src/images-gallery-2/zoom.tsx +35 -0
  134. package/src/is-in-popup.ts +1 -1
  135. package/src/kbd.tsx +46 -0
  136. package/src/layout-styles.ts +21 -1
  137. package/src/lists/actions-menu-row-surface.tsx +3 -1
  138. package/src/lists/list-row-surface.tsx +7 -1
  139. package/src/mobile-keyboard-aware-popup.tsx +87 -0
  140. package/src/mobile-styles.ts +8 -0
  141. package/src/modal-menu/contexts/modal-menu-context.tsx +22 -0
  142. package/src/modal-menu/contexts/modal-submenu-context.tsx +16 -0
  143. package/src/modal-menu/index.tsx +14 -0
  144. package/src/modal-menu/modal-menu-content.tsx +68 -0
  145. package/src/modal-menu/modal-menu-group.tsx +10 -0
  146. package/src/modal-menu/modal-menu-item.tsx +45 -0
  147. package/src/modal-menu/modal-menu-label.tsx +24 -0
  148. package/src/modal-menu/modal-menu-root.tsx +57 -0
  149. package/src/modal-menu/modal-menu-separator.tsx +14 -0
  150. package/src/modal-menu/modal-menu-trigger.tsx +54 -0
  151. package/src/modal-menu/modal-submenu-content.tsx +49 -0
  152. package/src/modal-menu/modal-submenu-trigger.tsx +34 -0
  153. package/src/modal-menu/modal-submenu.tsx +17 -0
  154. package/src/notification-dot.tsx +16 -7
  155. package/src/online-users.tsx +3 -3
  156. package/src/palette.ts +1 -1
  157. package/src/platform-symbols.ts +9 -0
  158. package/src/platform.ts +2 -0
  159. package/src/popover/index.tsx +710 -0
  160. package/src/popover/mobile-popup-context.tsx +29 -0
  161. package/src/{popup → popover}/modifiers.tsx +25 -25
  162. package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
  163. package/src/reactions/reaction-button.tsx +342 -135
  164. package/src/reactions/reaction-picker.tsx +51 -44
  165. package/src/reactions/reactions.tsx +11 -1
  166. package/src/reactions/tootltip.tsx +55 -0
  167. package/src/rich-text-embed-error.tsx +2 -1
  168. package/src/select/components/group-heading.tsx +8 -0
  169. package/src/select/components/menu-list-virtualized.tsx +6 -2
  170. package/src/select/components/option.tsx +4 -0
  171. package/src/select/index.tsx +8 -4
  172. package/src/select/select-control-settings-context.tsx +11 -2
  173. package/src/select/select-in-popover.tsx +30 -39
  174. package/src/select/styles.ts +21 -1
  175. package/src/tab-nav/tab-nav.tsx +36 -10
  176. package/src/toast/primitives.tsx +8 -1
  177. package/src/toggle-button/round-toggle-button.tsx +23 -0
  178. package/src/toggle-button/toggle-button-group.tsx +34 -0
  179. package/src/toggle-button/toggle-button.tsx +164 -0
  180. package/src/toggle.tsx +11 -3
  181. package/src/tooltip.tsx +29 -20
  182. package/src/type-badge.tsx +5 -2
  183. package/src/unit/styles.ts +2 -2
  184. package/src/unit/unit-with-tooltip.tsx +1 -1
  185. package/src/use-is-phone.tsx +50 -4
  186. package/src/use-is-support-hover.ts +1 -1
  187. package/src/use-on-screen-keyboard-data.tsx +66 -0
  188. package/src/workflow-progress-icon.tsx +16 -22
  189. package/src/popup/index.tsx +0 -383
  190. package/src/shortcut-badge.tsx +0 -29
  191. /package/src/{popup → popover}/popup-stack-context.tsx +0 -0
  192. /package/src/{popup → popover}/reference.ts +0 -0
  193. /package/src/{popup → popover}/styles.ts +0 -0
  194. /package/src/{popup → popover}/use-click-outside.ts +0 -0
@@ -0,0 +1,29 @@
1
+ import _ from "lodash";
2
+ import {FC, ReactNode, useState, useMemo} from "react";
3
+ import {createContext} from "@fibery/react/src/create-context";
4
+
5
+ type MobilePopupContext = {
6
+ title?: string;
7
+ headerSlot?: ReactNode;
8
+ setTitle: (title: string) => void;
9
+ setHeader: (header?: ReactNode) => void;
10
+ };
11
+
12
+ const [Provider, useMobilePopup] = createContext<MobilePopupContext>("MobilePopupContext", {
13
+ setTitle: _.noop,
14
+ setHeader: _.noop,
15
+ });
16
+
17
+ export const MobilePopupProvider: FC<{children?: ReactNode}> = ({children}) => {
18
+ const [title, setTitle] = useState<string | undefined>();
19
+ const [headerSlot, setHeader] = useState<ReactNode | undefined>();
20
+
21
+ const contextValue = useMemo(
22
+ () => ({title, headerSlot, setTitle, setHeader}),
23
+ [title, headerSlot, setTitle, setHeader]
24
+ );
25
+
26
+ return <Provider value={contextValue}>{children}</Provider>;
27
+ };
28
+
29
+ export {useMobilePopup};
@@ -1,37 +1,37 @@
1
1
  import {Options as PreventOverflowOptions} from "@popperjs/core/lib/modifiers/preventOverflow";
2
- import {$TSFixMe} from "../tsfixme";
3
- import {Modifier, ModifierArguments} from "@popperjs/core";
2
+ import {Modifier, ModifierArguments, Placement, Boundary, RootBoundary, Padding, Context} from "@popperjs/core";
4
3
  import maxSize from "popper-max-size-modifier";
5
4
  import {getResizeListener} from "@fibery/helpers/utils/resize-listener";
6
5
  import {isElementReference} from "./reference";
7
6
  import _ from "lodash";
8
7
 
9
- type PopupModifier = Modifier<$TSFixMe, $TSFixMe>;
8
+ type MaxSizeOptions = {
9
+ placement: Placement;
10
+ boundary: Boundary;
11
+ rootBoundary: RootBoundary;
12
+ elementContext: Context;
13
+ altBoundary: boolean;
14
+ padding: Padding;
15
+ };
10
16
 
11
- export const getMaxSize = (overflowOptions: Partial<PreventOverflowOptions>): PopupModifier[] => [
12
- {
17
+ export const makeMaxSizeModifier = (options: Partial<PreventOverflowOptions>): Modifier<"maxSize", MaxSizeOptions> => {
18
+ return {
13
19
  ...maxSize,
14
- options: overflowOptions,
15
- },
16
- {
17
- name: "applyMaxSize",
18
- enabled: true,
19
- phase: "beforeWrite",
20
- requires: ["maxSize"],
21
- fn({state}) {
22
- const {width, height} = state.modifiersData.maxSize;
23
- state.styles.popper.maxWidth = `${width}px`;
24
- state.styles.popper.maxHeight = `${height}px`;
25
- },
26
- },
27
- ];
20
+ options,
21
+ };
22
+ };
28
23
 
29
- export const disableGpuAcceleration = {
30
- name: "computeStyles",
31
- options: {
32
- gpuAcceleration: false,
24
+ export const applyMaxSize: Modifier<"applyMaxSize", Record<string, never>> = {
25
+ name: "applyMaxSize",
26
+ enabled: true,
27
+ phase: "beforeWrite",
28
+ requires: ["maxSize"],
29
+ fn({state}) {
30
+ const {width, height} = state.modifiersData.maxSize;
31
+ state.styles.popper.maxWidth = `${width}px`;
32
+ state.styles.popper.maxHeight = `${height}px`;
33
33
  },
34
- } as unknown as PopupModifier;
34
+ };
35
35
 
36
36
  const observeWidthEffect: (arg0: ModifierArguments<Record<string, unknown>>) => void = ({state, instance}) => {
37
37
  const {popper, reference} = state.elements;
@@ -61,7 +61,7 @@ const observeWidthEffect: (arg0: ModifierArguments<Record<string, unknown>>) =>
61
61
  };
62
62
  };
63
63
 
64
- export const observeWidth: PopupModifier = {
64
+ export const observeWidth: Modifier<"observeWidth", Record<string, never>> = {
65
65
  name: "observeWidth",
66
66
  enabled: true,
67
67
  phase: "main",
@@ -2,11 +2,11 @@ import {createContext} from "@fibery/react/src/create-context";
2
2
  import {getPopupContainerElement} from "../utils-dom";
3
3
  import {$TSFixMe} from "../tsfixme";
4
4
  import {Modifier} from "react-popper";
5
- import {Props} from "./index";
5
+ import {PopoverOldProps} from "./index";
6
6
 
7
7
  export const [PopupModifiersProvider, usePopupModifiers] = createContext<{
8
8
  getPopupContainer: () => HTMLElement;
9
9
  additionalModifiers?: Array<Partial<Modifier<$TSFixMe, $TSFixMe>>>;
10
- preventOverflowOptions?: Props["preventOverflowOptions"];
11
- flipOptions?: Props["flipOptions"];
10
+ preventOverflowOptions?: PopoverOldProps["preventOverflowOptions"];
11
+ flipOptions?: PopoverOldProps["flipOptions"];
12
12
  }>("PopupModifiersProvider", {getPopupContainer: getPopupContainerElement});
@@ -1,122 +1,357 @@
1
- import {css, cx} from "@linaria/core";
1
+ import {css} from "@linaria/core";
2
+ import {Fragment, ReactEventHandler, ReactNode, useCallback, useState, useRef} from "react";
2
3
  import {createPortal} from "react-dom";
3
- import {useLongPress} from "../use-long-press";
4
- import {Fragment, ReactNode, useState} from "react";
4
+ import {fontSize, fontWeight, space, themeVars} from "../design-system";
5
5
  import {Emoji} from "../emoji-picker/emoji";
6
- import {border, lineHeight, space, textStyles, themeVars} from "../design-system";
6
+ import {ToggleButton} from "../toggle-button/toggle-button";
7
7
  import {Tooltip} from "../tooltip";
8
8
  import {useIsPhone} from "../use-is-phone";
9
+ import {mobileRootSelector, safeAreaInsetBottomVar} from "../mobile-styles";
10
+ import {useLongPress} from "../use-long-press";
9
11
  import {getWordDivider} from "./get-word-divider";
12
+ import {EmojiTooltipDescription, EmojiTooltipTitle} from "./tootltip";
13
+ import {TabNavLink, TabNavRoot, TabNavList, tabButton} from "../tab-nav/tab-nav";
14
+ import {AvatarImage} from "../avatar";
15
+ import {getPopupContainerElement} from "../utils-dom";
10
16
 
11
17
  export type Reaction = {
12
18
  count: number;
13
19
  key: string;
14
20
  selected: boolean;
15
21
  alias?: string;
16
- userNames?: Array<string>;
22
+ users?: Array<{name: string; avatarUrl: string | null}>;
17
23
  };
18
24
 
19
25
  type Props = {
20
26
  reaction: Reaction;
27
+ reactions: Array<Reaction>;
21
28
  disabled?: boolean;
22
29
  onSelect: (reactionKey: string) => unknown;
23
30
  };
24
31
 
25
- export const reactionButtonCss = css`
26
- all: unset;
27
- padding-inline: ${space.s6}px;
28
- box-sizing: border-box;
29
- display: flex;
30
- align-items: center;
32
+ const reactionButtonCss = css`
31
33
  min-width: ${space.s24 + space.s12}px;
32
- justify-content: center;
33
- height: ${space.s24 + 2}px;
34
- border: 1.5px solid ${themeVars.colorBgReactionsDefault};
35
- border-radius: ${border.radius8}px;
36
- background-color: ${themeVars.colorBgReactionsDefault};
37
- cursor: pointer;
38
- line-height: ${lineHeight.nowrap};
39
- -webkit-user-select: none;
40
-
41
- &[aria-disabled="true"] {
42
- cursor: default;
43
- border-color: ${themeVars.colorBorderReactionsHover};
44
- background-color: transparent;
45
- }
46
-
47
- &:not([aria-disabled="true"]):hover {
48
- background-color: ${themeVars.colorBgReactionsHover};
49
- border-color: ${themeVars.colorBorderReactionsHover};
50
- }
51
- `;
52
-
53
- export const selectedReactionButtonCss = css`
54
- .${reactionButtonCss}& {
55
- &:not([aria-disabled="true"]) {
56
- background-color: ${themeVars.colorBgReactionsSelectedDefault};
57
- border-color: ${themeVars.colorBorderReactionsSelectedDefault};
58
- }
59
-
60
- &:not([aria-disabled="true"]):hover {
61
- background-color: ${themeVars.colorBgReactionsSelectedHover};
62
- border-color: ${themeVars.colorBorderReactionsSelectedHover};
63
- }
64
- }
65
- `;
66
-
67
- const countCss = css`
68
- ${textStyles.small};
69
- line-height: ${lineHeight.nowrap};
70
- padding: ${space.s2}px ${space.s2}px ${space.s2}px ${space.s4}px;
71
- .${selectedReactionButtonCss}:not(:disabled) & {
72
- color: ${themeVars.colorTextReactionsSelected};
34
+ ${mobileRootSelector} & {
35
+ height: ${space.s28}px;
36
+ padding-inline: ${space.s6}px;
73
37
  }
74
38
  `;
75
-
39
+ const zIndexOverlay = 10001;
76
40
  const overlayClassName = css`
77
41
  position: absolute;
78
- z-index: 10001;
42
+ z-index: ${zIndexOverlay};
79
43
  display: flex;
80
44
  flex-direction: column;
81
45
  inset: 0;
82
46
  `;
83
47
 
84
48
  function TouchOverlay({onClick}: {onClick: () => void}) {
85
- return createPortal(<div className={overlayClassName} onClick={onClick} />, document.body);
49
+ return createPortal(<div className={overlayClassName} onClick={onClick} />, getPopupContainerElement());
86
50
  }
87
51
 
88
52
  function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => void}) {
53
+ const handleClose: ReactEventHandler<HTMLDivElement> = useCallback(
54
+ (e) => {
55
+ e.stopPropagation();
56
+ onClose();
57
+ },
58
+ [onClose]
59
+ );
89
60
  return createPortal(
90
61
  <div className={overlayClassName}>
91
62
  <div
92
- onClick={onClose}
63
+ onPointerDown={handleClose}
93
64
  className={css`
94
65
  background-color: ${themeVars.modalBg};
95
66
  flex-grow: 1;
96
67
  `}
97
68
  />
98
69
  <div
70
+ onPointerDown={(e) => {
71
+ e.stopPropagation();
72
+ }}
99
73
  className={css`
100
74
  flex-shrink: 0;
101
- background-color: ${themeVars.tooltipBgColor};
75
+ height: 70vh;
76
+ background-color: ${themeVars.panelBg};
77
+ padding-bottom: var(${safeAreaInsetBottomVar});
102
78
  `}
103
79
  >
104
80
  {content}
105
81
  </div>
106
82
  </div>,
107
- document.body
83
+ getPopupContainerElement()
84
+ );
85
+ }
86
+
87
+ const navLinkClassName = css`
88
+ &.${tabButton} {
89
+ height: 32px;
90
+ }
91
+ `;
92
+
93
+ const canScrollVar = "--can-scroll-fibery-reaction";
94
+
95
+ const tabNavRootWithShadow = css`
96
+ padding: 0;
97
+ display: flex;
98
+ overflow-x: auto;
99
+ scrollbar-width: none;
100
+ position: relative;
101
+ align-items: center;
102
+ border-bottom: 0.5px solid ${themeVars.separatorColor};
103
+ & > div {
104
+ flex-grow: 1;
105
+ top: ${space.s6}px;
106
+ }
107
+ :not(ul) ul {
108
+ gap: ${space.s12}px;
109
+ }
110
+ /* Only show Scroll Indicators when the scroller can actually scroll */
111
+ @keyframes detect-scroll {
112
+ from,
113
+ to {
114
+ ${canScrollVar}: 1;
115
+ }
116
+ }
117
+ /* Scroll Indicators */
118
+ @keyframes reveal {
119
+ 0% {
120
+ opacity: 0;
121
+ }
122
+
123
+ 100% {
124
+ opacity: 1;
125
+ }
126
+ }
127
+ &::before,
128
+ &::after {
129
+ content: "";
130
+ display: block;
131
+ flex-shrink: 0;
132
+ width: 12px;
133
+ height: ${44 + 12}px;
134
+ position: sticky;
135
+ visibility: hidden;
136
+ }
137
+
138
+ @supports (animation-timeline: scroll()) {
139
+ & {
140
+ scroll-timeline: --scroll-timeline x;
141
+ }
142
+ &::before {
143
+ background: linear-gradient(to right, rgba(0, 0, 0, 0.15), transparent);
144
+ }
145
+
146
+ &::after {
147
+ background: linear-gradient(to left, rgba(0, 0, 0, 0.15), transparent);
148
+ animation-direction: reverse;
149
+ animation-range: calc(100% - 40px) calc(100% - 20px);
150
+ }
151
+ &::before,
152
+ &::after {
153
+ animation-name: reveal;
154
+ animation-timeline: --scroll-timeline;
155
+ animation-fill-mode: both;
156
+ }
157
+
158
+ &::before {
159
+ left: 0;
160
+ animation-range: 1em 2em;
161
+ }
162
+
163
+ &::after {
164
+ right: 0;
165
+ animation-direction: reverse;
166
+ animation-range: calc(100% - 2em) calc(100% - 1em);
167
+ }
168
+
169
+ & {
170
+ animation: detect-scroll;
171
+ animation-timeline: --scroll-timeline;
172
+ animation-fill-mode: none;
173
+ }
174
+
175
+ &::before,
176
+ &::after {
177
+ --visibility-if-can-scroll: var(${canScrollVar}) visible;
178
+ --visibility-if-cant-scroll: hidden;
179
+ visibility: var(--visibility-if-can-scroll, var(--visibility-if-cant-scroll));
180
+ }
181
+ }
182
+ `;
183
+
184
+ function PhoneTooltipContent({reactions}: {reactions: Array<Reaction>}): JSX.Element {
185
+ const [selectedTab, setSelectedTab] = useState("all");
186
+ const listRef = useRef<HTMLUListElement>(null);
187
+ const hasMultipleReactions = reactions.length > 1;
188
+
189
+ const allReactionsContent = (
190
+ <div
191
+ className={css`
192
+ display: flex;
193
+ flex-direction: column;
194
+ gap: ${space.s16}px;
195
+ `}
196
+ >
197
+ {reactions.map((reaction) => (
198
+ <div
199
+ key={reaction.key}
200
+ className={css`
201
+ display: flex;
202
+ align-items: center;
203
+ gap: ${space.s16}px;
204
+ `}
205
+ >
206
+ <Emoji size={24} emoji={reaction.key} />
207
+ <div>
208
+ <div
209
+ className={css`
210
+ font-size: ${fontSize.sm}px;
211
+ font-weight: ${fontWeight.medium};
212
+ `}
213
+ >
214
+ {reaction.alias || reaction.key}
215
+ </div>
216
+ {reaction.users ? (
217
+ <div
218
+ className={css`
219
+ color: ${themeVars.accentTextColor};
220
+ display: -webkit-box;
221
+ -webkit-line-clamp: 3;
222
+ -webkit-box-orient: vertical;
223
+ overflow: hidden;
224
+ text-overflow: ellipsis;
225
+ `}
226
+ >
227
+ <PrintNames users={reaction.users} />
228
+ </div>
229
+ ) : null}
230
+ </div>
231
+ </div>
232
+ ))}
233
+ </div>
234
+ );
235
+
236
+ const singleReactionContent = (reaction: Reaction | undefined | null) => {
237
+ if (!reaction) {
238
+ return null;
239
+ }
240
+ return (
241
+ <div
242
+ className={css`
243
+ display: flex;
244
+ flex-direction: column;
245
+ gap: ${space.s16}px;
246
+ `}
247
+ >
248
+ <div
249
+ className={css`
250
+ font-weight: ${fontWeight.medium};
251
+ `}
252
+ >
253
+ {reaction.alias || reaction.key}
254
+ </div>
255
+ {reaction.users?.map(({name: userName, avatarUrl}) => (
256
+ <div
257
+ key={userName}
258
+ className={css`
259
+ display: flex;
260
+ align-items: center;
261
+ gap: ${space.s12}px;
262
+ `}
263
+ >
264
+ <AvatarImage avatarUrl={avatarUrl} title={userName} size={24} />
265
+ <span
266
+ className={css`
267
+ overflow-wrap: anywhere;
268
+ font-size: ${fontSize.sm}px;
269
+ font-weight: ${fontWeight.medium};
270
+ `}
271
+ >
272
+ {userName}
273
+ </span>
274
+ </div>
275
+ ))}
276
+ </div>
277
+ );
278
+ };
279
+
280
+ return (
281
+ <>
282
+ <TabNavRoot className={tabNavRootWithShadow}>
283
+ <TabNavList ref={listRef}>
284
+ {hasMultipleReactions ? (
285
+ <TabNavLink
286
+ className={navLinkClassName}
287
+ wide
288
+ active={selectedTab === "all"}
289
+ onClick={() => setSelectedTab("all")}
290
+ >
291
+ All
292
+ </TabNavLink>
293
+ ) : null}
294
+ {reactions.map((reaction) => (
295
+ <TabNavLink
296
+ className={navLinkClassName}
297
+ key={reaction.key}
298
+ wide
299
+ active={selectedTab === reaction.key || !hasMultipleReactions}
300
+ onClick={() => setSelectedTab(reaction.key)}
301
+ before={<Emoji emoji={reaction.key} />}
302
+ >
303
+ {reaction.count}
304
+ </TabNavLink>
305
+ ))}
306
+ </TabNavList>
307
+ </TabNavRoot>
308
+
309
+ <div
310
+ className={css`
311
+ padding: ${space.s12}px;
312
+ overflow-y: auto;
313
+ `}
314
+ >
315
+ {selectedTab === "all" && hasMultipleReactions
316
+ ? allReactionsContent
317
+ : singleReactionContent(hasMultipleReactions ? reactions.find((r) => r.key === selectedTab) : reactions[0])}
318
+ </div>
319
+ </>
108
320
  );
109
321
  }
110
322
 
111
- export const ReactionButton = ({reaction, disabled, onSelect}: Props): JSX.Element => {
323
+ function PrintNames({users}: {users: {name: string}[]}): JSX.Element {
324
+ return (
325
+ <>
326
+ {users.map(({name}, index, names) => {
327
+ return (
328
+ <Fragment key={index}>
329
+ <span
330
+ className={css`
331
+ overflow-wrap: anywhere;
332
+ `}
333
+ >
334
+ {name}
335
+ </span>
336
+ {getWordDivider(names.length, index)}
337
+ </Fragment>
338
+ );
339
+ })}{" "}
340
+ </>
341
+ );
342
+ }
343
+
344
+ export const ReactionButton = ({reaction, disabled, onSelect, reactions}: Props): JSX.Element => {
112
345
  const [showOverlay, setShowOverlay] = useState<true | undefined>(undefined);
113
346
  const isPhone = useIsPhone();
347
+
114
348
  const onLongPress = () => {
115
349
  // https://github.com/radix-ui/primitives/issues/931 - disable text selection
116
350
  if (isPhone) {
117
351
  document.body.style.userSelect = "none";
118
352
  document.body.style.webkitUserSelect = "none";
119
353
  }
354
+
120
355
  setShowOverlay(true);
121
356
  };
122
357
  const close = () => {
@@ -131,85 +366,56 @@ export const ReactionButton = ({reaction, disabled, onSelect}: Props): JSX.Eleme
131
366
  isPreventDefault: true,
132
367
  delay: 300,
133
368
  });
369
+
134
370
  const button = (
135
- <button
136
- type="button"
137
- aria-disabled={disabled}
138
- className={cx(reactionButtonCss, reaction.selected && selectedReactionButtonCss)}
139
- onClick={() => {
140
- if (!disabled) {
141
- onSelect(reaction.key);
142
- }
143
- }}
144
- {...longPressEvent}
145
- >
146
- <div
147
- className={css`
148
- font-size: 18px;
149
- height: 18px;
150
- width: 18px;
151
- `}
152
- >
153
- <Emoji emoji={reaction.key} />
154
- </div>
155
- <span className={countCss}>{reaction.count}</span>
156
- </button>
157
- );
158
- if (reaction?.userNames?.length) {
159
- // noinspection CssInvalidPropertyValue
160
- const title = (
161
- <div
162
- className={css`
163
- padding-top: ${space.s6}px;
164
- padding-left: ${space.s6}px;
165
- padding-right: ${space.s6}px;
166
- display: flex;
167
- justify-content: center;
168
- `}
169
- >
371
+ <ToggleButton
372
+ className={reactionButtonCss}
373
+ disabled={disabled}
374
+ iconStart={
170
375
  <div
171
376
  className={css`
172
- background-color: ${themeVars.whiteColor};
173
- padding: ${space.s4}px;
174
- border-radius: ${border.radius4}px;
377
+ font-size: 16px;
378
+ height: 16px;
379
+ width: 16px;
380
+ font-size-adjust: none;
381
+
382
+ ${mobileRootSelector} & {
383
+ font-size: 18px;
384
+ height: 18px;
385
+ width: 18px;
386
+ line-height: 18px;
387
+ @supports (-webkit-touch-callout: none) {
388
+ /* Safari specific fix */
389
+ line-height: 17px;
390
+ .emoji {
391
+ font-size: 0.8em;
392
+ position: relative;
393
+ top: -1px;
394
+ img {
395
+ font-size: 1.2em;
396
+ top: 1px;
397
+ }
398
+ }
399
+ }
400
+ }
175
401
  `}
402
+ {...longPressEvent}
176
403
  >
177
- <Emoji emoji={reaction.key} size={64} />
404
+ <Emoji emoji={reaction.key} />
178
405
  </div>
179
- </div>
180
- );
406
+ }
407
+ onPressedChange={() => onSelect(reaction.key)}
408
+ pressed={reaction.selected}
409
+ >
410
+ <span>{reaction.count}</span>
411
+ </ToggleButton>
412
+ );
413
+
414
+ if (reaction?.users?.length) {
415
+ const title = <EmojiTooltipTitle emoji={reaction.key} />;
181
416
  const description = (
182
- <div
183
- className={cx(
184
- css`
185
- padding-top: ${space.s8}px;
186
- padding-bottom: ${space.s6}px;
187
- padding-left: ${space.s6}px;
188
- padding-right: ${space.s6}px;
189
- text-align: center;
190
- word-wrap: break-word;
191
- color: ${themeVars.whiteColor};
192
- `,
193
- !isPhone &&
194
- css`
195
- max-width: 200px;
196
- `
197
- )}
198
- >
199
- {reaction.userNames.map((name, index, names) => {
200
- return (
201
- <Fragment key={index}>
202
- <span
203
- className={css`
204
- overflow-wrap: break-word;
205
- `}
206
- >
207
- {name}
208
- </span>
209
- {getWordDivider(names.length, index)}
210
- </Fragment>
211
- );
212
- })}
417
+ <EmojiTooltipDescription>
418
+ <PrintNames users={reaction.users} />
213
419
  <span
214
420
  className={css`
215
421
  color: ${themeVars.shortcutTextColor};
@@ -217,7 +423,7 @@ export const ReactionButton = ({reaction, disabled, onSelect}: Props): JSX.Eleme
217
423
  >
218
424
  reacted with {reaction.alias || reaction.key}
219
425
  </span>
220
- </div>
426
+ </EmojiTooltipDescription>
221
427
  );
222
428
  if (isPhone) {
223
429
  return (
@@ -229,11 +435,12 @@ export const ReactionButton = ({reaction, disabled, onSelect}: Props): JSX.Eleme
229
435
  content={
230
436
  <div
231
437
  className={css`
232
- padding: ${space.s12}px;
438
+ display: flex;
439
+ height: 100%;
440
+ flex-direction: column;
233
441
  `}
234
442
  >
235
- {title}
236
- {description}
443
+ <PhoneTooltipContent reactions={reactions} />
237
444
  </div>
238
445
  }
239
446
  />