بازدان بۆ ناوەڕۆک

ئەم وەرگێڕانە بە یارمەتیی AI نووسراوە و پێویستی بە پێداچوونەوەی کەسێکی زمانزان هەیە.

@0xdolan/deq-icons

ئەم ناوەڕۆکە هێشتا بە زمانەکەت بەردەست نییە.

Deq shapes as icon data, SVG strings, raw SVG files and a sprite.

import { rojHalfSun, toSvg } from "@0xdolan/deq-icons";
const svg = toSvg(rojHalfSun, { size: 32 });

Source: packages/icons. Install with npm install @0xdolan/deq-icons.

Per-shape exports

93 generated exports, one per shape, such as archDot, archDotColumn, arrowDown. The icon list shows every shape.

Functions

iconComponentName

function iconComponentName(id: string): string

The component name of an icon: roj-half-sun → RojHalfSun.

iconExportName

function iconExportName(id: string): string

The JavaScript export name of an icon: roj-half-sun → rojHalfSun.

nodeMarkup

function nodeMarkup(node: IconNode): string

The child elements of node as SVG markup.

rootAttributes

function rootAttributes(icon: DeqIcon, options?: IconOptions): Attribute[]

The root <svg> attributes for icon with options, unescaped. With default options the result matches render(icon.name) from @0xdolan/deq-core. Framework packages use this so every package writes the same markup.

toSvg

function toSvg(icon: DeqIcon, options?: IconOptions): string

A standalone SVG document for icon. With default options it is byte for byte render(icon.name) from @0xdolan/deq-core.

import { rojHalfSun, toSvg } from "@0xdolan/deq-icons";
toSvg(rojHalfSun, { size: 32, color: "#ED2024" });

@throws {DeqError} INVALID_OPTIONS for a bad size, stroke width, colour or title.

Constants

icons

const icons: Readonly<Record<string, DeqIcon>>

Every icon by catalog id. Importing this keeps all icons in a bundle.

packageName

const packageName: '@0xdolan/deq-icons'

The npm package name.

Interfaces

DeqIcon

interface DeqIcon

One Deq shape as icon data, rendered with core’s default options.

  • name: string: Catalog id, for example roj-half-sun.
  • title: string: English name, used as the default accessible title.
  • node: IconNode

IconOptions

interface IconOptions

The options icons support. They only change root attributes, so every icon keeps its precomputed geometry. For dot scale, rotation, fills or parameters, use @0xdolan/deq-core instead.

  • size?: string | number: Width and height in px, or any CSS length. Default 24.
  • color?: string: Stroke and dot colour (CSS colour). Default currentColor.
  • strokeWidth?: string | number: Stroke width in grid units. Default 2.
  • absoluteStrokeWidth?: boolean: Keep the stroke strokeWidth px wide at any numeric size. Default false.
  • title?: string: Accessible title. Default: the English name. "" marks the icon decorative.

Types

Attribute

type Attribute = readonly [name: string, value: string]

Root attribute name and value, in the order core writes them.

IconElement

type IconElement = readonly [ tag: "circle" | "ellipse" | "line" | "path" | "polygon" | "polyline", attrs: Readonly<Record<string, string>>, ]

An SVG child element: tag name and attributes, in the order core writes them.

IconNode

type IconNode = readonly IconElement[]

The elements of an icon, drawn in order inside a 24×24 view box.