Skip to content

Commit 863ca81

Browse files
committed
mobile mode
1 parent dd92b95 commit 863ca81

File tree

8 files changed

+56
-23
lines changed

8 files changed

+56
-23
lines changed

index-dist.html

-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vue SFC Playground</title>
8-
9-
<link rel="preconnect" href="https://fonts.gstatic.com" />
10-
<link
11-
href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap"
12-
rel="stylesheet"
13-
/>
14-
158
<style>
169
body {
1710
margin: 0;

index.html

-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vue SFC Playground</title>
8-
9-
<link rel="preconnect" href="https://fonts.gstatic.com" />
10-
<link
11-
href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap"
12-
rel="stylesheet"
13-
/>
14-
158
<style>
169
body {
1710
margin: 0;

src/Message.vue

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ function formatMessage(err: string | Error): string {
5555
overflow-y: scroll;
5656
}
5757
58+
@media (max-width: 720px) {
59+
.msg {
60+
bottom: 50px;
61+
}
62+
}
63+
5864
.msg.err {
5965
color: red;
6066
border-color: red;

src/Repl.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ provide('store', props.store)
3939
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
4040
color: var(--base);
4141
margin: 0;
42+
overflow: hidden;
4243
background-color: #f8f8f8;
4344
--base: #444;
44-
--font-code: 'Source Code Pro', monospace;
45+
--font-code: Menlo, Monaco, Consolas, "Courier New", monospace;
4546
--color-branding: #3ca877;
4647
--color-branding-dark: #416f9c;
4748
}

src/SplitPane.vue

+41-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { ref, reactive } from 'vue'
33
44
const container = ref()
55
6+
// mobile only
7+
const showOutput = ref(false)
8+
69
const state = reactive({
710
dragging: false,
811
split: 50
@@ -40,7 +43,7 @@ function dragEnd() {
4043
<div
4144
ref="container"
4245
class="split-pane"
43-
:class="{ dragging: state.dragging }"
46+
:class="{ dragging: state.dragging, 'show-output': showOutput }"
4447
@mousemove="dragMove"
4548
@mouseup="dragEnd"
4649
@mouseleave="dragEnd"
@@ -52,13 +55,18 @@ function dragEnd() {
5255
<div class="right" :style="{ width: 100 - boundSplit() + '%' }">
5356
<slot name="right" />
5457
</div>
58+
59+
<button class="toggler" @click="showOutput = !showOutput">
60+
{{ showOutput ? '< Code' : 'Output >' }}
61+
</button>
5562
</div>
5663
</template>
5764

5865
<style scoped>
5966
.split-pane {
6067
display: flex;
6168
height: 100%;
69+
position: relative;
6270
}
6371
.split-pane.dragging {
6472
cursor: ew-resize;
@@ -84,4 +92,36 @@ function dragEnd() {
8492
width: 10px;
8593
cursor: ew-resize;
8694
}
95+
.toggler {
96+
display: none;
97+
z-index: 999;
98+
font-family: var(--font-code);
99+
color: #444;
100+
position: absolute;
101+
left: 50%;
102+
bottom: 20px;
103+
background-color: #fff;
104+
padding: 8px 12px;
105+
border-radius: 8px;
106+
transform: translateX(-50%);
107+
box-shadow: 0 3px 8px rgba(0,0,0,0.25);
108+
}
109+
@media (max-width: 720px) {
110+
.toggler {
111+
display: block;
112+
}
113+
.left,
114+
.right {
115+
width: 100% !important;
116+
}
117+
.right {
118+
display: none;
119+
}
120+
.split-pane.show-output .right {
121+
display: block;
122+
}
123+
.split-pane.show-output .left {
124+
display: none;
125+
}
126+
}
87127
</style>

src/codemirror/CodeMirror.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ onMounted(() => {
6969
}
7070
7171
.CodeMirror {
72-
font-family: 'Source Code Pro', monospace;
72+
font-family: var(--font-code);
73+
line-height: 1.5;
7374
height: 100%;
7475
}
7576
</style>

src/editor/FileSelector.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ function doneAddFile() {
9393
cursor: pointer;
9494
color: #999;
9595
box-sizing: border-box;
96-
height: 34px;
9796
}
9897
.file.active {
9998
color: var(--color-branding);
@@ -120,13 +119,13 @@ function doneAddFile() {
120119
padding-left: 0;
121120
}
122121
.add {
123-
font-size: 20px;
122+
font-size: 18px;
124123
font-family: var(--font-code);
125124
color: #999;
126125
vertical-align: middle;
127126
margin-left: 6px;
128127
position: relative;
129-
top: -2px;
128+
top: -1px;
130129
}
131130
.add:hover {
132131
color: var(--color-branding);

src/output/Preview.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ async function updatePreview() {
184184
</script>
185185

186186
<template>
187-
<div class="preview-container" ref="container"></div>
187+
<div class="vue-repl-preview-container" ref="container"></div>
188188
<Message :err="runtimeError" />
189189
<Message v-if="!runtimeError" :warn="runtimeWarning" />
190190
</template>
191191

192192
<style>
193-
.preview-container,
194-
iframe {
193+
.vue-repl-preview-container,
194+
.vue-repl-preview-container iframe {
195195
width: 100%;
196196
height: 100%;
197197
border: none;

0 commit comments

Comments
 (0)