Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file modified edge-apps/clock/screenshots/1080x1920.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/1280x720.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/1920x1080.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/2160x3840.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/2160x4096.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/3840x2160.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/4096x2160.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/480x800.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/720x1280.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/clock/screenshots/800x480.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions edge-apps/edge-apps-library/src/assets/images/screenly.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 35 additions & 1 deletion edge-apps/edge-apps-library/src/utils/theme.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { describe, test, expect, beforeEach, afterEach } from 'bun:test'
import { describe, test, expect, beforeEach, afterEach, mock } from 'bun:test'
import {
getPrimaryColor,
getSecondaryColor,
getThemeColors,
applyThemeColors,
setupTheme,
setupBrandingLogo,
DEFAULT_THEME_COLORS,
} from './theme'
import { setupScreenlyMock, resetScreenlyMock } from '../test/mock'
import defaultLogoUrl from '../assets/images/screenly.svg'

// eslint-disable-next-line max-lines-per-function
describe('theme utilities', () => {
Expand Down Expand Up @@ -151,4 +153,36 @@ describe('theme utilities', () => {
).toBe('#FF0000')
})
})

describe('setupBrandingLogo', () => {
let originalFetch: typeof globalThis.fetch

beforeEach(() => {
originalFetch = globalThis.fetch
})

afterEach(() => {
globalThis.fetch = originalFetch
})

test('should return default logo when no logos are configured', async () => {
const result = await setupBrandingLogo()
expect(result).toBe(defaultLogoUrl)
})

test('should return default logo when primary and fallback fetches fail', async () => {
setupScreenlyMock(
{},
{
screenly_logo_light: 'http://example.com/logo.png',
screenly_logo_dark: '',
},
)
globalThis.fetch = mock(() =>
Promise.reject(new Error('Network error')),
) as typeof globalThis.fetch
const result = await setupBrandingLogo()
expect(result).toBe(defaultLogoUrl)
})
})
})
34 changes: 16 additions & 18 deletions edge-apps/edge-apps-library/src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ThemeColors, BrandingConfig } from '../types/index.js'
import defaultLogoUrl from '../assets/images/screenly.svg'

/**
* Default theme colors used by Screenly
Expand Down Expand Up @@ -169,12 +170,11 @@ export async function fetchLogoImage(fileUrl: string): Promise<string> {
* Setup branding logo from Screenly settings.
*
* Attempts to fetch the logo image using a CORS proxy URL based on the current theme.
* Falls back to a direct URL if the proxy fetch fails, and returns an empty string if no logo is configured or all fetch attempts fail.
* Falls back to a direct URL if the proxy fetch fails, and returns the default logo if no logo is configured or all fetch attempts fail.
*
* @returns {Promise<string>} The processed logo URL:
* - Returns a data URI for SVG images, or the original URL for PNG/JPEG images, if successfully fetched via the CORS proxy or fallback URL.
* - Returns the fallback URL if all fetch attempts fail but a logo URL is configured.
* - Returns an empty string if no logo is configured or all fetch attempts fail.
* - Returns the default logo URL if no logo is configured or all fetch attempts fail.
*/
export async function setupBrandingLogo(): Promise<string> {
const settings = screenly.settings
Expand All @@ -187,20 +187,18 @@ export async function setupBrandingLogo(): Promise<string> {
let logoUrl = ''
let fallbackUrl = ''

if (theme === 'light') {
logoUrl = lightLogo
? `${screenly.cors_proxy_url}/${lightLogo}`
: `${screenly.cors_proxy_url}/${darkLogo}`
fallbackUrl = lightLogo || darkLogo || ''
} else if (theme === 'dark') {
logoUrl = darkLogo
? `${screenly.cors_proxy_url}/${darkLogo}`
: `${screenly.cors_proxy_url}/${lightLogo}`
fallbackUrl = darkLogo || lightLogo || ''
const isDark = theme === 'dark'
const primaryLogo = isDark ? darkLogo : lightLogo
const secondaryLogo = isDark ? lightLogo : darkLogo
const resolvedLogo = primaryLogo || secondaryLogo

if (resolvedLogo) {
logoUrl = `${screenly.cors_proxy_url}/${resolvedLogo}`
fallbackUrl = resolvedLogo
}

// Return early if logoUrl is empty
if (!logoUrl) return ''
// Return default logo if no logo is configured
if (!fallbackUrl) return defaultLogoUrl
// Try to fetch the image using the CORS proxy URL
try {
return await fetchLogoImage(logoUrl)
Expand All @@ -217,8 +215,8 @@ export async function setupBrandingLogo(): Promise<string> {
err,
)
}
// Return empty string if all fetches fail
return ''
// Return default logo if all fetches fail
return defaultLogoUrl
}

/**
Expand All @@ -230,6 +228,6 @@ export async function setupBranding(): Promise<BrandingConfig> {

return {
colors,
logoUrl: logoUrl || undefined,
logoUrl,
}
}
Binary file modified edge-apps/simple-message-app/screenshots/1080x1920.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/1280x720.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/1920x1080.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/2160x3840.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/2160x4096.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/3840x2160.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/4096x2160.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/480x800.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/720x1280.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-message-app/screenshots/800x480.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-timer/screenshots/1080x1920.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-timer/screenshots/1280x720.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-timer/screenshots/1920x1080.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-timer/screenshots/2160x3840.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified edge-apps/simple-timer/screenshots/2160x4096.webp
Binary file modified edge-apps/simple-timer/screenshots/3840x2160.webp
Binary file modified edge-apps/simple-timer/screenshots/4096x2160.webp
Binary file modified edge-apps/simple-timer/screenshots/480x800.webp
Binary file modified edge-apps/simple-timer/screenshots/720x1280.webp
Binary file modified edge-apps/simple-timer/screenshots/800x480.webp
Binary file modified edge-apps/weather/screenshots/1080x1920.webp
Binary file modified edge-apps/weather/screenshots/1280x720.webp
Binary file modified edge-apps/weather/screenshots/1920x1080.webp
Binary file modified edge-apps/weather/screenshots/2160x3840.webp
Binary file modified edge-apps/weather/screenshots/2160x4096.webp
Binary file modified edge-apps/weather/screenshots/3840x2160.webp
Binary file modified edge-apps/weather/screenshots/4096x2160.webp
Binary file modified edge-apps/weather/screenshots/480x800.webp
Binary file modified edge-apps/weather/screenshots/720x1280.webp
Binary file modified edge-apps/weather/screenshots/800x480.webp
Binary file modified edge-apps/welcome-app/screenshots/1080x1920.webp
Binary file modified edge-apps/welcome-app/screenshots/1280x720.webp
Binary file modified edge-apps/welcome-app/screenshots/1920x1080.webp
Binary file modified edge-apps/welcome-app/screenshots/2160x3840.webp
Binary file modified edge-apps/welcome-app/screenshots/2160x4096.webp
Binary file modified edge-apps/welcome-app/screenshots/3840x2160.webp
Binary file modified edge-apps/welcome-app/screenshots/4096x2160.webp
Binary file modified edge-apps/welcome-app/screenshots/480x800.webp
Binary file modified edge-apps/welcome-app/screenshots/720x1280.webp
Binary file modified edge-apps/welcome-app/screenshots/800x480.webp
Loading