The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
[FRONT COMPONENTS] Create Icon component in twenty ui (#17797)
Raphaël Bosi7fbd50e5a073
diff --git a/packages/twenty-ui/src/display/icon/components/Icon.tsx b/packages/twenty-ui/src/display/icon/components/Icon.tsxnew file mode 100644index 00000000000..a692a9dacf7--- /dev/null+++ b/packages/twenty-ui/src/display/icon/components/Icon.tsx@@ -0,0 +1,29 @@+import { useIcons } from '@ui/display/icon/hooks/useIcons';+import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';++export type IconProps = IconComponentProps & {+ name: string;+};++export const Icon = ({+ name,+ className,+ style,+ size,+ stroke,+ color,+}: IconProps) => {+ const { getIcon } = useIcons();++ const ResolvedIcon = getIcon(name);++ return (+ <ResolvedIcon+ className={className}+ style={style}+ size={size}+ stroke={stroke}+ color={color}+ />+ );+};diff --git a/packages/twenty-ui/src/display/icon/components/__stories__/Icon.stories.tsx b/packages/twenty-ui/src/display/icon/components/__stories__/Icon.stories.tsxnew file mode 100644index 00000000000..73518f49ba9--- /dev/null+++ b/packages/twenty-ui/src/display/icon/components/__stories__/Icon.stories.tsx@@ -0,0 +1,59 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';++import { IconsProvider } from '@ui/display/icon/providers/IconsProvider';+import { ComponentDecorator } from '@ui/testing/decorators/ComponentDecorator';+import { RecoilRootDecorator } from '@ui/testing/decorators/RecoilRootDecorator';++import { Icon } from '../Icon';++const meta: Meta<typeof Icon> = {+ title: 'UI/Display/Icon/Icon',+ component: Icon,+ decorators: [+ ComponentDecorator,+ (Story) => (+ <IconsProvider>+ <Story />+ </IconsProvider>+ ),+ RecoilRootDecorator,+ ],+};++export default meta;+type Story = StoryObj<typeof Icon>;++export const Default: Story = {+ args: {+ name: 'IconUser',+ },+};++export const WithCustomSize: Story = {+ args: {+ name: 'IconSettings',+ size: 32,+ },+};++export const WithCustomColor: Story = {+ args: {+ name: 'IconHeart',+ color: 'red',+ size: 24,+ },+};++export const WithCustomStroke: Story = {+ args: {+ name: 'IconStar',+ size: 24,+ stroke: 1,+ },+};++export const InvalidName: Story = {+ args: {+ name: 'NonExistentIcon',+ },+};diff --git a/packages/twenty-ui/src/display/index.ts b/packages/twenty-ui/src/display/index.tsindex 27599c3d43b..e12755ebacf 100644--- a/packages/twenty-ui/src/display/index.ts+++ b/packages/twenty-ui/src/display/index.ts@@ -29,6 +29,8 @@ export type {} from './color/components/ColorSample';export { ColorSample } from './color/components/ColorSample';export { CommandBlock } from './command-block/components/CommandBlock';+export type { IconProps } from './icon/components/Icon';+export { Icon } from './icon/components/Icon';export { IconAddressBook } from './icon/components/IconAddressBook';export { IconChartBarHorizontal } from './icon/components/IconChartBarHorizontal';export { IconGmail } from './icon/components/IconGmail';