refactor(arch): linting/doc strings for icon related code

This commit is contained in:
NicolasNewman 2024-07-09 15:59:21 -05:00
parent 78dfffa1a7
commit d9b16953f0
6 changed files with 1366 additions and 1306 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,8 @@
import { createIcon } from "../../svgRegister.js";
import { createIcon } from '../../svgRegister.js';
// cSpell:disable
const digitalOceanIcons = {
'do:api': createIcon(`<g>
'do:api': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}.cls-4{font-size:16px;fill:#fff;font-family:ProximaNova-Extrabld,
@ -13,8 +14,11 @@ const digitalOceanIcons = {
<path class="cls-3"
d="M32.8,22.44V19.65l-3.09-1a9.47,9.47,0,0,0-.89-2.1l1.51-2.9-2-2-2.88,1.45h0a9.45,9.45,0,0,0-2-.88h0l-1-3.07H19.59l-1,3.11a9.39,9.39,0,0,0-2.09.89h0l-2.89-1.5-2,2,1.5,2.89h0a8.91,8.91,0,0,0-.88,2L9.2,19.65v2.83l3.1,1h0a9.07,9.07,0,0,0,.82,2h0l-1.46,2.87,2,2,2.9-1.51a9,9,0,0,0,2,.89l1,3.11H22.4l1-3.08h0a8.65,8.65,0,0,0,2-.82h0l2.89,1.51,2-2.06L28.8,25.49a9.48,9.48,0,0,0,.88-2.07Zm-11.8,2A3.45,3.45,0,1,1,24.44,21v0A3.44,3.44,0,0,1,21,24.42Z" />
</g>
</g>`, 41.61),
'do:cli': createIcon(`<g>
</g>`,
41.61
),
'do:cli': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -25,8 +29,11 @@ const digitalOceanIcons = {
<polyline class="cls-3" points="14.34 24.5 17.84 21 14.34 17.5" />
<line class="cls-3" x1="20.13" y1="23.89" x2="27.53" y2="23.89" />
</g>
</g>`, 41.61),
'do:dns': createIcon(`<g>
</g>`,
41.61
),
'do:dns': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -40,8 +47,11 @@ const digitalOceanIcons = {
<path class="cls-3" d="M21,32.87c-3.27,0-5.93-8.6-5.93-11.87S17.73,9.13,21,9.13" />
<path class="cls-3" d="M21.09,9.13C24.36,9.13,27,17.73,27,21s-2.66,11.87-5.93,11.87" />
</g>
</g>`, 41.61),
'do:droplet': createIcon(`<g>
</g>`,
41.61
),
'do:droplet': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -53,8 +63,11 @@ const digitalOceanIcons = {
<path class="cls-3"
d="M21,26.28a3.37,3.37,0,0,1-3.39-3.39c0-2.61,3.39-5.09,3.39-5.09s3.39,2.42,3.39,5.09A3.37,3.37,0,0,1,21,26.28Z" />
</g>
</g>`, 41.61),
'do:kubernetes': createIcon(`<g>
</g>`,
41.61
),
'do:kubernetes': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -64,8 +77,11 @@ const digitalOceanIcons = {
<path class="cls-3"
d="M31.15,21.18A10.19,10.19,0,1,1,21,11,10.19,10.19,0,0,1,31.15,21.18Zm-6.51,0A3.64,3.64,0,1,1,21,17.56,3.64,3.64,0,0,1,24.64,21.2ZM21,17.47v0ZM10.1,12.33,18,18.79Zm21.79,0L24,18.79ZM34.72,24.2,24.75,22Zm-27.44,0,10-2.18Zm19.93,9.62-4.53-9.43Zm-12.41,0,4.45-9.43Z" />
</g>
</g>`, 41.61),
'do:local-ssd': createIcon(`<g>
</g>`,
41.61
),
'do:local-ssd': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -77,8 +93,11 @@ const digitalOceanIcons = {
<path class="cls-3"
d="M21,26.28a3.37,3.37,0,0,1-3.39-3.39c0-2.61,3.39-5.09,3.39-5.09s3.39,2.42,3.39,5.09A3.37,3.37,0,0,1,21,26.28Z" />
</g>
</g>`, 41.61),
'do:mysql': createIcon(`<g>
</g>`,
41.61
),
'do:mysql': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-4{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3,.cls-5{fill:#fff;}.cls-4{stroke:#fff;stroke-width:1.49px;}.cls-5{font-size:16px;font-family:ProximaNova-Extrabld,
@ -101,8 +120,11 @@ const digitalOceanIcons = {
d="M13.89,14.44c-2.54-.46-4.23-1.27-4.23-2.2,0-1.43,4-2.58,8.88-2.58s8.87,1.15,8.87,2.58-4,2.58-8.87,2.58a27,27,0,0,1-4.65-.38" />
<circle class="cls-4" cx="25.44" cy="25.43" r="6.91" />
</g>
</g>`, 41.61),
'do:redis-copy': createIcon(`<g>
</g>`,
41.61
),
'do:redis-copy': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}.cls-4{fill:#fff;}</style>
@ -126,8 +148,11 @@ const digitalOceanIcons = {
<path class="cls-3" d="M15.83,29.69c-2.54-.45-4.23-1.27-4.23-2.2" />
<path class="cls-4" d="M30.41,26.2v0Z" />
</g>
</g>`, 41.61),
'do:redis': createIcon(`<g>
</g>`,
41.61
),
'do:redis': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}.cls-4{fill:#fff;}</style>
@ -149,8 +174,11 @@ const digitalOceanIcons = {
<path class="cls-4"
d="M28.47,24a2.68,2.68,0,0,0-2.68-2.65H23.88a.75.75,0,0,0-.57.21.77.77,0,0,0-.23.57v6.73a.77.77,0,0,0,1.53,0V26.62h.53l1.5,2.58a.76.76,0,0,0,.66.37.75.75,0,0,0,.38-.1.76.76,0,0,0,.27-1l-1.17-2a2.78,2.78,0,0,0,.9-.58A2.72,2.72,0,0,0,28.47,24Zm-3.86-1.12h1.14a1.18,1.18,0,0,1,.82.33,1.11,1.11,0,0,1,0,1.58,1.14,1.14,0,0,1-.82.33H24.61Z" />
</g>
</g>`, 41.61),
'do:monitoring': createIcon(`<g>
</g>`,
41.61
),
'do:monitoring': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -165,8 +193,11 @@ const digitalOceanIcons = {
<circle class="cls-3" cx="12.4" cy="29.13" r="2.39" />
<circle class="cls-3" cx="29.6" cy="12.87" r="2.39" />
</g>
</g>`, 41.61),
'do:projects': createIcon(`<g>
</g>`,
41.61
),
'do:projects': createIcon(
`<g>
<defs>
<style>
.cls-1{fill:none;stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{fill:#fff;}</style>
@ -182,8 +213,11 @@ const digitalOceanIcons = {
<rect class="cls-3" x="16.21" y="22.18" width="1.18" height="1.22" />
<rect class="cls-3" x="16.21" y="25.49" width="1.18" height="1.22" />
</g>
</g>`, 41.61),
'do:spaces-cdn': createIcon(`<g>
</g>`,
41.61
),
'do:spaces-cdn': createIcon(
`<g>
<defs>
<style>
.cls-1{fill:none;stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{fill:#fff;}</style>
@ -199,8 +233,11 @@ const digitalOceanIcons = {
<path class="cls-3"
d="M16.66,10.9a1,1,0,0,0,1-.87.94.94,0,0,0-.86-1h-.1a.92.92,0,0,0-.61.2.88.88,0,0,0-.34.69,1.08,1.08,0,0,0,.19.65A.84.84,0,0,0,16.66,10.9ZM21,28.84V27.2a6.27,6.27,0,0,1,0-12.54V13a7.92,7.92,0,0,0,0,15.83Zm.42-20.53V10a11.05,11.05,0,0,1,0,22.1v1.64a12.69,12.69,0,0,0,0-25.38Z" />
</g>
</g>`, 41.61),
'do:spaces-object-storage': createIcon(`<g>
</g>`,
41.61
),
'do:spaces-object-storage': createIcon(
`<g>
<defs>
<style>
.cls-1{fill:none;stroke:#000;stroke-miterlimit:10;}.cls-2{font-size:16px;font-family:ProximaNova-Extrabld,
@ -218,8 +255,11 @@ const digitalOceanIcons = {
<path class="cls-20"
d="M16.66,10.9a1,1,0,0,0,1-.87.94.94,0,0,0-.86-1h-.1a.92.92,0,0,0-.61.2.88.88,0,0,0-.34.69,1.08,1.08,0,0,0,.19.65A.84.84,0,0,0,16.66,10.9ZM21,28.84V27.2a6.27,6.27,0,0,1,0-12.54V13a7.92,7.92,0,0,0,0,15.83Zm.42-20.53V10a11.05,11.05,0,0,1,0,22.1v1.64a12.69,12.69,0,0,0,0-25.38Z" />
</g>
</g>`, 41.61),
'do:teams': createIcon(`<g>
</g>`,
41.61
),
'do:teams': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -235,8 +275,11 @@ const digitalOceanIcons = {
d="M26.33,28.79a5.1,5.1,0,0,0-4.92-5.29,2.94,2.94,0,0,0-.42,0,5.12,5.12,0,0,0-5.3,4.94,2.67,2.67,0,0,0,0,.4" />
<circle class="cls-3" cx="20.99" cy="20.8" r="2.7" />
</g>
</g>`, 41.61),
'do:terraform-provider': createIcon(`<g>
</g>`,
41.61
),
'do:terraform-provider': createIcon(
`<g>
<defs>
<style>
.cls-1,.cls-3{fill:none;stroke-miterlimit:10;}.cls-1{stroke:#000;}.cls-2{fill:#0069ff;}.cls-3{stroke:#fff;stroke-width:1.49px;}</style>
@ -248,8 +291,11 @@ const digitalOceanIcons = {
<path class="cls-3" d="M26.5,19.34v5.25l4.61-2.65V16.7Z" />
<path class="cls-3" d="M18.63,31l4.62,2.64V28.43l-4.6-2.62Z" />
</g>
</g>`, 41.61),
'do:volumes-block-storage': createIcon(`<g>
</g>`,
41.61
),
'do:volumes-block-storage': createIcon(
`<g>
<defs>
<style>.cls-1,.cls-3,.cls-4,.cls-5,.cls-6,.cls-7{fill:none;}.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#0069ff;}.cls-3,.cls-4,.cls-5,.cls-6,.cls-7{stroke:#fff;stroke-width:1.49px;}.cls-3,.cls-4,.cls-5,.cls-6{stroke-linecap:round;}.cls-4{stroke-dasharray:0
3.11;}.cls-5{stroke-dasharray:0 2.94;}.cls-6{stroke-dasharray:0 2.95;}</style>
@ -267,7 +313,9 @@ const digitalOceanIcons = {
<path class="cls-7"
d="M21,21V33.44M21,21.2,11,15m20.11,0L21,21.2m-10.1-6.42V27.17l10,6.22L31,27.17V14.73l-10-6.17Z" />
</g>
</g>`, 41.61),
}
</g>`,
41.61
),
};
export default digitalOceanIcons
export default digitalOceanIcons;

View File

@ -1,7 +1,8 @@
import { createIcon } from "../../svgRegister.js";
import { createIcon } from '../../svgRegister.js';
const githubIcons = {
"gh:action": createIcon(`<g>
'gh:action': createIcon(
`<g>
<path d="M46.62.3c23.51,2.97,39.85,24.77,36.41,48.15-3.04,18.63-19.42,34.09-38.47,34.89-2.09-.07-2.23,1.19-1.34,3.21,3.19,9.13,13.37,14.89,22.82,13.27.55-.09,1.02-.48,1.21-1,.05-.14.1-.3.13-.46.58-2.8,1.67-5.54,3.04-8.07,13.28-23.34,47.81-18.65,53.98,7.57.23,1.5,1.13,2.27,2.52,2.22,4.21.01,8.46,0,12.72,0,2.24.2,2.74-1.22,3.06-3.18.01-.07.03-.14.04-.2,3.26-11.55,14-20.72,26.11-21.53,15.8-1.4,30.54,11.69,31.32,27.5,1.12,23.22-23.72,38.33-43.92,26.85-6.53-3.98-12-11.09-13.56-18.62-.17-.77-.35-1.65-1.02-2.1-.14-.09-.31-.15-.47-.19-2.48-.57-5.2-.08-7.73-.23-2.53.16-5.21-.34-7.66.23-.16.04-.33.09-.47.19-.58.4-.78,1.14-.91,1.82-.3,2.05-1.09,4.03-1.95,5.94-12.63,25.63-49.17,20.91-55.28-6.89-.04-.2-.11-.4-.24-.55-.43-.54-1.08-.72-1.84-.76-7.29.43-14.77-1.31-20.49-6.1,0,0-.01,0-.02-.01-1.06-.63-2.41,0-2.47,1.23-.61,12.63-.33,23.57-.18,36.22s10.41,26.21,22.99,27.03c1.25.15,2.22-.37,2.48-1.7,8.11-33.08,54.11-29.65,57.79,4.14,1.2,17.3-14.66,32.64-31.85,30.93-12.42-1.1-23.31-10.88-25.89-23.1-.21-1.05-.98-1.78-2.06-1.83-19.33-.73-32.03-16.21-32.03-35.45,0-.04,0-3.67,0-3.71-.06-17.49-.02-33.52-.02-50.98.27-2.06-1.33-2.74-3.05-3.06C10.77,76.56-2.44,56.23.38,36.18,3.55,14.18,24.38-2.44,46.62.3ZM41.85,75.27c44.21-2.12,44.37-64.72-.02-66.93-.08,0-.17,0-.25,0-3.69.33-7.43.81-10.96,1.98C-4.29,23.25,4.48,74.43,41.68,75.27c.05,0,.11,0,.17,0ZM75.05,171.2c-.09,13.85,14.54,24.2,27.55,19.6,17.62-6.27,19.43-30.16,2.64-38.57-13.49-6.81-30.67,3.69-30.19,18.97ZM95.82,125.2c16.03.11,25.96-16.9,18.54-30.94-9.48-16.62-34.24-13.51-38.65,5.26-3.3,12.67,7.01,25.63,20.11,25.68ZM171.09,125.19c14.62.2,24.97-15.63,19.18-28.94-6.98-16.77-30.91-17.13-38.28-.53-6.29,13.76,3.91,29.61,19.1,29.47Z" style="fill: #228afe; stroke-width: 0px;"/>
<path d="M167.78,199.97c-12.35-1.36-23-11.04-25.4-23.25-.2-1.05-.9-1.59-1.92-1.59-1.75-.08-3.65.24-5.12-.7-1.86-1.06-2.38-3.51-1.36-5.35,1.26-2.51,4.42-1.98,6.72-2.25,1.71-.19,1.68-2.06,2.04-3.37.67-2.29,1.52-4.67,2.84-6.84,10.46-18.3,36.75-19.95,48.97-2.66,15.1,20.27-1.86,48.47-26.61,46.02l-.16-.03ZM170.33,150.06c-17.86.92-26.76,21.77-14.72,35.12,9.48,9.89,25.18,8.64,32.89-2.69,9.06-14.11-1.07-32.64-17.99-32.43h-.18Z" style="fill: #79b9fe; stroke-width: 0px;"/>
<path d="M33.52,20.07c1.33.07,2.9.44,4.08,1.22,5.34,3.05,10.44,6.45,15.62,9.75,2.96,2.15,6.82,3.53,8.76,6.78,1.35,2.66,1.34,6.21-.33,8.69-3.01,3.94-7.92,5.77-11.91,8.56-3.01,1.8-6.09,3.62-8.95,5.47-2,1.19-4.26,2.93-6.62,2.9-3.05.04-6.36-1.31-7.78-4-1.18-2.06-1.35-4.27-1.24-6.57,0-3.35,0-6.7,0-10.05,0-4.56,0-9.12,0-13.67-.4-4.71,3.69-8.75,8.22-9.07h.15ZM54.58,42.18c-6.35-5-13.46-9.01-20.07-13.33-.28-.17-.83-.49-1.02-.22-.48,8.53-.04,17.15-.16,25.79.04.62.33.8.89.52,6.79-4.13,13.78-8.4,20.36-12.66v-.09Z" style="fill: #228afe; stroke-width: 0px;"/>
@ -9,12 +10,17 @@ const githubIcons = {
<path d="M165.95,115.32c-3.16-.96-4.95-4-7.45-6.2-.66-.71-1.43-1.39-1.85-2.28-.71-2.11-.09-4.52,2.07-5.54,2.51-1.22,4.14.35,5.81,2.09.76.65,1.59,1.81,2.35,1.5,3.09-2.55,5.82-5.72,8.72-8.56,1.5-1.51,3.64-2.72,5.72-1.63,1.55.67,1.99,1.84,2.36,3.2.29,1.28-.44,2.53-1.3,3.43-4.22,4.25-8.49,8.52-12.73,12.76-.9.97-2.21,1.52-3.53,1.26l-.18-.04Z" style="fill: #228afe; stroke-width: 0px;"/>
<circle cx="87.78" cy="170.74" r="5" style="fill: #79b9fe; stroke-width: 0px;"/>
<circle cx="104.28" cy="170.74" r="5" style="fill: #79b9fe; stroke-width: 0px;"/>
</g>`, 200),
"github": createIcon(`<g>
</g>`,
200
),
'gh:github': createIcon(
`<g>
<path fill-rule="evenodd" clip-rule="evenodd"
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
fill="#24292f" />
</g>`, 98)
}
</g>`,
98
),
};
export default githubIcons
export default githubIcons;

View File

@ -20,7 +20,7 @@ const defaultIconLibrary: IconLibrary = {
blank: blank,
...awsCommon,
...digitalOcean,
...github
...github,
};
export default defaultIconLibrary;

View File

@ -6,6 +6,12 @@ type IconResolver = (
) => Selection<SVGGElement, unknown, Element | null, unknown>;
type IconLibrary = Record<string, IconResolver>;
/**
* Converts an SVG Icon passed as a string into a properly formatted IconResolver
* @param icon - html code for the svg icon as a string (the SVG tag should not be included)
* @param originalSize - the original size of the SVG Icon in pixels
* @returns IconResolver
*/
const createIcon: (icon: string, originalSize: number) => IconResolver = (icon, originalSize) => {
return (
parent: Selection<SVGGElement, unknown, Element | null, unknown>,