Skip to content

Commit b4f49ae

Browse files
committed
Try to make it work on Heroku again
1 parent eb76d92 commit b4f49ae

File tree

7 files changed

+164
-33
lines changed

7 files changed

+164
-33
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: mix phx.server

assets/js/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "../css/app.css";
22

33
import "phoenix_html";
44
import { Socket } from "phoenix";
5-
import topbar from "topbar";
5+
import topbar from "../vendor/topbar.js";
66
import { LiveSocket } from "phoenix_live_view";
77

88
let csrfToken = document

assets/package-lock.json

-24
This file was deleted.

assets/package.json

-5
This file was deleted.

assets/vendor/topbar.js

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/**
2+
* @license MIT
3+
* topbar 1.0.0, 2021-01-06
4+
* http://buunguyen.github.io/topbar
5+
* Copyright (c) 2021 Buu Nguyen
6+
*/
7+
(function (window, document) {
8+
"use strict";
9+
10+
// https://gist.github.com/paulirish/1579671
11+
(function () {
12+
var lastTime = 0;
13+
var vendors = ["ms", "moz", "webkit", "o"];
14+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
15+
window.requestAnimationFrame =
16+
window[vendors[x] + "RequestAnimationFrame"];
17+
window.cancelAnimationFrame =
18+
window[vendors[x] + "CancelAnimationFrame"] ||
19+
window[vendors[x] + "CancelRequestAnimationFrame"];
20+
}
21+
if (!window.requestAnimationFrame)
22+
window.requestAnimationFrame = function (callback, element) {
23+
var currTime = new Date().getTime();
24+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
25+
var id = window.setTimeout(function () {
26+
callback(currTime + timeToCall);
27+
}, timeToCall);
28+
lastTime = currTime + timeToCall;
29+
return id;
30+
};
31+
if (!window.cancelAnimationFrame)
32+
window.cancelAnimationFrame = function (id) {
33+
clearTimeout(id);
34+
};
35+
})();
36+
37+
var canvas,
38+
progressTimerId,
39+
fadeTimerId,
40+
currentProgress,
41+
showing,
42+
addEvent = function (elem, type, handler) {
43+
if (elem.addEventListener) elem.addEventListener(type, handler, false);
44+
else if (elem.attachEvent) elem.attachEvent("on" + type, handler);
45+
else elem["on" + type] = handler;
46+
},
47+
options = {
48+
autoRun: true,
49+
barThickness: 3,
50+
barColors: {
51+
0: "rgba(26, 188, 156, .9)",
52+
".25": "rgba(52, 152, 219, .9)",
53+
".50": "rgba(241, 196, 15, .9)",
54+
".75": "rgba(230, 126, 34, .9)",
55+
"1.0": "rgba(211, 84, 0, .9)",
56+
},
57+
shadowBlur: 10,
58+
shadowColor: "rgba(0, 0, 0, .6)",
59+
className: null,
60+
},
61+
repaint = function () {
62+
canvas.width = window.innerWidth;
63+
canvas.height = options.barThickness * 5; // need space for shadow
64+
65+
var ctx = canvas.getContext("2d");
66+
ctx.shadowBlur = options.shadowBlur;
67+
ctx.shadowColor = options.shadowColor;
68+
69+
var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
70+
for (var stop in options.barColors)
71+
lineGradient.addColorStop(stop, options.barColors[stop]);
72+
ctx.lineWidth = options.barThickness;
73+
ctx.beginPath();
74+
ctx.moveTo(0, options.barThickness / 2);
75+
ctx.lineTo(
76+
Math.ceil(currentProgress * canvas.width),
77+
options.barThickness / 2
78+
);
79+
ctx.strokeStyle = lineGradient;
80+
ctx.stroke();
81+
},
82+
createCanvas = function () {
83+
canvas = document.createElement("canvas");
84+
var style = canvas.style;
85+
style.position = "fixed";
86+
style.top = style.left = style.right = style.margin = style.padding = 0;
87+
style.zIndex = 100001;
88+
style.display = "none";
89+
if (options.className) canvas.classList.add(options.className);
90+
document.body.appendChild(canvas);
91+
addEvent(window, "resize", repaint);
92+
},
93+
topbar = {
94+
config: function (opts) {
95+
for (var key in opts)
96+
if (options.hasOwnProperty(key)) options[key] = opts[key];
97+
},
98+
show: function () {
99+
if (showing) return;
100+
showing = true;
101+
if (fadeTimerId !== null) window.cancelAnimationFrame(fadeTimerId);
102+
if (!canvas) createCanvas();
103+
canvas.style.opacity = 1;
104+
canvas.style.display = "block";
105+
topbar.progress(0);
106+
if (options.autoRun) {
107+
(function loop() {
108+
progressTimerId = window.requestAnimationFrame(loop);
109+
topbar.progress(
110+
"+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
111+
);
112+
})();
113+
}
114+
},
115+
progress: function (to) {
116+
if (typeof to === "undefined") return currentProgress;
117+
if (typeof to === "string") {
118+
to =
119+
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0
120+
? currentProgress
121+
: 0) + parseFloat(to);
122+
}
123+
currentProgress = to > 1 ? 1 : to;
124+
repaint();
125+
return currentProgress;
126+
},
127+
hide: function () {
128+
if (!showing) return;
129+
showing = false;
130+
if (progressTimerId != null) {
131+
window.cancelAnimationFrame(progressTimerId);
132+
progressTimerId = null;
133+
}
134+
(function loop() {
135+
if (topbar.progress("+.1") >= 1) {
136+
canvas.style.opacity -= 0.05;
137+
if (canvas.style.opacity <= 0.05) {
138+
canvas.style.display = "none";
139+
fadeTimerId = null;
140+
return;
141+
}
142+
}
143+
fadeTimerId = window.requestAnimationFrame(loop);
144+
})();
145+
},
146+
};
147+
148+
if (typeof module === "object" && typeof module.exports === "object") {
149+
module.exports = topbar;
150+
} else if (typeof define === "function" && define.amd) {
151+
define(function () {
152+
return topbar;
153+
});
154+
} else {
155+
this.topbar = topbar;
156+
}
157+
}.call(this, window, document));

elixir_buildpack.config

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ elixir_version=1.12.3
33

44
# Erlang version
55
# available versions https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions
6-
erlang_version=23.3.2
6+
erlang_version=23.3.2
7+
8+
# Invoke assets.deploy defined in your mix.exs to deploy assets with esbuild
9+
# Note we nuke the esbuild executable from the image
10+
hook_post_compile="mix assets.deploy && rm -f _build/esbuild"

phoenix_static_buildpack.config

-2
This file was deleted.

0 commit comments

Comments
 (0)