Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Add multiplayer cursors and cursor chat #89

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@tailwind components;
@tailwind utilities;


/* @layer components {
.testing {
@apply bg-red-200;
Expand Down Expand Up @@ -276,7 +275,7 @@ button, input[type=submit] {
input[type=text], input[type=email], input[type=number], .input2, x-selectmenu::part(button) {
background-color: #262626 !important;
border: 1.5px solid var(--cultured)!important;
border-radius: 5px !important;
border-radius: 5px;
min-width: 350px;
color: white;
}
Expand Down
9 changes: 9 additions & 0 deletions app/channels/cursor_chat_channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CursorChatChannel < ApplicationCable::Channel
def subscribed
stream_from params[:id]
end

def receive(data)
ActionCable.server.broadcast(params[:id], data)
end
end
1 change: 1 addition & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import "controllers"
import "@hotwired/turbo-rails"
import "selectlist"
import("selectlist")

8 changes: 8 additions & 0 deletions app/javascript/controllers/cursorchat_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { initCursorChat } from "cursor-chat"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
initCursorChat()
}
}
8 changes: 7 additions & 1 deletion app/views/layouts/domain.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<%= stylesheet_link_tag "https://unpkg.com/cursor-chat/dist/style.css" %>

<%# https://icons.hackclub.com/ %>
<div class="flex flex-col lg:flex-row gap-12">
<div class="flex flex-col lg:flex-row gap-12" data-controller="cursorchat">
<div class="flex flex-row flex-wrap lg:flex-col gap-6 side-menu">
<%# link to the dns action %>
<%= link_to records_path(@domain) do %>
Expand Down Expand Up @@ -35,4 +37,8 @@
<%= yield_nested %>
</div>
</div>
</div>

<div id="cursor-chat-layer">
<input type="text" id="cursor-chat-box">
</div>
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
pin "url-safe-base64", to: "https://ga.jspm.io/npm:[email protected]/src/index.js"
pin_all_from "app/javascript"
pin "selectlist", to: "https://esm.sh/[email protected]", preload: true
pin "cursor-chat", to: "https://esm.sh/gh/obl-ong/cursor-chat-actioncable@9befe0089b/dist/cursor-chat.es.js"
Loading