Compare commits
No commits in common. "2d0f6eefab983619602d062b8ff87df9538b63a9" and "0d4deb680576c6c420fe7936c94da4adf8f9e2c4" have entirely different histories.
2d0f6eefab
...
0d4deb6805
@ -26,18 +26,26 @@ import 'phoenix_html'
|
|||||||
import { Socket } from 'phoenix'
|
import { Socket } from 'phoenix'
|
||||||
import { LiveSocket } from 'phoenix_live_view'
|
import { LiveSocket } from 'phoenix_live_view'
|
||||||
import topbar from 'topbar'
|
import topbar from 'topbar'
|
||||||
import Date from './date'
|
|
||||||
import DateTime from './datetime'
|
|
||||||
import MaintainAttrs from './maintain_attrs'
|
import MaintainAttrs from './maintain_attrs'
|
||||||
|
import Alpine from 'alpinejs'
|
||||||
|
|
||||||
const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
|
const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
|
||||||
let csrfToken
|
let csrfToken
|
||||||
if (csrfTokenElement) { csrfToken = csrfTokenElement.getAttribute('content') }
|
if (csrfTokenElement) { csrfToken = csrfTokenElement.getAttribute('content') }
|
||||||
const liveSocket = new LiveSocket('/live', Socket, {
|
const liveSocket = new LiveSocket('/live', Socket, {
|
||||||
|
dom: {
|
||||||
|
onBeforeElUpdated (from, to) {
|
||||||
|
if (from._x_dataStack) { window.Alpine.clone(from, to) }
|
||||||
|
}
|
||||||
|
},
|
||||||
params: { _csrf_token: csrfToken },
|
params: { _csrf_token: csrfToken },
|
||||||
hooks: { Date, DateTime, MaintainAttrs }
|
hooks: { MaintainAttrs }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// alpine.js
|
||||||
|
window.Alpine = Alpine
|
||||||
|
Alpine.start()
|
||||||
|
|
||||||
// Show progress bar on live navigation and form submits
|
// Show progress bar on live navigation and form submits
|
||||||
topbar.config({ barThickness: 1, barColors: { 0: '#fff' }, shadowColor: 'rgba(0, 0, 0, .3)' })
|
topbar.config({ barThickness: 1, barColors: { 0: '#fff' }, shadowColor: 'rgba(0, 0, 0, .3)' })
|
||||||
window.addEventListener('phx:page-loading-start', info => topbar.show())
|
window.addEventListener('phx:page-loading-start', info => topbar.show())
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
export default {
|
|
||||||
displayDate (el) {
|
|
||||||
const date =
|
|
||||||
Intl.DateTimeFormat([], { timeZone: 'Etc/UTC', dateStyle: 'short' })
|
|
||||||
.format(new Date(el.dateTime))
|
|
||||||
|
|
||||||
el.innerText = date
|
|
||||||
},
|
|
||||||
mounted () { this.displayDate(this.el) },
|
|
||||||
updated () { this.displayDate(this.el) }
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
export default {
|
|
||||||
displayDateTime (el) {
|
|
||||||
const date =
|
|
||||||
Intl.DateTimeFormat([], { dateStyle: 'short', timeStyle: 'long' })
|
|
||||||
.format(new Date(el.dateTime))
|
|
||||||
|
|
||||||
el.innerText = date
|
|
||||||
},
|
|
||||||
mounted () { this.displayDateTime(this.el) },
|
|
||||||
updated () { this.displayDateTime(this.el) }
|
|
||||||
}
|
|
13996
assets/package-lock.json
generated
13996
assets/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "v18.9.1",
|
"node": "v18.9.1",
|
||||||
"npm": "8.19.1"
|
"npm": "8.10.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "NODE_ENV=production webpack --mode production",
|
"deploy": "NODE_ENV=production webpack --mode production",
|
||||||
@ -13,35 +13,35 @@
|
|||||||
"test": "standard"
|
"test": "standard"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/nunito-sans": "^4.5.10",
|
"@fontsource/nunito-sans": "^4.5.8",
|
||||||
"@fortawesome/fontawesome-free": "^6.3.0",
|
"@fortawesome/fontawesome-free": "^6.1.1",
|
||||||
|
"alpinejs": "^3.10.2",
|
||||||
"phoenix": "file:../deps/phoenix",
|
"phoenix": "file:../deps/phoenix",
|
||||||
"phoenix_html": "file:../deps/phoenix_html",
|
"phoenix_html": "file:../deps/phoenix_html",
|
||||||
"phoenix_live_view": "file:../deps/phoenix_live_view",
|
"phoenix_live_view": "file:../deps/phoenix_live_view",
|
||||||
"topbar": "^2.0.1"
|
"topbar": "^1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.21.3",
|
"@babel/core": "^7.17.10",
|
||||||
"@babel/preset-env": "^7.20.2",
|
"@babel/preset-env": "^7.17.10",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.7",
|
||||||
"babel-loader": "^9.1.2",
|
"babel-loader": "^8.2.5",
|
||||||
"copy-webpack-plugin": "^11.0.0",
|
"copy-webpack-plugin": "^10.2.4",
|
||||||
"css-loader": "^6.7.3",
|
"css-loader": "^6.7.1",
|
||||||
"css-minimizer-webpack-plugin": "^4.2.2",
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
||||||
"file-loader": "^6.2.0",
|
"file-loader": "^6.2.0",
|
||||||
"mini-css-extract-plugin": "^2.7.5",
|
"mini-css-extract-plugin": "^2.6.0",
|
||||||
"npm-check-updates": "^16.7.12",
|
"postcss": "^8.4.13",
|
||||||
"postcss": "^8.4.21",
|
"postcss-import": "^14.1.0",
|
||||||
"postcss-import": "^15.1.0",
|
"postcss-loader": "^6.2.1",
|
||||||
"postcss-loader": "^7.1.0",
|
"postcss-preset-env": "^7.5.0",
|
||||||
"postcss-preset-env": "^8.0.1",
|
"sass": "^1.56.0",
|
||||||
"sass": "^1.59.3",
|
"sass-loader": "^12.6.0",
|
||||||
"sass-loader": "^13.2.1",
|
|
||||||
"standard": "^17.0.0",
|
"standard": "^17.0.0",
|
||||||
"tailwindcss": "^3.2.7",
|
"tailwindcss": "^3.0.24",
|
||||||
"terser-webpack-plugin": "^5.3.7",
|
"terser-webpack-plugin": "^5.3.1",
|
||||||
"webpack": "^5.76.2",
|
"webpack": "^5.72.0",
|
||||||
"webpack-cli": "^5.0.1",
|
"webpack-cli": "^4.9.2",
|
||||||
"webpack-dev-server": "^4.13.1"
|
"webpack-dev-server": "^4.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# v0.1.10
|
# v0.1.10
|
||||||
- Improve accessibility
|
- Improve accessibility
|
||||||
- Code quality improvements
|
- Code quality improvements
|
||||||
- Fix dates displaying incorrectly
|
|
||||||
|
|
||||||
# v0.1.9
|
# v0.1.9
|
||||||
- Improve server log
|
- Improve server log
|
||||||
|
@ -89,7 +89,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Phoenix.Component for a <time> element that renders the naivedatetime in the
|
Phoenix.Component for a <time> element that renders the naivedatetime in the
|
||||||
user's local timezone
|
user's local timezone with Alpine.js
|
||||||
"""
|
"""
|
||||||
def datetime(assigns)
|
def datetime(assigns)
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Phoenix.Component for a <date> element that renders the Date in the user's
|
Phoenix.Component for a <date> element that renders the Date in the user's
|
||||||
local timezone
|
local timezone with Alpine.js
|
||||||
"""
|
"""
|
||||||
def date(assigns)
|
def date(assigns)
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
<time :if={@date} id={@id} datetime={Date.to_iso8601(@date, :extended)} phx-hook="Date">
|
<time :if={@date} id={@id} datetime={@date |> Date.to_iso8601(:extended)} x-data={~s<{
|
||||||
<%= Date.to_iso8601(@date, :extended) %>
|
date:
|
||||||
|
Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'})
|
||||||
|
.format(new Date("#{Date.to_iso8601(@date, :extended)}"))
|
||||||
|
}>} x-text="date">
|
||||||
|
<%= @date |> Date.to_iso8601(:extended) %>
|
||||||
</time>
|
</time>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} phx-hook="DateTime">
|
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} x-data={~s/{
|
||||||
|
datetime:
|
||||||
|
Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'})
|
||||||
|
.format(new Date("#{cast_datetime(@datetime)}"))
|
||||||
|
}/} x-text="datetime">
|
||||||
<%= cast_datetime(@datetime) %>
|
<%= cast_datetime(@datetime) %>
|
||||||
</time>
|
</time>
|
||||||
|
Loading…
Reference in New Issue
Block a user