forked from rauversion/rauversion-phx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
625 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// Place your chaskiq workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | ||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | ||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | ||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | ||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | ||
// Placeholders with the same ids are connected. | ||
// Example: | ||
// "Print to console": { | ||
// "scope": "javascript,typescript", | ||
// "prefix": "log", | ||
// "body": [ | ||
// "console.log('$1');", | ||
// "$2" | ||
// ], | ||
// "description": "Log output to console" | ||
// } | ||
"pry": { | ||
"prefix": "pry", | ||
"body": "require IEx; IEx.pry" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"prettier.singleQuote": true, | ||
"typescript.preferences.quoteStyle": "single", | ||
"javascript.preferences.quoteStyle": "single", | ||
"elixirLS.enableTestLenses": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// app/javascript/controllers/audio_controller.js | ||
import { Controller } from "@hotwired/stimulus" | ||
import WaveSurfer from 'wavesurfer' | ||
|
||
export default class extends Controller { | ||
static targets = ['player', 'play', 'pause'] | ||
initialize() {} | ||
connect() { | ||
this.wave() | ||
} | ||
disconnect() {} | ||
|
||
wave(){ | ||
if (this._wave == undefined) { | ||
this._wave = WaveSurfer.create({ | ||
container: this.playerTarget, | ||
backend: 'MediaElement', | ||
waveColor: 'violet', | ||
progressColor: 'purple', | ||
//fillParent: false, | ||
barWidth: 2, | ||
barHeight: 10, // the height of the wave | ||
barGap: null | ||
}) | ||
this._wave.load(this.data.get('url')) | ||
var _this = this | ||
// var that = this | ||
_this.pauseTarget.style.display = 'none' | ||
this._wave.on('pause', function () { | ||
_this.playTarget.style.display = 'block' | ||
_this.pauseTarget.style.display = 'none' | ||
}) | ||
this._wave.on('play', function () { | ||
_this.playTarget.style.display = 'none' | ||
_this.pauseTarget.style.display = 'block' | ||
}) | ||
} | ||
return this._wave | ||
} | ||
|
||
play(){ | ||
this.wave().play() | ||
} | ||
|
||
pause(){ | ||
this.wave().pause() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
connect() { | ||
this.element.textContent = "Hello World!" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Application } from "@hotwired/stimulus" | ||
import Dropdown from "stimulus-dropdown" | ||
|
||
const application = Application.start() | ||
|
||
// Configure Stimulus development experience | ||
application.debug = false | ||
window.Stimulus = application | ||
|
||
application.register("dropdown", Dropdown) | ||
|
||
export { application } | ||
|
||
|
||
|
||
|
||
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) | ||
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" | ||
// lazyLoadControllersFrom("controllers", application) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// app/javascript/controllers/infinite_scoll_controller.js | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
static targets = ["scrollArea", "pagination"] | ||
|
||
connect() { | ||
this.createObserver() | ||
} | ||
createObserver() { | ||
const observer = new IntersectionObserver( | ||
entries => this.handleIntersect(entries), | ||
{ | ||
// https://github.com/w3c/IntersectionObserver/issues/124#issuecomment-476026505 | ||
threshold: [0, 1.0], | ||
} | ||
) | ||
observer.observe(this.scrollAreaTarget) | ||
} | ||
handleIntersect(entries) { | ||
entries.forEach(entry => { | ||
if (entry.isIntersecting) { | ||
this.loadMore() | ||
} | ||
}) | ||
} | ||
loadMore() { | ||
const next = this.paginationTarget.querySelector("[rel=next]") | ||
if (!next) { | ||
return | ||
} | ||
const href = next.href | ||
fetch(href, { | ||
headers: { | ||
Accept: "text/vnd.turbo-stream.html", | ||
}, | ||
}) | ||
.then(r => r.text()) | ||
.then(html => Turbo.renderStreamMessage(html)) | ||
.then(_ => history.replaceState(history.state, "", href)) | ||
} | ||
} | ||
|
||
|
||
/* | ||
// stefanwienert.de/blog/2021/04/17/endless-scroll-with-turbo-streams/ | ||
// index.html.slim | ||
.list-group(data-controller="infinite-scroll") | ||
// If you need to enable Live Updates, you could connect to a | ||
// = turbo_stream_from current_user, :posts | ||
#posts | ||
= render @posts | ||
div(data-infinite-scroll-target='scrollArea') | ||
#pagination.list-group-item.pt-3(data-infinite-scroll-target="pagination") | ||
== pagy_bootstrap_nav(@pagy) | ||
In this index we, | ||
wrap our posts with a Stimulus Controller and | ||
mark the posts into a div with id=posts (to later append to) | ||
add a scrollArea empty element div just below our posts list - This area will be used for our Intersection Observer later on | ||
add the pagy_nav or pagy_bootstrap_nav pagination tags on the bottom, also wrapped in a Stimulus Target to later on pick the next page’s link from it | ||
Now, before we modify the controller to respond to Turbo events, we implement the Stimulus Controller | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
connect() {} | ||
|
||
close() { | ||
this.element.remove(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
const parseSelect2OptionName = (item) => { | ||
item = item.slice(7); | ||
return item.charAt(0).toLowerCase() + item.slice(1); | ||
}; | ||
|
||
export default class extends Controller { | ||
get select() { | ||
return $(this.element); | ||
} | ||
|
||
get options() { | ||
let data = this.select.data(); | ||
let options = {}; | ||
|
||
for (let item in data) { | ||
if (item.indexOf('select2') > -1) { | ||
options = { ...options, [parseSelect2OptionName(item)]: data[item] }; | ||
} | ||
} | ||
|
||
return options; | ||
} | ||
|
||
connect() { | ||
this.select.select2(this.options); | ||
} | ||
|
||
disconnect() { | ||
this.select.select2('destroy'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
connect() { | ||
const el = $(this.element) | ||
|
||
el.find("[data-toggle='tab']").on("click", (e)=>{ | ||
e.preventDefault() | ||
const tabId = $(e.currentTarget).attr("href") | ||
const tab = $(tabId) | ||
tab.siblings(".tab-pane.active").toggleClass("active") | ||
if(tab.hasClass('active')) return | ||
tab.toggleClass("active") | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"@hotwired/stimulus": "^3.0.1", | ||
"@rails/activestorage": "^6.0.5", | ||
"stimulus-dropdown": "^2.0.0", | ||
"wavesurfer": "^1.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Arguments: | ||
/Users/michelson/.nvm/versions/node/v15.4.0/bin/node /usr/local/Cellar/yarn/1.22.18/libexec/bin/yarn.js add @hotwired/stimulus-loading | ||
|
||
PATH: | ||
/Users/michelson/.rvm/gems/ruby-2.7.1/bin:/Users/michelson/.rvm/gems/ruby-2.7.1@global/bin:/Users/michelson/.rvm/rubies/ruby-2.7.1/bin:/Users/michelson/.wasmer/bin:/Users/michelson/.nvm/versions/node/v15.4.0/bin:/Users/Shared/DBngin/mysql/8.0.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/Users/michelson/miniconda2/bin:/Users/michelson/anaconda/bin:/Users/michelson/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/michelson/Library/Android/sdk/platform-tools:/Users/michelson/.rvm/gems/ruby-2.7.1/bin:/Users/michelson/.rvm/gems/ruby-2.7.1@global/bin:/Users/michelson/.rvm/rubies/ruby-2.7.1/bin:/Users/michelson/.wasmer/bin:/Users/michelson/.nvm/versions/node/v15.4.0/bin:/Users/Shared/DBngin/mysql/8.0.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/Users/michelson/miniconda2/bin:/Users/michelson/anaconda/bin:/Users/michelson/.yarn/bin:/Users/michelson/.cargo/bin:/Users/michelson/Library/Android/sdk/tools:/Users/michelson/.pulumi/bin:/Users/michelson/.rvm/bin:/Users/michelson/.wasmer/globals/wapm_packages/.bin:/Users/michelson/.cargo/bin:/Users/michelson/Library/Android/sdk/tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/Users/michelson/miniconda2/bin:/Users/michelson/anaconda/bin:/Users/michelson/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/michelson/Library/Android/sdk/platform-tools:/Users/michelson/.rvm/gems/ruby-2.7.1/bin:/Users/michelson/.rvm/gems/ruby-2.7.1@global/bin:/Users/michelson/.rvm/rubies/ruby-2.7.1/bin:/Users/michelson/.wasmer/bin:/Users/michelson/.nvm/versions/node/v15.4.0/bin:/Users/Shared/DBngin/mysql/8.0.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/Users/michelson/miniconda2/bin:/Users/michelson/anaconda/bin:/Users/michelson/.yarn/bin:/Users/michelson/.cargo/bin:/Users/michelson/Library/Android/sdk/tools:/Users/michelson/.pulumi/bin:/Users/michelson/.rvm/bin:/Users/michelson/.wasmer/globals/wapm_packages/.bin:/Users/michelson/.cargo/bin:/Users/michelson/Library/Android/sdk/tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/michelson/.pulumi/bin:/Users/michelson/.rvm/bin:/Users/michelson/.wasmer/globals/wapm_packages/.bin | ||
|
||
Yarn version: | ||
1.22.18 | ||
|
||
Node version: | ||
15.4.0 | ||
|
||
Platform: | ||
darwin x64 | ||
|
||
Trace: | ||
Error: https://registry.yarnpkg.com/@hotwired%2fstimulus-loading: Not found | ||
at Request.params.callback [as _callback] (/usr/local/Cellar/yarn/1.22.18/libexec/lib/cli.js:66138:18) | ||
at Request.self.callback (/usr/local/Cellar/yarn/1.22.18/libexec/lib/cli.js:140883:22) | ||
at Request.emit (node:events:376:20) | ||
at Request.<anonymous> (/usr/local/Cellar/yarn/1.22.18/libexec/lib/cli.js:141855:10) | ||
at Request.emit (node:events:376:20) | ||
at IncomingMessage.<anonymous> (/usr/local/Cellar/yarn/1.22.18/libexec/lib/cli.js:141777:12) | ||
at Object.onceWrapper (node:events:482:28) | ||
at IncomingMessage.emit (node:events:388:22) | ||
at endReadableNT (node:internal/streams/readable:1295:12) | ||
at processTicksAndRejections (node:internal/process/task_queues:80:21) | ||
|
||
npm manifest: | ||
{ | ||
"dependencies": { | ||
"@hotwired/stimulus": "^3.0.1", | ||
"wavesurfer": "^1.3.4" | ||
} | ||
} | ||
|
||
yarn manifest: | ||
No manifest | ||
|
||
Lockfile: | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@hotwired/stimulus@^3.0.1": | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.0.1.tgz#141f15645acaa3b133b7c247cad58ae252ffae85" | ||
integrity sha512-oHsJhgY2cip+K2ED7vKUNd2P+BEswVhrCYcJ802DSsblJFv7mPFVk3cQKvm2vHgHeDVdnj7oOKrBbzp1u8D+KA== | ||
|
||
wavesurfer@^1.3.4: | ||
version "1.3.4" | ||
resolved "https://registry.yarnpkg.com/wavesurfer/-/wavesurfer-1.3.4.tgz#17908abd20da11a8db460c5a176679621d519bfa" | ||
integrity sha512-Td6t6x8vtBWHQu8ijX+OW5O1z3uDOmHrvOl2P7l1638Cy+8MWLM6kYYp7UDNQc3OZgukm8T6Z5+Dnvie9Rjw0w== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@hotwired/stimulus@^3.0.1": | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.0.1.tgz#141f15645acaa3b133b7c247cad58ae252ffae85" | ||
integrity sha512-oHsJhgY2cip+K2ED7vKUNd2P+BEswVhrCYcJ802DSsblJFv7mPFVk3cQKvm2vHgHeDVdnj7oOKrBbzp1u8D+KA== | ||
|
||
"@rails/activestorage@^6.0.5": | ||
version "6.0.5" | ||
resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-6.0.5.tgz#446e4b3f45bf1d4e1c6fd0b8b6e2566cb70c2b18" | ||
integrity sha512-jp2UKh1QChjOGsApYO3HHuBH1yfv4mqOcKuB70fsT79O/CJWEACVnjKIdaqO+B9BJTKihaxyyepvL7kLfUFiDw== | ||
dependencies: | ||
spark-md5 "^3.0.0" | ||
|
||
hotkeys-js@>=3: | ||
version "3.9.4" | ||
resolved "https://registry.yarnpkg.com/hotkeys-js/-/hotkeys-js-3.9.4.tgz#ce1aa4c3a132b6a63a9dd5644fc92b8a9b9cbfb9" | ||
integrity sha512-2zuLt85Ta+gIyvs4N88pCYskNrxf1TFv3LR9t5mdAZIX8BcgQQ48F2opUptvHa6m8zsy5v/a0i9mWzTrlNWU0Q== | ||
|
||
spark-md5@^3.0.0: | ||
version "3.0.2" | ||
resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.2.tgz#7952c4a30784347abcee73268e473b9c0167e3fc" | ||
integrity sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw== | ||
|
||
stimulus-dropdown@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/stimulus-dropdown/-/stimulus-dropdown-2.0.0.tgz#3d401e418be21787f182c0de4bf0d2fd91cfbf8e" | ||
integrity sha512-3VUZ4TI9qHvzw+sOEX1oQA8Pw8C/K5yI+oltr5B9DTwFzuJrFZRWR33OK3ERllzZep+quvHZZljIpIRifKCmCg== | ||
dependencies: | ||
stimulus-use "^0.50.0-2" | ||
|
||
stimulus-use@^0.50.0-2: | ||
version "0.50.0" | ||
resolved "https://registry.yarnpkg.com/stimulus-use/-/stimulus-use-0.50.0.tgz#0bae92fbb1fd961cbb23569f9edd12ae642ce4a6" | ||
integrity sha512-9NScZQiOycQdzh8VZ15pxk6ep/a22fgha2halOvZFpJITC4nsTbWlO7D1hm+9LspFxa5b28tQhm3XkbH/qAlGw== | ||
dependencies: | ||
hotkeys-js ">=3" | ||
|
||
wavesurfer@^1.3.4: | ||
version "1.3.4" | ||
resolved "https://registry.yarnpkg.com/wavesurfer/-/wavesurfer-1.3.4.tgz#17908abd20da11a8db460c5a176679621d519bfa" | ||
integrity sha512-Td6t6x8vtBWHQu8ijX+OW5O1z3uDOmHrvOl2P7l1638Cy+8MWLM6kYYp7UDNQc3OZgukm8T6Z5+Dnvie9Rjw0w== |
Oops, something went wrong.