Skip to content

Commit 28aeabf

Browse files
committed
feat(CanvasEditor): Add instructions. Refactored CSS for fixed height
1 parent 1f7f117 commit 28aeabf

File tree

1 file changed

+76
-56
lines changed

1 file changed

+76
-56
lines changed

src/components/CanvasEditor.vue

Lines changed: 76 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
<template>
2-
<div class="main">
3-
<div class="image-container">
2+
<div class="canvas-editor">
3+
<div class="canvas-editor__canvas">
44
<img
5-
class="hide-image"
5+
class="canvas-editor__hidden-image"
66
ref="imgSource"
77
:alt="fileName"
88
tabindex="-1"
99
@load="setupCanvas"
1010
/>
11-
<canvas class="canvas" ref="canvas" :title="fileName"></canvas>
12-
13-
<div class="control-footer">
14-
<span>Name</span>
15-
<span :title="fileName">{{ fileName }}</span>
16-
<app-button @click="openFilePicker">
17-
<img src="@/assets/triangle.svg" alt="" srcset="" />
18-
Upload
19-
</app-button>
11+
<div v-if="!imageData" class="canvas-editor__instructions">
12+
Please click on the UPLOAD button to display an image file
2013
</div>
14+
<canvas ref="canvas" :title="fileName"></canvas>
15+
</div>
16+
17+
<div class="canvas-editor__footer">
18+
<span>Name</span>
19+
<span :title="fileName">{{ fileName }}</span>
20+
<app-button @click="openFilePicker">
21+
<img src="@/assets/triangle.svg" alt="" srcset="" />
22+
Upload
23+
</app-button>
2124
</div>
22-
<input
23-
type="file"
24-
class="hidden"
25-
ref="fileSelector"
26-
accept="image/png, image/jpeg"
27-
@change="loadImageFile"
28-
/>
2925
</div>
26+
<input
27+
type="file"
28+
class="hidden"
29+
ref="fileSelector"
30+
accept="image/png, image/jpeg"
31+
@change="loadImageFile"
32+
/>
3033
</template>
3134

3235
<script>
@@ -49,7 +52,7 @@ export default {
4952
return {
5053
fileName: "\xa0",
5154
context: null,
52-
imageData: {}
55+
imageData: null
5356
};
5457
},
5558
methods: {
@@ -78,7 +81,7 @@ export default {
7881
},
7982
filterBrightness(imgData, brightness) {
8083
const data = imgData.data;
81-
const factor = brightness * 1.28; // 2.55;
84+
const factor = brightness * 2; // Originally 2.55 but was reduced to be more granular.
8285
for (let i = 0; i < data.length; i += 4) {
8386
data[i] += factor;
8487
data[i + 1] += factor;
@@ -122,50 +125,67 @@ export default {
122125
</script>
123126

124127
<style lang="scss" scoped>
125-
.image-container {
128+
.canvas-editor {
129+
display: flex;
130+
flex-direction: column;
131+
margin-top: 30px;
132+
height: 268px;
126133
border: 1px solid $grey-2;
127134
border-radius: $border-radius;
128135
overflow: hidden;
129-
}
130136
131-
.hide-image {
132-
position: absolute;
133-
opacity: 0;
134-
z-index: -10;
135-
}
136-
.control-footer {
137-
display: flex;
138-
align-items: center;
139-
padding: 10px;
140-
border-top: 1px solid $grey-2;
137+
&__hidden-image {
138+
position: absolute;
139+
opacity: 0;
140+
z-index: -10;
141+
}
142+
143+
&__canvas {
144+
position: relative;
145+
flex: 1;
146+
overflow: hidden;
147+
}
148+
149+
&__instructions {
150+
padding: 80px 40px;
151+
height: 100%;
152+
background-color: $grey-1;
153+
color: $grey-4;
154+
}
141155
142-
> span {
143-
@extend %control-style;
156+
&__footer {
157+
display: flex;
158+
align-items: center;
159+
padding: 10px;
144160
145-
&:first-of-type {
146-
background-color: $grey-1;
147-
border-top-left-radius: $border-radius;
148-
border-bottom-left-radius: $border-radius;
149-
color: $grey-4;
161+
> span {
162+
@extend %control-style;
163+
164+
&:first-of-type {
165+
background-color: $grey-1;
166+
border-top-left-radius: $border-radius;
167+
border-bottom-left-radius: $border-radius;
168+
color: $grey-4;
169+
}
170+
171+
&:last-of-type {
172+
flex-grow: 1;
173+
display: block;
174+
border-left-width: 0;
175+
border-top-right-radius: $border-radius;
176+
border-bottom-right-radius: $border-radius;
177+
color: $green;
178+
line-height: 28px;
179+
text-align: left;
180+
white-space: nowrap;
181+
text-overflow: ellipsis;
182+
overflow: hidden;
183+
}
150184
}
151185
152-
&:last-of-type {
153-
display: block;
154-
flex-grow: 1;
155-
border-left-width: 0;
156-
border-top-right-radius: $border-radius;
157-
border-bottom-right-radius: $border-radius;
158-
color: $green;
159-
line-height: 28px;
160-
text-align: left;
161-
white-space: nowrap;
162-
text-overflow: ellipsis;
163-
overflow: hidden;
186+
button {
187+
margin-left: $gutter;
164188
}
165189
}
166190
}
167-
168-
.app-btn {
169-
margin-left: 15px;
170-
}
171191
</style>

0 commit comments

Comments
 (0)