Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Refactor icon generator (i.e. VueSimpleIcon component) #20

Merged
merged 12 commits into from
Dec 25, 2018

Conversation

ericcornelissen
Copy link
Contributor

Description

The primary change is reducing the code complexity of and improving the performance when generating icons utilizing the domProps property to inject the SVG as it is provided by SimpleIcons. The <svg> itself is still created as a VNode in order to keep the size changes easy, but the contents of the SVG come straight from icon.svg.

The second change is the introduction of the title argument to the renderError() function, which makes it easier to render errors with a custom message/title.

Other changes:

  • Rename h to createElement for clarity.
  • Rename x in the name property validator to name for clarity.
  • Removed this.parser from the VueSimpleIcon class, it is no longer needed as per the primary change.
  • Use string literals rather then string concatenation (e.g. "#" + this.color --> #${this.color}).

Possible improvements:

  • Remove </svg> using a fixed method (e.g. String.substr) rather then a Regular Expression for performance. However, it is rather convenient to have the Regular Expression remove both the opening and closing SVG tag.
  • Inject custom titles in another way not using Regular Expressions to increase performance. However, this would require removing <title>...</title> from the icon.svg string which would probably still require a Regular Expression.

Why is this change required?

Should improve code readability and performance, not critical though.

  • I've read the contributing guidelines and the Code of Conduct

@ericcornelissen ericcornelissen added the enhancement New feature or request label Dec 23, 2018
@codecov
Copy link

codecov bot commented Dec 23, 2018

Codecov Report

Merging #20 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #20   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          50     41    -9     
  Branches       16     11    -5     
=====================================
- Hits           50     41    -9
Impacted Files Coverage Δ
src/VueSimpleIcon.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8826b4f...0911c2f. Read the comment docs.

src/VueSimpleIcon.ts Outdated Show resolved Hide resolved
@dsseng dsseng self-requested a review December 24, 2018 13:30
Copy link
Owner

@dsseng dsseng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dsseng dsseng merged commit ab0b631 into master Dec 25, 2018
@dsseng
Copy link
Owner

dsseng commented Dec 25, 2018

@ericcornelissen Thanks for these improvements!

@dsseng dsseng deleted the refactor-component branch December 25, 2018 11:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants