From d294398f28e388eca100d22dc204439c4b716522 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 22 Sep 2022 21:58:03 -0400 Subject: [PATCH] Add export to unsubmitted segments --- public/content.css | 8 +++ public/icons/export.svg | 64 +++++++++++++------- public/icons/import.svg | 18 +++--- src/components/NoticeComponent.tsx | 2 +- src/components/SubmissionNoticeComponent.tsx | 36 ++++++++++- src/render/GenericNotice.tsx | 40 ++++++------ 6 files changed, 118 insertions(+), 50 deletions(-) diff --git a/public/content.css b/public/content.css index 6703cddf..22452fe1 100644 --- a/public/content.css +++ b/public/content.css @@ -235,6 +235,10 @@ div:hover > .sponsorBlockChapterBar { min-width: 100%; } +.exportCopiedNotice .sponsorSkipNoticeTableContainer { + background-color: transparent; +} + .sponsorSkipNotice { transition: all 0.1s ease-out; } @@ -256,6 +260,10 @@ div:hover > .sponsorBlockChapterBar { animation: fadeIn 0.5s ease-out; } +.exportCopiedNotice .sponsorSkipNoticeFadeIn { + animation: none; +} + .sponsorSkipNoticeFaded { opacity: 0.5; } diff --git a/public/icons/export.svg b/public/icons/export.svg index 337823ab..50e4e2a2 100644 --- a/public/icons/export.svg +++ b/public/icons/export.svg @@ -8,7 +8,7 @@ style="enable-background:new 0 0 67.671 67.671;" xml:space="preserve" sodipodi:docname="export.svg" - inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" + inkscape:version="1.2.1 (9c6d41e410, 2022-07-14, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" @@ -23,17 +23,20 @@ inkscape:pagecheckerboard="0" showgrid="false" inkscape:zoom="9.309749" - inkscape:cx="33.835499" - inkscape:cy="16.649214" - inkscape:window-width="1366" - inkscape:window-height="731" + inkscape:cx="33.889206" + inkscape:cy="33.835499" + inkscape:window-width="1920" + inkscape:window-height="983" inkscape:window-x="0" - inkscape:window-y="0" + inkscape:window-y="768" inkscape:window-maximized="1" - inkscape:current-layer="Capa_1" /> + inkscape:current-layer="Capa_1" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1" /> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,6)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> + style="fill:#ffffff" + transform="matrix(0.82363056,0,0,0.82363056,5.9675483,5.9675483)"> diff --git a/public/icons/import.svg b/public/icons/import.svg index b1692f37..0c6824e6 100644 --- a/public/icons/import.svg +++ b/public/icons/import.svg @@ -8,7 +8,7 @@ style="enable-background:new 0 0 67.671 67.671;" xml:space="preserve" sodipodi:docname="import.svg" - inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" + inkscape:version="1.2.1 (9c6d41e410, 2022-07-14, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" @@ -23,25 +23,27 @@ inkscape:pagecheckerboard="0" showgrid="false" inkscape:zoom="9.309749" - inkscape:cx="33.835499" + inkscape:cx="33.889206" inkscape:cy="33.835499" inkscape:window-width="1920" inkscape:window-height="983" - inkscape:window-x="482" + inkscape:window-x="0" inkscape:window-y="768" inkscape:window-maximized="1" - inkscape:current-layer="g6" /> + inkscape:current-layer="g6" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1" /> + style="fill:#ffffff;stroke-width:0.823631" /> + style="fill:#ffffff;stroke-width:0.823631" /> diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index cf108671..ec8139fa 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -19,7 +19,7 @@ export interface NoticeProps { fadeIn?: boolean, startFaded?: boolean, - firstColumn?: React.ReactElement, + firstColumn?: React.ReactElement[] | React.ReactElement, firstRow?: React.ReactElement, bottomRow?: React.ReactElement[], diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx index 6e7c0a2f..471ab8e3 100644 --- a/src/components/SubmissionNoticeComponent.tsx +++ b/src/components/SubmissionNoticeComponent.tsx @@ -8,6 +8,7 @@ import NoticeComponent from "./NoticeComponent"; import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; import SponsorTimeEditComponent from "./SponsorTimeEditComponent"; import { getGuidelineInfo } from "../utils/constants"; +import { exportTimes } from "../utils/exporter"; export interface SubmissionNoticeProps { // Contains functions and variables from the content script needed by the skip notice @@ -78,15 +79,24 @@ class SubmissionNoticeComponent extends React.Component this.sortSegments()} title={chrome.i18n.getMessage("sortSegments")} + key="sortButton" src={chrome.extension.getURL("icons/sort.svg")}> ; + const exportButton = + this.exportSegments()} + title={chrome.i18n.getMessage("exportSegments")} + key="exportButton" + src={chrome.extension.getURL("icons/export.svg")}> + ; return ( + firstColumn={[sortButton, exportButton]}> {/* Text Boxes */} {this.getMessageBoxes()} @@ -216,6 +226,30 @@ class SubmissionNoticeComponent extends React.Component a.segment[0] - b.segment[0]); + window.navigator.clipboard.writeText(exportTimes(sponsorTimesSubmitting)); + + new GenericNotice(null, "exportCopied", { + title: chrome.i18n.getMessage(`CopiedExclamation`), + timed: true, + maxCountdownTime: () => 0.6, + referenceNode: document.querySelector(".noticeLeftIcon"), + dontPauseCountdown: true, + style: { + top: 0, + bottom: 0, + minWidth: 0, + right: "30px", + margin: "auto" + }, + hideLogo: true, + hideRightInfo: true, + extraClass: "exportCopiedNotice" + }); + } + categoryChangeListener(index: number, category: Category): void { const dialogWidth = this.noticeRef?.current?.getElement()?.current?.offsetWidth; if (category !== "chooseACategory" && Config.config.showCategoryGuidelines diff --git a/src/render/GenericNotice.tsx b/src/render/GenericNotice.tsx index a02b4afa..63a4c879 100644 --- a/src/render/GenericNotice.tsx +++ b/src/render/GenericNotice.tsx @@ -67,25 +67,31 @@ export default class GenericNotice { hideLogo={options.hideLogo} hideRightInfo={options.hideRightInfo} closeListener={() => this.close()} > - - - - {this.getMessageBoxes(this.idSuffix, options.textBoxes)} - - + {options.textBoxes?.length > 0 ? + + + {this.getMessageBoxes(this.idSuffix, options.textBoxes)} + + + : null} - - + {!options.hideLogo ? + <> + + + + + + {this.getButtons(options.buttons)} + + + + : null} - - - {this.getButtons(options.buttons)} - - , this.noticeElement );