-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
129 lines (113 loc) · 4.01 KB
/
index.html
File metadata and controls
129 lines (113 loc) · 4.01 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tiny Notes</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<style>
:root {
--bg-color: snow;
--line-color: lightblue;
--margin-color: salmon;
--text-color: #333;
--line-height: 4rem;
}
body.dark-mode {
--bg-color: #1e1e1e;
--line-color: #333;
--margin-color: #444;
--text-color: #d4d4d4;
}
* { box-sizing: border-box; }
html { font-size: clamp(15px, 2vw, 25px); height: 100%; }
body {
height: 100%;
margin: 0;
background-color: var(--bg-color);
font-family: Verdana, Geneva, Tahoma, sans-serif;
transition: background-color 0.3s ease;
overflow: hidden; /* Prevents double scrollbars */
}
textarea {
display: block;
width: 100%;
height: 100%;
border: none;
outline: none;
padding: 0 0 0 5rem;
resize: none;
font-size: 2rem;
line-height: var(--line-height);
color: var(--text-color);
background-color: transparent;
overflow-wrap: break-word;
white-space: pre-wrap;
background-image:
linear-gradient(90deg, transparent calc(4rem - 1px), var(--margin-color) 4rem, transparent 4rem),
linear-gradient(var(--line-color) 1px, transparent 1px);
background-size: 100% var(--line-height);
background-attachment: local;
}
textarea::first-line { font-weight: 600; }
.theme-toggle {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 10;
width: 45px;
height: 45px;
border-radius: 50%;
border: 1px solid var(--line-color);
background: var(--bg-color);
cursor: pointer;
font-size: 1rem;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: all 0.2s ease;
line-height: 1;
}
.theme-toggle:hover { transform: scale(1.05); }
.theme-toggle:active { transform: scale(0.95); }
</style>
</head>
<body>
<button class="theme-toggle" id="theme-btn" aria-label="Toggle Dark Mode">☀️</button>
<label for="note-area" style="display:none;">Note Content</label>
<textarea id="note-area" placeholder="Type here. Save nowhere."></textarea>
<script>
const textarea = document.getElementById('note-area');
const themeBtn = document.getElementById('theme-btn');
const body = document.body;
// Load Content
textarea.value = localStorage.getItem('tiny_notes_content') || '';
textarea.focus();
textarea.addEventListener('input', () => {
localStorage.setItem('tiny_notes_content', textarea.value);
});
// Theme Handling
const updateUI = (isDark) => {
if (isDark) {
body.classList.add('dark-mode');
themeBtn.textContent = '🌙';
themeBtn.setAttribute('aria-label', 'Switch to light mode');
} else {
body.classList.remove('dark-mode');
themeBtn.textContent = '☀️';
themeBtn.setAttribute('aria-label', 'Switch to dark mode');
}
};
const savedTheme = localStorage.getItem('tiny_theme');
updateUI(savedTheme === 'dark');
themeBtn.addEventListener('click', () => {
const isNowDark = !body.classList.contains('dark-mode');
localStorage.setItem('tiny_theme', isNowDark ? 'dark' : 'light');
updateUI(isNowDark);
});
</script>
</body>
</html>