mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-12 05:10:51 +02:00
show theme creator name in dropdown
This commit is contained in:
@@ -50,6 +50,19 @@ type ThemeCreditSource = {
|
||||
description?: string
|
||||
} | null | undefined
|
||||
|
||||
type ThemeOptionLabelSource = {
|
||||
name: string
|
||||
credit?: string
|
||||
}
|
||||
|
||||
export function resolveThemeOptionLabel(theme: ThemeOptionLabelSource): string {
|
||||
const credit = typeof theme.credit === 'string' && theme.credit.trim()
|
||||
? theme.credit.trim()
|
||||
: null
|
||||
|
||||
return credit ? `${theme.name} - ${credit}` : theme.name
|
||||
}
|
||||
|
||||
export function resolveThemeCreditDetails(theme: ThemeCreditSource): {
|
||||
credit: string | null
|
||||
url: string | null
|
||||
@@ -408,7 +421,7 @@ export default function BottomBar({ onClose, onHeightChange }: BottomBarProps):
|
||||
>
|
||||
{themeEntries.map(([id, theme]) => (
|
||||
<option key={id} value={id}>
|
||||
{theme.name}
|
||||
{resolveThemeOptionLabel(theme)}
|
||||
</option>
|
||||
))}
|
||||
</ThemedSelect>
|
||||
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
useSettingsStore,
|
||||
} from '../src/renderer/stores/settingsStore'
|
||||
import { useThemeStore } from '../src/renderer/stores/themeStore'
|
||||
import { resolveThemeCreditDetails } from '../src/renderer/components/BottomBar'
|
||||
import { resolveThemeCreditDetails, resolveThemeOptionLabel } from '../src/renderer/components/BottomBar'
|
||||
import { scopeSettingsToOptions } from '../src/renderer/components/ScopeModule'
|
||||
import { scopeSummary } from '../src/renderer/components/ScopeSettingsSection'
|
||||
import {
|
||||
@@ -2189,6 +2189,21 @@ test('resolveThemeCreditDetails normalizes descriptions and enables links only f
|
||||
)
|
||||
})
|
||||
|
||||
test('resolveThemeOptionLabel appends creator credit when present', () => {
|
||||
assert.equal(
|
||||
resolveThemeOptionLabel({ name: 'Night Shift', credit: 'Astra' }),
|
||||
'Night Shift - Astra',
|
||||
)
|
||||
assert.equal(
|
||||
resolveThemeOptionLabel({ name: 'Night Shift' }),
|
||||
'Night Shift',
|
||||
)
|
||||
assert.equal(
|
||||
resolveThemeOptionLabel({ name: 'Night Shift', credit: ' ' }),
|
||||
'Night Shift',
|
||||
)
|
||||
})
|
||||
|
||||
test('BottomBar theme section renders compact credit metadata and opens valid links through Electron', async () => {
|
||||
const componentSource = await readFile(join(process.cwd(), 'src', 'renderer', 'components', 'BottomBar.tsx'), 'utf8')
|
||||
const stylesSource = await readFile(join(process.cwd(), 'src', 'renderer', 'styles', 'globals.css'), 'utf8')
|
||||
|
||||
Reference in New Issue
Block a user