Skip to content

Commit 2b8f40b

Browse files
committed
get from address live + enhance styling
1 parent c3f4b7e commit 2b8f40b

File tree

5 files changed

+72
-38
lines changed

5 files changed

+72
-38
lines changed

public/global.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ html, body {
22
position: relative;
33
width: 100%;
44
height: 100%;
5+
background-color: #2673b8;
56
}
67

78
body {
8-
color: #333;
9+
color: white;
910
margin: 0;
1011
padding: 8px;
1112
box-sizing: border-box;

src/App.svelte

+12-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
}
3333
3434
const uploadToSC = async (e) => {
35+
console.log(callerAddress);
3536
const ipfsHash = e.detail.path;
3637
//convert ipfsHash to bytes32 to fit the SC
3738
const hashToSend = hashToBytes32(ipfsHash);
@@ -89,7 +90,7 @@
8990
}
9091
9192
function startApp() {
92-
etherGram = new web3.eth.Contract(ethergramABI,scAddress);
93+
etherGram = new web3.eth.Contract(ethergramABI,scAddress);
9394
}
9495
9596
window.addEventListener('load', async function() {
@@ -108,26 +109,30 @@
108109
var accounts = await web3.eth.getAccounts();
109110
callerAddress = accounts[0];
110111
111-
var accountInterval = setInterval(function() {
112-
if (web3.eth.accounts[0] !== callerAddress) {
113-
callerAddress = web3.eth.accounts[0];
112+
var accountInterval = setInterval(async function() {
113+
let accounts = await web3.eth.getAccounts();
114+
if (accounts[0] !== callerAddress) {
115+
callerAddress = accounts[0];
114116
}
115117
}, 100);
118+
119+
console.log(callerAddress);
116120
})
117121
118122
119123
</script>
120124

121125
<style>
122126
h1 {
123-
color: rgb(59, 70, 168);
127+
color: white;
124128
font-size: 80px;
125129
text-align: center;
126-
background-color: azure
130+
background-color: #31b3ca
127131
}
128132
</style>
129133

130-
<h1>Picture board DApp by Jason</h1>
134+
135+
<h1 class="title">Picture board DApp by Jason</h1>
131136

132137

133138
{#if pages.postImage}

src/Upload.svelte

+18-13
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,30 @@
2828
const reader = new FileReader()
2929
return new Promise((resolve, reject) => {
3030
reader.onerror = () => {
31-
reader.abort()
32-
reject(`problem reading file ${file.name}`)
31+
reader.abort()
32+
reject(`problem reading file ${file.name}`)
3333
}
3434
reader.onload = () => {
35-
resolve(reader.result)
35+
resolve(reader.result)
3636
}
3737
reader.readAsDataURL(file)
3838
})
3939
}
4040
4141
</script>
4242

43-
<h2>Upload your Images to Picture Board</h2>
44-
45-
<img src={filePreview} alt="filepreview" />
46-
47-
<form on:submit={onSubmit}>
48-
<input type="file" on:change={fileChange} />
49-
<input type="submit">
50-
</form>
51-
52-
<input type="submit" on:click={() => dispatch("viewImage")} value="View Picture Board" />
43+
<h2 class="subtitle">Upload your Images to Picture Board</h2>
44+
<div class="preview">
45+
<img src={filePreview} alt="filepreview" />
46+
</div>
47+
48+
<div class="upload-form" id="upload-form">
49+
<form on:submit={onSubmit}>
50+
<input type="file" on:change={fileChange} />
51+
<input type="submit">
52+
</form>
53+
</div>
54+
55+
<div class="view-image-button">
56+
<input type="submit" on:click={() => dispatch("viewImage")} value="View Picture Board" />
57+
</div>

src/Uploading.svelte

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
<style>
22
h1 {
3-
text-align: center;
43
text-emphasis: 10;
54
}
5+
6+
.loader-container{
7+
text-align: center;
8+
}
9+
10+
.loader {
11+
display: inline-block;
12+
border-bottom: 16px solid #31b3ca;
13+
border-top: 16px solid white; /*#2673b8*/
14+
border-radius: 50%;
15+
width: 120px;
16+
height: 120px;
17+
animation: spin 2s linear infinite;
18+
}
19+
20+
@keyframes spin {
21+
0% { transform: rotate(0deg); }
22+
100% { transform: rotate(360deg); }
23+
}
24+
625
</style>
726

8-
<h1>Please wait...</h1>
27+
<div class="loader-container">
28+
<div class="loader"></div>
29+
<h1>Please wait...</h1>
30+
</div>

src/ViewImage.svelte

+16-15
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,26 @@
1515
}
1616
</script>
1717

18-
<h2>Picture Board</h2>
18+
<h2 class="subtitle">Picture Board</h2>
1919

2020
<p>Double-click on image to give it a like. <br/>
2121
And, feel free to drop your comments and submit them.</p>
2222

2323
<input type="submit" value="Back" on:click={() => dispatch("back")}/>
2424

25-
<ul>
2625
{#each postsFromSC as post}
27-
<li>
28-
<form on:dblclick={clap} on:submit={commentOnPost} name={post.image}>
29-
<img src="https://ipfs.infura.io/ipfs/{post.image}" alt={post.image}/>
30-
<input type="text" placeholder="Comment your thoughts about this image" maxlength="32"/> <input type="submit">
31-
</form>
32-
<p>{post.clapCounts} Like(s) </p>
33-
<p><b>Comments ({post.comment.length})</b></p>
34-
{#each post.comment as comment}
35-
<p>{comment} <br /> </p>
36-
{/each}
37-
</li>
38-
{/each}
39-
</ul>
26+
<div class="post-box">
27+
<form on:dblclick={clap} on:submit={commentOnPost} name={post.image}>
28+
<img src="https://ipfs.infura.io/ipfs/{post.image}" alt={post.image}/>
29+
<input type="text" placeholder="Comment your thoughts about this image" maxlength="32"/> <input type="submit">
30+
</form>
31+
<p>{post.clapCounts} Like(s) </p>
32+
33+
<div class="comment-display">
34+
<p><b>Comments ({post.comment.length})</b></p>
35+
{#each post.comment as comment}
36+
<p>{comment} <br /> </p>
37+
{/each}
38+
</div>
39+
</div>
40+
{/each}

0 commit comments

Comments
 (0)