JIGH4T-OT commited on
Commit
47df9fc
·
verified ·
1 Parent(s): 307bc7d

Create a clean, minimalist timer website that allows users to:

Browse files

Set countdown timers with start, pause, and reset functionality.

Use an alarm sound when the timer reaches zero.

Input time quickly via intuitive controls (e.g., typing or slider).

Have a clear, readable display of the remaining time.

Support basic customization like choosing alarm sounds and light/dark mode.

Be responsive for desktop and mobile devices.

Focus on simplicity and ease of use, with no clutter or unnecessary features. Prioritize fast loading speed and accessibility. Provide a modern, friendly UI design that users of all ages find straightforward.

Files changed (4) hide show
  1. README.md +7 -4
  2. index.html +122 -19
  3. script.js +137 -0
  4. style.css +13 -21
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Ticktock Timer
3
- emoji: 👁
4
  colorFrom: yellow
5
- colorTo: pink
 
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: TickTock Timer ⏱️
 
3
  colorFrom: yellow
4
+ colorTo: red
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
index.html CHANGED
@@ -1,19 +1,122 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="light">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>TickTock Timer ⏱️</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://unpkg.com/feather-icons"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
+ <script>
12
+ tailwind.config = {
13
+ darkMode: 'class',
14
+ theme: {
15
+ extend: {
16
+ colors: {
17
+ primary: {
18
+ 100: '#d1d5db',
19
+ 200: '#9ca3af',
20
+ 300: '#6b7280',
21
+ 400: '#4b5563',
22
+ 500: '#374151',
23
+ 600: '#1f2937',
24
+ 700: '#111827',
25
+ },
26
+ secondary: {
27
+ 100: '#e5e7eb',
28
+ 200: '#d1d5db',
29
+ 300: '#9ca3af',
30
+ 400: '#6b7280',
31
+ 500: '#4b5563',
32
+ 600: '#374151',
33
+ 700: '#1f2937',
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ </script>
40
+ </head>
41
+ <body class="bg-gray-50 dark:bg-gray-900 min-h-screen transition-colors duration-300">
42
+ <div class="container mx-auto px-4 py-8 max-w-md">
43
+ <!-- Theme Toggle -->
44
+ <div class="flex justify-end mb-4">
45
+ <button id="theme-toggle" class="p-2 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors">
46
+ <i data-feather="moon" class="hidden dark:block"></i>
47
+ <i data-feather="sun" class="dark:hidden"></i>
48
+ </button>
49
+ </div>
50
+
51
+ <!-- Timer Header -->
52
+ <h1 class="text-3xl font-bold text-center text-gray-800 dark:text-gray-100 mb-8">TickTock Timer ⏱️</h1>
53
+
54
+ <!-- Timer Display -->
55
+ <div class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 mb-6">
56
+ <div id="timer-display" class="text-6xl font-mono text-center text-gray-800 dark:text-gray-100 mb-6">00:00:00</div>
57
+
58
+ <!-- Timer Controls -->
59
+ <div class="flex justify-center space-x-4 mb-6">
60
+ <button id="start-btn" class="bg-green-500 hover:bg-green-600 text-white px-6 py-2 rounded-lg font-medium transition-colors">
61
+ Start
62
+ </button>
63
+ <button id="pause-btn" class="bg-yellow-500 hover:bg-yellow-600 text-white px-6 py-2 rounded-lg font-medium transition-colors disabled:opacity-50" disabled>
64
+ Pause
65
+ </button>
66
+ <button id="reset-btn" class="bg-red-500 hover:bg-red-600 text-white px-6 py-2 rounded-lg font-medium transition-colors">
67
+ Reset
68
+ </button>
69
+ </div>
70
+
71
+ <!-- Time Input -->
72
+ <div class="space-y-4">
73
+ <div class="flex items-center space-x-2">
74
+ <span class="text-gray-700 dark:text-gray-300">Hours:</span>
75
+ <input type="number" id="hours-input" min="0" max="23" value="0" class="w-16 p-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100">
76
+ </div>
77
+ <div class="flex items-center space-x-2">
78
+ <span class="text-gray-700 dark:text-gray-300">Minutes:</span>
79
+ <input type="number" id="minutes-input" min="0" max="59" value="0" class="w-16 p-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100">
80
+ </div>
81
+ <div class="flex items-center space-x-2">
82
+ <span class="text-gray-700 dark:text-gray-300">Seconds:</span>
83
+ <input type="number" id="seconds-input" min="0" max="59" value="0" class="w-16 p-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100">
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ <!-- Alarm Settings -->
89
+ <div class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6">
90
+ <h2 class="text-xl font-semibold text-gray-800 dark:text-gray-100 mb-4">Alarm Settings</h2>
91
+ <div class="space-y-4">
92
+ <div class="flex items-center space-x-2">
93
+ <span class="text-gray-700 dark:text-gray-300">Alarm Sound:</span>
94
+ <select id="alarm-select" class="p-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100">
95
+ <option value="beep">Beep</option>
96
+ <option value="bell">Bell</option>
97
+ <option value="digital">Digital</option>
98
+ </select>
99
+ </div>
100
+ <div class="flex items-center space-x-2">
101
+ <span class="text-gray-700 dark:text-gray-300">Volume:</span>
102
+ <input type="range" id="volume-control" min="0" max="1" step="0.1" value="0.5" class="w-full">
103
+ </div>
104
+ <div class="flex items-center space-x-2">
105
+ <span class="text-gray-700 dark:text-gray-300">Test Alarm:</span>
106
+ <button id="test-alarm" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-1 rounded-lg text-sm transition-colors">
107
+ Play
108
+ </button>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <audio id="alarm-sound" src=""></audio>
115
+
116
+ <script src="script.js"></script>
117
+ <script>
118
+ feather.replace();
119
+ </script>
120
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
121
+ </body>
122
+ </html>
script.js ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ // DOM Elements
3
+ const timerDisplay = document.getElementById('timer-display');
4
+ const startBtn = document.getElementById('start-btn');
5
+ const pauseBtn = document.getElementById('pause-btn');
6
+ const resetBtn = document.getElementById('reset-btn');
7
+ const hoursInput = document.getElementById('hours-input');
8
+ const minutesInput = document.getElementById('minutes-input');
9
+ const secondsInput = document.getElementById('seconds-input');
10
+ const alarmSelect = document.getElementById('alarm-select');
11
+ const volumeControl = document.getElementById('volume-control');
12
+ const testAlarmBtn = document.getElementById('test-alarm');
13
+ const alarmSound = document.getElementById('alarm-sound');
14
+ const themeToggle = document.getElementById('theme-toggle');
15
+
16
+ // Timer variables
17
+ let timer;
18
+ let totalSeconds = 0;
19
+ let remainingSeconds = 0;
20
+ let isRunning = false;
21
+
22
+ // Theme toggle
23
+ themeToggle.addEventListener('click', () => {
24
+ document.documentElement.classList.toggle('dark');
25
+ feather.replace();
26
+ });
27
+
28
+ // Initialize timer display
29
+ updateTimerDisplay(0);
30
+
31
+ // Start button click handler
32
+ startBtn.addEventListener('click', () => {
33
+ if (!isRunning) {
34
+ if (remainingSeconds === 0) {
35
+ const hours = parseInt(hoursInput.value) || 0;
36
+ const minutes = parseInt(minutesInput.value) || 0;
37
+ const seconds = parseInt(secondsInput.value) || 0;
38
+ totalSeconds = (hours * 3600) + (minutes * 60) + seconds;
39
+ remainingSeconds = totalSeconds;
40
+ }
41
+
42
+ if (remainingSeconds > 0) {
43
+ isRunning = true;
44
+ startBtn.disabled = true;
45
+ pauseBtn.disabled = false;
46
+ toggleInputs(true);
47
+
48
+ timer = setInterval(() => {
49
+ remainingSeconds--;
50
+ updateTimerDisplay(remainingSeconds);
51
+
52
+ if (remainingSeconds <= 0) {
53
+ clearInterval(timer);
54
+ isRunning = false;
55
+ startBtn.disabled = false;
56
+ pauseBtn.disabled = true;
57
+ playAlarm();
58
+ }
59
+ }, 1000);
60
+ }
61
+ }
62
+ });
63
+
64
+ // Pause button click handler
65
+ pauseBtn.addEventListener('click', () => {
66
+ if (isRunning) {
67
+ clearInterval(timer);
68
+ isRunning = false;
69
+ startBtn.disabled = false;
70
+ pauseBtn.disabled = true;
71
+ }
72
+ });
73
+
74
+ // Reset button click handler
75
+ resetBtn.addEventListener('click', () => {
76
+ clearInterval(timer);
77
+ isRunning = false;
78
+ remainingSeconds = 0;
79
+ updateTimerDisplay(0);
80
+ startBtn.disabled = false;
81
+ pauseBtn.disabled = true;
82
+ toggleInputs(false);
83
+ });
84
+
85
+ // Test alarm button click handler
86
+ testAlarmBtn.addEventListener('click', () => {
87
+ playAlarm();
88
+ });
89
+
90
+ // Volume control change handler
91
+ volumeControl.addEventListener('input', () => {
92
+ alarmSound.volume = volumeControl.value;
93
+ });
94
+
95
+ // Update timer display
96
+ function updateTimerDisplay(seconds) {
97
+ const hours = Math.floor(seconds / 3600);
98
+ const minutes = Math.floor((seconds % 3600) / 60);
99
+ const secs = seconds % 60;
100
+
101
+ timerDisplay.textContent =
102
+ `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(secs).padStart(2, '0')}`;
103
+ }
104
+
105
+ // Play alarm sound
106
+ function playAlarm() {
107
+ const soundFile = {
108
+ 'beep': 'https://assets.mixkit.co/sfx/preview/mixkit-alarm-digital-clock-beep-989.mp3',
109
+ 'bell': 'https://assets.mixkit.co/sfx/preview/mixkit-digital-clock-digital-alarm-buzzer-992.mp3',
110
+ 'digital': 'https://assets.mixkit.co/sfx/preview/mixkit-simple-digital-clock-alarm-995.mp3'
111
+ }[alarmSelect.value];
112
+
113
+ alarmSound.src = soundFile;
114
+ alarmSound.volume = volumeControl.value;
115
+ alarmSound.play();
116
+ }
117
+
118
+ // Toggle input fields disabled state
119
+ function toggleInputs(disabled) {
120
+ hoursInput.disabled = disabled;
121
+ minutesInput.disabled = disabled;
122
+ secondsInput.disabled = disabled;
123
+ }
124
+
125
+ // Input validation
126
+ function validateInput(input, max) {
127
+ if (input.value > max) {
128
+ input.value = max;
129
+ } else if (input.value < 0) {
130
+ input.value = 0;
131
+ }
132
+ }
133
+
134
+ hoursInput.addEventListener('change', () => validateInput(hoursInput, 23));
135
+ minutesInput.addEventListener('change', () => validateInput(minutesInput, 59));
136
+ secondsInput.addEventListener('change', () => validateInput(secondsInput, 59));
137
+ });
style.css CHANGED
@@ -1,28 +1,20 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
 
 
 
2
 
3
+ body {
4
+ font-family: 'Inter', sans-serif;
 
5
  }
6
 
7
+ input[type="number"]::-webkit-inner-spin-button,
8
+ input[type="number"]::-webkit-outer-spin-button {
9
+ -webkit-appearance: none;
10
+ margin: 0;
 
11
  }
12
 
13
+ input[type="number"] {
14
+ -moz-appearance: textfield;
 
 
 
 
15
  }
16
 
17
+ #timer-display {
18
+ font-feature-settings: "tnum";
19
+ font-variant-numeric: tabular-nums;
20
+ }