Skip to content

Instantly share code, notes, and snippets.

View jmarsh24's full-sized avatar
🤓
Programming

Justin Marsh jmarsh24

🤓
Programming
View GitHub Profile
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static targets = [
"button",
"startTime",
"endTime",
"playbackSpeed",
"source",
];
class Video::Search
SEARCHABLE_COLUMNS = %w[
songs.title
songs.last_name_search
videos.channel_id
videos.performance_date
videos.view_count
videos.updated_at
videos.popularity
videos.like_count
<%= turbo_frame_tag "#{dom_id(@video)}_vote" do %>
<div class="like-buttons" style="display: flex; align-items: center;">
<%= render partial: "videos/show/upvote_link" %>
<%= render partial: "videos/show/like_count" %>
<%= render partial: "videos/show/downvote_link" %>
</div>
<% end %>
<ul role="listbox" data-combobox-target="list">
<% search_results.each_with_index do |result, index| %>
<li>
<%= link_to highlight(result, params[:query], :highlighter => '<b>\1</b>'), root_path(query: result.parameterize(separator: " ")), role: "option", id: "search_result_#{index}" %>
</li>
<% end %>
</ul>
import { Controller } from '@hotwired/stimulus'
import axios from 'axios'
import { autocomplete } from '@algolia/autocomplete-js'
export default class extends Controller {
static targets = ['field']
search (query, callback) {
axios.get('/search_suggestions', { params: { query } }).then(response => {
callback(response.data)
import { Controller } from "@hotwired/stimulus"
import Combobox from '@github/combobox-nav'
// Connects to data-controller="combobox"
export default class extends Controller {
static get targets() { return [ "input", "list" ] }
disconnect() {
this.combobox?.destroy()
}
import { Controller } from '@hotwired/stimulus'
import axios from 'axios'
import { autocomplete } from '@algolia/autocomplete-js'
export default class extends Controller {
static targets = ['field']
search (query, callback) {
axios.get('/search_suggestions', { params: { query } }).then(response => {
callback(response.data)