Creating Github-style Database Record References Using LiveView in Elixir

167
clicks
Creating Github-style Database Record References Using LiveView in Elixir
Jason Kaniekete details the development process for enhancing his Tekken Teacher application — a platform designed to help players learn and improve their Tekken game strategies. Seeking to provide a more effective way of linking to various game data elements such as character moves and properties, he created a system that allows inserting references to these elements directly into text fields via an 'input-detection' LiveView component. This system, inspired by Github's referencing feature, displays a dropdown menu suggesting possible database entities to link to when a '#' is typed within the input field. These suggestions come from querying two Elixir tables, 'states' and 'stances'. He incorporates a LiveView hook that listens for 'keyup' and 'term_selected' events to manage querying and term-selection functionality, using custom Javascript to handle user interactions with the UI component. The server-side logic is managed using the relevant handle_event functions in Phoenix's LiveView module.

© HashMerge 2024