@shware/workflow-ui 0.0.0-stage → 0.0.0
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.
- package/LICENSE +21 -0
- package/README.md +180 -2
- package/dist/assets/iphone-17-pro-DzaacWSl.png +0 -0
- package/dist/assets/pixel-10-pro-back-7MDj1_lz.webp +0 -0
- package/dist/assets/pixel-10-pro-mask-Bi1deQ9Y.webp +0 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +673 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/config.d.mts +247 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +27 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +451 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2722 -0
- package/dist/index.mjs.map +1 -0
- package/dist/postgres.d.mts +34 -0
- package/dist/postgres.d.mts.map +1 -0
- package/dist/postgres.mjs +313 -0
- package/dist/postgres.mjs.map +1 -0
- package/package.json +93 -3
- package/src/app/assets/devices/iphone-17-pro.png +0 -0
- package/src/app/assets/devices/pixel-10-pro-back.webp +0 -0
- package/src/app/assets/devices/pixel-10-pro-mask.webp +0 -0
- package/src/app/assets/flags/AC.svg +1 -0
- package/src/app/assets/flags/AD.svg +1 -0
- package/src/app/assets/flags/AE.svg +1 -0
- package/src/app/assets/flags/AF.svg +1 -0
- package/src/app/assets/flags/AG.svg +1 -0
- package/src/app/assets/flags/AI.svg +1 -0
- package/src/app/assets/flags/AL.svg +1 -0
- package/src/app/assets/flags/AM.svg +1 -0
- package/src/app/assets/flags/AO.svg +1 -0
- package/src/app/assets/flags/AQ.svg +1 -0
- package/src/app/assets/flags/AR.svg +1 -0
- package/src/app/assets/flags/AS.svg +1 -0
- package/src/app/assets/flags/AT.svg +1 -0
- package/src/app/assets/flags/AU.svg +1 -0
- package/src/app/assets/flags/AW.svg +1 -0
- package/src/app/assets/flags/AX.svg +1 -0
- package/src/app/assets/flags/AZ.svg +1 -0
- package/src/app/assets/flags/BA.svg +1 -0
- package/src/app/assets/flags/BB.svg +1 -0
- package/src/app/assets/flags/BD.svg +1 -0
- package/src/app/assets/flags/BE.svg +1 -0
- package/src/app/assets/flags/BF.svg +1 -0
- package/src/app/assets/flags/BG.svg +1 -0
- package/src/app/assets/flags/BH.svg +1 -0
- package/src/app/assets/flags/BI.svg +1 -0
- package/src/app/assets/flags/BJ.svg +1 -0
- package/src/app/assets/flags/BL.svg +1 -0
- package/src/app/assets/flags/BM.svg +1 -0
- package/src/app/assets/flags/BN.svg +1 -0
- package/src/app/assets/flags/BO.svg +1 -0
- package/src/app/assets/flags/BQ-BO.svg +1 -0
- package/src/app/assets/flags/BQ-SA.svg +1 -0
- package/src/app/assets/flags/BQ-SE.svg +1 -0
- package/src/app/assets/flags/BQ.svg +1 -0
- package/src/app/assets/flags/BR.svg +1 -0
- package/src/app/assets/flags/BS.svg +1 -0
- package/src/app/assets/flags/BT.svg +1 -0
- package/src/app/assets/flags/BV.svg +1 -0
- package/src/app/assets/flags/BW.svg +1 -0
- package/src/app/assets/flags/BY.svg +1 -0
- package/src/app/assets/flags/BZ.svg +1 -0
- package/src/app/assets/flags/CA.svg +1 -0
- package/src/app/assets/flags/CC.svg +1 -0
- package/src/app/assets/flags/CD.svg +1 -0
- package/src/app/assets/flags/CF.svg +1 -0
- package/src/app/assets/flags/CG.svg +1 -0
- package/src/app/assets/flags/CH.svg +1 -0
- package/src/app/assets/flags/CI.svg +1 -0
- package/src/app/assets/flags/CK.svg +1 -0
- package/src/app/assets/flags/CL.svg +1 -0
- package/src/app/assets/flags/CM.svg +1 -0
- package/src/app/assets/flags/CN.svg +1 -0
- package/src/app/assets/flags/CO.svg +1 -0
- package/src/app/assets/flags/CR.svg +1 -0
- package/src/app/assets/flags/CU.svg +1 -0
- package/src/app/assets/flags/CV.svg +1 -0
- package/src/app/assets/flags/CW.svg +1 -0
- package/src/app/assets/flags/CX.svg +1 -0
- package/src/app/assets/flags/CY.svg +1 -0
- package/src/app/assets/flags/CZ.svg +1 -0
- package/src/app/assets/flags/DE.svg +1 -0
- package/src/app/assets/flags/DJ.svg +1 -0
- package/src/app/assets/flags/DK.svg +1 -0
- package/src/app/assets/flags/DM.svg +1 -0
- package/src/app/assets/flags/DO.svg +1 -0
- package/src/app/assets/flags/DZ.svg +1 -0
- package/src/app/assets/flags/EC.svg +1 -0
- package/src/app/assets/flags/EE.svg +1 -0
- package/src/app/assets/flags/EG.svg +1 -0
- package/src/app/assets/flags/EH.svg +1 -0
- package/src/app/assets/flags/ER.svg +1 -0
- package/src/app/assets/flags/ES-CT.svg +1 -0
- package/src/app/assets/flags/ES.svg +1 -0
- package/src/app/assets/flags/ET.svg +1 -0
- package/src/app/assets/flags/EU.svg +1 -0
- package/src/app/assets/flags/FI.svg +1 -0
- package/src/app/assets/flags/FJ.svg +1 -0
- package/src/app/assets/flags/FK.svg +1 -0
- package/src/app/assets/flags/FM.svg +1 -0
- package/src/app/assets/flags/FO.svg +1 -0
- package/src/app/assets/flags/FR.svg +1 -0
- package/src/app/assets/flags/GA.svg +1 -0
- package/src/app/assets/flags/GB-ENG.svg +1 -0
- package/src/app/assets/flags/GB-NIR.svg +1 -0
- package/src/app/assets/flags/GB-SCT.svg +1 -0
- package/src/app/assets/flags/GB-WLS.svg +1 -0
- package/src/app/assets/flags/GB.svg +1 -0
- package/src/app/assets/flags/GD.svg +1 -0
- package/src/app/assets/flags/GE.svg +1 -0
- package/src/app/assets/flags/GF.svg +1 -0
- package/src/app/assets/flags/GG.svg +1 -0
- package/src/app/assets/flags/GH.svg +1 -0
- package/src/app/assets/flags/GI.svg +1 -0
- package/src/app/assets/flags/GL.svg +1 -0
- package/src/app/assets/flags/GM.svg +1 -0
- package/src/app/assets/flags/GN.svg +1 -0
- package/src/app/assets/flags/GP.svg +1 -0
- package/src/app/assets/flags/GQ.svg +1 -0
- package/src/app/assets/flags/GR.svg +1 -0
- package/src/app/assets/flags/GS.svg +1 -0
- package/src/app/assets/flags/GT.svg +1 -0
- package/src/app/assets/flags/GU.svg +1 -0
- package/src/app/assets/flags/GW.svg +1 -0
- package/src/app/assets/flags/GY.svg +1 -0
- package/src/app/assets/flags/HK.svg +1 -0
- package/src/app/assets/flags/HM.svg +1 -0
- package/src/app/assets/flags/HN.svg +1 -0
- package/src/app/assets/flags/HR.svg +1 -0
- package/src/app/assets/flags/HT.svg +1 -0
- package/src/app/assets/flags/HU.svg +1 -0
- package/src/app/assets/flags/IC.svg +1 -0
- package/src/app/assets/flags/ID.svg +1 -0
- package/src/app/assets/flags/IE.svg +1 -0
- package/src/app/assets/flags/IL.svg +1 -0
- package/src/app/assets/flags/IM.svg +1 -0
- package/src/app/assets/flags/IN.svg +1 -0
- package/src/app/assets/flags/IO.svg +1 -0
- package/src/app/assets/flags/IQ.svg +1 -0
- package/src/app/assets/flags/IR.svg +1 -0
- package/src/app/assets/flags/IS.svg +1 -0
- package/src/app/assets/flags/IT.svg +1 -0
- package/src/app/assets/flags/JE.svg +1 -0
- package/src/app/assets/flags/JM.svg +1 -0
- package/src/app/assets/flags/JO.svg +1 -0
- package/src/app/assets/flags/JP.svg +1 -0
- package/src/app/assets/flags/KE.svg +1 -0
- package/src/app/assets/flags/KG.svg +1 -0
- package/src/app/assets/flags/KH.svg +1 -0
- package/src/app/assets/flags/KI.svg +1 -0
- package/src/app/assets/flags/KM.svg +1 -0
- package/src/app/assets/flags/KN.svg +1 -0
- package/src/app/assets/flags/KP.svg +1 -0
- package/src/app/assets/flags/KR.svg +1 -0
- package/src/app/assets/flags/KW.svg +1 -0
- package/src/app/assets/flags/KY.svg +1 -0
- package/src/app/assets/flags/KZ.svg +1 -0
- package/src/app/assets/flags/LA.svg +1 -0
- package/src/app/assets/flags/LB.svg +1 -0
- package/src/app/assets/flags/LC.svg +1 -0
- package/src/app/assets/flags/LI.svg +1 -0
- package/src/app/assets/flags/LK.svg +1 -0
- package/src/app/assets/flags/LR.svg +1 -0
- package/src/app/assets/flags/LS.svg +1 -0
- package/src/app/assets/flags/LT.svg +1 -0
- package/src/app/assets/flags/LU.svg +1 -0
- package/src/app/assets/flags/LV.svg +1 -0
- package/src/app/assets/flags/LY.svg +1 -0
- package/src/app/assets/flags/MA.svg +1 -0
- package/src/app/assets/flags/MC.svg +1 -0
- package/src/app/assets/flags/MD.svg +1 -0
- package/src/app/assets/flags/ME.svg +1 -0
- package/src/app/assets/flags/MF.svg +1 -0
- package/src/app/assets/flags/MG.svg +1 -0
- package/src/app/assets/flags/MH.svg +1 -0
- package/src/app/assets/flags/MK.svg +1 -0
- package/src/app/assets/flags/ML.svg +1 -0
- package/src/app/assets/flags/MM.svg +1 -0
- package/src/app/assets/flags/MN.svg +1 -0
- package/src/app/assets/flags/MO.svg +1 -0
- package/src/app/assets/flags/MP.svg +1 -0
- package/src/app/assets/flags/MQ.svg +1 -0
- package/src/app/assets/flags/MR.svg +1 -0
- package/src/app/assets/flags/MS.svg +1 -0
- package/src/app/assets/flags/MT.svg +1 -0
- package/src/app/assets/flags/MU.svg +1 -0
- package/src/app/assets/flags/MV.svg +1 -0
- package/src/app/assets/flags/MW.svg +1 -0
- package/src/app/assets/flags/MX.svg +1 -0
- package/src/app/assets/flags/MY.svg +1 -0
- package/src/app/assets/flags/MZ.svg +1 -0
- package/src/app/assets/flags/NA.svg +1 -0
- package/src/app/assets/flags/NC.svg +1 -0
- package/src/app/assets/flags/NE.svg +1 -0
- package/src/app/assets/flags/NF.svg +1 -0
- package/src/app/assets/flags/NG.svg +1 -0
- package/src/app/assets/flags/NI.svg +1 -0
- package/src/app/assets/flags/NL.svg +1 -0
- package/src/app/assets/flags/NO.svg +1 -0
- package/src/app/assets/flags/NP.svg +1 -0
- package/src/app/assets/flags/NR.svg +1 -0
- package/src/app/assets/flags/NU.svg +1 -0
- package/src/app/assets/flags/NZ.svg +1 -0
- package/src/app/assets/flags/OM.svg +1 -0
- package/src/app/assets/flags/PA.svg +1 -0
- package/src/app/assets/flags/PE.svg +1 -0
- package/src/app/assets/flags/PF.svg +1 -0
- package/src/app/assets/flags/PG.svg +1 -0
- package/src/app/assets/flags/PH.svg +1 -0
- package/src/app/assets/flags/PK.svg +1 -0
- package/src/app/assets/flags/PL.svg +1 -0
- package/src/app/assets/flags/PM.svg +1 -0
- package/src/app/assets/flags/PN.svg +1 -0
- package/src/app/assets/flags/PR.svg +1 -0
- package/src/app/assets/flags/PS.svg +1 -0
- package/src/app/assets/flags/PT.svg +1 -0
- package/src/app/assets/flags/PW.svg +1 -0
- package/src/app/assets/flags/PY.svg +1 -0
- package/src/app/assets/flags/QA.svg +1 -0
- package/src/app/assets/flags/RE.svg +1 -0
- package/src/app/assets/flags/README.md +6 -0
- package/src/app/assets/flags/RO.svg +1 -0
- package/src/app/assets/flags/RS.svg +1 -0
- package/src/app/assets/flags/RU.svg +1 -0
- package/src/app/assets/flags/RW.svg +1 -0
- package/src/app/assets/flags/SA.svg +1 -0
- package/src/app/assets/flags/SB.svg +1 -0
- package/src/app/assets/flags/SC.svg +1 -0
- package/src/app/assets/flags/SD.svg +1 -0
- package/src/app/assets/flags/SE.svg +1 -0
- package/src/app/assets/flags/SG.svg +1 -0
- package/src/app/assets/flags/SH.svg +1 -0
- package/src/app/assets/flags/SI.svg +1 -0
- package/src/app/assets/flags/SJ.svg +1 -0
- package/src/app/assets/flags/SK.svg +1 -0
- package/src/app/assets/flags/SL.svg +1 -0
- package/src/app/assets/flags/SM.svg +1 -0
- package/src/app/assets/flags/SN.svg +1 -0
- package/src/app/assets/flags/SO.svg +1 -0
- package/src/app/assets/flags/SR.svg +1 -0
- package/src/app/assets/flags/SS.svg +1 -0
- package/src/app/assets/flags/ST.svg +1 -0
- package/src/app/assets/flags/SV.svg +1 -0
- package/src/app/assets/flags/SX.svg +1 -0
- package/src/app/assets/flags/SY.svg +1 -0
- package/src/app/assets/flags/SZ.svg +1 -0
- package/src/app/assets/flags/TA.svg +1 -0
- package/src/app/assets/flags/TC.svg +1 -0
- package/src/app/assets/flags/TD.svg +1 -0
- package/src/app/assets/flags/TF.svg +1 -0
- package/src/app/assets/flags/TG.svg +1 -0
- package/src/app/assets/flags/TH.svg +1 -0
- package/src/app/assets/flags/TJ.svg +1 -0
- package/src/app/assets/flags/TK.svg +1 -0
- package/src/app/assets/flags/TL.svg +1 -0
- package/src/app/assets/flags/TM.svg +1 -0
- package/src/app/assets/flags/TN.svg +1 -0
- package/src/app/assets/flags/TO.svg +1 -0
- package/src/app/assets/flags/TR.svg +1 -0
- package/src/app/assets/flags/TT.svg +1 -0
- package/src/app/assets/flags/TV.svg +1 -0
- package/src/app/assets/flags/TW.svg +1 -0
- package/src/app/assets/flags/TZ.svg +1 -0
- package/src/app/assets/flags/UA.svg +1 -0
- package/src/app/assets/flags/UG.svg +1 -0
- package/src/app/assets/flags/UM.svg +1 -0
- package/src/app/assets/flags/US.svg +1 -0
- package/src/app/assets/flags/UY.svg +1 -0
- package/src/app/assets/flags/UZ.svg +1 -0
- package/src/app/assets/flags/VA.svg +1 -0
- package/src/app/assets/flags/VC.svg +1 -0
- package/src/app/assets/flags/VE.svg +1 -0
- package/src/app/assets/flags/VG.svg +1 -0
- package/src/app/assets/flags/VI.svg +1 -0
- package/src/app/assets/flags/VN.svg +1 -0
- package/src/app/assets/flags/VU.svg +1 -0
- package/src/app/assets/flags/WF.svg +1 -0
- package/src/app/assets/flags/WS.svg +1 -0
- package/src/app/assets/flags/XA.svg +1 -0
- package/src/app/assets/flags/XC.svg +1 -0
- package/src/app/assets/flags/XK.svg +1 -0
- package/src/app/assets/flags/XO.svg +1 -0
- package/src/app/assets/flags/YE.svg +1 -0
- package/src/app/assets/flags/YT.svg +1 -0
- package/src/app/assets/flags/ZA.svg +1 -0
- package/src/app/assets/flags/ZM.svg +1 -0
- package/src/app/assets/flags/ZW.svg +1 -0
- package/src/app/email-preview.ts +46 -0
- package/src/app/index.css +203 -0
- package/src/app/index.html +12 -0
- package/src/app/integrations/i18n/react-i18next.d.ts +11 -0
- package/src/app/integrations/i18n/root-provider.tsx +62 -0
- package/src/app/integrations/tanstack-query/devtools.tsx +6 -0
- package/src/app/integrations/tanstack-query/root-provider.tsx +37 -0
- package/src/app/integrations/theme/root-provider.tsx +75 -0
- package/src/app/integrations/toast/toast-provider.tsx +46 -0
- package/src/app/locales/en-US/common.ts +268 -0
- package/src/app/locales/zh-CN/common.ts +263 -0
- package/src/app/main.tsx +40 -0
- package/src/app/page-chrome.tsx +79 -0
- package/src/app/router.tsx +40 -0
- package/src/app/routes/__root.tsx +293 -0
- package/src/app/routes/emails.tsx +199 -0
- package/src/app/routes/home.tsx +87 -0
- package/src/app/routes/index.ts +19 -0
- package/src/app/routes/metrics.tsx +541 -0
- package/src/app/routes/segment-overview.tsx +211 -0
- package/src/app/routes/segments.tsx +236 -0
- package/src/app/routes/settings.tsx +90 -0
- package/src/app/routes/workflows.tsx +348 -0
- package/src/app/studio.ts +16 -0
- package/src/app/svg.d.ts +17 -0
- package/src/app/virtual-config.d.ts +6 -0
- package/src/cli.ts +110 -0
- package/src/components/avatar.tsx +57 -0
- package/src/components/breadcrumb.tsx +49 -0
- package/src/components/button/index.tsx +86 -0
- package/src/components/channel-icon.ts +39 -0
- package/src/components/chat-markup.tsx +109 -0
- package/src/components/corner-shape.ts +13 -0
- package/src/components/date-range.tsx +181 -0
- package/src/components/discord-preview.tsx +165 -0
- package/src/components/dropdown/index.tsx +172 -0
- package/src/components/email-defaults.tsx +40 -0
- package/src/components/email-list.tsx +149 -0
- package/src/components/email-thumbnail.tsx +123 -0
- package/src/components/flag.tsx +40 -0
- package/src/components/input/index.tsx +40 -0
- package/src/components/input/search-input.tsx +24 -0
- package/src/components/layout.ts +403 -0
- package/src/components/menu/index.tsx +118 -0
- package/src/components/metric-card.tsx +321 -0
- package/src/components/modal/index.tsx +70 -0
- package/src/components/nav-drawer.tsx +84 -0
- package/src/components/node-inspector.tsx +242 -0
- package/src/components/profile-drawer.tsx +331 -0
- package/src/components/push-preview.tsx +470 -0
- package/src/components/push-thumbnail.tsx +78 -0
- package/src/components/segment-list.tsx +184 -0
- package/src/components/select/index.tsx +70 -0
- package/src/components/series-chart.tsx +120 -0
- package/src/components/slack-preview.tsx +223 -0
- package/src/components/sparkline.tsx +58 -0
- package/src/components/tabs/index.tsx +45 -0
- package/src/components/template-refs.ts +110 -0
- package/src/components/templates-page.tsx +601 -0
- package/src/components/textarea/index.tsx +37 -0
- package/src/components/thumbnail-window.tsx +65 -0
- package/src/components/workflow-canvas.tsx +503 -0
- package/src/components/workflow-list.tsx +231 -0
- package/src/config.ts +288 -0
- package/src/generate.ts +56 -0
- package/src/index.ts +35 -0
- package/src/postgres.ts +415 -0
- package/src/server/project.ts +290 -0
- package/src/server.ts +500 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/label.ts +12 -0
- package/src/utils/lookup.ts +11 -0
- package/src/utils/template-content.ts +213 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import { superellipse } from '../corner-shape';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Ported from the design system in the template project — same API, so the two
|
|
8
|
+
* stay diffable. Colours resolve through the studio's CSS variables
|
|
9
|
+
* (`--color-primary`, `--color-accent`, `--color-gray-*`), so a project that
|
|
10
|
+
* re-themes the ramp re-themes the buttons with it.
|
|
11
|
+
*/
|
|
12
|
+
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
13
|
+
|
|
14
|
+
interface Props extends Omit<ComponentProps<'button'>, 'type'> {
|
|
15
|
+
size?: Size;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
type?: 'submit' | 'reset' | 'button';
|
|
18
|
+
variant?: 'text' | 'accent' | 'default' | 'secondary' | 'destructive' | 'outline';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SIZE_STYLE: Record<Size, string> = {
|
|
22
|
+
xs: 'h-7 px-3 text-xs rounded-md focus-visible:ring-2',
|
|
23
|
+
sm: 'h-9 px-3 text-sm rounded-lg focus-visible:ring-3',
|
|
24
|
+
md: 'h-10 px-4 text-sm rounded-xl focus-visible:ring-3',
|
|
25
|
+
lg: 'h-12 px-6 text-base rounded-xl focus-visible:ring-4',
|
|
26
|
+
xl: 'h-14 px-8 text-lg rounded-2xl focus-visible:ring-4',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const VARIANT_STYLE = {
|
|
30
|
+
text: clsx(
|
|
31
|
+
'text-primary border-none bg-transparent',
|
|
32
|
+
'hover:bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80',
|
|
33
|
+
'dark:hover:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80'
|
|
34
|
+
),
|
|
35
|
+
accent: clsx(
|
|
36
|
+
'bg-accent active:bg-accent/80 text-white',
|
|
37
|
+
'focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50'
|
|
38
|
+
),
|
|
39
|
+
default: clsx(
|
|
40
|
+
'border-none bg-black text-white focus-visible:ring-black/20 dark:bg-white dark:text-black',
|
|
41
|
+
'active:bg-black/80 dark:focus-visible:ring-white/30 dark:active:bg-white/80'
|
|
42
|
+
),
|
|
43
|
+
secondary: clsx(
|
|
44
|
+
'text-primary bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80',
|
|
45
|
+
'dark:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80'
|
|
46
|
+
),
|
|
47
|
+
destructive: clsx(
|
|
48
|
+
'text-white focus-visible:ring-red-400/40',
|
|
49
|
+
'bg-red-400 active:bg-red-500/90',
|
|
50
|
+
'dark:bg-red-400/70 dark:active:bg-red-400/90'
|
|
51
|
+
),
|
|
52
|
+
outline: clsx(
|
|
53
|
+
'text-primary border',
|
|
54
|
+
'bg-white focus-visible:ring-black/10 active:bg-gray-100/70',
|
|
55
|
+
'dark:bg-gray-900/70 dark:focus-visible:ring-white/30 dark:active:bg-gray-900'
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export function Button({
|
|
60
|
+
children,
|
|
61
|
+
className,
|
|
62
|
+
size = 'md',
|
|
63
|
+
style,
|
|
64
|
+
type = 'button',
|
|
65
|
+
variant = 'default',
|
|
66
|
+
...props
|
|
67
|
+
}: Props) {
|
|
68
|
+
return (
|
|
69
|
+
<button
|
|
70
|
+
// oxlint-disable-next-line react/button-has-type
|
|
71
|
+
type={type}
|
|
72
|
+
style={{ ...superellipse, ...style }}
|
|
73
|
+
className={cn(
|
|
74
|
+
SIZE_STYLE[size],
|
|
75
|
+
VARIANT_STYLE[variant],
|
|
76
|
+
'inline-flex items-center justify-center',
|
|
77
|
+
'text-center font-medium transition-all duration-100 focus:outline-none',
|
|
78
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
79
|
+
className
|
|
80
|
+
)}
|
|
81
|
+
{...props}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
84
|
+
</button>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Bot,
|
|
3
|
+
Globe,
|
|
4
|
+
type LucideIcon,
|
|
5
|
+
Mail,
|
|
6
|
+
MessageCircle,
|
|
7
|
+
MessageSquareText,
|
|
8
|
+
MessagesSquare,
|
|
9
|
+
Send,
|
|
10
|
+
Smartphone,
|
|
11
|
+
Webhook,
|
|
12
|
+
} from 'lucide-react';
|
|
13
|
+
import type { MetricChannel } from '../config';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* One glyph per delivery channel, shared by the chart cards, the channel
|
|
17
|
+
* pickers and the message table — a channel has to read the same everywhere or
|
|
18
|
+
* the eye stops using the icon as an index.
|
|
19
|
+
*
|
|
20
|
+
* lucide dropped brand marks, so iOS and Android borrow the nearest generic
|
|
21
|
+
* pair (a handset, a robot) and a browser push a globe: what matters here is that the two platforms are
|
|
22
|
+
* told apart at a glance, not that the logo is right.
|
|
23
|
+
*/
|
|
24
|
+
export const CHANNEL_ICON: Record<MetricChannel, LucideIcon> = {
|
|
25
|
+
email: Mail,
|
|
26
|
+
push_ios: Smartphone,
|
|
27
|
+
push_android: Bot,
|
|
28
|
+
push_web: Globe,
|
|
29
|
+
slack: MessagesSquare,
|
|
30
|
+
discord: MessageCircle,
|
|
31
|
+
sms: MessageSquareText,
|
|
32
|
+
webhook: Webhook,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Stand-in for "every channel": still a send, just not one transport. */
|
|
36
|
+
export const ALL_CHANNELS_ICON: LucideIcon = Send;
|
|
37
|
+
|
|
38
|
+
export const channelIcon = (channel: MetricChannel | undefined): LucideIcon =>
|
|
39
|
+
channel === undefined ? ALL_CHANNELS_ICON : CHANNEL_ICON[channel];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The inline formatting chat clients render, drawn as React nodes (never HTML strings): Discord's
|
|
5
|
+
* markdown (`**bold**`, `*italic*`, `__underline__`, `~~strike~~`, `` `code` ``, `[text](url)`)
|
|
6
|
+
* and Slack's mrkdwn (`*bold*`, `_italic_`, `~strike~`, `` `code` ``, `<url|text>`). Enough to
|
|
7
|
+
* preview a message faithfully, not a full parser: nesting is one level deep. Underscore (and
|
|
8
|
+
* Slack's `*` / `~`) markers only open and close at word boundaries, so `snake_case_name` stays text.
|
|
9
|
+
*/
|
|
10
|
+
export type Dialect = 'discord' | 'slack';
|
|
11
|
+
|
|
12
|
+
interface Rule {
|
|
13
|
+
pattern: RegExp;
|
|
14
|
+
render: (match: RegExpExecArray, key: string, linkClass: string) => ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const code = (text: string, key: string) => (
|
|
18
|
+
<code
|
|
19
|
+
key={key}
|
|
20
|
+
className="rounded bg-black/10 px-1 py-px font-mono text-[0.85em] dark:bg-white/10"
|
|
21
|
+
>
|
|
22
|
+
{text}
|
|
23
|
+
</code>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const link = (href: string, text: string, key: string, className: string) => (
|
|
27
|
+
<a key={key} href={href} target="_blank" rel="noreferrer" className={className}>
|
|
28
|
+
{text}
|
|
29
|
+
</a>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const RULES: Record<Dialect, Rule[]> = {
|
|
33
|
+
discord: [
|
|
34
|
+
{ pattern: /`([^`]+)`/, render: (m, key) => code(m[1] ?? '', key) },
|
|
35
|
+
{
|
|
36
|
+
pattern: /\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/,
|
|
37
|
+
render: (m, key, linkClass) => link(m[2] ?? '', m[1] ?? '', key, linkClass),
|
|
38
|
+
},
|
|
39
|
+
{ pattern: /\*\*([^*]+)\*\*/, render: (m, key) => <strong key={key}>{m[1]}</strong> },
|
|
40
|
+
{ pattern: /(?<!\w)__([^_]+)__(?!\w)/, render: (m, key) => <u key={key}>{m[1]}</u> },
|
|
41
|
+
{ pattern: /~~([^~]+)~~/, render: (m, key) => <s key={key}>{m[1]}</s> },
|
|
42
|
+
{
|
|
43
|
+
pattern: /\*([^*]+)\*|(?<!\w)_([^_]+)_(?!\w)/,
|
|
44
|
+
render: (m, key) => <em key={key}>{m[1] ?? m[2]}</em>,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
pattern: /(https?:\/\/[^\s<]+)/,
|
|
48
|
+
render: (m, key, linkClass) => link(m[1] ?? '', m[1] ?? '', key, linkClass),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
slack: [
|
|
52
|
+
{ pattern: /`([^`]+)`/, render: (m, key) => code(m[1] ?? '', key) },
|
|
53
|
+
{
|
|
54
|
+
pattern: /<((?:https?:\/\/|mailto:|tel:)[^|>]+)(?:\|([^>]+))?>/,
|
|
55
|
+
render: (m, key, linkClass) => link(m[1] ?? '', m[2] ?? m[1] ?? '', key, linkClass),
|
|
56
|
+
},
|
|
57
|
+
{ pattern: /(?<!\w)\*([^*]+)\*(?!\w)/, render: (m, key) => <strong key={key}>{m[1]}</strong> },
|
|
58
|
+
{ pattern: /(?<!\w)_([^_]+)_(?!\w)/, render: (m, key) => <em key={key}>{m[1]}</em> },
|
|
59
|
+
{ pattern: /(?<!\w)~([^~]+)~(?!\w)/, render: (m, key) => <s key={key}>{m[1]}</s> },
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function inline(text: string, dialect: Dialect, linkClass: string, prefix: string): ReactNode[] {
|
|
64
|
+
const out: ReactNode[] = [];
|
|
65
|
+
let rest = text;
|
|
66
|
+
let index = 0;
|
|
67
|
+
while (rest !== '') {
|
|
68
|
+
// The earliest match of any rule wins; ties go to the rule listed first
|
|
69
|
+
let best: { match: RegExpExecArray; rule: Rule } | undefined;
|
|
70
|
+
for (const rule of RULES[dialect]) {
|
|
71
|
+
const match = rule.pattern.exec(rest);
|
|
72
|
+
if (match !== null && (best === undefined || match.index < best.match.index)) {
|
|
73
|
+
best = { match, rule };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (best === undefined) {
|
|
77
|
+
out.push(rest);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (best.match.index > 0) out.push(rest.slice(0, best.match.index));
|
|
81
|
+
out.push(best.rule.render(best.match, `${prefix}${index++}`, linkClass));
|
|
82
|
+
rest = rest.slice(best.match.index + best.match[0].length);
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Lines kept as lines; each formatted inline. */
|
|
88
|
+
export function ChatMarkup({
|
|
89
|
+
text,
|
|
90
|
+
dialect,
|
|
91
|
+
linkClass,
|
|
92
|
+
}: {
|
|
93
|
+
text: string;
|
|
94
|
+
dialect: Dialect;
|
|
95
|
+
linkClass: string;
|
|
96
|
+
}) {
|
|
97
|
+
const lines = text.split('\n');
|
|
98
|
+
return (
|
|
99
|
+
<>
|
|
100
|
+
{lines.map((line, i) => (
|
|
101
|
+
// oxlint-disable-next-line react/no-array-index-key -- lines have no identity but their place
|
|
102
|
+
<span key={i}>
|
|
103
|
+
{inline(line, dialect, linkClass, `${i}-`)}
|
|
104
|
+
{i < lines.length - 1 && <br />}
|
|
105
|
+
</span>
|
|
106
|
+
))}
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Every rounded surface that is not a full pill carries this.
|
|
5
|
+
*
|
|
6
|
+
* A plain border-radius leaves a visible curvature break where the arc meets
|
|
7
|
+
* the straight edge; a superellipse blends the two, which is what the canvas
|
|
8
|
+
* cards already do. Pills (`rounded-full`) are continuous by construction, so
|
|
9
|
+
* they skip it.
|
|
10
|
+
*
|
|
11
|
+
* Cast because `corner-shape` is not in React's CSSProperties yet.
|
|
12
|
+
*/
|
|
13
|
+
export const superellipse = { cornerShape: 'superellipse(1.2)' } as CSSProperties;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FloatingFocusManager,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
offset,
|
|
6
|
+
shift,
|
|
7
|
+
useClick,
|
|
8
|
+
useDismiss,
|
|
9
|
+
useFloating,
|
|
10
|
+
useInteractions,
|
|
11
|
+
useRole,
|
|
12
|
+
} from '@floating-ui/react';
|
|
13
|
+
import { Calendar } from 'lucide-react';
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { cn } from '../utils/cn';
|
|
17
|
+
import { Button } from './button';
|
|
18
|
+
import { superellipse } from './corner-shape';
|
|
19
|
+
import { Input } from './input';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The range every panel on the Overview reads from. Both ends are inclusive
|
|
23
|
+
* ISO `YYYY-MM-DD` days — the same shape the stats contract takes, so the
|
|
24
|
+
* picker's value can be handed straight to a query.
|
|
25
|
+
*/
|
|
26
|
+
export interface DateRange {
|
|
27
|
+
from: string;
|
|
28
|
+
to: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A local calendar day, not a UTC instant. `toISOString().slice(0, 10)` is the
|
|
33
|
+
* usual shortcut and it is wrong west of Greenwich for most of the day: it
|
|
34
|
+
* reports yesterday, so "last 30 days" silently ends a day early.
|
|
35
|
+
*/
|
|
36
|
+
export function isoDay(date: Date): string {
|
|
37
|
+
const year = date.getFullYear();
|
|
38
|
+
const month = `${date.getMonth() + 1}`.padStart(2, '0');
|
|
39
|
+
const day = `${date.getDate()}`.padStart(2, '0');
|
|
40
|
+
return `${year}-${month}-${day}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Parse an ISO day back to local midnight — `new Date(iso)` would read it as UTC. */
|
|
44
|
+
export function parseIsoDay(iso: string): Date {
|
|
45
|
+
const [year = 1970, month = 1, day = 1] = iso.split('-').map(Number);
|
|
46
|
+
return new Date(year, month - 1, day);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The inclusive range of the `count` days ending today. */
|
|
50
|
+
export function lastDays(count: number): DateRange {
|
|
51
|
+
const to = new Date();
|
|
52
|
+
const from = new Date();
|
|
53
|
+
from.setDate(from.getDate() - (count - 1));
|
|
54
|
+
return { from: isoDay(from), to: isoDay(to) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 'Aug 21, 2026' — the compact form, for the toolbar trigger. */
|
|
58
|
+
export function formatDay(iso: string, locale: string): string {
|
|
59
|
+
return parseIsoDay(iso).toLocaleDateString(locale, {
|
|
60
|
+
year: 'numeric',
|
|
61
|
+
month: 'short',
|
|
62
|
+
day: 'numeric',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const PRESETS = [7, 14, 30, 90] as const;
|
|
67
|
+
|
|
68
|
+
interface Props {
|
|
69
|
+
value: DateRange;
|
|
70
|
+
onChange: (range: DateRange) => void;
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Presets plus two date fields, rather than a drawn calendar.
|
|
76
|
+
*
|
|
77
|
+
* Reporting ranges are chosen by duration ("the last month"), not by hunting
|
|
78
|
+
* for a Tuesday, so the presets answer nearly every case; the two fields cover
|
|
79
|
+
* the rest at a fraction of a calendar widget's weight — and the native picker
|
|
80
|
+
* they carry is already localized and keyboard-accessible.
|
|
81
|
+
*/
|
|
82
|
+
export function DateRangePicker({ value, onChange, className }: Props) {
|
|
83
|
+
const { t, i18n } = useTranslation();
|
|
84
|
+
const [open, setOpen] = useState(false);
|
|
85
|
+
|
|
86
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
87
|
+
open,
|
|
88
|
+
onOpenChange: setOpen,
|
|
89
|
+
placement: 'bottom-start',
|
|
90
|
+
whileElementsMounted: autoUpdate,
|
|
91
|
+
middleware: [offset(4), flip({ padding: 8 }), shift({ padding: 8 })],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
95
|
+
useClick(context),
|
|
96
|
+
useDismiss(context),
|
|
97
|
+
useRole(context, { role: 'dialog' }),
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* A native date field reports '' when it is cleared, and an out-of-calendar
|
|
102
|
+
* year is just as reachable by typing. Neither is a range: '' parses to 1900
|
|
103
|
+
* and would ask the stats source for a century of daily buckets. Ignore
|
|
104
|
+
* anything that is not a plain ISO day and the field snaps back to the value
|
|
105
|
+
* it had, which is the only other honest answer — the range is required.
|
|
106
|
+
*/
|
|
107
|
+
const isDay = (value: string) => /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
108
|
+
/* An inverted range is never what was meant; pin the other end to the edit. */
|
|
109
|
+
const setFrom = (from: string) => {
|
|
110
|
+
if (isDay(from)) onChange({ from, to: from > value.to ? from : value.to });
|
|
111
|
+
};
|
|
112
|
+
const setTo = (to: string) => {
|
|
113
|
+
if (isDay(to)) onChange({ from: to < value.from ? to : value.from, to });
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<>
|
|
118
|
+
<Button
|
|
119
|
+
ref={refs.setReference}
|
|
120
|
+
size="sm"
|
|
121
|
+
variant="outline"
|
|
122
|
+
className={cn('gap-2 font-normal', className)}
|
|
123
|
+
{...getReferenceProps()}
|
|
124
|
+
>
|
|
125
|
+
<Calendar size={16} strokeWidth={2} aria-hidden className="text-secondary shrink-0" />
|
|
126
|
+
<span className="tabular-nums">
|
|
127
|
+
{formatDay(value.from, i18n.language)} – {formatDay(value.to, i18n.language)}
|
|
128
|
+
</span>
|
|
129
|
+
</Button>
|
|
130
|
+
{open && (
|
|
131
|
+
<FloatingFocusManager context={context} modal={false}>
|
|
132
|
+
<div
|
|
133
|
+
ref={refs.setFloating}
|
|
134
|
+
style={{ ...floatingStyles, ...superellipse }}
|
|
135
|
+
className="border-border bg-card shadow-card-shadow z-50 w-64 rounded-xl border p-2 shadow-lg"
|
|
136
|
+
{...getFloatingProps()}
|
|
137
|
+
>
|
|
138
|
+
{PRESETS.map((days) => (
|
|
139
|
+
<button
|
|
140
|
+
key={days}
|
|
141
|
+
type="button"
|
|
142
|
+
className="hover:bg-hover block w-full rounded-lg px-2.5 py-1.5 text-left text-sm"
|
|
143
|
+
style={superellipse}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
onChange(lastDays(days));
|
|
146
|
+
setOpen(false);
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{t('metrics.range.lastDays', { count: days })}
|
|
150
|
+
</button>
|
|
151
|
+
))}
|
|
152
|
+
<div className="border-border mt-2 space-y-2 border-t pt-2">
|
|
153
|
+
<label className="block">
|
|
154
|
+
<span className="text-muted text-xs">{t('metrics.range.from')}</span>
|
|
155
|
+
<Input
|
|
156
|
+
size="sm"
|
|
157
|
+
type="date"
|
|
158
|
+
max={value.to}
|
|
159
|
+
value={value.from}
|
|
160
|
+
className="mt-1 w-full"
|
|
161
|
+
onChange={(event) => setFrom(event.target.value)}
|
|
162
|
+
/>
|
|
163
|
+
</label>
|
|
164
|
+
<label className="block">
|
|
165
|
+
<span className="text-muted text-xs">{t('metrics.range.to')}</span>
|
|
166
|
+
<Input
|
|
167
|
+
size="sm"
|
|
168
|
+
type="date"
|
|
169
|
+
min={value.from}
|
|
170
|
+
value={value.to}
|
|
171
|
+
className="mt-1 w-full"
|
|
172
|
+
onChange={(event) => setTo(event.target.value)}
|
|
173
|
+
/>
|
|
174
|
+
</label>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</FloatingFocusManager>
|
|
178
|
+
)}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { DiscordContent } from '@shware/workflow';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { ChatMarkup } from './chat-markup';
|
|
4
|
+
import { superellipse } from './corner-shape';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A webhook message as Discord draws it in a channel: the webhook's name and avatar with the APP
|
|
8
|
+
* tag, the content, and every embed (accent bar, author, title, description, fields, image,
|
|
9
|
+
* thumbnail, footer). Discord's own palette for each theme; close enough to judge the message,
|
|
10
|
+
* not a pixel copy.
|
|
11
|
+
*/
|
|
12
|
+
export interface DiscordPreviewProps {
|
|
13
|
+
message: DiscordContent;
|
|
14
|
+
/** The name a webhook posts under when the message names none: the project title upstream. */
|
|
15
|
+
appName: string;
|
|
16
|
+
scheme: 'light' | 'dark';
|
|
17
|
+
zoom: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PALETTE = {
|
|
21
|
+
dark: { bg: '#313338', text: '#dbdee1', muted: '#949ba4', name: '#f2f3f5', embed: '#2b2d31' },
|
|
22
|
+
light: { bg: '#ffffff', text: '#313338', muted: '#5c5e66', name: '#060607', embed: '#f2f3f5' },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const hex = (color: number | null | undefined) =>
|
|
26
|
+
color === undefined || color === null ? '#1e1f22' : `#${color.toString(16).padStart(6, '0')}`;
|
|
27
|
+
|
|
28
|
+
export function DiscordPreview({ message, appName, scheme, zoom }: DiscordPreviewProps) {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
const colors = PALETTE[scheme];
|
|
31
|
+
const name = message.username ?? appName;
|
|
32
|
+
const linkClass = 'text-[#00a8fc] hover:underline';
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
className="mx-auto w-full max-w-2xl overflow-hidden rounded-2xl shadow-sm"
|
|
36
|
+
style={{
|
|
37
|
+
...superellipse,
|
|
38
|
+
background: colors.bg,
|
|
39
|
+
transform: `scale(${zoom})`,
|
|
40
|
+
transformOrigin: 'top center',
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<div className="flex gap-4 px-4 py-4" style={{ color: colors.text }}>
|
|
44
|
+
{message.avatar_url ? (
|
|
45
|
+
<img
|
|
46
|
+
src={message.avatar_url}
|
|
47
|
+
alt=""
|
|
48
|
+
className="size-10 shrink-0 rounded-full object-cover"
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
<div className="flex size-10 shrink-0 items-center justify-center rounded-full bg-[#5865f2] text-sm font-semibold text-white">
|
|
52
|
+
{name.slice(0, 1).toUpperCase()}
|
|
53
|
+
</div>
|
|
54
|
+
)}
|
|
55
|
+
<div className="min-w-0 flex-1 text-[15px] leading-[1.375]">
|
|
56
|
+
<div className="flex items-center gap-1.5">
|
|
57
|
+
<span className="font-medium" style={{ color: colors.name }}>
|
|
58
|
+
{name}
|
|
59
|
+
</span>
|
|
60
|
+
<span className="rounded-[3px] bg-[#5865f2] px-1 text-[10px] leading-4 font-semibold text-white">
|
|
61
|
+
APP
|
|
62
|
+
</span>
|
|
63
|
+
<span className="text-xs" style={{ color: colors.muted }}>
|
|
64
|
+
{t('emails.chatNow')}
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
{message.content !== undefined && message.content !== '' && (
|
|
68
|
+
<div className="break-words whitespace-pre-wrap">
|
|
69
|
+
<ChatMarkup text={message.content} dialect="discord" linkClass={linkClass} />
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
{(message.embeds ?? []).map((embed, index) => (
|
|
73
|
+
<div
|
|
74
|
+
// oxlint-disable-next-line react/no-array-index-key -- embeds are positional
|
|
75
|
+
key={index}
|
|
76
|
+
className="mt-1.5 grid max-w-[516px] grid-cols-[1fr_auto] gap-x-4 rounded-[4px] border-l-4 py-2 pr-4 pl-3"
|
|
77
|
+
style={{ borderLeftColor: hex(embed.color), background: colors.embed }}
|
|
78
|
+
>
|
|
79
|
+
<div className="min-w-0">
|
|
80
|
+
{embed.author !== undefined && (
|
|
81
|
+
<div
|
|
82
|
+
className="mt-1 flex items-center gap-2 text-sm font-semibold"
|
|
83
|
+
style={{ color: colors.name }}
|
|
84
|
+
>
|
|
85
|
+
{embed.author.icon_url !== undefined && (
|
|
86
|
+
<img src={embed.author.icon_url} alt="" className="size-6 rounded-full" />
|
|
87
|
+
)}
|
|
88
|
+
{embed.author.name}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
{embed.title !== undefined && (
|
|
92
|
+
<div
|
|
93
|
+
className="mt-1 font-semibold"
|
|
94
|
+
style={{ color: embed.url ? undefined : colors.name }}
|
|
95
|
+
>
|
|
96
|
+
{embed.url ? (
|
|
97
|
+
<a href={embed.url} target="_blank" rel="noreferrer" className={linkClass}>
|
|
98
|
+
{embed.title}
|
|
99
|
+
</a>
|
|
100
|
+
) : (
|
|
101
|
+
embed.title
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
{embed.description !== undefined && (
|
|
106
|
+
<div className="mt-1 text-sm break-words whitespace-pre-wrap">
|
|
107
|
+
<ChatMarkup text={embed.description} dialect="discord" linkClass={linkClass} />
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
{(embed.fields ?? []).length > 0 && (
|
|
111
|
+
<div className="mt-2 grid grid-cols-3 gap-2">
|
|
112
|
+
{(embed.fields ?? []).map((field, i) => (
|
|
113
|
+
<div
|
|
114
|
+
// oxlint-disable-next-line react/no-array-index-key -- fields are positional
|
|
115
|
+
key={i}
|
|
116
|
+
className={field.inline ? 'col-span-1' : 'col-span-3'}
|
|
117
|
+
>
|
|
118
|
+
<div className="text-sm font-semibold" style={{ color: colors.name }}>
|
|
119
|
+
{field.name}
|
|
120
|
+
</div>
|
|
121
|
+
<div className="text-sm whitespace-pre-wrap">
|
|
122
|
+
<ChatMarkup text={field.value} dialect="discord" linkClass={linkClass} />
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
{embed.image?.url !== undefined && (
|
|
129
|
+
<img
|
|
130
|
+
src={embed.image.url}
|
|
131
|
+
alt=""
|
|
132
|
+
className="mt-4 max-h-[300px] rounded-[4px] object-contain"
|
|
133
|
+
/>
|
|
134
|
+
)}
|
|
135
|
+
{(embed.footer !== undefined || embed.timestamp !== undefined) && (
|
|
136
|
+
<div
|
|
137
|
+
className="mt-2 flex items-center gap-2 text-xs"
|
|
138
|
+
style={{ color: colors.muted }}
|
|
139
|
+
>
|
|
140
|
+
{embed.footer?.icon_url !== undefined && (
|
|
141
|
+
<img src={embed.footer.icon_url} alt="" className="size-5 rounded-full" />
|
|
142
|
+
)}
|
|
143
|
+
{[
|
|
144
|
+
embed.footer?.text,
|
|
145
|
+
embed.timestamp && new Date(embed.timestamp).toLocaleString(),
|
|
146
|
+
]
|
|
147
|
+
.filter(Boolean)
|
|
148
|
+
.join(' • ')}
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
152
|
+
{embed.thumbnail?.url !== undefined && (
|
|
153
|
+
<img
|
|
154
|
+
src={embed.thumbnail.url}
|
|
155
|
+
alt=""
|
|
156
|
+
className="mt-2 size-20 rounded-[4px] object-cover"
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
))}
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
}
|