WIP: Add TailwindCSS Plugin #2

Draft
cswimr wants to merge 17 commits from tailwindcss into main
3 changed files with 51 additions and 4 deletions
Showing only changes of commit c6ad8bf111 - Show all commits

View file

@ -44,9 +44,15 @@ Copy emojis to your clipboard from Gauntlet!
[[supported_system]]
os = 'linux'
[[supported_system]]
os = 'macos'
[[supported_system]]
os = 'windows'
[permissions]
main_search_bar = ["read"]
clipboard = ["write"]
[permissions.exec]
command = ["xdg-open"]
command = ["xdg-open", "open", "start", "firefox"]

View file

@ -2,14 +2,18 @@ import { List } from "@project-gauntlet/api/components";
import React, { ReactElement, useState } from "react";
import documentation from "./documentation/tailwind-css";
import { Clipboard } from "@project-gauntlet/api/helpers";
//import { open } from "@opensrc/deno-open"; # pending a fix for https://github.com/project-gauntlet/gauntlet/issues/28
import open from "../../utils/open-url";
// @ts-expect-error gauntlet uses deno and not node
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const denoCore: DenoCore = Deno[Deno.internal].core;
export default function SearchDocumentation(): ReactElement {
const [searchText, setSearchText] = useState<string | undefined>("");
const onClick = async (url: string) => {
//await open(url);
await Clipboard.writeText(url);
await open(url);
//await Clipboard.writeText(url);
};
return (

37
src/utils/open-url.ts Normal file
View file

@ -0,0 +1,37 @@
const getOpenCommand = (platform: typeof Deno.build.os): string => {
const commands = {
windows: "start",
darwin: "open",
linux: "xdg-open",
freebsd: "xdg-open",
netbsd: "xdg-open",
android: "open",
solaris: "firefox", //FIXME - use a different command that doesn't force a specific browser
aix: "firefox",
illumos: "firefox",
} as const;
return commands[platform] || commands.linux;
};
/**
* Open a URL in the user's configured default browser
* @param url The url you want to open in the default browser
* @returns Promise<Deno.CommandStatus> The status of the command
*/
const open = async (url: string) => {
// Yes, this function uses Deno. Yes, this repository uses Node.js for tooling.
// Gauntlet runs loaded plugins in a Deno runtime, so this works fine.
// Hop off Copilot I know this isn't using Node.js APIs
const platform = Deno.build.os;
const cmd = getOpenCommand(platform);
const process = new Deno.Command(cmd, {
args: [url],
env: {
LD_LIBRARY_PATH: "",
},
});
const child = process.spawn();
return await child.status;
};
export default open;