Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-142927: Tachyon: Start with user's default light/dark theme#142987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hugovk wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromhugovk:3.15-tachyon-browser-default-dark-light
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletionsLib/profiling/sampling/_heatmap_assets/heatmap.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,37 +15,13 @@ let coldCodeHidden = false;
// ============================================================================

function toggleTheme() {
const html = document.documentElement;
const current = html.getAttribute('data-theme') || 'light';
const next = current === 'light' ? 'dark' : 'light';
html.setAttribute('data-theme', next);
localStorage.setItem('heatmap-theme', next);

// Update theme button icon
const btn = document.getElementById('theme-btn');
if (btn) {
btn.querySelector('.icon-moon').style.display = next === 'dark' ? 'none' : '';
btn.querySelector('.icon-sun').style.display = next === 'dark' ? '' : 'none';
}
toggleAndSaveTheme();
applyLineColors();

// Rebuild scroll marker with new theme colors
buildScrollMarker();
}

function restoreUIState() {
// Restore theme
const savedTheme = localStorage.getItem('heatmap-theme');
if (savedTheme) {
document.documentElement.setAttribute('data-theme', savedTheme);
const btn = document.getElementById('theme-btn');
if (btn) {
btn.querySelector('.icon-moon').style.display = savedTheme === 'dark' ? 'none' : '';
btn.querySelector('.icon-sun').style.display = savedTheme === 'dark' ? '' : 'none';
}
}
}

// ============================================================================
// Utility Functions
// ============================================================================
Expand Down
27 changes: 1 addition & 26 deletionsLib/profiling/sampling/_heatmap_assets/heatmap_index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,35 +19,10 @@ function applyHeatmapBarColors() {
// ============================================================================

function toggleTheme() {
const html = document.documentElement;
const current = html.getAttribute('data-theme') || 'light';
const next = current === 'light' ? 'dark' : 'light';
html.setAttribute('data-theme', next);
localStorage.setItem('heatmap-theme', next);

// Update theme button icon
const btn = document.getElementById('theme-btn');
if (btn) {
btn.querySelector('.icon-moon').style.display = next === 'dark' ? 'none' : '';
btn.querySelector('.icon-sun').style.display = next === 'dark' ? '' : 'none';
}

toggleAndSaveTheme();
applyHeatmapBarColors();
}

function restoreUIState() {
// Restore theme
const savedTheme = localStorage.getItem('heatmap-theme');
if (savedTheme) {
document.documentElement.setAttribute('data-theme', savedTheme);
const btn = document.getElementById('theme-btn');
if (btn) {
btn.querySelector('.icon-moon').style.display = savedTheme === 'dark' ? 'none' : '';
btn.querySelector('.icon-sun').style.display = savedTheme === 'dark' ? '' : 'none';
}
}
}

// ============================================================================
// Type Section Toggle (stdlib, project, etc)
// ============================================================================
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<!doctype html>
<htmllang="en"data-theme="light">
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<!doctype html>
<htmllang="en"data-theme="light">
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
Expand Down
36 changes: 36 additions & 0 deletionsLib/profiling/sampling/_heatmap_assets/heatmap_shared.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,42 @@ function intensityToColor(intensity) {
return rootStyle.getPropertyValue(`--heat-${level}`).trim();
}

// ============================================================================
// Theme Support
// ============================================================================

// Get the preferred theme from localStorage or browser preference
function getPreferredTheme() {
const saved = localStorage.getItem('heatmap-theme');
if (saved) return saved;
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}

// Apply theme and update UI. Returns the applied theme.
function applyTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
const btn = document.getElementById('theme-btn');
if (btn) {
btn.querySelector('.icon-moon').style.display = theme === 'dark' ? 'none' : '';
btn.querySelector('.icon-sun').style.display = theme === 'dark' ? '' : 'none';
}
return theme;
}

// Toggle theme and save preference. Returns the new theme.
function toggleAndSaveTheme() {
const current = document.documentElement.getAttribute('data-theme') || 'light';
const next = current === 'light' ? 'dark' : 'light';
applyTheme(next);
localStorage.setItem('heatmap-theme', next);
return next;
}

// Restore theme from localStorage, or use browser preference
function restoreUIState() {
applyTheme(getPreferredTheme());
}

// ============================================================================
// Favicon (Reuse logo image as favicon)
// ============================================================================
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp