Skip to content

Commit cc0a3c6

Browse files
committed
Add status bar
1 parent d9a048b commit cc0a3c6

6 files changed

Lines changed: 115 additions & 17 deletions

File tree

src/App.vue

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
22
<n-config-provider>
3-
<n-split direction="horizontal" :resize-trigger-size="8" v-model:size="width">
4-
<template #1>
5-
<editor v-model:content="editorStore.content" v-model:selection="editorStore.selection"
6-
v-model:scroll="editorStore.scroll" :icons="iconStore.icons" :size="editorStore.size" />
7-
</template>
8-
<template #2>
9-
<scroller v-model:scroll="editorStore.scroll">
10-
<BSMap :map="ast" :size="editorStore.size" />
11-
</scroller>
12-
</template>
13-
<template #resize-trigger>
14-
<div :class="$style.resizer">
15-
</div>
16-
</template>
17-
</n-split>
3+
<div :class="$style.container">
4+
<n-split :class="$style.main" direction="horizontal" :resize-trigger-size="8" v-model:size="width">
5+
<template #1>
6+
<editor v-model:content="editorStore.content" v-model:selection="editorStore.selection"
7+
v-model:scroll="editorStore.scroll" :icons="iconStore.icons" :size="editorStore.size" />
8+
</template>
9+
<template #2>
10+
<scroller v-model:scroll="editorStore.scroll">
11+
<BSMap :map="ast" :size="editorStore.size" />
12+
</scroller>
13+
</template>
14+
<template #resize-trigger>
15+
<div :class="$style.resizer" />
16+
</template>
17+
</n-split>
18+
<app-bar />
19+
</div>
1820
</n-config-provider>
1921
</template>
2022

@@ -33,6 +35,7 @@ import { useIconStore } from '@/stores/icon';
3335
import Scroller from './components/Scroller.vue';
3436
import BSMap from './components/BSMap.vue';
3537
import Editor from './components/Editor.vue';
38+
import AppBar from './components/AppBar.vue';
3639
3740
const editorStore = useEditorStore();
3841
const iconStore = useIconStore();
@@ -63,6 +66,17 @@ const ast = computed(() => parseMap(editorStore.content));
6366
overscroll-behavior: none;
6467
}
6568
69+
.container {
70+
display: flex;
71+
flex-direction: column;
72+
height: 100vh;
73+
}
74+
75+
.main {
76+
flex: 1 1 auto;
77+
min-height: 0;
78+
}
79+
6680
.resizer {
6781
height: 100%;
6882
background: #cccccc;

src/components/AppBar.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<n-flex align="center" justify="space-between" :class="$style.appBar">
3+
<n-space>
4+
<icon-status />
5+
</n-space>
6+
<n-space>
7+
<size-setter />
8+
</n-space>
9+
</n-flex>
10+
</template>
11+
12+
<script lang="ts" setup>
13+
import {
14+
NFlex,
15+
NSpace,
16+
} from 'naive-ui';
17+
18+
import IconStatus from './AppBar/IconStatus.vue';
19+
import SizeSetter from './AppBar/SizeSetter.vue';
20+
</script>
21+
22+
<style lang="scss" module>
23+
.appBar {
24+
border-top: 1px solid #ddd;
25+
padding: 0 16px;
26+
}
27+
</style>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<n-element :class="$style.status">
3+
<template v-if="loading > 0">
4+
Loading {{ loading }} icons…
5+
</template>
6+
<template v-else>
7+
Ready, {{ ready }} icons loaded.
8+
</template>
9+
</n-element>
10+
</template>
11+
12+
<script lang="ts" setup>
13+
import { NElement } from 'naive-ui';
14+
import { useIconStore } from '@/stores/icon';
15+
import { computed } from 'vue';
16+
17+
const iconStore = useIconStore();
18+
19+
const loading = computed(() => Object.values(iconStore.icons).filter((icon) => icon.status === 'loading').length);
20+
const ready = computed(() => Object.values(iconStore.icons).filter((icon) => icon.status === 'ready').length);
21+
</script>
22+
23+
<style lang="scss" module>
24+
.status {
25+
font-size: var(--font-size-tiny);
26+
color: var(--text-color-1);
27+
}
28+
</style>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<n-popover trigger="click">
3+
<template #trigger>
4+
<n-button quaternary size="tiny">Size: {{ editorStore.size }}</n-button>
5+
</template>
6+
<div :class="$style.setter">
7+
<n-slider v-model:value="editorStore.size" :min="20" :max="60" />
8+
</div>
9+
</n-popover>
10+
</template>
11+
12+
<script lang="ts" setup>
13+
import {
14+
NButton,
15+
NPopover,
16+
NSlider,
17+
} from 'naive-ui';
18+
19+
import { useEditorStore } from '@/stores/editor';
20+
21+
const editorStore = useEditorStore();
22+
</script>
23+
24+
<style lang="scss" module>
25+
.setter {
26+
width: 200px;
27+
padding: 8px var(--n-option-prefix-width);
28+
}
29+
</style>

src/components/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div ref="holder" :style="{
33
width: `100%`,
4-
height: `100vh`,
4+
height: `100%`,
55
lineHeight: `${size}px`,
66
}" />
77
</template>

src/components/Scroller.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function onScroll(): void {
3333

3434
<style lang="scss" module>
3535
.scroller {
36-
height: 100vh;
36+
height: 100%;
3737
overflow-y: scroll;
3838
overflow-x: hidden;
3939
background: #f9f9f9;

0 commit comments

Comments
 (0)