Skip to content

Commit 6d94a4c

Browse files
committed
feat: add scale prop to svg element filter & refactor all SVG file usage
1 parent ebd406e commit 6d94a4c

File tree

9 files changed

+33
-11
lines changed

9 files changed

+33
-11
lines changed

components/SvgElementFilter.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const props = defineProps<{
1010
1111
// A string or array of strings representing CSS classes to be applied to the generated inner SVG element.
1212
svgClass?: string | string[]
13+
14+
// An optional scale factor to apply to the SVG. This can be used to resize the SVG.
15+
scale?: number
1316
}>()
1417
1518
const svgContainer = ref(null)
@@ -37,6 +40,9 @@ function processAndFilterSvg() {
3740
// Create a new SVG element to house the filtered children
3841
const newSvgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
3942
43+
const scaleFactor = props.scale || 1
44+
newSvgElement.setAttribute('transform', `scale(${scaleFactor})`)
45+
4046
// Copy attributes from the original SVG to the new one (e.g., viewBox, width, height)
4147
Array.from(svgElement.attributes).forEach((attr) => {
4248
newSvgElement.setAttribute(attr.name, attr.value)

components/SvgWrapper/ClientSideAndServerSideSvg.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { computed } from 'vue'
44
import SvgElementFilter from '../SvgElementFilter.vue'
55
import mySvgContent from '/assets/excalidraw-drawings/client-side-and-server-side_light.svg?raw'
66
7+
const prop = defineProps<{
8+
scale?: number
9+
}>()
10+
711
const { clicks } = useNav()
812
913
const elementsToShow = computed<number[] | 'all'>(() => {
@@ -40,7 +44,7 @@ const elementsToShow = computed<number[] | 'all'>(() => {
4044
<template>
4145
<SvgElementFilter
4246
:display-indices="elementsToShow"
43-
svg-class="w-full"
47+
:scale="prop.scale"
4448
:svg-content="mySvgContent"
4549
/>
4650
</template>

components/SvgWrapper/InternetFoundationSvg.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { computed } from 'vue'
44
import SvgElementFilter from '../SvgElementFilter.vue'
55
import mySvgContent from '/assets/excalidraw-drawings/internet-foundation_light.svg?raw'
66
7+
const prop = defineProps<{
8+
scale?: number
9+
}>()
10+
711
const { clicks } = useNav()
812
913
const fonts = [0, 1, 2]
@@ -63,7 +67,7 @@ const elementsToShow = computed<number[] | 'all'>(() => {
6367
<template>
6468
<SvgElementFilter
6569
:display-indices="elementsToShow"
66-
svg-class="w-full"
70+
:scale="prop.scale"
6771
:svg-content="mySvgContent"
6872
/>
6973
</template>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<script setup lang="ts">
22
import SvgElementFilter from '../SvgElementFilter.vue'
33
import mySvgContent from '/assets/excalidraw-drawings/osi-layers_light.svg?raw'
4+
5+
const prop = defineProps<{
6+
scale?: number
7+
}>()
48
</script>
59

610
<template>
711
<SvgElementFilter
812
display-indices="all"
9-
svg-class="w-full"
13+
:scale="prop.scale"
1014
:svg-content="mySvgContent"
1115
/>
1216
</template>

components/SvgWrapper/WhatIsTheWebSvg.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { computed } from 'vue'
44
import SvgElementFilter from '../SvgElementFilter.vue'
55
import mySvgContent from '/assets/excalidraw-drawings/Web-Mindmap_light.svg?raw'
66
7+
const prop = defineProps<{
8+
scale?: number
9+
}>()
10+
711
const { clicks } = useNav()
812
913
const elementsToShow = computed<number[] | 'all'>(() => {
@@ -17,7 +21,7 @@ const elementsToShow = computed<number[] | 'all'>(() => {
1721
<template>
1822
<SvgElementFilter
1923
:display-indices="elementsToShow"
20-
svg-class="w-full"
24+
:scale="prop.scale"
2125
:svg-content="mySvgContent"
2226
/>
2327
</template>

content/client-side-and-server-side.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ layout: basic
44

55
# Client-Side & Server-Side
66

7-
<div class="w-full flex justify-center -mt-20">
8-
<ClientSideAndServerSideSvg class="w-[90%]" />
7+
<div class="w-full h-full flex justify-center items-center -mt-20">
8+
<ClientSideAndServerSideSvg :scale="0.95" />
99
</div>
1010

1111
<!-- dummy only to force the click count on this slide manually -->

content/internet-foundation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ layout: basic
44

55
# Internet Foundation
66

7-
<div class="w-full flex justify-center -mt-27">
8-
<InternetFoundationSvg class="w-full" />
7+
<div class="w-full h-full flex justify-center items-center -mt-18">
8+
<InternetFoundationSvg :scale="0.9" />
99
</div>
1010

1111
<!-- dummy only to force the click count on this slide manually -->

content/osi-layers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ layout: basic
99
</div>
1010

1111
<div class="w-full h-full flex justify-center items-center mt-0">
12-
<OsiLayersSvg class="w-[70%]" />
12+
<OsiLayersSvg :scale="1" />
1313
</div>
1414

1515
<!-- dummy only to force the click count on this slide manually -->

content/what-is-the-web.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ layout: basic
44

55
# What is the Web?
66

7-
<div class="w-full flex justify-center -mt-25">
8-
<WhatIsTheWebSvg class="w-full" />
7+
<div class="w-full h-full flex justify-center items-center -mt-15">
8+
<WhatIsTheWebSvg :scale="0.8" />
99
</div>
1010

1111
<!-- dummy only to force the click count on this slide manually -->

0 commit comments

Comments
 (0)