@ghs- 危险图片/ 分数
所有全球统一制度化学品危险象形图(GHS01-GHS09)和联合国运输危险类象形图的数据、类型和查询助手.
这是本集其他包所消耗的基础包. 当需要程序访问象形元数据、内置SVG或资产路径时直接使用它——而不与任何UI框架相接.
安装
npm install @ghs-hazard-pictograms/core
# or
yarn add @ghs-hazard-pictograms/core
# or
pnpm add @ghs-hazard-pictograms/core
快开始
import { getPictogram, getGHSPictograms, getAllPictograms } from '@ghs-hazard-pictograms/core';
// Look up a single pictogram by slug ID
const explosive = getPictogram('ghs01-explosive');
console.log(explosive?.name); // "Explosive"
console.log(explosive?.code); // "GHS01"
console.log(explosive?.category); // "physical_hazards"
// Render the inline SVG directly
document.getElementById('icon')!.innerHTML = explosive!.svg;
// Get all 9 core GHS pictograms
const ghsPictograms = getGHSPictograms();
// Get every pictogram (GHS + transport)
const all = getAllPictograms();
console.log(all.length); // 27
API 参考
pictograms
import { pictograms } from '@ghs-hazard-pictograms/core';
所有27个象形图的预建阵列. 包括9个全球统一制度化学品危险象形图和18个联合国运输危险类象相图.
getAllPictograms()
getAllPictograms(): Pictogram[]
返回登记册中的每个象形图(GHS01-GHS09加上所有运输类别).
getGHSPictograms()
getGHSPictograms(): Pictogram[]
只返回9个核心全球统一制度化学品危险象形图(GHS01-GHS09),不包括联合国运输类别.
getPictogram(id)
getPictogram(id: string): Pictogram | undefined
以弹道识别器显示一个象形图 回返 undefined 如果找不到的话.
getPictogram('ghs01-explosive');
getPictogram('ghs09-hazardous-to-the-environment');
getPictogram('divisions-1-1-1-3'); // transport
getPictogram('un-class-8'); // transport
getPictogramsByCategory(category)
getPictogramsByCategory(category: PictogramCategory): Pictogram[]
返回属于指定类别的所有象形图.
import { getPictogramsByCategory } from '@ghs-hazard-pictograms/core';
const physical = getPictogramsByCategory('physical_hazards');
const transport = getPictogramsByCategory('transport');
类型脚本
Pictogram
interface Pictogram {
/** Slug identifier, e.g. "ghs01-explosive". */
id: string;
/** GHS code, e.g. "GHS01". Empty string for transport-only pictograms. */
code: string;
/** Human-readable name, e.g. "Explosive". */
name: string;
/** Pictogram category. */
category: PictogramCategory;
/** Documentation text from Wikipedia describing the hazard classes covered. */
description: string;
/** Full inline SVG string (optimised by SVGO). */
svg: string;
/** Pre-built image asset paths at multiple sizes and formats. */
assets: PictogramAssets;
}
PictogramAssets
interface PictogramAssets {
/** Relative path to the original SVG source file. */
svg: string;
/** Map of pixel size → relative path for PNG variants. */
png: Record<number, string>;
/** Map of pixel size → relative path for JPEG variants. */
jpg: Record<number, string>;
/** Map of pixel size → relative path for WebP variants. */
webp: Record<number, string>;
}
可用大小 : 240、512、768、1024、2048 px2 (英语).
PictogramCategory
type PictogramCategory =
| 'physical_hazards' // GHS01–GHS05 (explosive, flammable, oxidising, compressed gas, corrosive)
| 'health_hazards' // GHS06–GHS08 (toxic, health hazard, serious health hazard)
| 'physical_and_health_hazards' // unused: GHS05 is filed under physical_hazards
| 'environmental_hazards' // GHS09 (hazardous to the aquatic environment)
| 'transport'; // UN transport hazard class pictograms (divisions 1.1–9)
相关软件包
| 软件包 | 说明 |
|---|---|
@ghs-hazard-pictograms/react | 每种象形图的反应组件 |
@ghs-hazard-pictograms/css | CSS 有短工具类名称的图示工作表 |
@ghs-hazard-pictograms/assets | 静态 SVG/PNG/JPG/WebP 图像文件 |
@ghs-hazard-pictograms/sprite | 特别工作组 <symbol> 图标用于 <use href> 嵌入 |