Skip to content

Commit 73064bf

Browse files
authored
Firefoxにコントリビューションして得られた学び (#450)
* Add firefox-contribution package with initial configuration and styles * slidevjs/slidev#2413 の問題を回避するために一時的にtwoslash-vueのバージョンを固定 * 雛形作成 * レイアウト調整など * QRCodeコンポーネントを新規作成し、QRコード生成機能を追加 * wip * スクリーンショットを追加 * スクリーンショットの貼り付け * WPTのスクショ追加 * タイトルテンプレートの引用符を修正し、prettier-ignoreコメントを追加 * 最後のまとめを書く * スライドのセクションタイトルを改善し、CSSスタイルを追加 * Add section on CSS Engine to slides.md with accompanying image * wip * wip * wip * wip * Add comment for inline code styling in layout.css * wip * Add styling for horizontal rules in layout.css * wip * wip * wip * wip * wip * wip * fix lint error * todo * wip * wip * wip * wip * wip * wip * wip * update slidev * wip * wip * wip * wip * wip * wip * wip * 一旦完成 * wip * wip * wip
1 parent 0519d76 commit 73064bf

36 files changed

Lines changed: 12676 additions & 1935 deletions
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<script setup lang="ts">
2+
import { computed, onMounted, ref } from "vue";
3+
import QRCode from "qrcode";
4+
5+
export type Props = {
6+
text: string;
7+
removeParams?: boolean;
8+
width?: number | undefined;
9+
};
10+
11+
const props = withDefaults(defineProps<Props>(), {
12+
text: "",
13+
removeParams: true,
14+
width: undefined,
15+
});
16+
17+
const canvas = ref<HTMLCanvasElement>();
18+
19+
const removeParams = (text: string) => {
20+
if (!URL.canParse(text)) {
21+
return text;
22+
}
23+
const noParamsURL = text.split("?")[0];
24+
25+
return props.removeParams ? noParamsURL : props.text;
26+
};
27+
28+
const link = computed(() =>
29+
URL.canParse(props.text) ? removeParams(props.text) : undefined,
30+
);
31+
32+
onMounted(() => {
33+
if (!(canvas.value instanceof HTMLCanvasElement)) return;
34+
QRCode.toCanvas(canvas.value, removeParams(props.text) ?? "", {
35+
width: props.width,
36+
});
37+
});
38+
</script>
39+
40+
<template>
41+
<a class="outer" :href="link" target="_blank" rel="noreferrer">
42+
<canvas class="canvas" ref="canvas"></canvas>
43+
</a>
44+
</template>
45+
46+
<style lang="css" scoped>
47+
.outer {
48+
display: block;
49+
width: fit-content;
50+
border: solid 3px;
51+
border-radius: 8px;
52+
overflow: hidden;
53+
color: #333;
54+
55+
&[href]:hover {
56+
opacity: 0.8;
57+
}
58+
}
59+
60+
.canvas {
61+
display: block;
62+
height: inherit;
63+
width: inherit;
64+
}
65+
</style>

firefox-contribution/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@slide/firefox-contribution",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"dev": "slidev",
9+
"export": "slidev export"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "MIT",
14+
"type": "commonjs"
15+
}

0 commit comments

Comments
 (0)