Skip to content

Commit 0111ea1

Browse files
tiger init follow up (supabase#30659)
* meetups link * max-height * fix cursor and update share text
1 parent d2facb9 commit 0111ea1

File tree

13 files changed

+93
-120
lines changed

13 files changed

+93
-120
lines changed

apps/www/app/api-v2/ticket-og/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export async function GET(req: Request, res: Response) {
9797
const OG_WIDTH = 1200
9898
const OG_HEIGHT = 628
9999
const USERNAME_LEFT = 400
100-
const USERNAME_BOTTOM = 60
100+
const USERNAME_BOTTOM = 100
101101
const USERNAME_WIDTH = 400
102102
const DISPLAY_NAME = name || username
103103

apps/www/components/LaunchWeek/13/Multiplayer/CanvasPartyMode.tsx

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,17 @@ import { Coordinates, Payload, User } from './types'
1515
import { cloneDeep, throttle } from 'lodash'
1616
import Cursor from './Cursor'
1717

18-
/**
19-
* [x] multiplayer cursors
20-
* [x] show own cursor
21-
* [x] show own trail
22-
* [x] show other users cursors
23-
* [x] brand color for current user
24-
* [x] gray for online users
25-
* [x] offset cursor position by scroll offset Y
26-
* [ ] hide own cursor on touch devices
27-
*/
28-
29-
const GRID_SIZE = 100
30-
const CELL_SIZE = 35
31-
const CANVAS_WIDTH = 1800
32-
const CANVAS_HEIGHT = 1600
33-
const HOVER_DURATION = 100
34-
const FADE_DURATION = 300
18+
export const GRID_SIZE = 100
19+
export const CELL_SIZE = 40
20+
export const CANVAS_WIDTH = 1800
21+
export const CANVAS_HEIGHT = 1600
22+
export const HOVER_DURATION = 100
23+
export const FADE_DURATION = 300
3524

3625
const MAX_ROOM_USERS = 50
3726
const MAX_EVENTS_PER_SECOND = 10
38-
const X_THRESHOLD = 25
39-
const Y_THRESHOLD = 65
27+
export const X_THRESHOLD = 25
28+
export const Y_THRESHOLD = 65
4029

4130
interface CellState {
4231
isHovered: boolean
@@ -72,6 +61,7 @@ export default function InteractiveGrid() {
7261
const [users, setUsers] = useState<{ [key: string]: User }>({})
7362

7463
const setMousePosition = (coordinates: Coordinates) => {
64+
// if (!mousePositionRef.current) return
7565
mousePositionRef.current = coordinates
7666
_setMousePosition(coordinates)
7767
}
@@ -110,7 +100,7 @@ export default function InteractiveGrid() {
110100
Client is joining 'rooms' channel to examine existing rooms and their users
111101
and then the channel is removed once a room is selected
112102
*/
113-
roomChannel = supabase?.channel('rooms')!
103+
roomChannel = supabase?.channel('lw13_rooms')!
114104

115105
roomChannel
116106
.on(REALTIME_LISTEN_TYPES.PRESENCE, { event: REALTIME_PRESENCE_LISTEN_EVENTS.SYNC }, () => {
@@ -133,7 +123,7 @@ export default function InteractiveGrid() {
133123
.subscribe()
134124
} else {
135125
// When user has been placed in a room
136-
roomChannel = supabase?.channel('rooms', { config: { presence: { key: roomId } } })!
126+
roomChannel = supabase?.channel('lw13_rooms', { config: { presence: { key: roomId } } })!
137127
roomChannel.on(
138128
REALTIME_LISTEN_TYPES.PRESENCE,
139129
{ event: REALTIME_PRESENCE_LISTEN_EVENTS.SYNC },
@@ -155,7 +145,7 @@ export default function InteractiveGrid() {
155145
}, [supabase, roomId])
156146

157147
useEffect(() => {
158-
if (!roomId || !isInitialStateSynced) return
148+
// if (!roomId || !isInitialStateSynced) return
159149

160150
let messageChannel: RealtimeChannel
161151
let setMouseEvent: (e: MouseEvent) => void = () => {}
@@ -190,28 +180,28 @@ export default function InteractiveGrid() {
190180
}
191181
)
192182

193-
messageChannel.subscribe((status: `${REALTIME_SUBSCRIBE_STATES}`) => {
194-
if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED) {
195-
// Lodash throttle will be removed once realtime-js client throttles on the channel level
196-
const sendMouseBroadcast = throttle(({ x, y }) => {
197-
messageChannel
198-
.send({
199-
type: 'broadcast',
200-
event: 'POS',
201-
payload: { user_id: userId, x, y },
202-
})
203-
.catch(() => {})
204-
}, 1000 / MAX_EVENTS_PER_SECOND)
205-
206-
setMouseEvent = (e: MouseEvent) => {
207-
const top = window.pageYOffset || document.documentElement.scrollTop
208-
const [x, y] = [e.clientX, e.clientY - Y_THRESHOLD + top]
183+
messageChannel?.subscribe((status: `${REALTIME_SUBSCRIBE_STATES}`) => {
184+
// Lodash throttle will be removed once realtime-js client throttles on the channel level
185+
const sendMouseBroadcast = throttle(({ x, y }) => {
186+
messageChannel
187+
.send({
188+
type: 'broadcast',
189+
event: 'POS',
190+
payload: { user_id: userId, x, y },
191+
})
192+
.catch(() => {})
193+
}, 1000 / MAX_EVENTS_PER_SECOND)
194+
195+
setMouseEvent = (e: MouseEvent) => {
196+
const top = window.pageYOffset || document.documentElement.scrollTop
197+
const [x, y] = [e.clientX, e.clientY - Y_THRESHOLD + top]
198+
if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED) {
209199
sendMouseBroadcast({ x, y })
210-
setMousePosition({ x, y })
211200
}
212-
213-
window.addEventListener('mousemove', setMouseEvent)
201+
setMousePosition({ x, y })
214202
}
203+
204+
window.addEventListener('mousemove', setMouseEvent)
215205
})
216206

217207
return () => {
@@ -337,7 +327,7 @@ export default function InteractiveGrid() {
337327
}, [hoveredCells, setCellHovered, userData])
338328

339329
return (
340-
<div className="absolute inset-0 w-screen h-screen flex justify-center items-center max-w-screen max-h-screen cursor-none">
330+
<div className="absolute inset-0 w-screen h-screen flex justify-center items-center max-w-screen max-h-screen">
341331
<canvas
342332
ref={canvasRef}
343333
width={CANVAS_WIDTH}
@@ -348,7 +338,7 @@ export default function InteractiveGrid() {
348338
/>
349339

350340
{/* Current user cursor */}
351-
<Cursor
341+
{/* <Cursor
352342
key={userId}
353343
x={mousePosition?.x}
354344
y={mousePosition?.y}
@@ -357,7 +347,7 @@ export default function InteractiveGrid() {
357347
message={''}
358348
isTyping={false}
359349
isCurrentUser={true}
360-
/>
350+
/> */}
361351

362352
{/* Online users cursors */}
363353
{Object.entries(users).reduce((acc, [userId, data]) => {

apps/www/components/LaunchWeek/13/Multiplayer/CanvasSingleMode.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import { useTheme } from 'next-themes'
77
import Cursor from './Cursor'
88
import { getColor } from './randomColor'
99
import { Coordinates } from './types'
10-
11-
const GRID_SIZE = 100
12-
const CELL_SIZE = 35
13-
const CANVAS_WIDTH = 1800
14-
const CANVAS_HEIGHT = 1600
15-
const HOVER_DURATION = 100
16-
const FADE_DURATION = 300
17-
const Y_THRESHOLD = 65
10+
import {
11+
HOVER_DURATION,
12+
CANVAS_WIDTH,
13+
CANVAS_HEIGHT,
14+
GRID_SIZE,
15+
CELL_SIZE,
16+
FADE_DURATION,
17+
Y_THRESHOLD,
18+
} from './CanvasPartyMode'
1819

1920
interface CellState {
2021
isHovered: boolean
@@ -189,7 +190,7 @@ export default function InteractiveGridSingle() {
189190
}, [supabase])
190191

191192
return (
192-
<div className="absolute inset-0 w-screen h-screen flex justify-center items-center max-w-screen max-h-screen cursor-none">
193+
<div className="absolute inset-0 w-screen h-screen flex justify-center items-center max-w-screen max-h-screen">
193194
<canvas
194195
ref={canvasRef}
195196
width={CANVAS_WIDTH}
@@ -200,15 +201,15 @@ export default function InteractiveGridSingle() {
200201
/>
201202

202203
{/* Current user cursor */}
203-
<Cursor
204+
{/* <Cursor
204205
x={mousePosition?.x}
205206
y={mousePosition?.y}
206207
color={getColor('brand').bg}
207208
hue={getColor('brand').hue}
208209
message={''}
209210
isTyping={false}
210211
isCurrentUser={true}
211-
/>
212+
/> */}
212213
</div>
213214
)
214215
}

apps/www/components/LaunchWeek/13/Multiplayer/Cursor.tsx

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useBreakpoint } from 'common'
2-
import { FC, FormEvent, useEffect, useRef, useState } from 'react'
2+
import { FC, useEffect, useRef, useState } from 'react'
33
import { cn } from 'ui'
44

55
interface Props {
@@ -15,10 +15,7 @@ interface Props {
1515
onUpdateMessage?: (message: string) => void
1616
}
1717

18-
const MAX_MESSAGE_LENGTH = 70
1918
const MAX_DURATION = 4000
20-
const MAX_BUBBLE_WIDTH_THRESHOLD = 280 + 50
21-
const MAX_BUBBLE_HEIGHT_THRESHOLD = 40 + 50
2219

2320
const Cursor: FC<Props> = ({
2421
x,
@@ -32,16 +29,13 @@ const Cursor: FC<Props> = ({
3229
isLocalClient,
3330
onUpdateMessage = () => {},
3431
}) => {
35-
// Don't show cursor for the local client
3632
const _isLocalClient = !x || !y
3733
const inputRef = useRef() as any
3834
const timeoutRef = useRef() as any
3935
const chatBubbleRef = useRef() as any
4036
const isMobile = useBreakpoint('sm')
4137

4238
const [isTouchDevice, setIsTouchDevice] = useState(false)
43-
const [flipX, setFlipX] = useState(false)
44-
const [flipY, setFlipY] = useState(false)
4539
const [hideInput, setHideInput] = useState(false)
4640
const [showMessageBubble, setShowMessageBubble] = useState(false)
4741

@@ -68,14 +62,6 @@ const Cursor: FC<Props> = ({
6862
}
6963
}, [isLocalClient, isTyping, isCancelled, message, inputRef])
7064

71-
useEffect(() => {
72-
// [Joshen] Experimental: dynamic flipping to ensure that chat
73-
// bubble always stays within the viewport, comment this block
74-
// out if the effect seems weird.
75-
setFlipX((x || 0) + MAX_BUBBLE_WIDTH_THRESHOLD >= window.innerWidth)
76-
setFlipY((y || 0) + MAX_BUBBLE_HEIGHT_THRESHOLD >= window.innerHeight)
77-
}, [x, y, isTyping, chatBubbleRef])
78-
7965
useEffect(() => {
8066
// touchscreen
8167
if (window.matchMedia('(pointer: coarse)').matches && isMobile) {
@@ -119,39 +105,9 @@ const Cursor: FC<Props> = ({
119105
)}
120106
style={{
121107
backgroundColor: color,
122-
transform: `translateX(${
123-
(x || 0) + (flipX ? -chatBubbleRef.current.clientWidth - 20 : 20)
124-
}px) translateY(${(y || 0) + (flipY ? -chatBubbleRef.current.clientHeight - 20 : 20)}px)`,
108+
transform: `translateX(${(x || 0) + 20}px) translateY(${(y || 0) + 20}px)`,
125109
}}
126-
>
127-
{_isLocalClient && !hideInput ? (
128-
<>
129-
<input
130-
ref={inputRef}
131-
value={message}
132-
className="w-full !outline-none bg-transparent !border-none text-foreground"
133-
onChange={(e: FormEvent<HTMLInputElement>) => {
134-
const text = e.currentTarget.value
135-
if (text.length <= MAX_MESSAGE_LENGTH) onUpdateMessage(e.currentTarget.value)
136-
}}
137-
/>
138-
<p className="text-xs" style={{ color: hue }}>
139-
{message.length}/{MAX_MESSAGE_LENGTH}
140-
</p>
141-
</>
142-
) : message.length ? (
143-
<div className="truncate text-foreground-light">{message}</div>
144-
) : (
145-
<div className="flex items-center justify-center">
146-
<div className="loader-dots block relative h-6 w-10">
147-
<div className="absolute top-0 my-2.5 w-1.5 h-1.5 rounded-full bg-foreground opacity-75"></div>
148-
<div className="absolute top-0 my-2.5 w-1.5 h-1.5 rounded-full bg-foreground opacity-75"></div>
149-
<div className="absolute top-0 my-2.5 w-1.5 h-1.5 rounded-full bg-foreground opacity-75"></div>
150-
<div className="absolute top-0 my-2.5 w-1.5 h-1.5 rounded-full bg-foreground opacity-75"></div>
151-
</div>
152-
</div>
153-
)}
154-
</div>
110+
></div>
155111
</>
156112
)
157113
}

apps/www/components/LaunchWeek/13/ThreeTicketCanvas.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,11 @@ const ThreeTicketCanvas: React.FC<{
503503
return (
504504
<div
505505
className={cn(
506-
'w-screen absolute inset-0 lg:h-full lg:min-h-full flex justify-end items-center overflow-hidden pointer-events-none',
506+
'w-screen absolute inset-0 lg:h-full lg:min-h-full lg:max-h-[1000px] flex justify-end items-center overflow-hidden pointer-events-none',
507507
className
508508
)}
509509
>
510-
<div ref={canvasRef} className="w-full lg:h-full !cursor-none" />
510+
<div ref={canvasRef} className="w-full lg:h-full" />
511511
{isGameMode && !hasWon && !sharePage && (
512512
<InputOTP
513513
ref={inputRef}

apps/www/components/LaunchWeek/13/Ticket/TicketActions.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { Check } from 'lucide-react'
44
import { useTheme } from 'next-themes'
55
import Link from 'next/link'
66
import { useEffect, useRef, useState } from 'react'
7-
import { Button } from 'ui'
7+
import { Button, cn } from 'ui'
88
import useConfData from '~/components/LaunchWeek/hooks/use-conf-data'
99
import { LW_URL, TWEET_TEXT, TWEET_TEXT_PLATINUM, TWEET_TEXT_SECRET } from '~/lib/constants'
10+
import useLWPartyMode from '../useLWPartyMode'
1011

1112
export default function TicketActions() {
1213
const { resolvedTheme } = useTheme()
@@ -74,13 +75,13 @@ export default function TicketActions() {
7475
}
7576

7677
return (
77-
<div className="flex flex-row flex-wrap justify-start w-full gap-2 pointer-events-auto !cursor-none">
78+
<div className="flex flex-row flex-wrap justify-start w-full gap-2 pointer-events-auto">
7879
<Button
7980
onClick={() => handleShare('twitter')}
8081
type={userData.shared_on_twitter ? 'secondary' : 'default'}
8182
icon={userData.shared_on_twitter && <Check strokeWidth={2} />}
8283
size={isLessThanMd ? 'tiny' : 'small'}
83-
className="px-2 lg:px-3.5 h-[28px] lg:h-[34px] flex-grow !cursor-none"
84+
className="px-2 lg:px-3.5 h-[28px] lg:h-[34px] flex-grow"
8485
asChild
8586
>
8687
<Link href={tweetUrl} target="_blank">
@@ -92,7 +93,7 @@ export default function TicketActions() {
9293
type={userData.shared_on_linkedin ? 'secondary' : 'default'}
9394
icon={userData.shared_on_linkedin && <Check strokeWidth={2} />}
9495
size={isLessThanMd ? 'tiny' : 'small'}
95-
className="px-2 lg:px-3.5 h-[28px] lg:h-[34px] flex-grow !cursor-none"
96+
className="px-2 lg:px-3.5 h-[28px] lg:h-[34px] flex-grow"
9697
asChild
9798
>
9899
<Link href={linkedInUrl} target="_blank">

apps/www/components/LaunchWeek/13/Ticket/TicketCopy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function TicketCopy() {
2929
}, 2000)
3030
})
3131
}}
32-
className="font-mono w-full flex-grow px-2 lg:px-3.5 !pr-1 py-1 rounded-md bg-alternative-200 border flex gap-2 relative text-foreground-light hover:text-foreground text-xs pointer-events-auto justify-between items-center hover:border-stronger transition-all !cursor-none"
32+
className="font-mono w-full flex-grow px-2 lg:px-3.5 !pr-1 py-1 rounded-md bg-alternative-200 border flex gap-2 relative text-foreground-light hover:text-foreground text-xs pointer-events-auto justify-between items-center hover:border-stronger transition-all"
3333
>
3434
<span className="truncate">{displayUrl}</span>
3535
<div className="w-6 min-w-6 h-6 flex items-center justify-center flex-shrink-0 border border-strong rounded bg-muted hover:bg-selection hover:border-stronger">

apps/www/components/LaunchWeek/13/Ticket/TicketForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export default function TicketForm() {
156156
onClick={handleGithubSignIn}
157157
loading={formState === 'loading'}
158158
type="default"
159-
className="sm:pl-1 cursor-none"
159+
className="sm:pl-1"
160160
>
161161
<div className="flex items-center">
162162
<div className="relative h-6 w-6 border rounded bg-surface-75 mr-2 uppercase hidden sm:flex items-center justify-center">

apps/www/components/LaunchWeek/13/Ticket/TicketPresence.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const TicketPresence = (props: { className?: string }) => {
1717
useEffect(() => {
1818
// Listen to realtime presence
1919
if (!realtimeChannel && supabase) {
20-
const lw13Room = supabase?.channel('lw13_online', {
20+
const lw13Room = supabase?.channel('lw13_rooms', {
2121
config: { broadcast: { self: true, ack: true } },
2222
})
2323

0 commit comments

Comments
 (0)