Skip to content

Implement SVG Icon System with Text Icon #16

Closed

Description

@malibio

Create type-safe SVG icon component and integrate text node icon for professional node type indicators.

Dependencies

Related Issues

Requirements

  • Icon Component: Svelte component with props: name: IconName, size?: number, className?: string, color?: string
  • SVG Specs: viewBox "0 -960 960 960", currentColor fill support, default 20px size
  • Text Icon: Document with pencil SVG path: "M160-400v-80h280v80H160Zm0-160v-80h440v80H160Zm0-160v-80h440v80H160Zm360 560v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"
  • File Structure: src/lib/design/icons/Icon.svelte, src/lib/design/icons/ui/text.ts, src/lib/design/icons/index.ts
  • Type Safety: Export IconName union type, currently 'text' (expandable for future)
  • Tree Shaking: Modular exports for optimal bundle size
  • Documentation: Clean comments describing icon purpose (no external design system references)

Technical Implementation

  • Icon Component: Create in src/lib/design/icons/Icon.svelte
  • SVG Structure: Standard <svg> element with <path> child, responsive sizing
  • Type Definition: Create IconName union type in index.ts for autocomplete
  • Export Pattern: Follow design system modular export structure
  • Theme Integration: Use currentColor for automatic theme color inheritance
  • Reference: Follow existing design system component patterns

Example Implementation

<\!-- Icon.svelte -->
<script lang="ts">
  import type { IconName } from './index.js';
  export let name: IconName;
  export let size: number = 20;
  export let className: string = '';
  export let color: string = 'currentColor';
  // Icon path lookup logic
</script>
<svg width={size} height={size} viewBox="0 -960 960 960" class="ns-icon {className}" style:fill={color}>
  <path d={iconPath} />
</svg>

Acceptance Criteria

  • Icon component renders SVG with proper viewBox and sizing
  • Text icon displays correctly at various sizes (16px, 20px, 24px)
  • TypeScript provides autocomplete for icon names
  • Icons support theme color changes through currentColor
  • Component ready for additional icons (infrastructure in place)
  • Icons render crisply at different zoom levels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions