Git Product home page Git Product logo

custom_svg_generator's Introduction

Custom SVG Generator

License: MIT

Technology Used πŸ–₯️

Technology Used Resource URL
JavaScript https://developer.mozilla.org/en-US/docs/Web/JavaScript
Inquirer https://github.com/SBoudrias/Inquirer.js/
node.js https://nodejs.org/en
Jest https://jestjs.io/
Git https://git-scm.com/

Description πŸ“

Create your own (albeit simple) SVG!

Choose your desired text, shape color, text color and desired shape out of the ones available.

Through the utilization of Node.js, Inquirer, and Jest, this application was able to be created.

  • Node.js's preinstalled filesystem module along with the built-in JavaScript runtime environment allowed this project to be executed.
  • Inquirer's prompt() method allows the application to take in user inputs and manipulate the SVG file based on said inputs.
  • Jest allowed for me to create test cases for the application and ensure that everything was running properly.

Running index.js example


Table of Contents πŸ“‹


Learning Points πŸ“–

A major learning point in this project was the usage of class inheritance and TDD.

Class Inheritance

Class inheritance is simply creating new instances of a class and that new instance will have the parent's methods and properties.

An example of class inheritance that I used in this application can be seen below:

  • Below is the original parent class
class Shape { //the parent shape constructor that we'll use to make the other shape classes
    constructor(text, text_color, shape_color){
        this.text = text;
        this.text_color = text_color;
        this.shape_color = shape_color;
    };
};
  • Below is the child of said parent class inheriting the text, text_color, and shape_color properties
class Square extends Shape { //copies the properties of the Shape class from ./shape.js
    constructor(text, text_color, shape_color){
        super(text, text_color, shape_color);
    };

Test Driven Development (TDD)

TDD is a concept where developers will initially write tests that outline the desired outcome for our code, then write code that passes the test, then refactor the code to make it more efficient and concise and the loop occurs all over again.

Using this concept, I wrote tests that outlined my desired outcomes and wrote code to satisfy those tests. An Example test can be seen below:

    describe('Circle Text Test',()=>{
        it('The circle text should equal dae', ()=>{ //tests if the circle's text is accurate
            const text = 'dae';
            const testCircle = new Circle(text);
            expect(testCircle.text).toEqual('dae');
        });
    });

Installation Instructions πŸ“₯

To install the application, simply download the files or clone this GitHub repo on to your local machine.

To see how to use the application, checkout the section below!


Usage Information βœ…

To use the application:

  1. Clone this repo or download the files on to your local machine.
  2. Open the terminal in the root directory of this app.
  3. Download node.js on to your local machine.
  4. Run npm i or npm install in the terminal to download inquirer and jest.
  5. Then run node index.js and complete the following prompts.
  6. Check the ./examples folder to see your newly renderedShape.svg.

Alternatively, you can watch this video.


Test Instructions πŸ§ͺ

If you'd like to run the tests for this application, simply open the terminal in the root directory of this app and run npm run test.


Author Info πŸ‘Ί

daevidvo


Questions ❓

Email me at: [email protected] or visit my GitHub


License 🚩

https://opensource.org/licenses/MIT

The MIT License (MIT)

Copyright Β© daevidvo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

custom_svg_generator's People

Contributors

daevidvo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.