Skip to content

Commit

Permalink
Merge pull request #22 from oriverk/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
oriverk authored Sep 24, 2024
2 parents 1ff88fd + 5fac7fd commit 7d3d8a5
Show file tree
Hide file tree
Showing 26 changed files with 3,263 additions and 4,202 deletions.
6,495 changes: 2,683 additions & 3,812 deletions package-lock.json

Large diffs are not rendered by default.

62 changes: 33 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"script:feed": "node script/getFeed.mjs",
"script:github": "node -r dotenv/config script/getGitHubUserContent.mjs",
"script:cv": "node -r dotenv/config script/getGitHubRepositoryContent.mjs",
"algolia": "node -r dotenv/config script/algolia.mjs",
"astro": "astro",
"sync": "astro sync",
"dev": "astro dev",
"build": "astro build",
"postbuild": "npx pagefind --site dist",
"preview": "astro preview",
"lint": "run-p lint:*",
"lint:prettier": "biome format ./src",
Expand All @@ -35,64 +35,68 @@
"lint:textlint": "textlint ./src/**/*.{md,mdx}",
"fix": "run-s fix:*",
"fix:prettier": "biome format --write ./src",
"fix:eslint": "biome check --apply ./src",
"fix:eslint": "biome check --write ./src",
"fix:markdownlint": "markdownlint --fix ./src/**/*.{md,mdx}",
"fix:textlint": "textlint --fix ./src/**/*.{md,mdx}",
"prepare": "husky"
},
"dependencies": {
"@astrojs/mdx": "^2.2.0",
"@astrojs/rss": "^4.0.5",
"@astrojs/svelte": "^5.2.0",
"@expressive-code/plugin-line-numbers": "^0.33.5",
"@octokit/graphql": "^8.0.1",
"algoliasearch": "^4.22.1",
"astro": "^4.5.5",
"astro-expressive-code": "^0.33.5",
"clsx": "^2.1.0",
"date-fns": "^3.6.0",
"@astrojs/mdx": "^3.1.6",
"@astrojs/rss": "^4.0.7",
"@astrojs/svelte": "^5.7.0",
"@expressive-code/plugin-line-numbers": "^0.36.1",
"@octokit/graphql": "^8.1.1",
"astro": "^4.15.5",
"astro-expressive-code": "^0.36.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"dotenv": "^16.4.5",
"fetch-site-metadata": "^0.2.0",
"gray-matter": "^4.0.3",
"hast": "^1.0.0",
"html-to-image": "^1.11.11",
"mdast": "^3.0.0",
"pagefind": "^1.1.1",
"remark": "^15.0.1",
"remark-comment": "^1.0.0",
"remark-github-alerts": "^0.1.0-beta.3",
"rss-parser": "^3.13.0",
"satori": "^0.10.13",
"sharp": "^0.33.3",
"satori": "^0.11.0",
"sharp": "^0.33.5",
"strip-markdown": "^6.0.0",
"svelte": "^4.2.12",
"unified": "^11.0.4",
"unist-util-inspect": "^8.0.0",
"svelte": "^5.0.0-next.247",
"unified": "^11.0.5",
"unist-util-inspect": "^8.1.0",
"unist-util-is": "^6.0.0",
"unist-util-visit": "^5.0.0",
"url-join": "^5.0.0"
},
"devDependencies": {
"@biomejs/biome": "1.6.1",
"@commitlint/cli": "^19.2.0",
"@commitlint/config-conventional": "^19.1.0",
"@octokit/graphql-schema": "^15.3.0",
"@biomejs/biome": "1.9.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@octokit/graphql-schema": "^15.25.0",
"@proofdict/textlint-rule-proofdict": "^3.1.2",
"@textlint/textlint-plugin-markdown": "^14.0.4",
"@textlint/textlint-plugin-markdown": "^14.2.0",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.28",
"@types/node": "^22.5.5",
"fs-extra": "^11.2.0",
"husky": "^9.0.11",
"markdownlint-cli": "^0.39.0",
"npm-run-all2": "^6.1.2",
"textlint": "^14.0.4",
"husky": "^9.1.6",
"markdownlint-cli": "^0.41.0",
"npm-run-all2": "^6.2.3",
"textlint": "^14.2.0",
"textlint-filter-rule-allowlist": "^4.0.0",
"textlint-plugin-latex2e": "^1.2.1",
"textlint-rule-aws-service-name": "^1.7.0",
"textlint-rule-aws-service-name": "^1.11.0",
"textlint-rule-ja-no-abusage": "^3.0.0",
"textlint-rule-ja-no-inappropriate-words": "^2.0.0",
"textlint-rule-no-kangxi-radicals": "^0.2.2",
"textlint-rule-period-in-list-item": "^1.0.1",
"textlint-rule-preset-ja-spacing": "^2.3.1",
"textlint-rule-preset-ja-spacing": "^2.4.3",
"textlint-rule-preset-ja-technical-writing": "^10.0.1",
"ts-node": "^10.9.2"
},
"overrides": {
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6"
}
}
103 changes: 0 additions & 103 deletions script/algolia.mjs

This file was deleted.

7 changes: 7 additions & 0 deletions src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ const { github, zenn, x } = siteConfig;
<Icon type="zenn" size="medium" />
<span class="sr-only">Zenn.dev link</span>
</a>
<a
href="/icon"
title="My Icon Generator"
>
<Icon type="oriver" size="medium" />
<span class="sr-only">My Icon Generator link</span>
</a>
</div>
</div>

Expand Down
170 changes: 170 additions & 0 deletions src/components/IconGenerator.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<script lang="ts">
// @ts-ignore
import { toJpeg, toPng, toSvg } from "html-to-image";
let obj = $state({
type: "png",
size: 300,
padding: 50,
opacity: 1,
bgColor: "transparent",
iconColor: "",
radius: "30% 70% 59% 41% / 30% 26% 74% 70%",
});
function handleOnChange(event: Event) {
const target = event.target as HTMLInputElement;
const { name, value } = target;
// @ts-ignore
obj[name] = value;
}
async function handleOnClick() {
const target = document.getElementById("target");
if(!target) return;
const dest = document.getElementById("dest");
dest?.querySelector("img")?.remove();
const options = {
pixelRatio: 1,
};
try {
let dataUrl = "";
switch (obj.type) {
case "jpeg":
dataUrl = await toJpeg(target, options);
break;
case "svg":
dataUrl = await toSvg(target, options);
break;
default:
dataUrl = await toPng(target, options);
break;
}
const img = new Image();
img.src = dataUrl;
dest?.appendChild(img);
} catch (error) {
console.error("oops, something went wrong!", error);
}
}
</script>

<div class="forms">
<dl>
<dt>
<label for="size">icon-size: {obj.size}</label>
</dt>
<dd>
<input type="range" name="size" min="100" max="500" step="10" bind:value={obj.size} onchange={handleOnChange} />
</dd>
<dt>
<label for="padding">padding: {obj.padding}</label>
</dt>
<dd>
<input type="range" name="padding" min="0" max="100" step="10" bind:value={obj.padding} onchange={handleOnChange} />
</dd>

<dt>
<label for="opacity">opacity {obj.opacity}</label>
</dt>
<dd>
<input type="range" name="opacity" min="0" max="1" step="0.1" bind:value={obj.opacity} onchange={handleOnChange} />
</dd>
<dt>
<label for="radius">icon-radius: {obj.radius}</label>
</dt>
<dd>
<input type="text" name="radius" id="" bind:value={obj.radius} onchange={handleOnChange} placeholder="50%">
</dd>
<dt>
<label for="bg-color">background color: {obj.bgColor}</label>
</dt>
<dd>
<input type="color" name="bgColor" bind:value={obj.bgColor} onchange={handleOnChange} />
</dd>
<dt>
<label for="icon-color">icon color: {obj.iconColor || "favorite gradient color"}</label>
</dt>
<dd>
<input type="color" name="icon-color" bind:value={obj.iconColor} onchange={handleOnChange} />
</dd>
<dt>
<label for="img-type">img extension: {obj.type}</label>
</dt>
<dd>
<select name="img-type" bind:value={obj.type} onchange={handleOnChange}>
<option value="png">PNG</option>
<option value="jpeg">JPEG</option>
<option value="svg">SVG</option>
</select>
</dd>
</dl>
<button type="button" onclick={handleOnClick}>Convert to Image / SVG</button>
<button type="button" onclick={() => location.reload()}>Reset</button>
</div>
<div class='target-container'>
<div id='target' style={`--size: ${obj.size}px;--padding: ${obj.padding}px;--opacity: ${obj.opacity};--bg-color: ${obj.bgColor};`}>
<div class='content' class:miku-gradient={!obj.iconColor} style={`--icon-color: ${obj.iconColor};--icon-radius: ${obj.radius};`}></div>
</div>
</div>
<div id='dest'></div>

<style>
dt, dd {
margin-block-end: .5rem;
}
input[type=text], select, option {
color: black;
}
input[type="color"] {
background: none;
}
button {
color: white;
padding-block: .5rem;
padding-inline: 1rem;
border: 1px solid transparent;
border-radius: 0.5rem;
transition: background-color 100ms ease-in;
background-color: rgb(var(--color-hover));
&:hover {
background-color: rgba(0 0 0 / 0.3);
}
}
.forms {
margin-block-end: 1rem;
}
.target-container, #dest:has(> img) {
margin-block: 1rem;
margin-inline-end: .5rem;
border: 1px solid white;
display: inline-block;
}
#target {
display: inline-block;
padding: var(--padding);
background-color: var(--bg-color);
& > .content {
aspect-ratio: 1 / 1;
opacity: var(--opacity);
width: var(--size);
border-radius: var(--icon-radius);
background-color: var(--icon-color);
&.miku-gradient {
background: var(--accent-gradient);
}
}
}
</style>
Loading

0 comments on commit 7d3d8a5

Please sign in to comment.