From f5e8c140b50bd7ee1d21098bc7a227a2c60af2fb Mon Sep 17 00:00:00 2001 From: Christy Presler <6210279+cpresler@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:42:08 -0500 Subject: [PATCH] Adding Links to Change Logs (#63) Co-authored-by: Christy Presler --- widget-src/Widget.tsx | 9 +- widget-src/components/Button.tsx | 57 ++--- widget-src/components/ChangeLogRow.tsx | 62 +++++- widget-src/components/Footer.tsx | 6 +- widget-src/components/header/Meta.tsx | 4 +- widget-src/components/log/AddLink.tsx | 51 +++++ widget-src/components/log/Link.tsx | 188 ++++++++++++++++ widget-src/components/log/LinkForm.tsx | 277 ++++++++++++++++++++++++ widget-src/components/log/LinkList.tsx | 44 ++++ widget-src/components/log/Type.tsx | 4 +- widget-src/svgs/ActionAddIcon.tsx | 4 +- widget-src/svgs/ActionDeleteIcon.tsx | 4 +- widget-src/svgs/ActionEditIcon.tsx | 4 +- widget-src/svgs/ActionLinkIcon.tsx | 6 +- widget-src/svgs/BrandAsanaIcon.tsx | 6 +- widget-src/svgs/BrandAtlassianIcon.tsx | 7 + widget-src/svgs/BrandBasecampIcon.tsx | 7 + widget-src/svgs/BrandBitbucketIcon.tsx | 11 +- widget-src/svgs/BrandChatGptIcon.tsx | 7 + widget-src/svgs/BrandClickUpIcon.tsx | 8 + widget-src/svgs/BrandCodePen.tsx | 7 + widget-src/svgs/BrandCodeSandbox.tsx | 7 + widget-src/svgs/BrandFigmaIcon.tsx | 4 +- widget-src/svgs/BrandFramer.tsx | 7 + widget-src/svgs/BrandGithubIcon.tsx | 7 +- widget-src/svgs/BrandGitlabIcon.tsx | 4 +- widget-src/svgs/BrandGoogleIcon.tsx | 8 + widget-src/svgs/BrandJiraIcon.tsx | 7 - widget-src/svgs/BrandMicrosoftIcon.tsx | 7 + widget-src/svgs/BrandMiroIcon.tsx | 7 + widget-src/svgs/BrandMondayIcon.tsx | 10 + widget-src/svgs/BrandMuralIcon.tsx | 7 + widget-src/svgs/BrandNotionIcon.tsx | 4 +- widget-src/svgs/BrandSlack.tsx | 15 ++ widget-src/svgs/BrandSmartsheetIcon.tsx | 7 + widget-src/svgs/BrandStorybookIcon.tsx | 5 +- widget-src/svgs/BrandTeamsIcon.tsx | 8 + widget-src/svgs/BrandTrelloIcon.tsx | 9 + widget-src/svgs/Check.tsx | 6 +- widget-src/svgs/FileHistory.tsx | 9 + widget-src/svgs/Prototype.tsx | 7 + widget-src/types/ChangeLog.ts | 9 +- widget-src/types/LinkTypes.ts | 6 + widget-src/utilities/Regexes.ts | 51 +++++ 44 files changed, 899 insertions(+), 85 deletions(-) create mode 100644 widget-src/components/log/AddLink.tsx create mode 100644 widget-src/components/log/Link.tsx create mode 100644 widget-src/components/log/LinkForm.tsx create mode 100644 widget-src/components/log/LinkList.tsx create mode 100644 widget-src/svgs/BrandAtlassianIcon.tsx create mode 100644 widget-src/svgs/BrandBasecampIcon.tsx create mode 100644 widget-src/svgs/BrandChatGptIcon.tsx create mode 100644 widget-src/svgs/BrandClickUpIcon.tsx create mode 100644 widget-src/svgs/BrandCodePen.tsx create mode 100644 widget-src/svgs/BrandCodeSandbox.tsx create mode 100644 widget-src/svgs/BrandFramer.tsx create mode 100644 widget-src/svgs/BrandGoogleIcon.tsx delete mode 100644 widget-src/svgs/BrandJiraIcon.tsx create mode 100644 widget-src/svgs/BrandMicrosoftIcon.tsx create mode 100644 widget-src/svgs/BrandMiroIcon.tsx create mode 100644 widget-src/svgs/BrandMondayIcon.tsx create mode 100644 widget-src/svgs/BrandMuralIcon.tsx create mode 100644 widget-src/svgs/BrandSlack.tsx create mode 100644 widget-src/svgs/BrandSmartsheetIcon.tsx create mode 100644 widget-src/svgs/BrandTeamsIcon.tsx create mode 100644 widget-src/svgs/BrandTrelloIcon.tsx create mode 100644 widget-src/svgs/FileHistory.tsx create mode 100644 widget-src/svgs/Prototype.tsx create mode 100644 widget-src/types/LinkTypes.ts create mode 100644 widget-src/utilities/Regexes.ts diff --git a/widget-src/Widget.tsx b/widget-src/Widget.tsx index 22e4c5b..a2067f2 100644 --- a/widget-src/Widget.tsx +++ b/widget-src/Widget.tsx @@ -14,7 +14,7 @@ function Widget() { const [showDescription, setShowDescription] = useSyncedState('showDescription', true); const [showStatus, setShowStatus] = useSyncedState('showStatus', '0'); const [showVersion, setShowVersion] = useSyncedState('showVersion', false); - const [showBranding, setShowBranding] = useSyncedState('showBranding', true); + const [showBranding, setShowBranding] = useSyncedState('showBradning', true); // fixing the typo messes with branding state on existing widgets const [showLogTypes, setShowLogTypes] = useSyncedState('showLogTypes', false); // Meta Data const [createdDate, setCreatedDate] = useSyncedState('createdDate', 0); @@ -33,7 +33,12 @@ function Widget() { editedDate: Date.now(), user: currentUser, editCount: 0, - showTypeMenu: false, + state: { + showTypeMenu: false, + showLinkForm: false, + linkFormError: { label: false, url: false } + }, + links: [], }); setChangeIds([changeToAdd, ...changeIds]); setUpdatedDate(Date.now()); diff --git a/widget-src/components/Button.tsx b/widget-src/components/Button.tsx index a8ac590..24f0bc6 100644 --- a/widget-src/components/Button.tsx +++ b/widget-src/components/Button.tsx @@ -1,36 +1,25 @@ -import { ActionEditIcon } from '../svgs/ActionEditIcon'; -import { ActionDeleteIcon } from '../svgs/ActionDeleteIcon'; import { COLOR, FONT, GAP, PADDING, RADIUS, SPACE } from '../utilities/Styles'; const { widget } = figma; const { AutoLayout, Frame, SVG, Text } = widget; interface ButtonProps { - label: 'Edit' | 'Delete'; - hideLabel: boolean; + label: string; + hideLabel?: boolean; action: () => void; + iconSrc?: string; } export const Button = ({ label, - hideLabel, + hideLabel = false, action, + iconSrc }: ButtonProps) => { - let svgSrc = ''; - switch (label) { - case 'Edit': - svgSrc = ; - break; - case 'Delete': - svgSrc = ; - break; - default: - break; - } return ( - - - + {iconSrc && ( + + + + )} - {!!changeLog.showTypeMenu && ( + {!!changeLog.state?.showTypeMenu && ( { @@ -81,12 +86,18 @@ export const ChangeLogRow = ({ type: newType, editCount: addEdit ? changeLog.editCount + 1 : changeLog.editCount, editedDate: addEdit ? Date.now() : changeLog.editedDate, - showTypeMenu: !changeLog.showTypeMenu, + state: { + ...changeLog.state, + showTypeMenu: !changeLog.state?.showTypeMenu, + }, }); setUpdatedDate(Date.now()); } else { updateChange({ - showTypeMenu: !changeLog.showTypeMenu, + state: { + ...changeLog.state, + showTypeMenu: !changeLog.state?.showTypeMenu, + }, }) } }} @@ -98,11 +109,17 @@ export const ChangeLogRow = ({ action={() => { // toggle log type menu updateChange({ - showTypeMenu: !changeLog.showTypeMenu, + state: { + ...changeLog.state, + showTypeMenu: !changeLog.state?.showTypeMenu, + } }) // hide all other log type menues updateOthers({ - showTypeMenu: false, + state: { + ...changeLog.state, + showTypeMenu: false, + } }) }} /> @@ -136,7 +153,7 @@ export const ChangeLogRow = ({ horizontalAlignItems="end" verticalAlignItems="center" > -