Skip to content

Commit e8db38d

Browse files
committed
feat(content-diagram): add diagram max-width
1 parent c34b35d commit e8db38d

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

components/content/content-diagram.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</div>
2020
<div
2121
v-else-if="scheme"
22+
:style="diagramStyle"
2223
class="diagram__content"
2324
role="button"
2425
tabindex="0"
@@ -33,9 +34,12 @@
3334
<script setup lang="ts">
3435
interface ContentSchemeProperties {
3536
src: string;
37+
maxWidth?: string;
3638
}
3739
38-
const properties = defineProps<ContentSchemeProperties>();
40+
const properties = withDefaults(defineProps<ContentSchemeProperties>(), {
41+
maxWidth: "100%",
42+
});
3943
const requestURL = useRequestURL();
4044
const diagramZoom = useDiagramZoom();
4145
@@ -60,6 +64,12 @@ const showZoomPreview = (event: PointerEvent) => {
6064
6165
diagramZoom.show(scheme.value!);
6266
};
67+
68+
const diagramStyle = computed(() => {
69+
return {
70+
maxWidth: properties.maxWidth,
71+
};
72+
});
6373
</script>
6474

6575
<style scoped lang="scss">
@@ -87,10 +97,14 @@ const showZoomPreview = (event: PointerEvent) => {
8797
height: fit-content;
8898
}
8999
90-
&__content:deep(svg) {
91-
width: 100%;
92-
height: fit-content;
93-
font-family: "Virgil", 'Montserrat Variable', -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
100+
&__content {
101+
margin: 0 auto;
102+
103+
&:deep(svg) {
104+
width: 100%;
105+
height: fit-content;
106+
font-family: "Virgil", 'Montserrat Variable', -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
107+
}
94108
}
95109
}
96110

content/posts/js-bit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ console.log(0b1000 & 0b1100) // 1000 => 8
6161
console.log(0b1111 & 0b1111) // 1111 => 1 + 2 + 4 + 8 => 15
6262
```
6363

64-
::ContentDiagram{src="/posts/js-bit/js-bit-2.svg"}
64+
::ContentDiagram{src="/posts/js-bit/js-bit-2.svg" max-width="400px"}
6565
::
6666

6767
## «Битовый ИЛИ»: `|`
@@ -72,7 +72,7 @@ console.log(0b1000 | 0b1100) // 1100 => 12
7272
console.log(0b1111 | 0b1111) // 1111 => 1 + 2 + 4 + 8 => 15
7373
```
7474

75-
::ContentDiagram{src="/posts/js-bit/js-bit-3.svg"}
75+
::ContentDiagram{src="/posts/js-bit/js-bit-3.svg" max-width="400px"}
7676
::
7777

7878
## «Битовый НЕ»: `~`

0 commit comments

Comments
 (0)