3 Commits

  1. 13
      CHANGELOG.md
  2. 33
      assets/css/_tablesort.scss
  3. 1
      assets/css/app.scss
  4. 6
      assets/js/app.js
  5. 13
      assets/package-lock.json
  6. 3
      assets/package.json
  7. 4
      lib/mirage_web/live/goto_anything_live.ex
  8. 2
      mix.exs

13
CHANGELOG.md

@ -5,6 +5,19 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.45.0](https://git.inhji.de/inhji/mirage/compare/v0.44.2...v0.45.0) (2021-02-19)
### Features:
* add table sort
### Bug Fixes:
* add @impl true to gotoanything
## [v0.44.2](https://git.inhji.de/inhji/mirage/compare/v0.44.1...v0.44.2) (2021-02-19)

33
assets/css/_tablesort.scss

@ -0,0 +1,33 @@
th[role=columnheader]:not(.no-sort) {
cursor: pointer;
}
th[role=columnheader]:not(.no-sort):after {
content: '';
float: right;
margin-top: 7px;
border-width: 0 4px 4px;
border-style: solid;
border-color: #404040 transparent;
visibility: hidden;
opacity: 0;
-ms-user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
th[aria-sort=ascending]:not(.no-sort):after {
border-bottom: none;
border-width: 4px 4px 0;
}
th[aria-sort]:not(.no-sort):after {
visibility: visible;
opacity: 0.4;
}
th[role=columnheader]:not(.no-sort):hover:after {
visibility: visible;
opacity: 1;
}

1
assets/css/app.scss

@ -66,6 +66,7 @@ $border-base: #666;
@import "./markdown";
@import "./navigation";
@import "./forms";
@import "./tablesort";
/* === Base === */

6
assets/js/app.js

@ -17,6 +17,7 @@ import Prism from 'prismjs'
import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
import TableSort from "tablesort"
const handledKeys = ["p"]
@ -57,5 +58,10 @@ if (document.querySelector(element)) {
})
}
const tables = "table"
document.querySelectorAll(tables).forEach(table => {
new TableSort(table)
})
Prism.highlightAll();

13
assets/package-lock.json

@ -13,7 +13,8 @@
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"prismjs": "^1.23.0"
"prismjs": "^1.23.0",
"tablesort": "^5.2.1"
},
"devDependencies": {
"@babel/core": "^7.x",
@ -7146,6 +7147,11 @@
"mkdirp": "bin/cmd.js"
}
},
"node_modules/tablesort": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/tablesort/-/tablesort-5.2.1.tgz",
"integrity": "sha512-AmNSrtzyba5Bd+Fm8oJJj/xS2bj5acoHEsDHxER2/4Tzo+5noPORpEsSLT9dI15X2MIuXlNnj+BBQcpMsoeTXQ=="
},
"node_modules/tapable": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz",
@ -13353,6 +13359,11 @@
}
}
},
"tablesort": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/tablesort/-/tablesort-5.2.1.tgz",
"integrity": "sha512-AmNSrtzyba5Bd+Fm8oJJj/xS2bj5acoHEsDHxER2/4Tzo+5noPORpEsSLT9dI15X2MIuXlNnj+BBQcpMsoeTXQ=="
},
"tapable": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz",

3
assets/package.json

@ -13,7 +13,8 @@
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"prismjs": "^1.23.0"
"prismjs": "^1.23.0",
"tablesort": "^5.2.1"
},
"devDependencies": {
"@babel/core": "^7.x",

4
lib/mirage_web/live/goto_anything_live.ex

@ -6,21 +6,25 @@ defmodule MirageWeb.GotoAnythingLive do
{:ok, socket |> assign(%{popup_class: "closed", results: []})}
end
@impl true
def handle_event("hotkey", %{"key" => "p", "ctrlKey" => true}, socket) do
IO.inspect("Open Popup")
{:noreply, socket |> assign(%{popup_class: "open"})}
end
@impl true
def handle_event("hotkey", %{"key" => "Escape", "ctrlKey" => false}, socket) do
IO.inspect("Close Popup")
{:noreply, socket |> assign(%{popup_class: "closed"})}
end
@impl true
def handle_event("hotkey", params, socket) do
IO.inspect(params)
{:noreply, socket}
end
@impl true
def handle_event("search", %{"key" => _, "value" => query}, socket) do
results = Mirage.Notes.search_notes(query)
{:noreply, socket |> assign(%{results: results})}

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.44.2"
@version "0.45.0"
def project do
[

Loading…
Cancel
Save