Skip to content

Commit 02729b7

Browse files
committed
Refine Tooltip and Theme Transition Mechanics
- Enhance feature card tooltip with dynamic mouse-tracking parallax effect - Optimize theme transition logic with more precise state management - Adjust dark mode color palette and shadow styles for improved visual depth - Streamline notification animation with more dynamic keyframe transformations - Improve theme change performance with nested requestAnimationFrame
1 parent 3a6dd76 commit 02729b7

2 files changed

Lines changed: 46 additions & 75 deletions

File tree

css/style.css

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
[data-theme="dark"] {
5353
/* Dark theme with sci-fi feel */
5454
--primary-color: #f8fafc;
55-
--text-color: #f1f5f9;
56-
--bg-color: #030712;
55+
--text-color: #e2e8f0;
56+
--bg-color: #0f172a;
5757
--gray-50: #1e293b;
5858
--gray-100: #334155;
5959
--gray-200: #475569;
@@ -64,16 +64,16 @@
6464
--gray-700: #f1f5f9;
6565
--gray-800: #f8fafc;
6666
--gray-900: #ffffff;
67-
--card-bg: #0f172a;
67+
--card-bg: #1e293b;
6868

6969
/* Dark theme glass effect */
70-
--glass-bg: rgba(15, 23, 42, 0.85);
71-
--glass-border: rgba(255, 255, 255, 0.1);
70+
--glass-bg: rgba(15, 23, 42, 0.9);
71+
--glass-border: rgba(255, 255, 255, 0.15);
7272

7373
/* Enhanced dark shadows */
74-
--shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(8, 145, 178, 0.1);
75-
--shadow: 0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(37, 99, 235, 0.1);
76-
--shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(8, 145, 178, 0.1);
74+
--shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
75+
--shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
76+
--shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
7777
--footer-bg: var(--primary-color);
7878
--footer-text: var(--bg-color);
7979
color-scheme: dark;
@@ -1634,61 +1634,29 @@ textarea.is-invalid:focus-visible {
16341634
position: absolute;
16351635
bottom: 100%;
16361636
left: 50%;
1637-
transform: translateX(-50%) translateY(10px);
1637+
transform:
1638+
translateX(calc(-50% + var(--mouse-x, 0) * 0.02px))
1639+
translateY(calc(-10px + var(--mouse-y, 0) * -0.02px));
16381640
background: var(--glass-bg);
1639-
-webkit-backdrop-filter: blur(8px);
16401641
backdrop-filter: blur(8px);
1642+
-webkit-backdrop-filter: blur(8px);
16411643
padding: 0.75rem 1rem;
16421644
border-radius: 0.75rem;
16431645
width: max-content;
16441646
max-width: min(300px, 90vw);
16451647
opacity: 0;
16461648
visibility: hidden;
1647-
transition:
1648-
transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28),
1649-
opacity 0.2s ease;
1649+
transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
16501650
will-change: transform, opacity;
16511651
z-index: 1000;
16521652
box-shadow: var(--shadow-lg);
16531653
border: 1px solid var(--glass-border);
1654-
color: var(--text-color);
1655-
font-size: 0.875rem;
1656-
pointer-events: none;
1657-
text-align: center;
16581654
}
16591655

16601656
.learning-mode .feature-card:hover .feature-tooltip,
16611657
.learning-mode .feature-card:focus .feature-tooltip {
16621658
opacity: 1;
16631659
visibility: visible;
1664-
transform:
1665-
translateX(calc(-50% + var(--mouse-x, 0) * 0.5px))
1666-
translateY(calc(var(--mouse-y, 0) * -0.5px));
1667-
}
1668-
1669-
@keyframes notificationSlideIn {
1670-
from {
1671-
opacity: 0;
1672-
transform: translateX(100%) scale(0.9) rotate(2deg);
1673-
}
1674-
70% {
1675-
transform: translateX(-5%) scale(1.02) rotate(-1deg);
1676-
}
1677-
to {
1678-
opacity: 1;
1679-
transform: translateX(0) scale(1) rotate(0);
1680-
}
1681-
}
1682-
1683-
@keyframes notificationSlideOut {
1684-
from {
1685-
opacity: 1;
1686-
transform: translateX(0) scale(1) rotate(0);
1687-
}
1688-
to {
1689-
opacity: 0;
1690-
transform: translateX(100%) scale(0.9) rotate(2deg);
1691-
}
16921660
}
16931661

16941662
/* Notifications */
@@ -1737,22 +1705,25 @@ textarea.is-invalid:focus-visible {
17371705
@keyframes notificationSlideIn {
17381706
from {
17391707
opacity: 0;
1740-
transform: translateX(100%) scale(0.9);
1708+
transform: translateX(120%) scale(0.8) rotate(3deg);
1709+
}
1710+
60% {
1711+
transform: translateX(-10%) scale(1.05) rotate(-1deg);
17411712
}
17421713
to {
17431714
opacity: 1;
1744-
transform: translateX(0) scale(1);
1715+
transform: translateX(0) scale(1) rotate(0);
17451716
}
17461717
}
17471718

17481719
@keyframes notificationSlideOut {
17491720
from {
17501721
opacity: 1;
1751-
transform: translateX(0) scale(1);
1722+
transform: translateX(0) scale(1) rotate(0);
17521723
}
17531724
to {
17541725
opacity: 0;
1755-
transform: translateX(100%) scale(0.9);
1726+
transform: translateX(120%) scale(0.8) rotate(3deg);
17561727
}
17571728
}
17581729

js/main.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -444,41 +444,41 @@ const app = {
444444
},
445445

446446
updateTheme(isDark, enableTransition = true) {
447-
// Clear any pending transitions
448-
if (this.themeState.transitionTimeout) {
449-
clearTimeout(this.themeState.transitionTimeout);
450-
}
451-
if (this.themeState.rafHandle) {
452-
cancelAnimationFrame(this.themeState.rafHandle);
453-
}
454-
447+
// Clear existing transitions
448+
if (this.themeState.transitionTimeout) clearTimeout(this.themeState.transitionTimeout);
449+
if (this.themeState.rafHandle) cancelAnimationFrame(this.themeState.rafHandle);
450+
455451
const root = document.documentElement;
456452
const newTheme = isDark ? 'dark' : 'light';
457-
458-
// Skip if theme hasn't changed
459453
if (newTheme === this.themeState.currentTheme) return;
460-
461-
// Update state immediately
454+
455+
// Immediate state update
462456
this.themeState.currentTheme = newTheme;
463457
localStorage.setItem('theme', newTheme);
464-
458+
459+
const applyTheme = () => {
460+
root.setAttribute('data-theme', newTheme);
461+
if (this.darkModeToggle) this.darkModeToggle.checked = isDark;
462+
463+
// Update notification container theme if it exists
464+
const notificationContainer = document.querySelector('.notifications-container');
465+
if (notificationContainer) {
466+
notificationContainer.setAttribute('data-theme', newTheme);
467+
}
468+
};
469+
465470
if (enableTransition) {
466471
root.classList.add('theme-transitioning');
467-
requestAnimationFrame(() => {
468-
root.setAttribute('data-theme', newTheme);
469-
470-
this.themeState.transitionTimeout = setTimeout(() => {
471-
root.classList.remove('theme-transitioning');
472-
this.announceMessage(`Theme changed to ${newTheme} mode`);
473-
}, 300);
472+
this.themeState.rafHandle = requestAnimationFrame(() => {
473+
requestAnimationFrame(() => {
474+
applyTheme();
475+
this.themeState.transitionTimeout = setTimeout(() => {
476+
root.classList.remove('theme-transitioning');
477+
}, 300);
478+
});
474479
});
475480
} else {
476-
root.setAttribute('data-theme', newTheme);
477-
}
478-
479-
// Update toggle state
480-
if (this.darkModeToggle) {
481-
this.darkModeToggle.checked = isDark;
481+
applyTheme();
482482
}
483483
},
484484

0 commit comments

Comments
 (0)