Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Icon component #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/f-three.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

First, let's create a scene with `<f-three>` component. Then let's add `<f-three-mesh>` with `geometry` and `material` props.

Use the mouse or pointer to adjust the rotation of the scene.
> <Icon id="tabler:hand-finger" /> Use the mouse or pointer to adjust the rotation of the scene.

```md
<script setup>
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
},
"typings": "./dist/lib.esm.ts",
"scripts": {
"dev": "vite --port 3000 --host -c vite.config.app.ts --open",
"build": "vite build -c vite.config.esm.ts && vite build -c vite.config.cjs.ts && vite build -c vite.config.app.ts && vite build -c vite.config.internal.ts",
"preview": "vite preview --port 5000",
"dev": "vite --open --port 3000 -c vite.config.app.ts",
"build": "vite build -c vite.config.app.ts && vite build -c vite.config.esm.ts && vite build -c vite.config.cjs.ts && vite build -c vite.config.internal.ts",
"test": "vitest",
"typecheck": "vue-tsc --noEmit",
"release": "vitest --run && npm run build && vue-tsc --declaration --emitDeclarationOnly",
Expand All @@ -61,7 +60,7 @@
},
"devDependencies": {
"@babel/types": "^7.17.0",
"@iconify-json/tabler": "^1.1.3",
"@iconify-json/tabler": "^1.1.8",
"@tailwindcss/typography": "^0.5.2",
"@types/d3-shape": "^3.0.2",
"@types/katex": "^0.11.1",
Expand Down
11 changes: 8 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from "vue";
import { createApp, h, shallowRef, watchEffect } from "vue";
import { createRouter, createWebHistory } from "vue-router";

import routes from "virtual:generated-pages";
Expand All @@ -8,7 +8,7 @@ import App from "./App.vue";
import Layout from "./internal/Layout.vue";
import Editor from "./internal/Editor.vue";
import Button from "./internal/Button.vue";
import IconOne from "~icons/tabler/circle-1";
import Icon from "./internal/Icon.vue";

import "./app.css";

Expand All @@ -20,8 +20,13 @@ const router = createRouter({
const app = createApp(App);
app.use(router);
app.use(Fachwerk);

// Used by vue-markdown
app.component("Layout", Layout);

// Used inside markdown documents
app.component("Editor", Editor);
app.component("Button", Button);
app.component("IconOne", IconOne);
app.component("Icon", Icon);

app.mount("#app");
21 changes: 21 additions & 0 deletions src/internal/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const defaultClass = `
prose-a:text-lightblue-700
prose-a:underline
prose-a:underline-offset-2
prose-blockquote:text-gray-600
prose-blockquote:border-l-4
prose-blockquote:border-yellow-400
prose-blockquote:pl-6
Expand Down Expand Up @@ -68,4 +69,24 @@ const mergedClass = computed(() => twMerge(`${defaultClass} ${customClass}`));
.prose button {
@apply text-lightblue-800 inline-block rounded border-2 border-sky-800 px-3 py-1 text-center font-medium hover:bg-black/5;
}
.prose > * > h1:first-child,
.prose > * > h2:first-child,
.prose > * > h3:first-child,
.prose > * > h3:first-child,
.prose > * > h3:first-child,
.prose > * > h3:first-child,
.prose > * > h3:first-child,
.prose > * > h5:first-child,
.prose > * > h6:first-child {
@apply !mt-0;
}

.prose > * > * > h1,
.prose > * > * > h2,
.prose > * > * > h3,
.prose > * > * > h4,
.prose > * > * > h5,
.prose > * > * > h6 {
@apply !mt-0;
}
</style>
26 changes: 26 additions & 0 deletions src/internal/Icon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
import tabler from "@iconify-json/tabler/icons.json";
const icons = { tabler };

type Props = {
id: string;
};
const { id } = defineProps<Props>();
const [collection, name] = id.split(":");
//@ts-ignore
const icon = icons[collection]?.icons[name]?.body;
</script>

<template>
<svg
sstyle="
display: inline-block;
width: 24px;
height: 24px;
vertical-align: -webkit-baseline-middle;
"
class="text-lightgray-600 !inline-block h-5 align-[-webkit-baseline-middle]"
viewBox="0 0 24 24"
v-html="icon"
/>
</template>
1 change: 0 additions & 1 deletion vite.config.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export default defineConfig({
ViteIcons({ autoInstall: true }),
],
build: {
emptyOutDir: false,
outDir: "dist/docs",
},
});