Skip to content

Commit 81f8f89

Browse files
feat(editor): add code image (#550)
* feat(editor): add code image * feat(ui): add Switch component
1 parent df06fe1 commit 81f8f89

8 files changed

Lines changed: 562 additions & 3 deletions

File tree

src/renderer/components/editor/Editor.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const {
3030
selectedSnippetIds,
3131
isAvailableToCodePreview,
3232
} = useSnippets()
33-
const { isShowMarkdown, isShowMindmap, isShowCodePreview } = useApp()
33+
const { isShowMarkdown, isShowMindmap, isShowCodePreview, isShowCodeImage }
34+
= useApp()
3435
3536
const { addToUpdateContentQueue } = useSnippetUpdate()
3637
@@ -55,6 +56,7 @@ const isShowEditor = computed(() => {
5556
return (
5657
!isShowMarkdown.value
5758
&& !isShowMindmap.value
59+
&& !isShowCodeImage.value
5860
&& !isEmpty.value
5961
&& selectedSnippetIds.value.length === 1
6062
)
@@ -292,6 +294,7 @@ onMounted(() => {
292294
<EditorMarkdown v-if="isShowMarkdown" />
293295
<EditorFooter v-if="isShowEditor" />
294296
<EditorMindmap v-if="isShowMindmap" />
297+
<EditorCodeImage v-if="isShowCodeImage" />
295298
<div
296299
v-if="isEmpty || selectedSnippetIds.length > 1"
297300
class="row-span-full flex items-center justify-center"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts">
2+
import { Check } from 'lucide-vue-next'
3+
4+
type Active = 'disco' | 'salad' | 'cucumber' | 'aqua' | 'lovely'
5+
6+
const active = defineModel<Active>('active', {
7+
required: true,
8+
})
9+
10+
const gradients: { name: Active, class: string }[] = [
11+
{
12+
name: 'disco',
13+
class: 'gradient-disco',
14+
},
15+
{
16+
name: 'aqua',
17+
class: 'gradient-aqua',
18+
},
19+
{
20+
name: 'salad',
21+
class: 'gradient-salad',
22+
},
23+
{
24+
name: 'cucumber',
25+
class: 'gradient-cucumber',
26+
},
27+
{
28+
name: 'lovely',
29+
class: 'gradient-lovely',
30+
},
31+
]
32+
</script>
33+
34+
<template>
35+
<div class="flex items-center gap-2">
36+
<div
37+
v-for="gradient in gradients"
38+
:key="gradient.name"
39+
class="flex h-4 w-4 items-center justify-center rounded-sm"
40+
:class="gradient.class"
41+
@click="active = gradient.name"
42+
>
43+
<Check
44+
v-if="active === gradient.name"
45+
class="h-3 w-3 text-black"
46+
/>
47+
</div>
48+
</div>
49+
</template>

0 commit comments

Comments
 (0)