This repository was archived by the owner on Jan 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Rails from "@rails/ujs"
7
7
import Turbolinks from "turbolinks"
8
8
import * as ActiveStorage from "@rails/activestorage"
9
9
import "channels"
10
+ import "../src/change-background"
10
11
11
12
const images = require . context ( "../images" , true )
12
13
const imagePath = name => images ( name , true )
Original file line number Diff line number Diff line change
1
+ import avatarUrl from '../images/avatar.png'
2
+
3
+ document . addEventListener (
4
+ "turbolinks:load" ,
5
+ ( ) => {
6
+ document . getElementById ( 'add-avatar-button' ) . onclick = ( ) => {
7
+ const image = new Image ( ) ;
8
+ image . src = avatarUrl ;
9
+ document . getElementById ( 'so-many-avatars' ) . appendChild ( image ) ;
10
+ }
11
+ }
12
+ )
Original file line number Diff line number Diff line change @@ -23,3 +23,15 @@ body {
23
23
// TRICKY: ensure all child nodes' margins stay inside container
24
24
padding : 1px ;
25
25
}
26
+
27
+ section {
28
+ margin : 2em 1em 0 ;
29
+ }
30
+
31
+ button {
32
+ background-color : #1663b2 ;
33
+ border : 0 ;
34
+ border-radius : 0.25em ;
35
+ color : #fff ;
36
+ padding : 1em ;
37
+ }
Original file line number Diff line number Diff line change 58
58
vie.
59
59
</ p >
60
60
</ section >
61
+
62
+ < section >
63
+ < h2 > On image loading within JS:</ h2 >
64
+ < p >
65
+ Bjork is one of those artists that I always forget about, but am always
66
+ stoked to return to after a hiatus. 'Post' truly is an incredible album,
67
+ and features 'Army of Me', which has a music video containing what I can
68
+ only assume was the inspiration for that Tesla truck everyone mocked to
69
+ death. Very PS1.
70
+ </ p >
71
+ < p >
72
+ Speaking of 'Army of Me', the button below will use Webpacker-loaded
73
+ images within Webpacker-loaded JS to do that thing.
74
+ </ p >
75
+ < button id ="add-avatar-button " type ="button "> I MUST HAVE MORE</ button >
76
+ < div id ="so-many-avatars "> </ div >
77
+ </ section >
61
78
</ article >
You can’t perform that action at this time.
0 commit comments