Skip to content

Commit

Permalink
Merge pull request #2 from firezone/feat/ui
Browse files Browse the repository at this point in the history
feat: initial UI
  • Loading branch information
jamilbk authored Jul 7, 2024
2 parents 91eeec3 + 218dbc3 commit 2f5b054
Show file tree
Hide file tree
Showing 21 changed files with 10,883 additions and 547 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: mix
directory: .
schedule:
interval: weekly
- package-ecosystem: npm
directory: assets
schedule:
interval: weekly
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are used for the dev environment.
# This should match the versions used in the built product.
elixir 1.17.0-otp-27
elixir 1.17.1-otp-27
erlang 27.0
28 changes: 13 additions & 15 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,27 @@
//

// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
import "phoenix_html";
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
import topbar from "../vendor/topbar"
import { Socket } from "phoenix";
import { LiveSocket } from "phoenix_live_view";
import { DarkModeToggle } from "./hooks";
import "flowbite/dist/flowbite.phoenix.js";

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let csrfToken = document
.querySelector("meta[name='csrf-token']")
.getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {
longPollFallbackMs: 2500,
params: {_csrf_token: csrfToken}
})

// Show progress bar on live navigation and form submits
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
hooks: { DarkModeToggle },
params: { _csrf_token: csrfToken },
});

// connect if there are any LiveViews on the page
liveSocket.connect()
liveSocket.connect();

// expose liveSocket on window for web console debug logs and latency simulation:
// >> liveSocket.enableDebug()
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
// >> liveSocket.disableLatencySim()
window.liveSocket = liveSocket

window.liveSocket = liveSocket;
53 changes: 53 additions & 0 deletions assets/js/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
let DarkModeToggle = {
mounted() {
var themeToggleDarkIcon = document.getElementById("theme-toggle-dark-icon");
var themeToggleLightIcon = document.getElementById(
"theme-toggle-light-icon",
);

// Change the icons inside the button based on previous settings
if (
localStorage.getItem("color-theme") === "dark" ||
(!("color-theme" in localStorage) &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
themeToggleLightIcon.classList.remove("hidden");
} else {
themeToggleDarkIcon.classList.remove("hidden");
}

var themeToggleBtn = document.getElementById("theme-toggle");

// Add event listener to the button
themeToggleBtn.addEventListener("click", function () {
// toggle icons inside button
themeToggleDarkIcon.classList.toggle("hidden");
themeToggleLightIcon.classList.toggle("hidden");

// if set via local storage previously
if (localStorage.getItem("color-theme")) {
if (localStorage.getItem("color-theme") === "light") {
document.documentElement.classList.add("dark");
localStorage.setItem("color-theme", "dark");
console.log("set to dark");
} else {
document.documentElement.classList.remove("dark");
localStorage.setItem("color-theme", "light");
}

// if NOT set via local storage previously
} else {
console.log("not found in local storage");
if (document.documentElement.classList.contains("dark")) {
document.documentElement.classList.remove("dark");
localStorage.setItem("color-theme", "light");
} else {
document.documentElement.classList.add("dark");
localStorage.setItem("color-theme", "dark");
}
}
});
},
};

export { DarkModeToggle };
226 changes: 226 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "probe",
"version": "0.1.0",
"description": "Probe assets",
"main": "tailwind.config.js",
"scripts": {
"test": "npm test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/firezone/probe.git"
},
"author": "",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/firezone/probe/issues"
},
"homepage": "https://github.com/firezone/probe#readme",
"dependencies": {
"flowbite": "^2.4.1"
}
}
Loading

0 comments on commit 2f5b054

Please sign in to comment.