first commit
This commit is contained in:
6
src/composables/breakpoints.ts
Normal file
6
src/composables/breakpoints.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
|
||||
|
||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||
|
||||
export const isMobile = breakpoints.smallerOrEqual("md")
|
||||
export const isDesktop = breakpoints.greater("md")
|
||||
35
src/composables/code.ts
Normal file
35
src/composables/code.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ref } from "vue"
|
||||
import copyTextToClipboard from "copy-text-to-clipboard"
|
||||
import { Code } from "../types"
|
||||
import { sources } from "../templates"
|
||||
import { submit } from "../api"
|
||||
|
||||
export const code = ref<Code>({
|
||||
value: sources["python"],
|
||||
language: "python",
|
||||
})
|
||||
export const input = ref("")
|
||||
export const output = ref("")
|
||||
export const loading = ref(false)
|
||||
|
||||
export function copy() {
|
||||
copyTextToClipboard(code.value.value)
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
code.value.value = sources["python"]
|
||||
output.value = ""
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
loading.value = true
|
||||
const cleanCode = code.value.value.trim()
|
||||
if (!cleanCode) return
|
||||
output.value = ""
|
||||
const result = await submit(
|
||||
{ value: cleanCode, language: code.value.language },
|
||||
input.value.trim(),
|
||||
)
|
||||
output.value = result.output || ""
|
||||
loading.value = false
|
||||
}
|
||||
Reference in New Issue
Block a user