Skip to content

Commit c49572c

Browse files
Refresh the UI for the dashboard layout (#296)
2 parents 8fda1b5 + 15a83fa commit c49572c

File tree

21 files changed

+531
-412
lines changed

21 files changed

+531
-412
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ jobs:
4545
runs-on: ubuntu-latest
4646
steps:
4747
- name: Checkout the repository
48-
uses: actions/checkout@v3
48+
uses: actions/checkout@v4
4949
- name: Install Node
50-
uses: actions/setup-node@v3
50+
uses: actions/setup-node@v4
5151
with:
5252
node-version: 18
5353
- name: Install pnpm
54-
uses: pnpm/action-setup@v2
54+
uses: pnpm/action-setup@v4
5555
with:
56-
version: 8
5756
run_install: false
5857
- name: Get pnpm store directory
5958
shell: bash
@@ -75,15 +74,14 @@ jobs:
7574
runs-on: ubuntu-latest
7675
steps:
7776
- name: Checkout the repository
78-
uses: actions/checkout@v3
77+
uses: actions/checkout@v4
7978
- name: Install Node
80-
uses: actions/setup-node@v3
79+
uses: actions/setup-node@v4
8180
with:
8281
node-version: 18
8382
- name: Install pnpm
84-
uses: pnpm/action-setup@v2
83+
uses: pnpm/action-setup@v4
8584
with:
86-
version: 8
8785
run_install: false
8886
- name: Get pnpm store directory
8987
shell: bash
@@ -109,15 +107,14 @@ jobs:
109107
runs-on: ubuntu-latest
110108
steps:
111109
- name: Checkout the repository
112-
uses: actions/checkout@v3
110+
uses: actions/checkout@v4
113111
- name: Install Node
114-
uses: actions/setup-node@v3
112+
uses: actions/setup-node@v4
115113
with:
116114
node-version: 18
117115
- name: Install pnpm
118-
uses: pnpm/action-setup@v2
116+
uses: pnpm/action-setup@v4
119117
with:
120-
version: 8
121118
run_install: false
122119
- name: Get pnpm store directory
123120
shell: bash
@@ -158,15 +155,14 @@ jobs:
158155
runs-on: ubuntu-latest
159156
steps:
160157
- name: Checkout the repository
161-
uses: actions/checkout@v3
158+
uses: actions/checkout@v4
162159
- name: Install Node
163-
uses: actions/setup-node@v3
160+
uses: actions/setup-node@v4
164161
with:
165162
node-version: 18
166163
- name: Install pnpm
167-
uses: pnpm/action-setup@v2
164+
uses: pnpm/action-setup@v4
168165
with:
169-
version: 8
170166
run_install: false
171167
- name: Get pnpm store directory
172168
shell: bash
@@ -196,15 +192,14 @@ jobs:
196192
runs-on: ubuntu-latest
197193
steps:
198194
- name: Checkout the repository
199-
uses: actions/checkout@v3
195+
uses: actions/checkout@v4
200196
- name: Install Node
201-
uses: actions/setup-node@v3
197+
uses: actions/setup-node@v4
202198
with:
203199
node-version: 18
204200
- name: Install pnpm
205-
uses: pnpm/action-setup@v2
201+
uses: pnpm/action-setup@v4
206202
with:
207-
version: 8
208203
run_install: false
209204
- name: Get pnpm store directory
210205
shell: bash
@@ -228,15 +223,14 @@ jobs:
228223
runs-on: ubuntu-latest
229224
steps:
230225
- name: Checkout the repository
231-
uses: actions/checkout@v3
226+
uses: actions/checkout@v4
232227
- name: Install Node
233-
uses: actions/setup-node@v3
228+
uses: actions/setup-node@v4
234229
with:
235230
node-version: 18
236231
- name: Install pnpm
237-
uses: pnpm/action-setup@v2
232+
uses: pnpm/action-setup@v4
238233
with:
239-
version: 8
240234
run_install: false
241235
- name: Get pnpm store directory
242236
shell: bash

app.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,11 @@ svg {
123123
flex-direction: column;
124124
flex-grow: 1;
125125
}
126+
127+
.os-scrollbar {
128+
/* https://kingsora.github.io/OverlayScrollbars/#:~:text=to%20read%20it.-,Styling,-OverlayScrollbars%20comes%20with */
129+
--os-handle-bg: rgb(var(--layer-bg-hover));
130+
--os-handle-bg-hover: rgb(var(--layer-bg-hover));
131+
--os-handle-bg-active: rgb(var(--layer-bg-hover));
132+
}
126133
</style>

assets/css/tailwind.css

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,22 @@
8686
}
8787

8888
.light {
89-
--layer-0-bg: 255 255 255;
90-
--layer-0-bg-hover: 244 244 245;
91-
--layer-0-bg-active: 255 255 255;
92-
--layer-0-bg-disabled: 253 253 253;
89+
--layer-0-bg: 244 244 245;
90+
--layer-0-bg-hover: 228 228 231;
91+
--layer-0-bg-active: 228 228 231;
92+
--layer-0-bg-disabled: 242 242 243;
9393
--layer-0-border: var(--layer-0-bg-hover);
9494
--layer-0-text: 24 24 27;
9595
--layer-0-text-hover: 24 24 27;
9696
--layer-0-text-active: 24 24 27;
9797
--layer-0-text-disabled: 113 113 122;
9898
--layer-0-text-muted: 113 113 122;
9999

100-
--layer-1-bg: 244 244 245;
101-
--layer-1-bg-hover: 228 228 231;
102-
--layer-1-bg-active: 228 228 231;
103-
--layer-1-bg-disabled: 242 242 243;
104-
--layer-1-border: var(--layer-1-bg-hover);
100+
--layer-1-bg: 255 255 255;
101+
--layer-1-bg-hover: 244 244 245;
102+
--layer-1-bg-active: 255 255 255;
103+
--layer-1-bg-disabled: 253 253 253;
104+
--layer-1-border: var(--layer-0-bg-hover);
105105
--layer-1-text: 24 24 27;
106106
--layer-1-text-hover: 24 24 27;
107107
--layer-1-text-active: 24 24 27;
@@ -302,27 +302,27 @@
302302
}
303303

304304
.button {
305-
@apply inline-flex items-center rounded cursor-pointer focus:outline-none focus:ring focus-within:ring;
305+
@apply inline-flex items-center rounded cursor-pointer focus-visible:outline-none focus-visible:ring has-[:focus-visible]:ring;
306306
}
307307

308308
.core-button {
309309
@apply core-button-shape;
310310
@apply cursor-pointer;
311311
@apply outline-none;
312-
@apply focus:ring focus-within:ring;
312+
@apply focus-visible:ring has-[:focus-visible]:ring;
313313
@apply bg-layer;
314314
@apply disabled:bg-layer-disabled ui-disabled:bg-layer-disabled;
315315
@apply disabled:text-layer-disabled ui-disabled:text-layer-disabled;
316316
@apply disabled:hover:bg-layer-disabled;
317-
@apply disabled:cursor-not-allowed ui-disabled:cursor-not-allowed disabled-within:cursor-not-allowed;
317+
@apply disabled:cursor-default ui-disabled:cursor-default disabled-within:cursor-default;
318318
@apply disabled-within:bg-layer-disabled disabled-within:text-layer-disabled;
319319
@apply disabled-within:hover:bg-layer-disabled disabled-within:hover:text-layer-disabled;
320320
@apply hover:bg-layer-hover ui-active:bg-layer-hover;
321321
@apply whitespace-nowrap;
322322
}
323323

324324
.core-button-shape {
325-
@apply p-2 rounded inline-flex gap-3 items-center justify-center;
325+
@apply px-2 py-1 rounded inline-flex gap-2 items-center justify-center;
326326
}
327327

328328
/* utils */
@@ -373,6 +373,36 @@
373373
}
374374

375375
.sidebar-link {
376-
@apply flex items-center justify-between rounded p-2 hover:bg-layer-hover focus:outline-none focus:ring;
376+
@apply flex items-center justify-between rounded px-2 py-1 hover:bg-layer-hover focus-visible:outline-none focus-visible:ring;
377+
}
378+
}
379+
380+
@layer utilities {
381+
.flex-direction-inherit {
382+
flex-direction: inherit;
383+
}
384+
385+
.flex-inherit {
386+
align-items: inherit;
387+
flex-direction: inherit;
388+
flex-wrap: inherit;
389+
gap: inherit;
390+
justify-content: inherit;
391+
}
392+
393+
.flex-wrap-inherit {
394+
flex-wrap: inherit;
395+
}
396+
397+
.gap-inherit {
398+
gap: inherit;
399+
}
400+
401+
.items-inherit {
402+
align-items: inherit;
403+
}
404+
405+
.justify-inherit {
406+
justify-content: inherit;
377407
}
378408
}

components/CoreEditor.vue

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { type Options } from 'ink-mde'
2+
import { type Instance, type Options } from 'ink-mde'
33
import Ink from 'ink-mde/vue'
44
import { OverlayScrollbars } from 'overlayscrollbars'
55
import { type SystemAppearance } from '#composables/useAppearance'
@@ -37,12 +37,13 @@ export default defineComponent({
3737
const cssMaxWidth = computed(() => `${maxWidthInChars.value}ch`)
3838
const instance = computed(() => ink.value?.instance)
3939
40-
const editorOptions = computed(() => {
40+
const editorOptions = computed<Options>(() => {
4141
return {
4242
...props.options,
4343
interface: {
4444
...props.options?.interface,
4545
appearance: editorAppearance.value,
46+
toolbar: false,
4647
},
4748
}
4849
})
@@ -75,11 +76,35 @@ export default defineComponent({
7576
}
7677
})
7778
79+
const formatSelection = (type: Parameters<Instance['format']>[0]) => {
80+
instance.value?.format(type, {})
81+
}
82+
83+
const handleUpload = async (event: Event) => {
84+
const target = event.target as HTMLInputElement
85+
86+
if (target?.files) {
87+
try {
88+
const url = await props.options?.files?.handler?.(target.files)
89+
90+
if (url) {
91+
const markup = `![](${url})`
92+
93+
instance.value?.insert(markup)
94+
}
95+
} catch (error) {
96+
console.error(error)
97+
}
98+
}
99+
}
100+
78101
return {
79102
cssMaxWidth,
80103
currentLayer,
81104
editorOptions,
82105
focus,
106+
formatSelection,
107+
handleUpload,
83108
ink,
84109
instance,
85110
nextLayer,
@@ -90,14 +115,36 @@ export default defineComponent({
90115
</script>
91116

92117
<template>
93-
<Ink
94-
ref="ink"
95-
:model-value="modelValue"
96-
:options="editorOptions"
97-
class="core-editor flex flex-col flex-grow flex-shrink rounded"
98-
:class="currentLayer.class"
99-
@update:model-value="$emit('update:modelValue', $event)"
100-
/>
118+
<div class="core-editor flex flex-col-reverse lg:flex-col flex-grow flex-shrink min-h-0 rounded">
119+
<template v-if="options?.interface?.toolbar">
120+
<CoreScrollable class="core-editor-scrollable flex-shrink-0 w-full mx-auto">
121+
<CoreEditorToolbar
122+
class="core-editor-toolbar mx-auto px-1 overflow-hidden lg:px-0 py-1 flex-shrink-0 rounded min-w-full"
123+
:upload="options?.toolbar?.upload"
124+
@blockquote="formatSelection('quote')"
125+
@bold="formatSelection('bold')"
126+
@bullet-list="formatSelection('list')"
127+
@code="formatSelection('code')"
128+
@heading="formatSelection('heading')"
129+
@image="formatSelection('image')"
130+
@italic="formatSelection('italic')"
131+
@link="formatSelection('link')"
132+
@number-list="formatSelection('ordered_list')"
133+
@task-list="formatSelection('task_list')"
134+
@upload="handleUpload"
135+
/>
136+
</CoreScrollable>
137+
<CoreDivider />
138+
</template>
139+
<Ink
140+
ref="ink"
141+
:model-value="modelValue"
142+
:options="editorOptions"
143+
class="flex flex-col flex-grow flex-shrink min-h-0 rounded overflow-hidden"
144+
:class="currentLayer.class"
145+
@update:model-value="$emit('update:modelValue', $event)"
146+
/>
147+
</div>
101148
</template>
102149

103150
<style scoped>
@@ -115,9 +162,14 @@ export default defineComponent({
115162
--ink-syntax-hashtag-background-color: rgb(v-bind('nextLayer.bgCssVar'));
116163
--ink-syntax-processing-instruction-color: rgb(v-bind('nextLayer.textCssVar') / 0.1);
117164
165+
.core-editor-scrollable {
166+
max-width: var(--core-editor-max-width-in-chars);
167+
}
168+
118169
:deep(.ink-mde) {
119170
border: none;
120171
border-radius: 0;
172+
padding: 0;
121173
122174
.cm-placeholder {
123175
color: var(--core-editor-text-muted);
@@ -129,7 +181,11 @@ export default defineComponent({
129181
130182
.ink-mde-details {
131183
background-color: transparent;
132-
border-top: 1px solid var(--core-editor-layer-2-bg);
184+
border-top: 1px solid var(--core-editor-divider);
185+
padding: 0.25rem;
186+
}
187+
188+
.ink-mde-editor {
133189
padding: 0.25rem;
134190
}
135191

0 commit comments

Comments
 (0)