merge main
@@ -10,9 +10,9 @@
|
||||
<script type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
<link rel="stylesheet" href="build/pyscript.css" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
@@ -22,7 +22,6 @@
|
||||
</py-env>
|
||||
<h1>Bokeh Example</h1>
|
||||
<div id="myplot"></div>
|
||||
<py-repl id="my-repl"></py-repl>
|
||||
|
||||
<py-script>
|
||||
import json
|
||||
@@ -10,9 +10,9 @@
|
||||
<script type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
<link rel="stylesheet" href="build/pyscript.css" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
BIN
pyscriptjs/examples/favicon.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
122
pyscriptjs/examples/handtrack/say_hello.html
Normal file
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../../build/pyscript.css" />
|
||||
|
||||
<script defer src="../../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<py-script>
|
||||
from js import handTrack, setTimeout, requestAnimationFrame
|
||||
from pyodide import create_once_callable
|
||||
import asyncio
|
||||
|
||||
context = canvas.element.getContext("2d")
|
||||
|
||||
isVideo = False
|
||||
model = None
|
||||
|
||||
modelParams = {
|
||||
"flipHorizontal": True, # flip e.g for video
|
||||
"maxNumBoxes": 20, # maximum number of boxes to detect
|
||||
"iouThreshold": 0.5, # ioU threshold for non-max suppression
|
||||
"scoreThreshold": 0.6, # confidence threshold for predictions.
|
||||
}
|
||||
|
||||
def toggle_video(evt):
|
||||
global isVideo
|
||||
if (not isVideo):
|
||||
update_note.write("Starting video")
|
||||
pyscript.run_until_complete(start_video())
|
||||
else:
|
||||
update_note.write("Stopping video")
|
||||
handTrack.stopVideo(video.element)
|
||||
isVideo = False
|
||||
update_note.write("Video stopped")
|
||||
|
||||
async def start_video():
|
||||
global isVideo
|
||||
update_note.write("Inside sstart video")
|
||||
status = await handTrack.startVideo(video.element)
|
||||
console.log("video started", status)
|
||||
if status:
|
||||
update_note.write("Video started. Now tracking")
|
||||
isVideo = True
|
||||
console.log( "Calling RUN DETECTION")
|
||||
y = await run_detection()
|
||||
else:
|
||||
update_note.write( "Please enable video")
|
||||
|
||||
def sync_run_detection(evt):
|
||||
pyscript.run_until_complete(run_detection())
|
||||
|
||||
async def run_detection():
|
||||
console.log("in RUN DETECTION: ");
|
||||
global model
|
||||
global isVideo
|
||||
|
||||
console.log("...1")
|
||||
|
||||
predictions = await model.detect(video.element)
|
||||
console.log("done...1")
|
||||
console.log("Predictions: ", predictions);
|
||||
model.renderPredictions(predictions, canvas.element, context, video.element);
|
||||
console.log("is Video?", isVideo)
|
||||
if (isVideo):
|
||||
console.log("requestingAnimation!")
|
||||
await requestAnimationFrame(create_once_callable(sync_run_detection));
|
||||
console.log("...2")
|
||||
|
||||
def run_detection_image(img):
|
||||
console.log("in RUN DETECTION IMAGE", predictions);
|
||||
global model
|
||||
def detect(predition):
|
||||
console.log("Predictions: ", predictions);
|
||||
model.renderPredictions(predictions, canvas, context, img);
|
||||
console.log("...3")
|
||||
model.detect(img).then(detect)
|
||||
console.log("...4")
|
||||
|
||||
def handle_model(lmodel):
|
||||
global model
|
||||
model = lmodel
|
||||
update_note.write("Loaded Model!")
|
||||
|
||||
async def start():
|
||||
console.log("creating x")
|
||||
console.log("calling x")
|
||||
model = await handTrack.load(modelParams)#.then(handle_model)
|
||||
console.log("loaded model!")
|
||||
console.log(model)
|
||||
handle_model(model)
|
||||
print(dir(x))
|
||||
print(x)
|
||||
|
||||
pyscript.run_until_complete(start())
|
||||
|
||||
#});
|
||||
|
||||
</py-script>
|
||||
|
||||
<div class="mb10">
|
||||
<button id="trackbutton" class="bx--btn bx--btn--secondary" type="button" pys-onClick="toggle_video">
|
||||
Toggle Video
|
||||
</button>
|
||||
<button id="nextimagebutton" class="mt10 bx--btn bx--btn--secondary" type="button" disabled>
|
||||
Next Image
|
||||
</button>
|
||||
<div id="update-note" py-mount class="updatenote mt10">loading model ..</div>
|
||||
</div>
|
||||
<div>
|
||||
<video autoplay="autoplay" id="myvideo" py-mount="video"></video>
|
||||
<canvas id="canvas" py-mount class="border canvasbox"></canvas>
|
||||
</div>
|
||||
<script src="lib/handtrack.min.js"> </script>
|
||||
</html>
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<link rel="stylesheet" href="../../build/pyscript.css" />
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
<script defer src="../../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -140,5 +140,5 @@ pyscript.run_until_complete(start())
|
||||
<video autoplay="autoplay" id="myvideo" py-mount="video"></video>
|
||||
<canvas id="canvas" py-mount class="border canvasbox"></canvas>
|
||||
</div>
|
||||
<script src="../lib/handtrack.min.js"> </script>
|
||||
<script src="../handtrack/lib/handtrack.min.js"> </script>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@@ -6,8 +6,8 @@
|
||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@holoviz/panel@0.13.0-rc.10/dist/panel.min.js"></script>
|
||||
<link rel="stylesheet" href="build/pyscript.css" />
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<py-env>
|
||||
@@ -38,8 +38,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="build/pyscript.css" />
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<py-env>
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="build/bundle.css" />
|
||||
<link rel="stylesheet" href="../build/bundle.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="build/bundle.css" />
|
||||
<link rel="stylesheet" href="../build/bundle.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="build/bundle.css" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="build/bundle.css" />
|
||||
<link rel="stylesheet" href="../build/bundle.css" />
|
||||
|
||||
<script defer src="build/pyscript.js"></script>
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
83
pyscriptjs/examples/todo.html
Normal file
@@ -0,0 +1,83 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>Todo App</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../build/bundle.css" />
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
<py-script>
|
||||
from datetime import datetime as dt
|
||||
|
||||
tasks = []
|
||||
|
||||
# define the task template that will be use to render new templates to the page
|
||||
task_template = Element("task-template").select('.task', from_content=True)
|
||||
task_list = Element("list-tasks-container")
|
||||
new_task_content = Element("new-task-content")
|
||||
|
||||
def add_task(*ags, **kws):
|
||||
# create task
|
||||
task_id = f"task-{len(tasks)}"
|
||||
task = {"id": task_id, "content": new_task_content.element.value, "done": False, "created_at": dt.now()}
|
||||
tasks.append(task)
|
||||
|
||||
# add the task element to the page as new node in the list by cloning from a template
|
||||
taskHtml = task_template.clone(task_id, to=task_list)
|
||||
taskHtmlContent = taskHtml.select('p')
|
||||
taskHtmlContent.element.innerText = task['content']
|
||||
taskHtmlCheck = taskHtml.select('input')
|
||||
task_list.element.appendChild(taskHtml.element)
|
||||
|
||||
def check_task(evt=None):
|
||||
task['done'] = not task['done']
|
||||
if task['done']:
|
||||
taskHtmlContent.element.classList.add("line-through")
|
||||
else:
|
||||
taskHtmlContent.element.classList.remove("line-through")
|
||||
|
||||
new_task_content.clear()
|
||||
taskHtmlCheck.element.onclick = check_task
|
||||
|
||||
def add_task_event(e):
|
||||
console.log("im in")
|
||||
if (e.key == "Enter"):
|
||||
add_task()
|
||||
|
||||
</py-script>
|
||||
|
||||
<main class="max-w-xs mx-auto mt-4">
|
||||
<section>
|
||||
|
||||
<div class="text-center w-full mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-800 uppercase tracking-tight">To Do List</h1>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input id="new-task-content" class="border flex-1 mr-3 border-gray-300 p-2 rounded" type="text">
|
||||
<button id="new-task-btn" class="p-2 text-white bg-blue-600 border border-blue-600 rounded" type="submit" pys-onClick="add_task">
|
||||
Add task
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="list-tasks-container" class="flex flex-col-reverse mt-4">
|
||||
</div>
|
||||
|
||||
<template id="task-template">
|
||||
<section class="task bg-white my-1">
|
||||
<label for="flex items-center p-2 ">
|
||||
<input class="mr-2" type="checkbox" class="task-check">
|
||||
<p class="m-0 inline"></p>
|
||||
</label>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
</section>
|
||||
</main>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -40,7 +40,7 @@ export default {
|
||||
sourcemap: true,
|
||||
format: "iife",
|
||||
name: "app",
|
||||
file: "public/build/pyscript.js",
|
||||
file: "build/pyscript.js",
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
<script lang="ts">
|
||||
|
||||
import Fa from 'svelte-fa';
|
||||
import { faPlusCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
import Tailwind from "./Tailwind.svelte";
|
||||
import { loadInterpreter } from './interpreter';
|
||||
import { pyodideLoaded, loadedEnvironments, navBarOpen, componentsNavOpen, mode, scriptsQueue, initializers, postInitializers } from './stores';
|
||||
import Main from "./Main.svelte";
|
||||
import Header from "./Header.svelte";
|
||||
import SideNav from "./SideNav.svelte";
|
||||
import ComponentsNav from "./ComponentsNav.svelte";
|
||||
import ComponentDetailsNav from "./ComponentDetailsNav.svelte";
|
||||
|
||||
let iconSize = 2;
|
||||
let pyodideReadyPromise
|
||||
@@ -71,43 +64,4 @@
|
||||
<script src="https://cdn.jsdelivr.net/pyodide/v0.19.0/full/pyodide.js" on:load={initializePyodide}></script>
|
||||
</svelte:head>
|
||||
|
||||
<style>
|
||||
:global(div.dev-buttons-group) {
|
||||
margin-top: -15px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
:global(div.output) {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
:global(div.buttons-box) {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
:global(.parentBox:hover .buttons-box) {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<Tailwind />
|
||||
<!--
|
||||
<div class="flex flex-wrap bg-grey-light min-h-screen">
|
||||
<div>
|
||||
<SideNav />
|
||||
</div>
|
||||
<div>
|
||||
<ComponentsNav />
|
||||
</div>
|
||||
<div><ComponentDetailsNav /></div>
|
||||
<div id="main" class="w-full min-h-full absolute pin-r flex flex-col">
|
||||
<Header />
|
||||
<div id="add-component" class="lex flex-column w-full text-lg">
|
||||
<div style="margin-left: 50%;" on:mouseenter={bumpSize} on:mouseleave={downSize} on:click={toggleComponentsNavBar}>
|
||||
<Fa icon={faPlusCircle} class="grow-icon"style="transform: scale({iconSize});"/>
|
||||
</div>
|
||||
</div>
|
||||
<Main />
|
||||
</div>
|
||||
</div> -->
|
||||
@@ -1,89 +0,0 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { mainDiv, componentsNavOpen, componentDetailsNavOpen, currentComponentDetails } from './stores';
|
||||
import Fa from 'svelte-fa';
|
||||
import { faArrowRight, faL } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
let showMe = false;
|
||||
componentDetailsNavOpen.subscribe(value => {
|
||||
showMe = value;
|
||||
|
||||
console.log(showMe);
|
||||
});
|
||||
|
||||
currentComponentDetails.subscribe(value => {
|
||||
|
||||
})
|
||||
|
||||
function toggleNavBar(evt){
|
||||
componentDetailsNavOpen.set(!$componentDetailsNavOpen);
|
||||
if ($componentDetailsNavOpen == true && $componentDetailsNavOpen == $componentsNavOpen ){
|
||||
componentsNavOpen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
function addPyScript(evt){
|
||||
const newPyscript = document.createElement("py-script");
|
||||
newPyscript.setAttribute('auto-generate', null);
|
||||
$mainDiv.appendChild(newPyscript);
|
||||
toggleNavBar(evt);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(div.slow-moves) {
|
||||
transition: 2s;
|
||||
}
|
||||
|
||||
.rightsidebar-inactive {
|
||||
right: -300px;
|
||||
transition: left 2s;
|
||||
}
|
||||
|
||||
.rightsidebar{
|
||||
width: 300px;
|
||||
/* transition: right 2s; */
|
||||
}
|
||||
|
||||
.slide-right{
|
||||
right: 0;
|
||||
transition: right 1s;
|
||||
}
|
||||
|
||||
.properties{
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<nav id="component-detail-bar" class="properties absolute z-10 h-full mb-6 pin-y bg-white shadow-md rightsidebar" class:rightsidebar-inactive="{ !showMe }" class:slide-right="{ showMe }">
|
||||
<div class="flex flex-column w-full text-lg p-4 bg-grey-lighter shadow-md">
|
||||
<button id="menu-switch" class="focus:outline-none" on:click={toggleNavBar}>
|
||||
<Fa icon={faArrowRight} />
|
||||
</button>
|
||||
<div>
|
||||
<h1 class="text-lg p-2 pl-6 bg-grey-lighter border-grey-light border-b text-grey-darkest">Component Details</h1>
|
||||
</div>
|
||||
</div>
|
||||
<form>
|
||||
<table class="table-fixed border-collapse table-auto w-full text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left border-b dark:border-slate-600 font-medium p-4 pl-8 pt-0 pb-3 text-slate-400 dark:text-slate-200 text-left">Property</th>
|
||||
<th class="text-center border-b dark:border-slate-600 font-medium p-4 pl-8 pt-0 pb-3 text-slate-400 dark:text-slate-200 text-left">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{#each $currentComponentDetails as attribute}
|
||||
<tr class="border">
|
||||
<td class="border bg-gray-300">{attribute.key}</td>
|
||||
<td class="border"> <input class="text-center" placeholder={attribute.value} value="{attribute.value}"></td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</nav>
|
||||
@@ -1,89 +0,0 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { mainDiv, componentsNavOpen } from './stores';
|
||||
import Fa from 'svelte-fa';
|
||||
import { faArrowRight } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
let showMe = false;
|
||||
componentsNavOpen.subscribe(value => {
|
||||
showMe = value;
|
||||
|
||||
console.log(showMe);
|
||||
});
|
||||
|
||||
function toggleNavBar(evt){
|
||||
componentsNavOpen.set(!$componentsNavOpen);
|
||||
}
|
||||
|
||||
function addPyScript(evt){
|
||||
const newPyscript = document.createElement("py-script");
|
||||
newPyscript.setAttribute('auto-generate', null);
|
||||
$mainDiv.appendChild(newPyscript);
|
||||
toggleNavBar(evt);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(div.slow-moves) {
|
||||
transition: 2s;
|
||||
}
|
||||
|
||||
.rightsidebar-inactive {
|
||||
right: -250px;
|
||||
transition: left 2s;
|
||||
}
|
||||
|
||||
.rightsidebar{
|
||||
width: 250px;
|
||||
/* transition: right 2s; */
|
||||
}
|
||||
|
||||
.slide-right{
|
||||
right: 0;
|
||||
transition: right 1s;
|
||||
}
|
||||
</style>
|
||||
|
||||
<nav id="rightsidebar" class="absolute z-10 h-full mb-6 pin-y bg-white shadow-md rightsidebar" class:rightsidebar-inactive="{ !showMe }" class:slide-right="{ showMe }">
|
||||
<div class="flex flex-column w-full text-lg p-4 bg-grey-lighter shadow-md">
|
||||
<button id="menu-switch" class="focus:outline-none" on:click={toggleNavBar}>
|
||||
<Fa icon={faArrowRight} />
|
||||
</button>
|
||||
<div>
|
||||
<h1 class="text-lg p-2 pl-6 bg-grey-lighter border-grey-light border-b text-grey-darkest">Components Catalog</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="list-reset">
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-grip-horizontal"></span>
|
||||
REPL
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline" on:click={addPyScript}>
|
||||
<span class="fa fa-newspaper"></span>
|
||||
Script
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-ellipsis-h"></span>
|
||||
Console
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-envelope"></span>
|
||||
Div
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-cogs"></span>
|
||||
Settings
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -1,106 +0,0 @@
|
||||
<script lang="ts">
|
||||
import Fa from 'svelte-fa';
|
||||
import { faCog, faBars, faPlay, faTimes } from '@fortawesome/free-solid-svg-icons'
|
||||
import { pyodideLoaded, loadedEnvironments, navBarOpen } from './stores';
|
||||
|
||||
export let name = "PyScript";
|
||||
|
||||
let showNavBar = false;
|
||||
navBarOpen.subscribe(value => {
|
||||
showNavBar = value;
|
||||
|
||||
console.log(showNavBar);
|
||||
toggleSidebar();
|
||||
});
|
||||
|
||||
function toggleNavBar(evt){
|
||||
navBarOpen.set(!$navBarOpen);
|
||||
}
|
||||
|
||||
|
||||
function toggleSidebar() {
|
||||
let menuSwitch = document.querySelector("#menu-switch"),
|
||||
sidebar = document.querySelector("#sidebar"),
|
||||
main = document.querySelector("#main");
|
||||
|
||||
let classesToApplyForSidebar = {
|
||||
active: [],
|
||||
inactive: ["sidebar-inactive"]
|
||||
},
|
||||
classesToApplyForMain = {
|
||||
active: [], //["sm:w-2/3", "lg:w-3/4"],
|
||||
inactive: []
|
||||
},
|
||||
classesToApplyForMenuButton = {
|
||||
active: ["fa-times-circle", "text-red-light"],
|
||||
inactive: ["fa-bars"]
|
||||
};
|
||||
|
||||
// let isMenuActive = menuSwitch.getAttribute("data-menu-active") === "true";
|
||||
|
||||
if (!menuSwitch){
|
||||
return;
|
||||
}
|
||||
if (!showNavBar) {
|
||||
// menuSwitch.setAttribute("data-menu-active", null);
|
||||
|
||||
menuSwitch.children[0].classList.remove(
|
||||
...classesToApplyForMenuButton.active
|
||||
);
|
||||
menuSwitch.children[0].classList.add(
|
||||
...classesToApplyForMenuButton.inactive
|
||||
);
|
||||
|
||||
sidebar.classList.remove(...classesToApplyForSidebar.active);
|
||||
sidebar.classList.add(...classesToApplyForSidebar.inactive);
|
||||
|
||||
main.classList.remove(...classesToApplyForMain.active);
|
||||
main.classList.add(...classesToApplyForMain.inactive);
|
||||
} else {
|
||||
// menuSwitch.setAttribute("data-menu-active", true);
|
||||
|
||||
menuSwitch.children[0].classList.add(
|
||||
...classesToApplyForMenuButton.active
|
||||
);
|
||||
menuSwitch.children[0].classList.remove(
|
||||
...classesToApplyForMenuButton.inactive
|
||||
);
|
||||
|
||||
sidebar.classList.add(...classesToApplyForSidebar.active);
|
||||
sidebar.classList.remove(...classesToApplyForSidebar.inactive);
|
||||
|
||||
main.classList.add(...classesToApplyForMain.active);
|
||||
main.classList.remove(...classesToApplyForMain.inactive);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(div.main-squeezed) {
|
||||
transform: translateX(33.3333%);
|
||||
}
|
||||
|
||||
:global(.logo-title){
|
||||
font-family: FreeMono, monospace;
|
||||
}
|
||||
</style>
|
||||
|
||||
<aside id="navbar" class="flex flex-column w-full text-lg p-6 bg-grey-lighter shadow-md slow-moves">
|
||||
<button id="menu-switch" class="focus:outline-none" on:click={toggleNavBar}>
|
||||
<div class:hidden={showNavBar}>
|
||||
<Fa icon={faBars} />
|
||||
</div>
|
||||
<div class:hidden={!showNavBar}>
|
||||
<Fa icon={faTimes} color="red" />
|
||||
</div>
|
||||
</button>
|
||||
<p class="w-full logo-title text-center">{name}</p>
|
||||
<div class="flex flex-column">
|
||||
<button class="mr-6">
|
||||
<Fa icon={faPlay} color="black" />
|
||||
</button>
|
||||
<button class="">
|
||||
<Fa icon={faCog} color="black" />
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -1,34 +0,0 @@
|
||||
<script lang="ts">
|
||||
import Fa from 'svelte-fa';
|
||||
import { faWandMagic, faPlusCircle, faInfoCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
import SideNav from "./SideNav.svelte";
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import { mainDiv } from './stores';
|
||||
|
||||
// reference to the main application div
|
||||
let main;
|
||||
onMount(() => {
|
||||
// set the mainDiv in stores to point to the main div, after it has been mounted
|
||||
mainDiv.set(main);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div class="flex content-between flex-wrap min-h-full flex-grow">
|
||||
<main class="w-full p-6" bind:this={main}>
|
||||
<div role="alert" class="w-full p-2 rounded-full bg-teal-light text-teal-darker text-lg">
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="w-full p-6 bg-black text-white flex space-between">
|
||||
<p class="logo-title text-center">PyScript</p>
|
||||
<p class="w-full ml-6 text-center sm:text-left">Copyright © 2022</p>
|
||||
|
||||
<aside class="w-full sm:w-auto text-center sm:text-right">
|
||||
<a href="https://pyscript.com" title="PyScript" class="text-white block">
|
||||
<Fa icon={faInfoCircle} style="transform: scale(2);"/>
|
||||
</a>
|
||||
</aside>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -1,82 +0,0 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { pyodideLoaded, loadedEnvironments, navBarOpen } from './stores';
|
||||
import Fa from 'svelte-fa';
|
||||
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
let showNavBar = false;
|
||||
navBarOpen.subscribe(value => {
|
||||
showNavBar = value;
|
||||
|
||||
console.log(showNavBar);
|
||||
});
|
||||
|
||||
function toggleNavBar(evt){
|
||||
navBarOpen.set(!$navBarOpen);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(div.slow-moves) {
|
||||
transition: 2s;
|
||||
}
|
||||
|
||||
.sidebar-inactive {
|
||||
left: -250px;
|
||||
transition: left 2s;
|
||||
}
|
||||
|
||||
.sidebar{
|
||||
width: 250px;
|
||||
position: -250px
|
||||
/* transition: right 2s; */
|
||||
}
|
||||
|
||||
.slide-right{
|
||||
transition: right 2s;
|
||||
}
|
||||
</style>
|
||||
|
||||
<nav id="sidebar" class="fixed z-10 h-full mb-6 left-0 pin-y bg-white shadow-md sidebar" class:sidebar-inactive="{ !showNavBar }" class:slide-right="{ showNavBar }">
|
||||
<div class="flex flex-column w-full text-lg p-4 bg-grey-lighter shadow-md">
|
||||
<button id="menu-switch" class="focus:outline-none" on:click={toggleNavBar}>
|
||||
<Fa icon={faArrowLeft} />
|
||||
</button>
|
||||
<div>
|
||||
<h1 class="text-lg p-2 pl-6 bg-grey-lighter border-grey-light border-b text-grey-darkest">Components Catalog</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="list-reset">
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-grip-horizontal"></span>
|
||||
Load Template
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-newspaper"></span>
|
||||
Save Project
|
||||
</a>
|
||||
</li>
|
||||
<!-- <li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-ellipsis-h"></span>
|
||||
Console
|
||||
</a>
|
||||
</li>
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-envelope"></span>
|
||||
Div
|
||||
</a>
|
||||
</li> -->
|
||||
<li class="hover:bg-teal">
|
||||
<a href="#" class="block px-6 py-4 w-full text-grey-darkest font-bold hover:text-white text-left text-sm no-underline">
|
||||
<span class="fa fa-cogs"></span>
|
||||
Settings
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -1,7 +1,6 @@
|
||||
// @ts-nocheck
|
||||
// @ts-ignore
|
||||
let pyodideReadyPromise;
|
||||
|
||||
let pyodide;
|
||||
|
||||
let additional_definitions = `
|
||||
@@ -43,9 +42,6 @@ class PyScript:
|
||||
def run_until_complete(f):
|
||||
p = loop.run_until_complete(f)
|
||||
|
||||
pyscript = PyScript()
|
||||
|
||||
|
||||
|
||||
class Element:
|
||||
def __init__(self, element_id, element=None):
|
||||
@@ -97,6 +93,7 @@ class Element:
|
||||
|
||||
return Element(clone.id, clone)
|
||||
|
||||
pyscript = PyScript()
|
||||
`
|
||||
|
||||
let loadInterpreter = async function(): any {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import App from "./App.svelte";
|
||||
|
||||
import {EditorState, EditorView , basicSetup} from "@codemirror/basic-setup"
|
||||
import { python } from "@codemirror/lang-python"
|
||||
import { keymap } from "@codemirror/view";
|
||||
import { defaultKeymap } from "@codemirror/commands";
|
||||
import { oneDarkTheme } from "@codemirror/theme-one-dark";
|
||||
import { PyScript } from "./components/pyscript";
|
||||
import { PyRepl } from "./components/pyrepl";
|
||||
import { PyEnv } from "./components/pyenv"
|
||||
|
||||