File tree Expand file tree Collapse file tree 5 files changed +151
-5
lines changed Expand file tree Collapse file tree 5 files changed +151
-5
lines changed Original file line number Diff line number Diff line change 2
2
--sidebar-width : 180px ;
3
3
--snippets-list-width : 220px ;
4
4
--snippets-view-header-height : 60px ;
5
+ --snippets-view-header-top-height : 30px ;
5
6
--snippets-view-header-full-height : calc (var (--snippets-view-header-height ) + var (--snippets-tags-height ));
6
7
--snippets-view-footer-height : 30px ;
7
- --snippet-tab- header-height : 40 px ;
8
+ --snippet-header-fragment- height : 25 px ;
8
9
--snippet-tab-height : 30px ;
9
- --title-bar-height : 20 px ;
10
+ --title-bar-height : 15 px ;
10
11
--menu-header : 80px ;
11
12
12
13
--spacing-unit : 4px ;
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div class =" editor" >
2
+ <div
3
+ class =" editor"
4
+ :class =" { 'with-fragments': fragments }"
5
+ >
3
6
<div
4
7
ref =" editorRef"
5
8
class =" main"
@@ -38,6 +41,7 @@ import { languages, oldLanguageMap } from './languages'
38
41
interface Props {
39
42
lang: Language
40
43
theme: string
44
+ fragments: boolean
41
45
modelValue: string
42
46
}
43
47
@@ -48,7 +52,8 @@ interface Emits {
48
52
49
53
const props = withDefaults (defineProps <Props >(), {
50
54
lang: ' typescript' ,
51
- theme: ' google'
55
+ theme: ' google' ,
56
+ fragments: false
52
57
})
53
58
54
59
const emit = defineEmits <Emits >()
@@ -133,8 +138,21 @@ watch(
133
138
134
139
<style lang="scss" scoped>
135
140
.editor {
141
+ padding-top : 4px ;
142
+ & .with-fragments {
143
+ .main {
144
+ height : calc (
145
+ 100vh - var (--title-bar-height ) - var (--snippets-view-header-top-height ) -
146
+ var (--snippets-view-footer-height ) -
147
+ var (--snippet-header-fragment-height )
148
+ );
149
+ }
150
+ }
136
151
.main {
137
- height : calc (100vh - var (--title-bar-height ) - 30px );
152
+ height : calc (
153
+ 100vh - var (--title-bar-height ) - var (--snippets-view-header-top-height ) -
154
+ var (--snippets-view-footer-height )
155
+ );
138
156
}
139
157
.footer {
140
158
height : 30px ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" fragments" >
3
+ <div
4
+ v-for =" (i, index) in snippetStore.fragmentLabels"
5
+ :key =" index"
6
+ class =" item"
7
+ :class =" { 'is-active': index == snippetStore.fragment }"
8
+ @click =" onClickFragment(index)"
9
+ >
10
+ {{ i }}
11
+ </div >
12
+ </div >
13
+ </template >
14
+
15
+ <script setup lang="ts">
16
+ import { useSnippetStore } from ' @/store/snippets'
17
+
18
+ const snippetStore = useSnippetStore ()
19
+
20
+ const onClickFragment = (index : number ) => {
21
+ snippetStore .fragment = index
22
+ }
23
+ </script >
24
+
25
+ <style lang="scss" scoped>
26
+ .fragments {
27
+ display : flex ;
28
+ align-items : center ;
29
+ height : var (--snippet-header-fragment-height );
30
+ .item {
31
+ padding : 0 var (--spacing-xs );
32
+ display : flex ;
33
+ align-items : center ;
34
+ height : var (--snippet-header-fragment-height );
35
+ width : 1000% ;
36
+ border-top : 1px solid var (--color-border );
37
+ border-bottom : 1px solid var (--color-border );
38
+ & .is-active {
39
+ background-color : var (--color-contrast-lower );
40
+ }
41
+ }
42
+ }
43
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" header" >
3
+ <div class =" top" >
4
+ <div class =" name" >
5
+ {{ snippetStore.snippet?.name }}
6
+ </div >
7
+ <div class =" action" >
8
+ <AppActionButton >
9
+ <UniconsArrow />
10
+ </AppActionButton >
11
+ <AppActionButton >
12
+ <UniconsPlus />
13
+ </AppActionButton >
14
+ </div >
15
+ </div >
16
+ <div class =" bottom" >
17
+ <SnippetFragments v-if =" snippetStore.isFragmentsShow" />
18
+ </div >
19
+ </div >
20
+ </template >
21
+
22
+ <script setup lang="ts">
23
+ import { useSnippetStore } from ' @/store/snippets'
24
+
25
+ const snippetStore = useSnippetStore ()
26
+ </script >
27
+
28
+ <style lang="scss" scoped>
29
+ .header {
30
+ .top {
31
+ padding : 0 var (--spacing-xs );
32
+ display : flex ;
33
+ justify-content : space-between ;
34
+ align-items : center ;
35
+ height : var (--snippets-view-header-top-height );
36
+ }
37
+ .name {
38
+ font-size : 16px ;
39
+ }
40
+ .action {
41
+ display : flex ;
42
+ }
43
+ }
44
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" snippets-view" >
3
+ <SnippetHeader />
4
+ <TheEditor
5
+ v-model =" snippet"
6
+ v-model:lang =" lang"
7
+ :fragments =" snippetStore.isFragmentsShow"
8
+ />
9
+ </div >
10
+ </template >
11
+
12
+ <script setup lang="ts">
13
+ import { useSnippetStore } from ' @/store/snippets'
14
+ import { computed } from ' vue'
15
+
16
+ const snippetStore = useSnippetStore ()
17
+
18
+ const snippet = computed ({
19
+ get : () => snippetStore .currentContent || ' ' ,
20
+ set : v => {
21
+ if (! v ) return
22
+ if (snippetStore .currentContent !== v ) {
23
+ snippetStore .patchCurrentSnippetContentByKey (' value' , v )
24
+ }
25
+ }
26
+ })
27
+
28
+ const lang = computed ({
29
+ get : () => snippetStore .currentLanguage || ' plain_text' ,
30
+ set : v => {
31
+ snippetStore .patchCurrentSnippetContentByKey (' language' , v )
32
+ }
33
+ })
34
+ </script >
35
+
36
+ <style lang="scss" scoped>
37
+ .snippets-view {
38
+ padding-top : var (--title-bar-height );
39
+ }
40
+ </style >
You can’t perform that action at this time.
0 commit comments