Skip to content

Instantly share code, notes, and snippets.

@vogelino
Created September 15, 2022 21:58
Show Gist options
  • Save vogelino/b96a807c2c7a70b88193b03aac41b255 to your computer and use it in GitHub Desktop.
Save vogelino/b96a807c2c7a70b88193b03aac41b255 to your computer and use it in GitHub Desktop.
Script Kit - Tabler Icon
// Name: Get Tabler Icons
// Description: Copies a Tabler Icon from tabler open-sourced repository.
// Author: Lucas Vogel
// Twitter: @soyvogelino
import "@johnlindquist/kit";
const iconsPath = "https://tabler-icons.io/icons.json";
let files = [];
try {
let response = await get(iconsPath);
files = response.data;
} catch (error) {
notify(error);
}
const titleCase = (s) =>
s
.toLowerCase()
.split("-")
.map((w) => w[0].toUpperCase() + w.slice(1))
.join(" ");
const options = files.map((file, idx) => {
return {
name: titleCase(file.n),
description: file.t.split(" ").join(", "),
value: file,
preview: `
<table class="w-full">
<tr>
<td class="p-8">
<div className="m-8">${file.s}</div>
</td>
<td class="p-8">
<div>${file.s.replaceAll('"24"', '"100"')}</div>
</td>
<tr>
<td class="p-8 bg-black text-white">
<div className="m-8">${file.s}</div>
</td>
<td class="p-8 bg-black text-white">
<div>${file.s.replaceAll('"24"', '"100"')}</div>
</td>
</tr>
</tr>
</table>
`,
};
});
const icon = await arg("Search for an icon:", options);
try {
await copy(icon.s);
notify(`Copied ${titleCase(file.n)} icon to clipboard`);
} catch (error) {
notify(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment