Skip to content

Commit

Permalink
Tabler icons added to NamedIcon
Browse files Browse the repository at this point in the history
commit 13ed268
Author: Matt Aitken <matt@mattaitken.com>
Date:   Fri Oct 20 11:38:22 2023 +0100

    Added all the tabler-icons to Storybook

commit 62738d7
Author: Matt Aitken <matt@mattaitken.com>
Date:   Fri Oct 20 11:38:09 2023 +0100

    Use the no-stroke version of the tabler-sprite so we can control the stroke width

commit a1b7edd
Author: Matt Aitken <matt@mattaitken.com>
Date:   Fri Oct 20 11:37:54 2023 +0100

    Set the default width to 1.5, so they’re a bit thinner

commit 69ba388
Author: Matt Aitken <matt@mattaitken.com>
Date:   Fri Oct 20 10:55:34 2023 +0100

    Added a tabler icon to an events job catalog job

commit eb3c5f6
Author: Matt Aitken <matt@mattaitken.com>
Date:   Fri Oct 20 10:53:40 2023 +0100

    Moved the tabler sprite to the app and use an import. This means it’ll be cached and we can move it

commit c24d76e
Author: Chaturved Degloorkar <48447253+chaturrved@users.noreply.github.com>
Date:   Fri Oct 20 15:22:59 2023 +0530

    feat: Add support for tabler-icons when using the icon for Tasks  (#629)

    * Add support for tabler-icons

    * Changed the core update type from minor to a patch

    ---------

    Co-authored-by: Matt Aitken <matt@mattaitken.com>
  • Loading branch information
matt-aitken committed Oct 20, 2023
1 parent 84af641 commit abc9737
Show file tree
Hide file tree
Showing 9 changed files with 4,887 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-moles-smash.md
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Updated icon documentation in runTasks
16 changes: 16 additions & 0 deletions apps/webapp/app/components/primitives/NamedIcon.tsx
Expand Up @@ -68,6 +68,8 @@ import { Spinner } from "./Spinner";
import { SaplingIcon } from "~/assets/icons/SaplingIcon";
import { TwoTreesIcon } from "~/assets/icons/TwoTreesIcon";
import { OneTreeIcon } from "~/assets/icons/OneTreeIcon";
import { tablerIcons } from "~/utils/tablerIcons";
import tablerSpritePath from "./tabler-sprite.svg";

const icons = {
account: (className: string) => <UserCircleIcon className={cn("text-slate-400", className)} />,
Expand Down Expand Up @@ -215,6 +217,12 @@ export function NamedIcon({
);
}

if (tablerIcons.has("tabler-" + name)) {
return <TablerIcon name={"tabler-" + name} className={className} />;
} else if (name.startsWith("tabler-") && tablerIcons.has(name)) {
return <TablerIcon name={name} className={className} />;
}

console.log(`Icon ${name} not found`);

if (fallback) {
Expand Down Expand Up @@ -247,3 +255,11 @@ export function NamedIconInBox({
</div>
);
}

export function TablerIcon({ name, className }: { name: string; className?: string }) {
return (
<svg className={cn("stroke-[1.5]", className)}>
<use xlinkHref={`${tablerSpritePath}#${name}`} />
</svg>
);
}
1 change: 1 addition & 0 deletions apps/webapp/app/components/primitives/tabler-sprite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 30 additions & 10 deletions apps/webapp/app/components/stories/NamedIcon.stories.tsx
@@ -1,6 +1,8 @@
import type { Meta, StoryObj } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import { NamedIcon, iconNames } from "../primitives/NamedIcon";
import { tablerIcons } from "~/utils/tablerIcons";
import { Header1 } from "../primitives/Headers";

const meta: Meta<typeof NamedIcons> = {
title: "Icons",
Expand All @@ -25,17 +27,35 @@ export const Basic: Story = {

function NamedIcons() {
return (
<div className="grid grid-cols-8 gap-4">
{iconNames
.sort((a, b) => a.localeCompare(b))
.map((iconName) => (
<div key={iconName} className="flex items-center gap-2">
<div>
<NamedIcon name={iconName} className={"h-6 w-6"} />
<div className="flex flex-col gap-4">
<div>
<Header1 spacing>Internal</Header1>
<div className="grid grid-cols-8 gap-4">
{iconNames
.sort((a, b) => a.localeCompare(b))
.map((iconName) => (
<div key={iconName} className="flex items-center gap-2">
<div>
<NamedIcon name={iconName} className={"h-6 w-6"} />
</div>
<span className="text-xs text-dimmed">{iconName}</span>
</div>
))}
</div>
</div>
<div>
<Header1 spacing>Tabler</Header1>
<div className="grid grid-cols-8 gap-4">
{Array.from(tablerIcons).map((iconName) => (
<div key={iconName} className="flex items-center gap-2">
<div>
<NamedIcon name={iconName} className={"h-6 w-6 text-indigo-500"} />
</div>
<span className="text-xs text-dimmed">{iconName}</span>
</div>
<span className="text-xs text-dimmed">{iconName}</span>
</div>
))}
))}
</div>
</div>
</div>
);
}
3 changes: 2 additions & 1 deletion apps/webapp/app/utils/icon.ts
@@ -1,9 +1,10 @@
import { hasIcon } from "@trigger.dev/companyicons";
import { iconNames as namedIcons } from "~/components/primitives/NamedIcon";
import { tablerIcons } from "~/utils/tablerIcons";

export const isValidIcon = (icon?: string): boolean => {
if (!icon) {
return false;
}
return namedIcons.includes(icon) || hasIcon(icon);
return namedIcons.includes(icon) || hasIcon(icon) || tablerIcons.has(icon);
};

0 comments on commit abc9737

Please sign in to comment.