8 Commits

  1. 21
      CHANGELOG.md
  2. 21
      assets/css/app.scss
  3. 2
      assets/js/hooks.js
  4. 20
      lib/mirage/notes.ex
  5. 1
      lib/mirage_web/live/modal_component.html.leex
  6. 22
      lib/mirage_web/live/note_live/show.ex
  7. 2
      mix.exs

21
CHANGELOG.md

@ -5,6 +5,27 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.54.1](https://git.inhji.de/inhji/mirage/compare/v0.54.0...v0.54.1) (2021-02-22)
### Bug Fixes:
* lighter cards
* remove capture click to prevent unexpected closure of popup
* dont update timestamps when viewing a note, improve titles
* scroll to top when opening edit popup
* wider range for media query
* make goto anything button fixed
* remove grid tables
## [v0.54.0](https://git.inhji.de/inhji/mirage/compare/v0.53.0...v0.54.0) (2021-02-22)

21
assets/css/app.scss

@ -269,7 +269,7 @@ kbd {
.card {
border: 1px solid $border-base;
@include color-assign(border-color, on-surface);
@include color-assign(border-color, surface-var);
border-radius: 2px;
padding: 0.5rem;
@ -298,7 +298,7 @@ kbd {
#goto-anything-button {
display: none;
position: absolute;
position: fixed;
z-index: 10;
right: 20px;
bottom: 20px;
@ -354,21 +354,6 @@ kbd {
}
}
.grid-table {
width: 100%;
}
@media screen and (max-width:768px) {
.grid-table, .grid-table thead, .grid-table tbody {
display: block;
width: 100%;
}
.grid-table tr {
display: grid;
width: 100%;
grid-template-columns: auto auto auto;
}
}
/* === Content === */
article {
@ -405,7 +390,7 @@ article {
/* === Media Queries === */
@media (max-width: 400px) {
@media (max-width: 768px) {
.flex-grid {
display: block;
}

2
assets/js/hooks.js

@ -15,6 +15,8 @@ export const NoteForm = {
initEditor("#editor")
})
}
window.scrollTo({top: 0, left: 0, behavior: 'smooth'})
}
}

20
lib/mirage/notes.ex

@ -155,12 +155,20 @@ defmodule Mirage.Notes do
def preload_note(note), do: Repo.preload(note, @note_preloads)
def view_note!(note),
do:
update_note!(note, %{
views: note.views + 1,
viewed_at: DateTime.utc_now()
})
def view_note!(note) do
now = DateTime.utc_now()
from(n in Note,
where: ^note.id == n.id,
update: [
inc: [views: 1],
set: [viewed_at: ^now]
]
)
|> Repo.update_all([])
note
end
@doc """
Creates a note.

1
lib/mirage_web/live/modal_component.html.leex

@ -1,5 +1,4 @@
<div id="<%= @id %>" class="phx-modal"
phx-capture-click="close"
phx-window-keydown="close"
phx-key="escape"
phx-target="#<%= @id %>"

22
lib/mirage_web/live/note_live/show.ex

@ -5,25 +5,27 @@ defmodule MirageWeb.NoteLive.Show do
alias Mirage.Links
alias Mirage.Links.Link
defp page_title(:show), do: "Show Note"
defp page_title(:edit), do: "Edit Note"
defp page_title(:show, note), do: note.title
defp page_title(:edit, note), do: "[Edit] #{note.title}"
@impl true
def mount(_params, %{"user_id" => user_id}, socket) do
{:ok, socket |> assign(:current_user, Mirage.Accounts.get_user!(user_id))}
{:ok,
socket
|> assign(:current_user, Mirage.Accounts.get_user!(user_id))}
end
@impl true
def handle_params(%{"id" => id}, _, socket) do
note =
Notes.get_note!(id)
|> Notes.view_note!()
|> Notes.preload_note()
{:noreply,
socket
|> assign(:page_title, page_title(socket.assigns.live_action))
|> assign(
:note,
Notes.get_note!(id)
|> Notes.view_note!()
|> Notes.preload_note()
)
|> assign(:page_title, page_title(socket.assigns.live_action, note))
|> assign(:note, note)
|> assign(:link_changeset, Link.changeset(%Link{}, %{note_id: id}))}
end

2
mix.exs

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

Loading…
Cancel
Save