Skip to content

Commit

Permalink
Add explanatory text
Browse files Browse the repository at this point in the history
  • Loading branch information
nmarsceau committed May 17, 2024
1 parent e53971b commit aca1d60
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 22 deletions.
46 changes: 36 additions & 10 deletions _site/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,49 @@ body {
padding: 0;
}

.visuallyHidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

.hidden {
display: none;
}

#canvas {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

#instructions {
position: absolute;
left: 50%;
top: 45%;
transform: translate(-50%, -50%);

font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
line-height: 1.7;
color: #777;

.title {
font-size: 1.3em;
margin-block-end: 0;
}

.options {
font-size: 1.1em;
padding-left: 1em;
margin-block-start: 0;
}
}

.toolbar {
position: absolute;
bottom: 0;
Expand All @@ -32,16 +68,6 @@ body {
border-top-left-radius: 30px;
}

.visuallyHidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

.button {
color: var(--brown);
background: transparent;
Expand Down
17 changes: 17 additions & 0 deletions _site/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class App {
THICKNESS = 2
COLOR = "000000"
dom = null
instructions = null
canvas = null
context = null
img = new Image()
Expand All @@ -23,6 +24,11 @@ export class App {
}
this.context = this.canvas.getContext('2d')

// Instructions
if (selectors.instructions !== undefined) {
this.instructions = dom.querySelector(selectors.instructions)
}

// File Input
if (selectors.fileInput !== undefined) {
const fileInput = dom.querySelector(selectors.fileInput)
Expand Down Expand Up @@ -81,6 +87,12 @@ export class App {

drawImage() {
this.clearCanvas()

this.canvas.classList.remove('hidden')
if (this.instructions) {
this.instructions.classList.add('hidden')
}

this.canvas.width = this.img.naturalWidth + 2 * this.THICKNESS
this.canvas.height = this.img.naturalHeight + 2 * this.THICKNESS
this.context.drawImage(this.img, this.THICKNESS, this.THICKNESS)
Expand All @@ -95,6 +107,11 @@ export class App {
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
this.canvas.width = 0
this.canvas.height = 0

this.canvas.classList.add('hidden')
if (this.instructions) {
this.instructions.classList.remove('hidden')
}
}

copyImageToClipboard() {
Expand Down
3 changes: 2 additions & 1 deletion _site/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Frame-It</title><link href="./assets/css/style.css" rel="stylesheet"></head><body draggable="true"><div class="toolbar"><button type="button" id="upload" class="icon button"><span class="visuallyHidden">Select a file</span></button> <button type="button" id="copy" class="icon button"><span class="visuallyHidden">Copy</span></button> <button type="button" id="download" class="icon button"><span class="visuallyHidden">Download</span></button> <button type="button" id="clear" class="icon button"><span class="visuallyHidden">Clear</span></button></div><canvas id="canvas" width="0" height="0"></canvas><input type="file" id="file" accept="image/*, image/avif" class="visuallyHidden" tabindex="-1"><script type="module">import { App } from "./assets/js/app.js"
<!doctype html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Frame-It</title><link href="./assets/css/style.css" rel="stylesheet"></head><body draggable="true"><div class="toolbar"><button type="button" id="upload" class="icon button"><span class="visuallyHidden">Select a file</span></button> <button type="button" id="copy" class="icon button"><span class="visuallyHidden">Copy</span></button> <button type="button" id="download" class="icon button"><span class="visuallyHidden">Download</span></button> <button type="button" id="clear" class="icon button"><span class="visuallyHidden">Clear</span></button></div><div id="instructions"><p class="title">Select an image:</p><p class="options">Paste from the clipboard<br>Use the file picker below</p></div><canvas id="canvas" class="hidden"></canvas><input type="file" id="file" accept="image/*, image/avif" class="visuallyHidden" tabindex="-1"><script type="module">import { App } from "./assets/js/app.js"
new App().connectToDOM(document, {
instructions: "#instructions",
canvas: "#canvas",
fileInput: "#file",
clear: "#clear",
Expand Down
46 changes: 36 additions & 10 deletions src/_includes/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,49 @@ body {
padding: 0;
}

.visuallyHidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

.hidden {
display: none;
}

#canvas {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

#instructions {
position: absolute;
left: 50%;
top: 45%;
transform: translate(-50%, -50%);

font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
line-height: 1.7;
color: #777;

.title {
font-size: 1.3em;
margin-block-end: 0;
}

.options {
font-size: 1.1em;
padding-left: 1em;
margin-block-start: 0;
}
}

.toolbar {
position: absolute;
bottom: 0;
Expand All @@ -32,16 +68,6 @@ body {
border-top-left-radius: 30px;
}

.visuallyHidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

.button {
color: var(--brown);
background: transparent;
Expand Down
17 changes: 17 additions & 0 deletions src/_includes/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class App {
THICKNESS = 2
COLOR = "000000"
dom = null
instructions = null
canvas = null
context = null
img = new Image()
Expand All @@ -23,6 +24,11 @@ export class App {
}
this.context = this.canvas.getContext('2d')

// Instructions
if (selectors.instructions !== undefined) {
this.instructions = dom.querySelector(selectors.instructions)
}

// File Input
if (selectors.fileInput !== undefined) {
const fileInput = dom.querySelector(selectors.fileInput)
Expand Down Expand Up @@ -81,6 +87,12 @@ export class App {

drawImage() {
this.clearCanvas()

this.canvas.classList.remove('hidden')
if (this.instructions) {
this.instructions.classList.add('hidden')
}

this.canvas.width = this.img.naturalWidth + 2 * this.THICKNESS
this.canvas.height = this.img.naturalHeight + 2 * this.THICKNESS
this.context.drawImage(this.img, this.THICKNESS, this.THICKNESS)
Expand All @@ -95,6 +107,11 @@ export class App {
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
this.canvas.width = 0
this.canvas.height = 0

this.canvas.classList.add('hidden')
if (this.instructions) {
this.instructions.classList.remove('hidden')
}
}

copyImageToClipboard() {
Expand Down
10 changes: 9 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@
<span class="visuallyHidden">Clear</span>
</button>
</div>
<canvas id="canvas" width="0" height="0"></canvas>
<div id="instructions">
<p class="title">Select an image:</p>
<p class="options">
Paste from the clipboard<br>
Use the file picker below
</p>
</div>
<canvas id="canvas" class="hidden"></canvas>
<input type="file" id="file" accept="image/*, image/avif" class="visuallyHidden" tabindex="-1">
<script type="module">
import { App } from "./assets/js/app.js"
new App().connectToDOM(document, {
instructions: "#instructions",
canvas: "#canvas",
fileInput: "#file",
clear: "#clear",
Expand Down

0 comments on commit aca1d60

Please sign in to comment.