Skip to content

Commit 397f54b

Browse files
authored
Merge pull request #19 from htdguide/main
Catching up with minor details
2 parents 7ad8664 + dd4ac91 commit 397f54b

File tree

12 files changed

+562
-318
lines changed

12 files changed

+562
-318
lines changed

.github/workflows/docker-image.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- main
77

88
jobs:
9-
build:
10-
name: Push Docker Image to Docker Hub and Deploy to Server
9+
test:
10+
name: Run Vitest
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out repository
@@ -18,10 +18,19 @@ jobs:
1818
with:
1919
node-version: 18
2020

21-
- name: Install Dependencies and Run Vitest
22-
run: |
23-
npm install --legacy-peer-deps
24-
npm run test
21+
- name: Install Dependencies
22+
run: npm install --legacy-peer-deps
23+
24+
- name: Run Tests
25+
run: npm run test
26+
27+
build-deploy:
28+
name: Build and Deploy Docker Image to Server
29+
runs-on: ubuntu-latest
30+
needs: test # This ensures the build only runs if tests pass
31+
steps:
32+
- name: Check out repository
33+
uses: actions/checkout@v2
2534

2635
- name: Login to Docker Hub
2736
id: docker-hub

package-lock.json

Lines changed: 6 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"devDependencies": {
2020
"@eslint/js": "^9.17.0",
21+
"@testing-library/dom": "^10.4.0",
2122
"@testing-library/jest-dom": "^6.6.3",
2223
"@testing-library/react": "^16.2.0",
2324
"@testing-library/user-event": "^14.6.1",

src/App.jsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
22
import './App.css';
33
import Desktop from './components/Desktop/Desktop.jsx';
44
import DesktopAppsList from './lists/DesktopAppsList.jsx';
5+
import { AppsProvider } from './services/AppsContext/AppsContext.jsx';
56

67
function App() {
78
const [openApps, setOpenApps] = useState([]);
@@ -26,22 +27,24 @@ function App() {
2627
};
2728

2829
return (
29-
<div className="App">
30-
<Desktop onOpenApp={handleOpenApp} />
31-
{openApps.map((appId) => {
32-
const appConfig = DesktopAppsList.find((app) => app.id === appId);
33-
const AppComponent = appConfig?.component;
34-
35-
return (
36-
AppComponent && (
37-
<AppComponent
38-
key={appId}
39-
onClose={() => handleCloseApp(appId)}
40-
/>
41-
)
42-
);
43-
})}
44-
</div>
30+
<AppsProvider>
31+
<div className="App">
32+
<Desktop onOpenApp={handleOpenApp} />
33+
{openApps.map((appId) => {
34+
const appConfig = DesktopAppsList.find((app) => app.id === appId);
35+
const AppComponent = appConfig?.component;
36+
37+
return (
38+
AppComponent && (
39+
<AppComponent
40+
key={appId}
41+
onClose={() => handleCloseApp(appId)}
42+
/>
43+
)
44+
);
45+
})}
46+
</div>
47+
</AppsProvider>
4548
);
4649
}
4750

src/components/Desktop/Desktop.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useContext } from 'react';
2+
import { AppsContext } from '../../services/AppsContext/AppsContext.jsx';
23
import DesktopIcon from '../DesktopIcon/DesktopIcon.jsx';
3-
import DesktopAppsList from '../../lists/DesktopAppsList.jsx';
44
import { GRID_GAP, TOP_MARGIN, LEFT_MARGIN } from '../../configs/DesktopIconConfig/DesktopIconConfig.jsx';
55
import { GRID_SIZE } from '../../configs/DesktopIconConfig/DesktopIconConfig.jsx';
66
import './Desktop.css';
@@ -12,17 +12,15 @@ import { FocusWrapper } from '../../interactions/FocusControl/FocusControl.jsx';
1212
*/
1313
function getPositionFromPriority(priority) {
1414
const safePriority = priority && priority > 0 ? priority : 1;
15-
1615
// Single-column approach: each subsequent icon moves (GRID_SIZE + GRID_GAP) down
1716
const effectiveCellSize = GRID_SIZE + GRID_GAP;
18-
1917
const x = LEFT_MARGIN;
2018
const y = TOP_MARGIN + (safePriority - 1) * effectiveCellSize;
21-
2219
return { x, y };
2320
}
2421

2522
function Desktop({ onOpenApp }) {
23+
const { apps } = useContext(AppsContext);
2624
const [selectedIcon, setSelectedIcon] = useState(null);
2725

2826
const handleWallpaperClick = () => {
@@ -36,7 +34,7 @@ function Desktop({ onOpenApp }) {
3634
return (
3735
<FocusWrapper name="Desktop">
3836
<div className="desktop" onClick={handleWallpaperClick}>
39-
{DesktopAppsList.map((iconConfig) => {
37+
{apps.filter(iconConfig => !iconConfig.indock).map((iconConfig) => {
4038
// Convert the icon's priority into an (x,y) position,
4139
// now using GRID_GAP to keep them spaced out.
4240
const position = getPositionFromPriority(iconConfig.priority);
@@ -49,7 +47,7 @@ function Desktop({ onOpenApp }) {
4947
isSelected={selectedIcon === iconConfig.id}
5048
onClick={() => handleIconClick(iconConfig.id)}
5149
onDoubleClick={() => onOpenApp(iconConfig.id)}
52-
position={position}
50+
position={position}
5351
/>
5452
);
5553
})}

src/components/MiniApps/MiniApps.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function MiniApps() {
6969
.filter(app => app.available)
7070
.filter(app => {
7171
if (app.id === 'battery' && deviceInfo.battery.level === null) return false;
72-
if (app.id === 'user' && deviceInfo.orientation === 'portrait') return false;
7372
return true;
7473
})
7574
.slice()

src/lists/DesktopAppsList.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import awaiIcon from '../media/icons/awai.png';
88
/**
99
* Each icon now has a `priority` which determines its order on the desktop grid.
1010
* Additionally, apps that are only links have a `link` property.
11+
* The new `indock` field determines if the icon should be displayed on the desktop.
12+
* If `indock` is true, the icon will not be rendered on the desktop.
1113
*/
1214
const DesktopAppsList = [
1315
{
@@ -16,6 +18,7 @@ const DesktopAppsList = [
1618
icon: defaultIcon,
1719
component: SortingAlgorithms,
1820
priority: 4,
21+
indock: false,
1922
},
2023

2124
{
@@ -24,6 +27,7 @@ const DesktopAppsList = [
2427
icon: folderIcon,
2528
component: null,
2629
priority: 5,
30+
indock: true, // This icon will not display on the desktop
2731
},
2832

2933
{
@@ -33,6 +37,7 @@ const DesktopAppsList = [
3337
link: 'http://linkedin.com/in/htdguide/',
3438
component: null,
3539
priority: 2,
40+
indock: false,
3641
},
3742

3843
{
@@ -42,6 +47,7 @@ const DesktopAppsList = [
4247
link: 'https://github.com/htdguide',
4348
component: null,
4449
priority: 1,
50+
indock: true, // This icon will not display on the desktop
4551
},
4652

4753
{
@@ -51,6 +57,7 @@ const DesktopAppsList = [
5157
link: 'https://applywithai.com',
5258
component: null,
5359
priority: 3,
60+
indock: false,
5461
},
5562

5663
// Add more apps here as needed, with increasing `priority`

src/miniapps/ControlCentreMiniApp/ControlCentreMiniApp.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
width: 280px;
88
/* Semi-translucent white with blur, to mimic macOS style */
99
background: rgba(255, 255, 255, 0.5);
10+
11+
/* Ensures the blur effect works in Safari */
12+
-webkit-backdrop-filter: blur(16px);
1013
backdrop-filter: blur(16px);
14+
15+
/* Prevents artefacts in Safari */
16+
-webkit-background-clip: padding-box;
17+
background-clip: padding-box;
18+
1119
margin-top: 6px;
1220
padding-left: 10px;
1321
padding-right: 10px;
@@ -23,7 +31,12 @@
2331

2432
/* Each “segment” or “card” in the control center */
2533
.cc-segment {
26-
backdrop-filter: blur(1px);
34+
background: rgba(255, 255, 255, 0.5);
35+
36+
/* Clip the background to avoid artefacts */
37+
-webkit-background-clip: padding-box;
38+
background-clip: padding-box;
39+
2740
border-radius: 12px;
2841
padding: 12px 16px;
2942
margin-top: 10px;

src/miniapps/ControlCentreMiniApp/ControlCentreWidgets/MusicControl/MusicControl.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.song-title-container {
3131
overflow: hidden;
3232
white-space: nowrap;
33-
margin-top: -7px;
33+
margin-top: -5px;
3434
margin-left: 2px;
3535
}
3636

src/miniapps/ControlCentreMiniApp/ControlCentreWidgets/MusicControl/MusicControl.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ function MusicControl() {
3636
#888 80%)`
3737
};
3838

39-
// Convert seconds to mm:ss
39+
// Convert seconds to mm:ss, cutting off milliseconds
4040
const formatTime = (secs) => {
4141
if (!secs || secs < 0) secs = 0;
42-
const minutes = Math.floor(secs / 60);
43-
const seconds = secs % 60;
42+
const totalSeconds = Math.floor(secs); // <-- Truncate decimal part
43+
const minutes = Math.floor(totalSeconds / 60);
44+
const seconds = totalSeconds % 60;
4445
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
4546
};
4647

0 commit comments

Comments
 (0)