Skip to content

svgestor Overview #1

Description

@MindfulLearner

SVG Utility Project On React

Project Aim

This project aims to simplify the use of SVGs. in React

Description

I'll create a library that assists in managing SVGs, utilizing different interfaces to implement best practices and to support different cases.

Developer Experience

  • As a developer, I want to make my development faster and easier.
  • As a developer, I would like to have a documentation that guides me in building my applications with SVGs.

Problem

Often, when using Tailwind, I need to resize SVGs from external websites and convert them into components. This process is time-consuming.

Existing Solutions

  • svg-to-react-cli: This package exists but lacks interfaces for various use cases, and is not updated, but still resolve manual adjustment.

Use Cases For svgestor

  1. Square with SVG Inside: Includes sizing interface with animation for zooming in and out.
  2. Moving SVG: An interface that allows for animated SVG movement.
    etc.. will be more
    examples in progress:
export interface clickableSvgInterface {
    fill?: string;
    style?: React.CSSProperties;
    width?: string;
    height?: string;
    className?: string;
    onClick?: () => void;
    onMouseEnter?: () => void;
    onMouseLeave?: () => void;
}

References

Adam Wathan has created a video tutorial on managing SVGs, but it still requires a lot of manual adjustments, which is time-consuming.

Objective and Idea example

svg from svgrepo
component-gmail-svg.tsx

import React from "react";
import { SvgInterface } from "../../../interfaces/svgInterface";

const ItemGmailSvg: React.FC<SvgInterface> = ({ fill, width, height, style }) => {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      width={width}
      height={height}
      viewBox="0 0 32 32"
      style={style}
    >
      <path
        d="M30.996 7.824v17.382a2.044 2.044 0 0 1-2.044 2.044H24.179V15.663L16 21.799l-8.179-6.136v11.588H3.049a2.044 2.044 0 0 1-2.044-2.044V7.824A3.067 3.067 0 0 1 5.92 5.376l-.008-.006L16 12.937 26.088 5.37a3.067 3.067 0 0 1 4.907 2.454z"
        fill={fill}
      />
    </svg>
  );
};

export default ItemGmailSvg;

svginterface.tsx

/**
 * interface that will define the props of the svg components
 */
export interface SvgInterface {
    width?: string;
    height?: string;
    fill?: string;
    style?: React.CSSProperties;
}

Index.tsx

    <Item
                  fill={hoveredCard === index ? "black" : "white"}
                  width={hoveredCard === index ? "45" : "40"}
                  height={hoveredCard === index ? "45" : "40"}
                  style={{
                    transition:
                      "width 0.3s ease, height 0.3s ease, fill 0.3s ease",
                  }}

image

This is just a prototype of course will be more feature on the interfaces!

Metadata

Metadata

Labels

documentationImprovements or additions to documentationquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions