Skip to content

Commit 7d200e9

Browse files
authored
Merge pull request #166 from Mdwiki-TD/update_new
Update new
2 parents 06d5039 + e8d8e12 commit 7d200e9

File tree

10 files changed

+123
-110
lines changed

10 files changed

+123
-110
lines changed

css/dashboard_new1.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
/* font-weight: bold; */
1919
}
2020

21+
:root[data-bs-theme="dark"] {
22+
.navbar-nav .nav-item.active {
23+
/* background-color: #3a3f44; */
24+
}
25+
}
26+
2127
.navbar-nav li.active>a {
2228
color: #000;
2329
}
@@ -262,3 +268,11 @@ a {
262268
.btn-tool:focus {
263269
box-shadow: none !important;
264270
}
271+
272+
:root[data-bs-theme="dark"] .invert-on-dark {
273+
filter: invert(1) hue-rotate(180deg);
274+
}
275+
276+
:root[data-bs-theme="light"] .invert-on-dark {
277+
filter: invert(0) hue-rotate(0deg);
278+
}

css/sidebars.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
}
2424

2525
.bi {
26-
vertical-align: -.125em;
26+
/* vertical-align: -.125em;
2727
pointer-events: none;
28-
fill: currentColor;
28+
fill: currentColor; */
2929
}
3030

3131
.dropdown-toggle {

css/styles.css

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
}
3939

4040
.bi {
41-
width: 1em;
41+
/* width: 1em;
4242
height: 1em;
43-
fill: currentcolor;
43+
fill: currentcolor; */
4444
}
4545

4646
.color-modes {
@@ -60,3 +60,21 @@
6060
}
6161
}
6262
}
63+
64+
/* Mobile Responsiveness */
65+
@media (max-width: 750px) {
66+
.navbar-collapse {
67+
border-radius: 10px;
68+
border: 1px solid rgba(44, 62, 80, 0.98);
69+
padding: 1rem;
70+
margin-top: 1rem;
71+
}
72+
73+
.navbar-toggler {
74+
margin-right: auto;
75+
margin-left: 0;
76+
border: none;
77+
color: var(--light-text);
78+
}
79+
80+
}

head.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function get_host()
5858
"/Translation_Dashboard/css/dashboard_new1.css",
5959
"/Translation_Dashboard/css/sidebars.css",
6060
"$hoste/ajax/libs/font-awesome/5.15.3/css/all.min.css",
61-
"$hoste/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css",
61+
"$hoste/ajax/libs/bootstrap/5.3.7/css/bootstrap.min.css",
6262
"$hoste/ajax/libs/jqueryui/1.13.2/themes/base/jquery-ui.min.css",
6363
"$hoste/ajax/libs/bootstrap-select/1.14.0-beta3/css/bootstrap-select.css",
6464
"$hoste/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css",
@@ -69,12 +69,13 @@ function get_host()
6969

7070
"/Translation_Dashboard/css/mobile_format.css",
7171
"/Translation_Dashboard/css/Responsive_Table.css",
72+
"/Translation_Dashboard/css/theme.css",
7273
];
7374

7475
$scripts = [
7576
"$hoste/ajax/libs/jquery/3.7.0/jquery.min.js",
7677
"$hoste/ajax/libs/popper.js/2.11.8/umd/popper.min.js",
77-
"$hoste/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js",
78+
"$hoste/ajax/libs/bootstrap/5.3.7/js/bootstrap.min.js",
7879
"$hoste/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js",
7980
"$hoste/ajax/libs/bootstrap-select/1.14.0-beta3/js/bootstrap-select.min.js",
8081

@@ -90,6 +91,7 @@ function get_host()
9091
"/Translation_Dashboard/js/login.js",
9192
"/td/plugins/chart.js/Chart.min.js",
9293
"/Translation_Dashboard/js/g.js",
94+
"/Translation_Dashboard/js/theme.js",
9395
];
9496

9597
$scripts_module = [

header.php

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -47,50 +47,23 @@
4747
$coord_tools = '<a href="/tdc/index.php" class="nav-link py-2 px-0 px-lg-2"><span class="navtitles"></span>Coordinator Tools</a>';
4848
};
4949
//---
50-
$them_li = <<<HTML
51-
<button class="btn btn-link nav-link px-2 d-flex align-items-center " id="bd-theme" type="button" aria-expanded="false" data-bs-toggle="dropdown"
52-
data-bs-display="static" aria-label="Toggle theme (light)">
53-
<span class="theme-icon-active my-1">
54-
<i class="bi bi-circle-half"></i>
55-
</span>
56-
<span class="d-lg-none ms-2" id="bd-theme-text"></span>
57-
</button>
58-
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text">
59-
<li>
60-
<button type="button" class="dropdown-item d-flex align-items-center active" data-bs-theme-value="light" aria-pressed="true">
61-
<i class="bi bi-sun-fill me-2 opacity-50 theme-icon"></i> Light
62-
</button>
63-
</li>
64-
<li>
65-
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="dark" aria-pressed="false">
66-
<i class="bi bi-moon-stars-fill me-2 opacity-50 theme-icon"></i> Dark
67-
</button>
68-
</li>
69-
<li>
70-
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="auto" aria-pressed="false">
71-
<i class="bi bi-circle-half me-2 opacity-50 theme-icon"></i> Auto
72-
</button>
73-
</li>
74-
</ul>
75-
HTML;
76-
//---
7750
$li_user = <<<HTML
78-
<li class="nav-item col-4 col-lg-auto">
51+
<li class="nav-item col-6 col-lg-auto">
7952
<a role="button" class="nav-link py-2 px-0 px-lg-2" onclick="login()">
8053
<i class="fas fa-sign-in-alt fa-sm fa-fw mr-2"></i> <span class="navtitles">Login</span>
8154
</a>
82-
</li>
55+
</li>
8356
HTML;
8457
//---
8558
if (isset($GLOBALS['global_username']) && $GLOBALS['global_username'] != '') {
8659
$u_name = $GLOBALS['global_username'];
8760
$li_user = <<<HTML
88-
<li class="nav-item col-4 col-lg-auto">
61+
<li class="nav-item col-6 col-lg-auto">
8962
<a href="leaderboard.php?get=users&user=$u_name" class="nav-link py-2 px-0 px-lg-2">
9063
<i class="fas fa-user fa-sm fa-fw mr-2"></i> <span class="navtitles">$u_name</span>
9164
</a>
9265
</li>
93-
<li class="nav-item col-4 col-lg-auto">
66+
<li class="nav-item col-6 col-lg-auto">
9467
<a class="nav-link py-2 px-0 px-lg-2" href="#" data-bs-toggle="modal" data-bs-target="#logoutModal">
9568
<i class="fas fa-sign-out-alt fa-sm fa-fw mr-2"></i> <span class="d-lg-none navtitles">Logout</span>
9669
</a>
@@ -127,46 +100,43 @@ function is_active($url)
127100
</button>
128101
<div class="collapse navbar-collapse" id="collapsibleNavbar">
129102
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav">
130-
<li class="nav-item col-4 col-lg-auto <?php echo is_active('leaderboard.php'); ?>" id="leaderboard">
103+
<li class="nav-item col-6 col-lg-auto <?php echo is_active('leaderboard.php'); ?>" id="leaderboard">
131104
<a class="nav-link py-2 px-0 px-lg-2" href="leaderboard.php">
132105
<span class="navtitles">Leaderboard</span>
133106
</a>
134107
</li>
135-
<li class="nav-item col-4 col-lg-auto" id="Prior">
108+
<li class="nav-item col-6 col-lg-auto" id="Prior">
136109
<a class="nav-link py-2 px-0 px-lg-2" target="_blank" href="/prior">
137110
<span class="navtitles">Prior</span>
138111
</a>
139112
</li>
140-
<li class="nav-item col-4 col-lg-auto <?php echo is_active('missing.php'); ?>" id="missing">
113+
<li class="nav-item col-6 col-lg-auto <?php echo is_active('missing.php'); ?>" id="missing">
141114
<a class="nav-link py-2 px-0 px-lg-2" href="missing.php">
142115
<span class="navtitles">Missing</span>
143116
</a>
144117
</li>
145-
<li class="nav-item col-4 col-lg-auto" id="coord">
118+
<li class="nav-item col-6 col-lg-auto" id="coord">
146119
<?php echo $coord_tools; ?>
147120
</li>
148121

149-
<li class="nav-item col-4 col-lg-auto">
122+
<li class="nav-item col-6 col-lg-auto">
150123
<a class="nav-link py-2 px-0 px-lg-2" href="https://github.com/MrIbrahem/Translation-Dashboard" target="_blank">
151124
<span class="navtitles">Github</span>
152125
</a>
153126
</li>
154-
<li class="nav-item col-4 col-lg-auto">
127+
<li class="nav-item col-6 col-lg-auto">
155128
<span class="nav-link py-2 px-0 px-lg-2" id="load_time"></span>
156129
</li>
157130
</ul>
158-
<hr class="d-lg-none text-black-50">
131+
<hr class="d-lg-none text-dark-subtle text-50">
159132
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav ms-lg-auto">
160133
<?php echo $li_user; ?>
161134
</ul>
162135
</div>
163-
<div class="d-flex ms-2">
164-
<span class="nav-item col-4 col-lg-auto dropdown">
165-
<?php echo $them_li; ?>
166-
</span>
167-
<!-- <button class="theme-toggle btn btn-link me-ms-auto" aria-label="Toggle theme">
136+
<div class="d-flex">
137+
<button class="theme-toggle btn btn-link ms-me-auto" aria-label="Toggle theme">
168138
<i class="bi bi-moon-stars-fill"></i>
169-
</button> -->
139+
</button>
170140
</div>
171141
</div>
172142
</nav>

js/theme.js

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Theme toggle functionality
2-
const themeToggle = document.querySelector('.theme-toggle');
3-
const themeIcon = themeToggle.querySelector('i');
2+
let themeToggle;
3+
let themeIcon;
44
const htmlElement = document.documentElement;
55

66
// Available themes
@@ -24,20 +24,21 @@ function getSystemTheme() {
2424
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
2525
}
2626

27+
// Update theme icon based on current theme
28+
function updateThemeIcon(preference) {
29+
const { cfg } = themes[preference];
30+
if (!cfg || !themeIcon) return;
31+
const { icon } = cfg;
32+
themeIcon.className = `bi ${icon}`;
33+
}
34+
2735
// Function to update theme based on preference
2836
function updateTheme(preference) {
2937
const theme = preference === 'system' ? getSystemTheme() : preference;
3038
htmlElement.setAttribute('data-bs-theme', theme);
3139
updateThemeIcon(preference);
3240
}
3341

34-
// Update theme when system preference changes
35-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
36-
if (localStorage.getItem('theme') === 'system') {
37-
updateTheme('system');
38-
}
39-
});
40-
4142
// Function to create theme dropdown menu
4243
function createThemeMenu() {
4344
const menu = document.createElement('div');
@@ -61,59 +62,67 @@ function createThemeMenu() {
6162
return menu;
6263
}
6364

64-
// Initialize theme
65-
const savedTheme = localStorage.getItem('theme') || 'system';
66-
updateTheme(savedTheme);
65+
document.addEventListener('DOMContentLoaded', () => {
66+
themeToggle = document.querySelector('.theme-toggle');
67+
themeIcon = themeToggle.querySelector('i');
6768

68-
// Toggle theme menu on click
69-
let activeMenu = null;
70-
themeToggle.addEventListener('click', (e) => {
71-
e.stopPropagation();
69+
// Update theme when system preference changes
70+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
71+
if (localStorage.getItem('theme') === 'system') {
72+
updateTheme('system');
73+
}
74+
});
7275

73-
if (activeMenu) {
74-
activeMenu.remove();
75-
activeMenu = null;
76-
return;
77-
}
76+
// Initialize theme
77+
const savedTheme = localStorage.getItem('theme') || 'system';
78+
updateTheme(savedTheme);
7879

79-
const menu = createThemeMenu();
80-
document.body.appendChild(menu);
80+
// Toggle theme menu on click
81+
let activeMenu = null;
82+
themeToggle.addEventListener('click', (e) => {
83+
e.stopPropagation();
8184

82-
// Position menu below button
83-
const buttonRect = themeToggle.getBoundingClientRect();
84-
menu.style.position = 'fixed';
85-
menu.style.top = `${buttonRect.bottom + 5}px`;
85+
if (activeMenu) {
86+
activeMenu.remove();
87+
activeMenu = null;
88+
return;
89+
}
8690

87-
const isRTL = document.dir === 'rtl';
88-
const horizontalPosition = isRTL ? buttonRect.left : (window.innerWidth - buttonRect.right);
91+
const menu = createThemeMenu();
92+
document.body.appendChild(menu);
8993

90-
// Ensure menu stays within viewport
91-
const menuWidth = 150; // matches min-width from CSS
92-
const safeOffset = 5;
93-
const maxRight = window.innerWidth - menuWidth - safeOffset;
94-
const right = Math.min(horizontalPosition - safeOffset, maxRight);
94+
// Position menu below button
95+
const buttonRect = themeToggle.getBoundingClientRect();
96+
menu.style.position = 'fixed';
97+
menu.style.top = `${buttonRect.bottom + 5}px`;
9598

96-
menu.style[isRTL ? 'left' : 'right'] = `${right}px`;
97-
activeMenu = menu;
98-
});
99+
const isRTL = document.dir === 'rtl';
100+
const horizontalPosition = isRTL ? buttonRect.left : (window.innerWidth - buttonRect.right);
99101

100-
// Close menu when clicking outside
101-
document.addEventListener('click', (event) => {
102-
if (activeMenu) {
103-
activeMenu.remove();
104-
activeMenu = null;
105-
}
106-
});
102+
// Ensure menu stays within viewport
103+
const menuWidth = 150; // matches min-width from CSS
104+
const safeOffset = 5;
105+
const maxRight = window.innerWidth - menuWidth - safeOffset;
106+
const right = Math.min(horizontalPosition - safeOffset, maxRight);
107107

108-
// Add keyboard navigation
109-
document.addEventListener('keydown', (event) => {
110-
if (event.key === 'Escape' && activeMenu) {
111-
activeMenu.remove();
112-
activeMenu = null;
113-
}
114-
});
115-
// Update theme icon based on current theme
116-
function updateThemeIcon(preference) {
117-
const { icon } = themes[preference];
118-
themeIcon.className = `bi ${icon}`;
119-
}
108+
menu.style[isRTL ? 'left' : 'right'] = `${right}px`;
109+
activeMenu = menu;
110+
});
111+
112+
// Close menu when clicking outside
113+
document.addEventListener('click', (event) => {
114+
if (activeMenu) {
115+
activeMenu.remove();
116+
activeMenu = null;
117+
}
118+
});
119+
120+
// Add keyboard navigation
121+
document.addEventListener('keydown', (event) => {
122+
if (event.key === 'Escape' && activeMenu) {
123+
activeMenu.remove();
124+
activeMenu = null;
125+
}
126+
});
127+
128+
})

leaderboard/graph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function graph_html($keys, $values, $no_card = false)
2020
// ---
2121
$canvas = <<<HTML
2222
<div class="position-relative">
23-
<canvas id="$graph_id" height="200"></canvas>
23+
<canvas id="$graph_id" height="200" class="invert-on-dark"></canvas>
2424
</div>
2525
HTML;
2626
//---

leaderboard/lang_user_graph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function graph_data_new($dd)
7373
[$keys, $values, $count] = make_graph_data($dd);
7474
//---
7575
$text = <<<HTML
76-
<canvas id="$graph_id" height="100" width="200"></canvas>
76+
<canvas id="$graph_id" height="100" width="200" class="invert-on-dark"></canvas>
7777
HTML;
7878
//---
7979
if ($count > 0) {

leaderboard/others/graph_api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function graph_new_html($params, $no_card = false)
1919
// ---
2020
$canvas = <<<HTML
2121
<div class="position-relative">
22-
<canvas id="$graph_id" height="200"></canvas>
22+
<canvas id="$graph_id" height="200" class="invert-on-dark"></canvas>
2323
</div>
2424
HTML;
2525
//---

0 commit comments

Comments
 (0)