Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ const context = {
"@heroicons/react",
"@tabler/icons",
"@tabler/icons-react",
"classnames",
"react-icons"
"classnames"
],
format: "esm"
};
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@agility/plenum-ui",
"version": "2.2.6",
"version": "2.2.7",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": ["**/*.css"],
"engines": {
"node": ">= 18.0.0"
},
Expand Down Expand Up @@ -73,7 +74,6 @@
"jest-environment-jsdom": "^29.7.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.10.1",
"rimraf": "^5.0.1",
"storybook": "^7.1.1",
"ts-node": "^10.9.2",
Expand All @@ -88,7 +88,6 @@
"@tabler/icons-react": "^2.27.0",
"classnames": "^2.3.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.10.1"
"react-dom": "18.2.0"
}
}
32 changes: 10 additions & 22 deletions stories/atoms/icons/DynamicIcon.stories.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,31 @@
import type { Meta, StoryObj } from "@storybook/react"
import { DynamicIcon } from "./DynamicIcon"
import type { Meta, StoryObj } from "@storybook/react";
import { DynamicIcon } from "./DynamicIcon";

const meta: Meta<typeof DynamicIcon> = {
title: "Design System/atoms/Icons/DynamicIcon",
component: DynamicIcon,
tags: ["autodocs"]
}
};

type Story = StoryObj<typeof DynamicIcon>
type Story = StoryObj<typeof DynamicIcon>;

export const HeroIconSolid: Story = {
args: {
icon: "TrashIcon",
outline: false
}
}
export const HeroIconOutline: Story = {
args: {
icon: "TrashIcon",
outline: true
}
}
export const TablerIconSolid: Story = {
args: {
icon: "IconTrashFilled",
outline: false
}
}
};
export const TablerIconOutline: Story = {
args: {
icon: "IconTrash",
outline: true
}
}
export const FAIcon: Story = {
};
export const TablerIconBrandGithub: Story = {
args: {
icon: "FaGithub",
icon: "IconBrandGithub",
outline: true
}
}
};

export default meta
export default meta;
43 changes: 7 additions & 36 deletions stories/atoms/icons/DynamicIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import React from "react"
// TODO: Fix heroicons support
import * as SolidIcons from "@heroicons/react/solid"
import * as OutlineIcons from "@heroicons/react/outline"
import * as FA from "react-icons/fa"
// TODO: Fix heroicons support — using import type to avoid bundling full icon sets
import type * as SolidIcons from "@heroicons/react/solid"
import type * as OutlineIcons from "@heroicons/react/outline"
import { tablerIconNames, TablerIconName } from "./tablerIconNames"
import { default as cn } from "classnames"

import { ClassNameWithAutocomplete } from "@/utils/types"
import TablerIcon from "./TablerIcon"

export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons
export type FAIconName = keyof typeof FA

export type UnifiedIconName = TablerIconName | IconName | FAIconName
export type UnifiedIconName = TablerIconName | IconName

// isHeroIcon: heroicon support is pending (TODO: Fix heroicons support)
export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
return name in SolidIcons || name in OutlineIcons
return false
}

export function isTablerIcon(name: UnifiedIconName): name is TablerIconName {
return tablerIconNames.includes(name as TablerIconName)
}

export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
return name in FA
}

export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName {
return isTablerIcon(name) // || isHeroIcon(name) || isFAIcon(name)
return isTablerIcon(name)
}

export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
Expand Down Expand Up @@ -62,29 +57,5 @@ export const DynamicIcon = ({
)
}

if (isFAIcon(icon)) {
const Icon = FA[icon]
return (
<i {...{ ...props, className: "flex items-center justify-center" }}>
<Icon
className={cn(className, {
"h-5 w-5 text-gray-600": !className
})}
/>
</i>
)
}
if (isHeroIcon(icon)) {
const Icon = outline ? OutlineIcons[icon] : SolidIcons[icon]
return (
<i {...{ ...props, className: "flex items-center justify-center" }}>
<Icon
className={cn(className, {
"h-5 w-5 text-gray-600": !className
})}
/>
</i>
)
}
return <></>
}
64 changes: 61 additions & 3 deletions stories/atoms/icons/TablerIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,66 @@
import React from "react";
import { TablerIconName } from "./tablerIconNames";
import * as TablerIcons from "@tabler/icons-react";
import {
IconArrowDown,
IconArrowUp,
IconBan,
IconBell,
IconBrandGithub,
IconCheck,
IconChevronDown,
IconCode,
IconConfetti,
IconCopy,
IconCube,
IconDotsVertical,
IconEye,
IconEyeCheck,
IconEyeOff,
IconFolderPlus,
IconGridDots,
IconPaperclip,
IconPencil,
IconPlus,
IconSearch,
IconSelector,
IconThumbUp,
IconTrash,
IconTrashFilled,
IconUpload,
IconX,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going forward, if any component requires another TablerIcon, we will need to import it here

} from "@tabler/icons-react";
import { ClassNameWithAutocomplete } from "@/utils/types";

const tablerIconMap = {
IconArrowDown,
IconArrowUp,
IconBan,
IconBell,
IconBrandGithub,
IconCheck,
IconChevronDown,
IconCode,
IconConfetti,
IconCopy,
IconCube,
IconDotsVertical,
IconEye,
IconEyeCheck,
IconEyeOff,
IconFolderPlus,
IconGridDots,
IconPaperclip,
IconPencil,
IconPlus,
IconSearch,
IconSelector,
IconThumbUp,
IconTrash,
IconTrashFilled,
IconUpload,
IconX,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then add to the epxort list here

} as const;

export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
icon: TablerIconName;
className?: ClassNameWithAutocomplete;
Expand All @@ -12,8 +70,8 @@ const TablerIcon: React.FC<ITablerIconProps> = ({
icon,
className = "w-6 h-6 text-gray-600"
}: ITablerIconProps): JSX.Element => {
//@ts-ignore
const Icon = TablerIcons[icon];
const Icon = tablerIconMap[icon as keyof typeof tablerIconMap];
if (!Icon) return <></>;
return (
<i>
<Icon className={className} />
Expand Down
6 changes: 2 additions & 4 deletions stories/atoms/icons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {
DynamicIcon,
FAIconName,
IDynamicIconProps,
IconName,
UnifiedIconName,
isFAIcon,
isHeroIcon,
isTablerIcon,
isUnifiedIconName
} from "./DynamicIcon"
import IconWithShadow, { IIconWithShadowProps } from "./IconWithShadow"
export { DynamicIcon, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow }
export type { FAIconName, IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps }
export { DynamicIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, IconWithShadow }
export type { IDynamicIconProps, IconName, UnifiedIconName, IIconWithShadowProps }
4 changes: 0 additions & 4 deletions stories/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import Badge, { IBadgeProps } from "./badges";
import { Button, Capsule, BTNActionType, IButtonProps, ICapsuleProps } from "./buttons";
import {
DynamicIcon,
FAIconName,
IDynamicIconProps,
IIconWithShadowProps,
IconName,
IconWithShadow,
UnifiedIconName,
isFAIcon,
isHeroIcon,
isTablerIcon,
isUnifiedIconName
Expand All @@ -32,7 +30,6 @@ export type {
ParagraphProps,
UnifiedIconName,
IconName,
FAIconName,
BTNActionType
};
export {
Expand All @@ -47,7 +44,6 @@ export {
Heading,
Label,
Paragraph,
isFAIcon,
isHeroIcon,
isTablerIcon,
isUnifiedIconName
Expand Down
4 changes: 0 additions & 4 deletions stories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
IRadialProgressProps,
UnifiedIconName,
IconName,
FAIconName,
BTNActionType,
Avatar,
Badge,
Expand All @@ -20,7 +19,6 @@ import {
IconWithShadow,
Loader,
RadialProgress,
isFAIcon,
isHeroIcon,
isTablerIcon,
isUnifiedIconName,
Expand Down Expand Up @@ -108,7 +106,6 @@ export type {
IFormInputWithAddonsProps,
UnifiedIconName,
IconName,
FAIconName,
BTNActionType,
ITextInputProps,
ISimpleSelectOptions,
Expand Down Expand Up @@ -142,7 +139,6 @@ export {
IconWithShadow,
Loader,
RadialProgress,
isFAIcon,
isHeroIcon,
isTablerIcon,
isUnifiedIconName,
Expand Down
Loading