Skip to content

Commit

Permalink
Sprig!
Browse files Browse the repository at this point in the history
  • Loading branch information
kognise committed Mar 10, 2023
1 parent eda7ce3 commit 3cc2c5f
Show file tree
Hide file tree
Showing 69 changed files with 3,748 additions and 944 deletions.
7 changes: 6 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import { defineConfig } from 'astro/config'
import preact from '@astrojs/preact'
import vercel from '@astrojs/vercel/serverless'
import prefresh from '@prefresh/vite'
import svelte from '@astrojs/svelte'

export default defineConfig({
integrations: [ preact({ compat: true }) ],
site: 'https://sprig.hackclub.com',
integrations: [
preact({ compat: true }),
svelte()
],
output: 'server',
adapter: vercel(),
vite: {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
},
"dependencies": {
"@astrojs/preact": "^2.0.1",
"@astrojs/svelte": "^2.0.1",
"@astrojs/vercel": "^3.0.0",
"@codemirror/commands": "^6.2.0",
"@codemirror/lang-javascript": "^6.1.2",
"@codemirror/language": "^6.4.0",
"@codemirror/search": "^6.2.3",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.7.3",
"@lezer/common": "^1.0.2",
"@preact/signals": "^1.1.3",
"@sendgrid/mail": "^7.7.0",
"astro": "^2.0.0",
"codemirror": "^6.0.1",
"astro": "^2.0.4",
"debounce": "^1.2.1",
"esprima": "^4.0.1",
"firebase-admin": "^11.5.0",
Expand All @@ -31,12 +32,15 @@
"react": "npm:@preact/compat",
"react-dom": "npm:@preact/compat",
"react-icons": "^4.7.1",
"sass": "^1.58.0",
"svelte": "^3.54.0",
"three": "^0.149.0",
"tinykeys": "^1.4.0"
},
"devDependencies": {
"@prefresh/vite": "^2.2.9",
"@types/debounce": "^1.2.1",
"@types/esprima": "^4.0.3"
"@types/esprima": "^4.0.3",
"@types/three": "^0.149.0"
}
}
Binary file added public/SPRIGDINO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/SPRIGDINO.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/Billy-Bold.otf
Binary file not shown.
Binary file added public/fonts/Billy-Light.otf
Binary file not shown.
Binary file added public/fonts/Billy-Regular.otf
Binary file not shown.
Binary file added public/icons/battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/controls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/dimensions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/processor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/sound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/pcb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/preview.webp
Binary file not shown.
Binary file added public/sprig.glb
Binary file not shown.
Binary file added public/stories-big/develop.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-big/learn.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-big/orpheus.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-big/play.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-big/sprig-back.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-big/sprig-front.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/develop.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/learn.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/orpheus.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/play.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/sprig-back.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/stories-tiny/sprig-front.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions src/components/big-interactive-pages/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Navbar from '../navbar-editor'
import { IoPlayCircleOutline, IoVolumeHighOutline, IoVolumeMuteOutline } from 'react-icons/io5'
import { Signal, useSignal, useSignalEffect } from '@preact/signals'
import { useEffect, useRef } from 'preact/hooks'
import { codeMirror, errorLog, formatError, muted, PersistenceState } from '../../lib/state'
import { codeMirror, errorLog, muted, PersistenceState } from '../../lib/state'
import EditorModal from '../popups-etc/editor-modal'
import { runGame } from '../../lib/engine/3-editor'
import DraftWarningModal from '../popups-etc/draft-warning'
Expand Down Expand Up @@ -56,6 +56,7 @@ export default function Editor({ persistenceState, loggedIn, cookies }: EditorPr
errorLog.value = []

const code = codeMirror.value?.state.doc.toString() ?? ''
console.log(code)
const res = runGame(code, screen.current)

cleanup.current = res.cleanup
Expand Down Expand Up @@ -133,6 +134,7 @@ export default function Editor({ persistenceState, loggedIn, cookies }: EditorPr
? persistenceState.value.game.code
: ''}
onEditorView={(editor) => codeMirror.value = editor}
onRunShortcut={onClickRun}
onCodeChange={() => {
if (persistenceState.value.kind === 'PERSISTED') {
persistenceState.value = {
Expand All @@ -145,10 +147,9 @@ export default function Editor({ persistenceState, loggedIn, cookies }: EditorPr
/>
{errorLog.value.length > 0 && (
<div class={styles.errors}>
{errorLog.value.map((error) => {
const formatted = formatError(error)
return <div key={formatted}>{formatted}</div>
})}
{errorLog.value.map((error) => (
<div key={error.description}>{error.description}</div>
))}
</div>
)}
<Button accent icon={IoPlayCircleOutline} bigIcon iconSide='right' class={styles.playButton} onClick={onClickRun}>
Expand Down
14 changes: 13 additions & 1 deletion src/components/button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@

.button:disabled {
cursor: not-allowed;
opacity: 0.8;
opacity: 0.6;
}

.button.loading {
cursor: wait;
animation: shimmer 2.2s linear infinite forwards;
background-image: linear-gradient(to right, transparent 8%, #ffffffa1 18%, transparent 33%);
background-size: 1200px 100%;
}

.button:not(:disabled):hover {
Expand All @@ -44,4 +47,13 @@

.accent:not(:disabled):hover {
background: var(--accent-dark);
}

@keyframes shimmer {
0% {
background-position: -1200px 0;
}
100% {
background-position: 1200px 0;
}
}
7 changes: 6 additions & 1 deletion src/components/codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface CodeMirrorProps {
class?: string | undefined
initialCode?: string
onCodeChange?: () => void
onRunShortcut?: () => void
onEditorView?: (editor: EditorView) => void
}

Expand All @@ -17,6 +18,10 @@ export default function CodeMirror(props: CodeMirrorProps) {
const onCodeChangeRef = useRef(props.onCodeChange)
useEffect(() => { onCodeChangeRef.current = props.onCodeChange }, [ props.onCodeChange ])

// Run button
const onRunShortcutRef = useRef(props.onRunShortcut)
useEffect(() => { onRunShortcutRef.current = props.onRunShortcut }, [ props.onRunShortcut ])

useEffect(() => {
if (!parent.current) throw new Error('Oh golly! The editor parent ref is null')
let lastCode: string = props.initialCode ?? ''
Expand All @@ -25,7 +30,7 @@ export default function CodeMirror(props: CodeMirrorProps) {
if (editor.state.doc.toString() === lastCode) return
lastCode = editor.state.doc.toString()
onCodeChangeRef.current?.()
}),
}, () => onRunShortcutRef.current?.()),
parent: parent.current
})
if (props.initialCode) editor.dispatch({ changes: { from: 0, insert: props.initialCode } })
Expand Down
Loading

0 comments on commit 3cc2c5f

Please sign in to comment.