Skip to content

Commit 734378d

Browse files
authored
Merge pull request #284 from kravetsone/fixes-and-improves
fix light theme bug and improves
2 parents 4cd4cb9 + c995d69 commit 734378d

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

components/midori/community.vue

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
<script setup lang="ts">
2+
import useDark from './use-dark'
3+
4+
const isDark = useDark()
5+
</script>
6+
17
<template>
28
<article
3-
class="flex justify-between flex-col lg:flex-row-reverse items-center w-full max-w-6xl mx-auto my-8 gap-12"
4-
>
9+
class="flex justify-between flex-col lg:flex-row-reverse items-center w-full max-w-6xl mx-auto my-8 gap-12">
510
<section class="flex flex-col w-full max-w-lg">
611
<header class="flex flex-col justify-center items-start">
7-
<h2
8-
class="text-2xl md:text-3xl leading-tight font-medium text-gray-400 mb-2"
9-
>
12+
<h2 class="text-2xl md:text-3xl leading-tight font-medium text-gray-400 mb-2">
1013
Can't find what you're looking for?
1114
</h2>
1215
<h2
13-
class="text-5xl leading-tight font-semibold text-gray-400 mb-4 bg-clip-text text-transparent bg-gradient-to-tl from-fuchsia-500 to-blue-500"
14-
>
16+
class="text-5xl leading-tight font-semibold text-gray-400 mb-4 bg-clip-text text-transparent bg-gradient-to-tl from-fuchsia-500 to-blue-500">
1517
Join the community
1618
</h2>
1719
</header>
@@ -23,14 +25,12 @@
2325
</p>
2426
</section>
2527
<section class="flex flex-col w-full max-w-xl rounded-lg overflow-hidden">
26-
<iframe
27-
class="w-full h-64"
28-
src="https://discord.com/widget?id=1044804142461362206&theme=dark"
29-
allowtransparency="true"
30-
frameborder="0"
31-
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"
32-
loading="lazy"
33-
/>
28+
<iframe class="w-full h-64"
29+
:src="'https://discord.com/widget?id=1044804142461362206&theme=' + (isDark ? 'dark' : 'light')"
30+
allowtransparency="true"
31+
frameborder="0"
32+
loading="lazy"
33+
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts" />
3434
</section>
3535
</article>
3636
</template>

components/midori/editor.vue

+21-20
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ function saveCaretPosition(context) {
4242
}
4343
}
4444
45-
function nextCaretPosition(context) {
46-
const selection = window.getSelection()
47-
const range = selection.getRangeAt(0)
48-
range.setStart(context, 0)
49-
const len = range.toString().length
50-
51-
return function restore() {
52-
const pos = getTextNodeAtPosition(context, len)
53-
selection.removeAllRanges()
54-
55-
const range = new Range()
56-
range.setStart(pos.node, pos.position)
57-
selection.addRange(range)
58-
}
59-
}
45+
// function nextCaretPosition(context) {
46+
// const selection = window.getSelection()
47+
// const range = selection.getRangeAt(0)
48+
// range.setStart(context, 0)
49+
// const len = range.toString().length
50+
51+
// return function restore() {
52+
// const pos = getTextNodeAtPosition(context, len)
53+
// selection.removeAllRanges()
54+
55+
// const range = new Range()
56+
// range.setStart(pos.node, pos.position)
57+
// selection.addRange(range)
58+
// }
59+
// }
6060
6161
function getTextNodeAtPosition(root, index) {
6262
const NODE_TYPE = NodeFilter.SHOW_TEXT
@@ -113,12 +113,12 @@ const execute = async () => {
113113
})
114114
}
115115
116-
watch(isDark, (isDark) => {
116+
watch(isDark, (value) => {
117117
const editor = document.querySelector<HTMLElement>('pre.elysia-editor');
118118
119119
editor.innerHTML = highlighter.codeToHtml(
120120
editor.innerText, {
121-
theme: isDark ? 'github-dark' : 'github-light',
121+
theme: value ? 'github-dark' : 'github-light',
122122
lang: 'javascript',
123123
})
124124
})
@@ -127,7 +127,7 @@ onMounted(() => {
127127
const editor = document.querySelector<HTMLElement>('pre.elysia-editor')
128128
129129
editor.innerHTML = highlighter.codeToHtml(code, {
130-
theme: isDark ? 'github-dark' : 'github-light',
130+
theme: isDark.value ? 'github-dark' : 'github-light',
131131
lang: 'javascript',
132132
})
133133
@@ -136,7 +136,7 @@ onMounted(() => {
136136
137137
editor.innerHTML = highlighter.codeToHtml(
138138
event.currentTarget.innerText, {
139-
theme: isDark ? 'github-dark' : 'github-light',
139+
theme: isDark.value ? 'github-dark' : 'github-light',
140140
lang: 'javascript',
141141
})
142142
@@ -194,7 +194,8 @@ onMounted(() => {
194194
</p>
195195

196196
<aside class="flex flex-col md:flex-row justify-center items-center w-full max-w-6xl gap-8 my-8">
197-
<section class="flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl">
197+
<section
198+
class="flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl">
198199
<div class="mockup-window flex relative w-full h-full shadow-xl">
199200
<pre class="elysia-editor block !bg-transparent !text-base !font-mono rounded-xl w-full max-w-xl h-full !pt-0 !px-2 outline-none"
200201
contenteditable="true">

components/midori/index.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import '../tailwind.css'
1717
import './midori.css'
1818
1919
import BuiltWithLove from './built-with-love.vue'
20-
21-
import useDark from './use-dark'
22-
23-
const isDark = useDark()
2420
</script>
2521

2622
<template>
@@ -53,13 +49,15 @@ const isDark = useDark()
5349
<template v-slot:server>
5450
<slot name="server"></slot>
5551
</template>
52+
5653
<template v-slot:client>
5754
<slot name="client"></slot>
5855
</template>
5956
</E2ETypeSafety>
6057
<Plugins />
6158
<!-- <Suspense>
6259
<Editor />
60+
6361
<template #fallback>
6462
<video muted autoplay loop>
6563
<source src="/assets/elysia.mp4" />

0 commit comments

Comments
 (0)