Skip to content

Commit

Permalink
Added Nunito font and updated Electron to 27.0.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
YuhApps committed Nov 10, 2023
1 parent 72d3977 commit 527621a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 20 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"license": "ISC",
"devDependencies": {
"@electron/notarize": "^2.1.0",
"electron": "^27.0.0",
"electron": "^27.0.4",
"electron-builder": "^24.6.4"
},
"dependencies": {
Expand Down
42 changes: 32 additions & 10 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const os = require('os')
const path = require('path')
const sound = require('sound-play')
const PLATFORM = undefined
const BUILD_DATE = '2023.11.10'

let clips = []
let settings
Expand Down Expand Up @@ -60,8 +61,6 @@ app.whenReady().then(() => {
}
]
}
autoUpdater.on('update-downloaded', () => updateAvailable = true)
autoUpdater.checkForUpdatesAndNotify()
})

app.on('activate', createMainWindow)
Expand Down Expand Up @@ -120,10 +119,9 @@ ipcMain.on('unmaximize:main-window', () => mainWindow.unmaximize())
ipcMain.on('close:main-window', () => mainWindow.close())

function showAbout() {
let build_date = '(2023.10.24)'
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
message: 'Clippiez',
detail: 'Version ' + app.getVersion() + ' ' + build_date + '\nDeveloped by YUH APPS',
detail: 'Version ' + app.getVersion() + ' (' + BUILD_DATE + ')\nDeveloped by YUH APPS',
buttons: ['OK & Close', 'YUH APPS Website'],
defaultId: 0,
noLink: true,
Expand All @@ -134,6 +132,7 @@ function showAbout() {
}

function createAppMenu() {
let platform = PLATFORM || process.platform
let menu = [
{
label: 'Clippiez',
Expand Down Expand Up @@ -236,7 +235,7 @@ function createAppMenu() {
click: (menuItem, browserWindow, event) => {
settings['font'] = 'system'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', PLATFORM || process.platform, false, false))
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'system'))
}
},
{
Expand All @@ -246,7 +245,17 @@ function createAppMenu() {
click: (menuItem, browserWindow, event) => {
settings['font'] = 'lato'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', PLATFORM || process.platform, false, true))
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'lato'))
}
},
{
label: 'Nunito',
checked: settings['font'] === 'nunito',
type: 'radio',
click: (menuItem, browserWindow, event) => {
settings['font'] = 'nunito'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'nunito'))
}
}
]
Expand Down Expand Up @@ -466,7 +475,7 @@ function createAppOptionsMenu(bounds) {
click: (menuItem, browserWindow, event) => {
settings['font'] = 'system'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, nativeTheme.shouldUseDarkColors, false))
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'system'))
}
},
{
Expand All @@ -476,7 +485,17 @@ function createAppOptionsMenu(bounds) {
click: (menuItem, browserWindow, event) => {
settings['font'] = 'lato'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, nativeTheme.shouldUseDarkColors, true))
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'lato'))
}
},
{
label: 'Nunito',
checked: settings['font'] === 'nunito',
type: 'radio',
click: (menuItem, browserWindow, event) => {
settings['font'] = 'nunito'
menuItem.checked = true
BrowserWindow.getAllWindows().forEach((window) => window.webContents.send('platform', platform, settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark', 'nunito'))
}
}
]
Expand Down Expand Up @@ -533,9 +552,12 @@ function createMainWindow() {
mainWindow.show()
return
}
autoUpdater.checkForUpdatesAndNotify()
.then((res) => updateAvailable = res && res.updateInfo.version > app.getVersion())
.catch((error) => console.log(error))
let platform = PLATFORM || process.platform
let dark = settings['appearance'] === 'system' ? nativeTheme.shouldUseDarkColors : settings['appearance'] === 'dark'
let lato = (settings['font'] || 'system')=== 'lato'
let font = settings['font'] || 'system'
if (fs.existsSync(path.join(app.getPath('userData'), 'clips.json'))) {
let buffer = fs.readFileSync(path.join(app.getPath('userData'), 'clips.json'))
clips = JSON.parse(String(buffer))
Expand Down Expand Up @@ -594,7 +616,7 @@ function createMainWindow() {
}
mainWindow.loadFile('src/views/index.html')
mainWindow.webContents.on('did-finish-load', (e) => {
mainWindow.webContents.send('platform', platform, dark, lato, settings['dock-icon'])
mainWindow.webContents.send('platform', platform, dark, font, settings['dock-icon'])
mainWindow.webContents.send('update', clips)
mainWindow.show()
})
Expand Down
Binary file added src/fonts/nunito_bold.ttf
Binary file not shown.
Binary file added src/fonts/nunito_regular.ttf
Binary file not shown.
6 changes: 4 additions & 2 deletions src/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@
}
})

ipcRenderer.on('platform', (e, platform, dark, lato, dockIcon) => {
ipcRenderer.on('platform', (e, platform, dark, font, dockIcon) => {
console.log(font)
document.body.classList.add(platform)
document.body.classList[dark ? 'add' : 'remove']('dark')
document.body.classList[lato ? 'add' : 'remove']('lato')
document.body.classList[font === 'lato' ? 'add' : 'remove']('lato')
document.body.classList[font === 'nunito' ? 'add' : 'remove']('nunito')
document.body.classList.remove('hidden')
if (platform === 'darwin' && dockIcon === false) {
document.querySelectorAll('.hide-on-darwin-with-dock').forEach((el) => el.classList.remove('hidden'))
Expand Down
17 changes: 16 additions & 1 deletion src/views/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@

@font-face {
font-family: 'Montserrat';
font-weight: normal;
font-weight: bold;
src: URL('../fonts/montserrat_bold.ttf') format('truetype');
}

@font-face {
font-family: 'Nunito';
font-weight: normal;
src: URL('../fonts/nunito_regular.ttf') format('truetype');
}

@font-face {
font-family: 'Nunito';
font-weight: bold;
src: URL('../fonts/nunito_bold.ttf') format('truetype');
}

html {
--color-header-foreground: #404040;
}
Expand All @@ -40,6 +52,9 @@ body {
body.lato {
font-family: 'Lato';
}
body.nunito {
font-family: 'Nunito';
}
body.dark {
background: #202020;
}
Expand Down

0 comments on commit 527621a

Please sign in to comment.