/** * SVG-спрайты: типы и React-компонент. * @generated — this file is auto-generated, do not edit manually. */ import type { SVGAttributes, HTMLAttributes } from 'react' import styles from './svg-sprite.module.css' /** Имена иконок спрайта «icons». */ export type IconsIconName = | 'arrow-left' | 'arrow-right' | 'check' | 'discount-shape' | 'flash' | 'heart-tick' | 'heart-tick (1-я копия)' /** Имена иконок спрайта «logos». */ export type LogosIconName = | 'github' | 'twitter' | 'youtube' /** Маппинг имени спрайта на тип его иконок. */ export type SpriteMap = { icons: IconsIconName logos: LogosIconName } /** Имя спрайта. */ export type SpriteName = keyof SpriteMap /** Спрайт по умолчанию. */ export type DefaultSprite = 'icons' /** Имя иконки для конкретного спрайта. */ export type IconName = SpriteMap[S] const PUBLIC_PATH = '' const DEFAULT_SPRITE: SpriteName = 'icons' const SPRITE_FILES: Record = { icons: 'icons.sprite.svg', logos: 'logos.sprite.svg', } type IconBaseProps = { /** Имя иконки. */ icon: IconName /** Имя спрайта. По умолчанию: первый из конфига. */ sprite?: S } type IconSvgProps = IconBaseProps & { wrapped?: false } & SVGAttributes type IconWrappedProps = IconBaseProps & { wrapped: true } & HTMLAttributes export type SvgSpriteProps = | IconSvgProps | IconWrappedProps /** * Иконка из SVG-спрайта. * * Используется для: * - отображения иконки через `` * - обёртки в `` через проп `wrapped` * * Спрайт по умолчанию: «icons». */ export const SvgSprite = (props: SvgSpriteProps) => { const { icon, sprite = DEFAULT_SPRITE as S, wrapped, className, ...rest } = props const href = `${PUBLIC_PATH}/${SPRITE_FILES[sprite]}#${icon}` if (wrapped) { const { ...htmlAttr } = rest as HTMLAttributes return ( ) } const { ...svgAttr } = rest as SVGAttributes return ( ) }