-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotaryPhonePage.jsx
More file actions
200 lines (177 loc) · 6.18 KB
/
RotaryPhonePage.jsx
File metadata and controls
200 lines (177 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import React, { useState } from 'react';
import RotaryDial from '../../components/RotaryDial';
import BreadcrumbTitle from '../../components/BreadcrumbTitle';
import Seo from '../../components/Seo';
import DigitalDisplay from '../../components/DigitalDisplay';
import { BackspaceIcon, TrashIcon, PhoneIcon } from '@phosphor-icons/react';
import { useAchievements } from '../../context/AchievementContext';
const ACHIEVEMENTS_MAP = {
911: 'the_emergency',
0: 'operator',
123: 'speaking_clock',
1905: 'galatasaray',
6: 'm_for_murder',
5550690: 'trinity_calling',
'0451': 'immersive_sim_door_code',
555: 'call_me_generic',
117: 'mr_halo_himself',
47: 'barcode_man',
111111: 'skyrim',
52: 'new_dc_universe',
824: 'kobe',
42: 'the_answer',
80085: 'dealing_with_a_kid',
1984: 'dystopian_are_we',
404: 'not_found',
666: 'devil',
'007': 'the_worst_agent',
314: 'pie',
12: 'the_number_of_monkeys',
36: 'some_bodies_gonna_get_it',
182: 'fast_eyes',
808: 'and_heartbreak',
1337: 'elite',
3310: 'indestructible',
9000: 'daisy_daisy',
66: 'the_order',
99: 'one_less_problem',
3005: 'the_holo_grammy',
313: 'moms_spaghetti',
51: 'truth_is_out_there',
57: 'ketchup',
711: 'open_24_hours',
1066: 'invaded_england',
34: 'dont_google',
2: 'all_eyez_on_me',
343: 'the_monitor',
19: 'you_smart',
360: 'the_last_good_gen',
127001: 'cyber_homie',
418: 'teapot',
32: 'system',
5150: 'van_halen',
1993: 'rip_and_tear',
80211: 'wireless',
747: 'boing',
9: 'feline',
'000000': 'black',
2600: 'the_real_retro_gamer',
11: 'ocean',
20: 'critical_hit',
21: 'savage',
80: 'www',
24: 'ctu_agent',
};
const RotaryPhonePage = () => {
const [phoneNumber, setPhoneNumber] = useState('');
const [statusMessage, setStatusMessage] = useState(null);
const [isCalling, setIsCalling] = useState(false);
const { unlockAchievement } = useAchievements();
const handleDial = (digit) => {
if (isCalling) return;
setPhoneNumber((prev) => prev + digit);
};
const handleBackspace = () => {
if (isCalling) return;
setPhoneNumber((prev) => prev.slice(0, -1));
};
const handleClear = () => {
if (isCalling) return;
setPhoneNumber('');
};
const handleCall = () => {
if (!phoneNumber || isCalling) return;
setIsCalling(true);
setStatusMessage('Calling...');
setTimeout(() => {
let res = ACHIEVEMENTS_MAP[phoneNumber];
if (res) {
setStatusMessage('Connected');
unlockAchievement(res);
} else {
setStatusMessage('Dial Failed');
}
setTimeout(() => {
setStatusMessage(null);
setIsCalling(false);
}, 2000);
}, 2000);
};
const getDisplayText = () => {
if (statusMessage) return statusMessage;
return phoneNumber || <span className="opacity-20">...</span>;
};
const getDisplayColor = () => {
if (statusMessage === 'Dial Failed')
return 'text-red-500 drop-shadow-[0_0_8px_rgba(239,68,68,0.6)]';
if (statusMessage === 'Connected')
return 'text-blue-400 drop-shadow-[0_0_8px_rgba(96,165,250,0.6)]';
return 'text-green-400 drop-shadow-[0_0_8px_rgba(74,222,128,0.6)]';
};
return (
<div className="min-h-screen bg-gray-950 py-12 px-4 sm:px-6 lg:px-8 flex flex-col items-center relative overflow-hidden">
<Seo
title="Rotary Phone | Fezcodex"
description="A digital rotary phone. Dial numbers with your mouse or finger."
keywords="rotary phone, dialer, retro, interactive, web app"
/>
<div className="w-full max-w-7xl mx-auto relative z-10">
<BreadcrumbTitle title="Rotary Phone" slug="phone" />
</div>
<div className="z-10 w-full max-w-2xl flex flex-col items-center gap-12 mt-8">
{/* Display Area */}
<div className="w-full bg-gray-900 p-6 rounded-3xl shadow-2xl border border-gray-800 relative">
<div className="absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-gray-950 px-4 py-1 rounded-full border border-gray-800 text-gray-500 text-xs uppercase tracking-widest font-mono">
Display
</div>
<DigitalDisplay
text={getDisplayText()}
colorClass={getDisplayColor()}
showCursor={!isCalling}
/>
<div className="flex justify-end gap-3 mt-4">
<button
onClick={handleCall}
disabled={!phoneNumber || isCalling}
className="p-2 px-4 rounded-lg bg-green-600 text-white hover:bg-green-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 mr-auto"
title="Call"
>
<PhoneIcon size={24} weight="fill" />
<span className="font-bold font-mono">CALL</span>
</button>
<button
onClick={handleBackspace}
disabled={!phoneNumber || isCalling}
className="p-2 rounded-lg bg-gray-800 text-gray-400 hover:text-white hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
title="Backspace"
>
<BackspaceIcon size={24} />
</button>
<button
onClick={handleClear}
disabled={!phoneNumber || isCalling}
className="p-2 rounded-lg bg-red-900/30 text-red-400 hover:text-red-300 hover:bg-red-900/50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
title="Clear All"
>
<TrashIcon size={24} />
</button>
</div>
</div>
{/* The Dial */}
<div className="relative py-8">
<div className="absolute inset-0 bg-primary-500/5 blur-[100px] rounded-full pointer-events-none" />
<RotaryDial onDial={handleDial} />
</div>
{/* Instructions */}
<div className="text-gray-500 text-center max-w-md space-y-2">
<p className="text-lg font-medium text-gray-400">How to use:</p>
<p className="text-sm">
Click and hold a number hole, drag it clockwise until it hits the
metal stop at the bottom right, then release.
</p>
</div>
</div>
</div>
);
};
export default RotaryPhonePage;