From 6e5e40e111c34ff43d7f4e2a9b93f9c9331ee866 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 29 Jun 2026 20:34:59 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20ability=20to=20configure=20co?= =?UTF-8?q?py=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 15 ++++++++++++++- src/gitmoji.tsx | 33 ++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index edb9078..47a4407 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,20 @@ "mode": "view" } ], - "preferences": [], + "preferences": [ + { + "name": "copyFormat", + "title": "Copy Format", + "description": "What to copy to the clipboard when selecting a gitmoji.", + "required": false, + "type": "dropdown", + "data": [ + { "title": "Unicode Emoji", "value": "emoji" }, + { "title": "Gitmoji Code", "value": "code" } + ], + "default": "emoji" + } + ], "scripts": { "build": "vici build", "dev": "vici develop", diff --git a/src/gitmoji.tsx b/src/gitmoji.tsx index 773b5a7..abbdc99 100644 --- a/src/gitmoji.tsx +++ b/src/gitmoji.tsx @@ -1,5 +1,12 @@ import gitmojisData from "./gitmojis.json"; -import { Action, ActionPanel, List, showToast, Toast } from "@vicinae/api"; +import { + Action, + ActionPanel, + List, + showToast, + Toast, + getPreferenceValues, +} from "@vicinae/api"; type Gitmoji = { emoji: string; @@ -9,9 +16,25 @@ type Gitmoji = { name: string; }; +type CopyFormat = "emoji" | "code"; + +type GitmojiPreferences = { + copyFormat?: CopyFormat; +}; + const gitmojis = gitmojisData.gitmojis as Gitmoji[]; +const labelFor = (format: CopyFormat) => (format === "code" ? "Code" : "Emoji"); + +const contentFor = (gitmoji: Gitmoji, format: CopyFormat) => + format === "code" ? gitmoji.code : gitmoji.emoji; + export default function GitmojiList() { + const { copyFormat } = getPreferenceValues(); + const primaryFormat: CopyFormat = copyFormat === "code" ? "code" : "emoji"; + const secondaryFormat: CopyFormat = + primaryFormat === "code" ? "emoji" : "code"; + return ( {gitmojis.map((gitmoji) => ( @@ -25,8 +48,8 @@ export default function GitmojiList() { actions={ showToast( Toast.Style.Success, @@ -36,8 +59,8 @@ export default function GitmojiList() { } /> }