@freightos/相册
一个综合图标库,有280个SVG图标,为Frederos应用程序所设计. 由React所建,TypeScript所建,并铭记开发者的经验.
这个包裹住在 货运窗口 单重键 : packages/icons/。 。 。 .
特征
- 🎨 280 图标 - 全套专业设计的图标
- 📦 树能震动 - 只导入你需要的东西
- 🔷 类型脚本第一 - 包括全部类型定义
- ⚡ 双格式 - 包括无害环境管理和共同司法体系建设
- 🎯 语义大小 - 使用( I)
xs(12页x),sm(16个px),md(24个px),lg(32px)或任何数字/字符串 - 🎨 可主题 - 用途
currentColor以容易为目的 - ♿ 可访问 - 通过SVG道具提供适当的ARIA支助
- 🪶 轻巧 - 个人图标很小
- ⚛️ 反应 16.8+ - 使用钩子和现代反应
安装
npm install @freightos/icons
# or
yarn add @freightos/icons
# or
pnpm add @freightos/icons
Monorepo 用户 : 在FrederWind repo内,图标通过
workspace:*- 不需要安装.
使用指南
基本用途
直接从包中导入图标 :
import { IconSearch, IconUser, IconDashboard } from '@freightos/icons';
function MyComponent() {
return (
<div>
<IconSearch size={24} />
<IconUser color="blue" />
<IconDashboard className="my-icon" />
</div>
);
}
道具
所有图标接受以下道具:
| Prop | 类型 | 默认 | 说明 |
|---|---|---|---|
size | IconSize | number | string | '1em' | 宽度和高度——语义符号(xs, (中文(简体) ), sm, (中文(简体) ), md, (中文(简体) ), lg),像素数字,或 CSS 字符串 |
color | FreightosColor | string | 'currentColor' | 图标的颜色 - 支持具有自动完成或任何 CSS 颜色值的设计系统颜色 |
className | string | - 说吧 | 补充CSS类 |
...props | SVGProps<SVGSVGElement> | - 说吧 | 任何有效的 SVG 属性 |
大小
图标默认是响应的,并且与母字体大小相适应。 可以多种方式自定义大小 :
// Default size (1em - scales with font-size)
<IconSearch />
// Numeric size (pixels)
<IconSearch size={24} />
<IconSearch size={32} />
// String size (CSS units)
<IconSearch size="2rem" />
<IconSearch size="24px" />
// Responsive with parent font-size
<div className="text-lg">
<IconSearch /> {/* Icon automatically scales */}
</div>
// Using CSS classes (Tailwind example)
<IconSearch className="w-6 h-6" />
颜色
图标使用 currentColor 默认,使其易于主题。 这个 color 道克支持 Frederos 设计系统颜色并带有自动完成,加上任何 CSS 颜色值 :
// Freightos design system colors (with autocomplete!)
<IconSearch color="blue" />
<IconError color="red" />
<IconWarning color="yellow" />
<IconSuccess color="green" />
// Inherits parent text color
<div className="text-blue-500">
<IconSearch />
</div>
// Any CSS color value
<IconSearch color="#1890ff" />
<IconSearch color="var(--primary-color)" />
// Using CSS classes
<IconSearch className="text-blue-500" />
<IconSearch className="text-gray-900 dark:text-white" />
可用的设计系统颜色
下列Frederos设计系统颜色可自动支持:
蓝: blue-10, (中文(简体) ), blue-20, (中文(简体) ), blue, (中文(简体) ), blue-40, (中文(简体) ), blue-50
红: red-10, (中文(简体) ), red-20, (中文(简体) ), red, (中文(简体) ), red-40, (中文(简体) ), red-50
黄: yellow-10, (中文(简体) ), yellow-20, (中文(简体) ), yellow, (中文(简体) ), yellow-30, (中文(简体) ), yellow-40, (中文(简体) ), yellow-50
绿: green-10, (中文(简体) ), green-20, (中文(简体) ), green, (中文(简体) ), green-40, (中文(简体) ), green-50
灰色: white, (中文(简体) ), gray-05, (中文(简体) ), gray-10, (中文(简体) ), gray-20, (中文(简体) ), gray-30, (中文(简体) ), gray-40, (中文(简体) ), gray-50, (中文(简体) ), gray-60, (中文(简体) ), gray-70, (中文(简体) ), gray-80, (中文(简体) ), gray-90, (中文(简体) ), gray
紫外线: purple-10, (中文(简体) ), purple
特殊 : transparent
交互式图标
// With click handler
<IconSearch
onClick={() => console.log('Search clicked')}
className="cursor-pointer"
/>
// With hover effects
<IconSearch className="hover:text-blue-500 transition-colors" />
// As a button
<button>
<IconSearch size={20} />
Search
</button>
使用参考文献
import { useRef } from 'react';
import { IconSearch } from '@freightos/icons';
function Component() {
const iconRef = useRef<SVGSVGElement>(null);
return <IconSearch ref={iconRef} />;
}
类型脚本支持
使用图标类型
这个 Icon 类型允许您创建具有图标组件的类型安全变量:
import { Icon, IconSearch, IconUser, IconDashboard } from '@freightos/icons';
// Define an interface with an icon property
interface NavItem {
title: string;
icon: Icon; // Type for icon components
path: string;
}
// Assign icon components (not JSX elements)
const navItems: NavItem[] = [
{ title: 'Search', icon: IconSearch, path: '/search' },
{ title: 'Profile', icon: IconUser, path: '/profile' },
{ title: 'Dashboard', icon: IconDashboard, path: '/dashboard' },
];
// Use in your component
function Navigation() {
return (
<nav>
{navItems.map(item => {
const IconComponent = item.icon;
return (
<a key={item.title} href={item.path}>
<IconComponent size={20} />
<span>{item.title}</span>
</a>
);
})}
</nav>
);
}
动态图标选择
import { Icon, IconSearch, IconUser, IconDashboard } from '@freightos/icons';
const iconMap: Record<string, Icon> = {
search: IconSearch,
user: IconUser,
dashboard: IconDashboard,
};
function DynamicIcon({ name }: { name: string }) {
const IconComponent = iconMap[name];
if (!IconComponent) {
console.warn(`Icon "${name}" not found`);
return null;
}
return <IconComponent size={24} />;
}
可用图标
所有217个图标均可使用,按类别排列:
- 导航:搜索,菜单打开,菜单关闭,ArrowBack,ArrowForward,CaretUp,CaretDown等.
- 行动: 编辑、 回收站、 保存、 复制、 检查、 关闭、 附加、 最小值、 刷新等 .
- 运输: ModeAir,ModeShip,ModeTruck,ModeTrain,ModeAirExpress等.
- 商业:公司,工厂,仓库,办公室,账单,工资,钱库等.
- 通讯: 消息、呼叫、信封、聊天进展、通知 钟等.
- 用户:用户,用户循环,People,AddPerson等.
- 状态:警报循环、信息循环、检查循环、核实、等待等.
- 文档:文档,文档,下载,上传,存档,附件等.
- 接口: Dashboard,设置,过滤器,列表,网格,表格,平板等.
- 后勤: 集装箱,盒子,花板,克勒特,海关,保险,港口等.
参见您的 IDE 自动完成所有217 图标的完整列表 .
图标命名公约
图标遵循一致的命名模式:
- SVG 文件名 :
search.svg• 构成部分:IconSearch - SVG 文件名 :
menu-open.svg• 构成部分:IconMenuOpen - SVG 文件名 :
mode-air-express.svg• 构成部分:IconModeAirExpress
发展
添加新图标
- 将您的 SVG 文件添加到
packages/icons/svg/(使用 kebab 大小写命名 :my-icon.svg(中文(简体) ) - 生成反应组件 :
pnpm --filter @freightos/icons run generate
这将:
- 在
src/icons/ - 用导出更新索引文件
- 将硬码颜色替换为
currentColor
- 构建软件包 :
pnpm --filter @freightos/icons run build
可用的脚本
# Generate icons from SVG files
pnpm --filter @freightos/icons run generate
# Build all formats (ESM + CJS + Types)
pnpm --filter @freightos/icons run build
# Generate and build in one command
pnpm --filter @freightos/icons run dev
# Clean build output
pnpm --filter @freightos/icons run clean
出版
软件包以 npm 的形式发布 @freightos/icons数字 :
pnpm --filter @freightos/icons run release:patch # 1.0.12 → 1.0.13
pnpm --filter @freightos/icons run release:minor # 1.0.12 → 1.1.0
pnpm --filter @freightos/icons run release:major # 1.0.12 → 2.0.0
维护者
维护者 吉里·纳斯拉维 (单位:千美元)jiries @ freightos.com (法语)(中文(简体) )
许可证
麻省理工学院