-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0c9bda
commit 8996e69
Showing
15 changed files
with
1,276 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.vscode | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@vue3-simple-icons/buildtools", | ||
"description": "An example app created with Deno", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "deno run --allow-all src/main.ts --target test", | ||
"build": "deno run --allow-all src/main.ts --target ../src", | ||
"format": "deno run -A npm:@biomejs/biome format src --write", | ||
"lint": "deno run -A npm:@biomejs/biome lint src", | ||
"check": "deno run -A npm:@biomejs/biome check --apply src" | ||
}, | ||
"dependencies": { | ||
"change-case": "^5.3.0", | ||
"n2words": "^1.18.0", | ||
"simple-icons": "^10.4.0" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getIconSlug } from "simple-icons/sdk"; | ||
import { Brand } from "./types.ts"; | ||
const componentScript = await Deno.readTextFile("template.vue"); | ||
import * as changeCase from "change-case"; | ||
import n2words from "n2words"; | ||
|
||
export function buildComponent(iconSVG: string): string { | ||
const result = ` | ||
<template> | ||
${iconSVG.replace( | ||
/<svg([^>]+)>/, | ||
'<svg :width="finalSize" :height="finalSize" role="img" viewBox="0 0 24 24" v-bind="$attrs" >' | ||
)} | ||
</template> | ||
${componentScript}`; | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* If Brand.title is all AlphaNumeric characters and spaces convert to PascalCase | ||
* If Brand.Title is not use Brand slug | ||
* @param icon Brand | ||
* @returns string | ||
* | ||
*/ | ||
export function getComponentName(icon: Brand): string { | ||
if (icon.title.match(/^[a-zA-Z ]+$/)) { | ||
if (icon.slug) { | ||
const slug = changeCase.pascalCase(icon.slug); | ||
console.info("Using slug for component name", slug); | ||
return `${slug}Icon`; | ||
} | ||
const name = changeCase.pascalCase(icon.title); | ||
return `${name}Icon`; | ||
} | ||
let title = getIconSlug(icon); | ||
const beginningNumbers = icon.title.replace(/[^\d].*/, ""); | ||
if (beginningNumbers.length) { | ||
const numberInEnglish = n2words(beginningNumbers, { | ||
lang: "en", | ||
}) | ||
.split(" ") | ||
.filter((word) => word !== "and") | ||
.join("-"); | ||
|
||
const numberSlug = `${numberInEnglish}-`; | ||
title = title.replace(beginningNumbers, numberSlug); | ||
} | ||
const finalTile = changeCase.pascalCase(title); | ||
return `${finalTile}Icon`; | ||
} |
Oops, something went wrong.