Skip to content

Commit

Permalink
add deno blocks icon
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Jan 16, 2024
1 parent f0c3cb1 commit 7305d06
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
15 changes: 15 additions & 0 deletions components/deno_blocks_icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface DenoBlocksIconProps {
size?: string;
}

export default function DenoBlocksIcon(props: DenoBlocksIconProps) {
return (
<div
class="deno-blocks-icon"
role="img"
aria-label="Deno Blocks"
title="Deno Blocks"
style={props.size ? { width: props.size, height: props.size } : undefined}
/>
);
}
2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import * as $_404 from "./routes/_404.tsx";
import * as $_app from "./routes/_app.tsx";
import * as $icon from "./routes/icon.tsx";
import * as $index from "./routes/index.tsx";
import * as $deno_blocks_ide_island from "./islands/deno_blocks_ide_island.tsx";
import { type Manifest } from "$fresh/server.ts";
Expand All @@ -12,6 +13,7 @@ const manifest = {
routes: {
"./routes/_404.tsx": $_404,
"./routes/_app.tsx": $_app,
"./routes/icon.tsx": $icon,
"./routes/index.tsx": $index,
},
islands: {
Expand Down
47 changes: 36 additions & 11 deletions islands/deno_blocks_ide_island.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import {
denoBlockly,
type DenoBlocklyOptions,
} from "#/lib/blockly/examples/deno_blockly/mod.ts";
import DenoBlocksIcon from "#/components/deno_blocks_icon.tsx";

export type DenoBlocksIDEIslandProps = Pick<
DenoBlocklyOptions,
"getInitialWorkspace" | "onWorkspaceChange"
>;
export interface DenoBlocksIDEIslandProps extends
Pick<
DenoBlocklyOptions,
"getInitialWorkspace" | "onWorkspaceChange"
> {
projects?: {
id: string;
name: string;
}[];
}

export default function DenoBlocksIDEIsland(props: DenoBlocksIDEIslandProps) {
const blocklyRef = useRef<HTMLDivElement>(null);
Expand All @@ -27,12 +34,30 @@ export default function DenoBlocksIDEIsland(props: DenoBlocksIDEIslandProps) {
}, [blocklyRef, codeRef]);

return (
<div className="container">
<div className="blockly" ref={blocklyRef} />
<div className="output-pane">
<pre className="generated-code"><code ref={codeRef}/></pre>
<div className="output" />
</div>
</div>
<>
<nav>
<DenoBlocksIcon />

<div id="project-selector">
<select id="project-list">
{props.projects?.map((p) => <option value={p.id}>{p.name}</option>)}
</select>
<form action="/project" method="POST">
<button type="submit" id="new-project">
Generate New Project
</button>
</form>
</div>
</nav>
<main>
<div className="container">
<div className="blockly" ref={blocklyRef} />
<div className="output-pane">
<pre className="generated-code"><code ref={codeRef}/></pre>
<div className="output" />
</div>
</div>
</main>
</>
);
}
6 changes: 6 additions & 0 deletions routes/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import DenoBlocksIcon from "#/components/deno_blocks_icon.tsx";

export default function Icon(_request: Request) {
// TODO: Load workspace from Deno KV by session ID.
return <DenoBlocksIcon size="min(50vw, 50vh)" />;
}
6 changes: 1 addition & 5 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ import DenoBlocksIDEIsland from "#/islands/deno_blocks_ide_island.tsx";

export default /*async*/ function Home(_request: Request) {
// TODO: Load workspace from Deno KV by session ID.
return (
<main>
<DenoBlocksIDEIsland />
</main>
);
return <DenoBlocksIDEIsland />;
}
Binary file added static/deno-blocks-icon-frame-0.gif
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 static/deno-blocks-icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 82 additions & 4 deletions static/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
:root {
--nav-height: 42px;
}

*,
*::before,
Expand All @@ -7,13 +10,13 @@

* {
margin: 0;

}
button {
color: inherit;
}

button, [role="button"] {
button,
[role="button"] {
cursor: pointer;
}

Expand Down Expand Up @@ -42,6 +45,71 @@ html {
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

.deno-blocks-icon {
background-image: url("/deno-blocks-icon-frame-0.gif");
width: var(--nav-height);
height: var(--nav-height);
image-rendering: pixelated;
background-size: contain;
background-repeat: no-repeat;
}

.deno-blocks-icon:hover {
background-image: url("/deno-blocks-icon.gif");
}

nav {
position: absolute;
height: var(--nav-height);
top: 0;
left: 0;
right: 0;
border-bottom: 1px solid #555;
display: flex;
align-items: center;
gap: 20px;
overflow: hidden;
}

main {
position: absolute;
top: var(--nav-height);
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
}

h1 {
display: inline-block;
margin: 0 0 0 10px;
padding: 0;
font-size: 28px;
}

h3 {
font-size: 22px;
margin: 10px;
padding: 0;
}

select,
button {
height: 28px;
}

form {
display: inline;
}

#project-list {
margin-right: 10px;
}

#project-selector {
display: inline-block;
}

.container {
display: flex;
width: 100%;
Expand All @@ -53,15 +121,25 @@ html {
flex-basis: 100%;
height: 100%;
min-width: 600px;
position: absolute;
right: 30%;
top: 0;
left: 0;
bottom: 0;
overflow: hidden;
}

.output-pane {
display: flex;
flex-direction: column;
width: 400px;
flex: 0 0 400px;
overflow: auto;
margin: 1rem;
position: absolute;
width: 30%;
right: 0;
overflow: auto;
border-left: 1px solid #555;
}

.generated-code {
Expand All @@ -71,7 +149,7 @@ html {

.output {
height: 50%;
}
}

.transition-colors {
transition-property: background-color, border-color, color, fill, stroke;
Expand Down

3 comments on commit 7305d06

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 7305d06 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

UNCAUGHT_EXCEPTION

MissingEnvVarsError: The following variables were defined in the example file but are not present in the environment:
  GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET

Make sure to add them to your env file.

If you expect any of these variables to be empty, you can set the allowEmptyValues option to true.
    at assertSafe (https://deno.land/std@0.208.0/dotenv/mod.ts:286:11)
    at loadSync (https://deno.land/std@0.208.0/dotenv/mod.ts:209:5)
    at https://deno.land/std@0.208.0/dotenv/load.ts:11:3

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 7305d06 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

UNCAUGHT_EXCEPTION

MissingEnvVarsError: The following variables were defined in the example file but are not present in the environment:
  GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET

Make sure to add them to your env file.

If you expect any of these variables to be empty, you can set the allowEmptyValues option to true.
    at assertSafe (https://deno.land/std@0.208.0/dotenv/mod.ts:286:11)
    at loadSync (https://deno.land/std@0.208.0/dotenv/mod.ts:209:5)
    at https://deno.land/std@0.208.0/dotenv/load.ts:11:3

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 7305d06 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

UNCAUGHT_EXCEPTION

MissingEnvVarsError: The following variables were defined in the example file but are not present in the environment:
  GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET

Make sure to add them to your env file.

If you expect any of these variables to be empty, you can set the allowEmptyValues option to true.
    at assertSafe (https://deno.land/std@0.208.0/dotenv/mod.ts:286:11)
    at loadSync (https://deno.land/std@0.208.0/dotenv/mod.ts:209:5)
    at https://deno.land/std@0.208.0/dotenv/load.ts:11:3

Please sign in to comment.