misc: switch back to diecbear
This commit is contained in:
6 files changed
+46
-84
No files matched your search
@@ -5,6 +5,8 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@dicebear/core": "^9.3.1",
|
||||||
|
"@dicebear/initials": "^9.3.1",
|
||||||
"@eslint/compat": "^1.4.1",
|
"@eslint/compat": "^1.4.1",
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
"@svelte-put/qr": "^2.1.1",
|
"@svelte-put/qr": "^2.1.1",
|
||||||
@@ -65,6 +67,10 @@
|
|||||||
|
|
||||||
"@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],
|
"@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],
|
||||||
|
|
||||||
|
"@dicebear/core": ["@dicebear/core@9.3.1", "", { "dependencies": { "@types/json-schema": "^7.0.11" } }, "sha512-N6Gl9z3SxYp1OVtOzQegtURFqr0D62l3QcXgvshDAVXDNjkziZ5gWj//JxYJRWldNZfVp9/pm97V3ExKI5AXPg=="],
|
||||||
|
|
||||||
|
"@dicebear/initials": ["@dicebear/initials@9.3.1", "", { "peerDependencies": { "@dicebear/core": "^9.0.0" } }, "sha512-1O61oYxKVeeGL6QcNCcxH7zsqbp37NmHbR/Y5CVqr6AVv0bBswvCzVzUv/Zmmsp70DoYQB+lbX+oNIdcqUWAaw=="],
|
||||||
|
|
||||||
"@emnapi/runtime": ["@emnapi/runtime@1.8.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg=="],
|
"@emnapi/runtime": ["@emnapi/runtime@1.8.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg=="],
|
||||||
|
|
||||||
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.12", "", { "os": "aix", "cpu": "ppc64" }, "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA=="],
|
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.12", "", { "os": "aix", "cpu": "ppc64" }, "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA=="],
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@dicebear/core": "^9.3.1",
|
||||||
|
"@dicebear/initials": "^9.3.1",
|
||||||
"@eslint/compat": "^1.4.1",
|
"@eslint/compat": "^1.4.1",
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
"@svelte-put/qr": "^2.1.1",
|
"@svelte-put/qr": "^2.1.1",
|
||||||
|
|||||||
@@ -125,7 +125,6 @@
|
|||||||
<div class="iframe-container">
|
<div class="iframe-container">
|
||||||
{#if opened}
|
{#if opened}
|
||||||
{#if type == 'video'}
|
{#if type == 'video'}
|
||||||
<!-- svelte-ignore a11y_media_has_caption -->
|
|
||||||
<video {autoplay} controls>
|
<video {autoplay} controls>
|
||||||
<source src={url} />
|
<source src={url} />
|
||||||
</video>
|
</video>
|
||||||
|
|||||||
@@ -1,90 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { findClosestNumber } from '$lib/app/util.svelte'
|
|
||||||
import { optimizeImageURL } from '$lib/feature/post'
|
import { optimizeImageURL } from '$lib/feature/post'
|
||||||
|
import { createAvatar } from '@dicebear/core'
|
||||||
|
import * as initials from '@dicebear/initials'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
|
||||||
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
|
|
||||||
|
|
||||||
const colors = [
|
|
||||||
'7B68EE',
|
|
||||||
'FF6347',
|
|
||||||
'20B2AA',
|
|
||||||
'DDA0DD',
|
|
||||||
'F0E68C',
|
|
||||||
'FF1493',
|
|
||||||
'4682B4',
|
|
||||||
'32CD32',
|
|
||||||
'FFB6C1',
|
|
||||||
'8B4513',
|
|
||||||
'00CED1',
|
|
||||||
'9370DB',
|
|
||||||
'FFA500',
|
|
||||||
'2E8B57',
|
|
||||||
'DC143C',
|
|
||||||
'BA55D3',
|
|
||||||
'708090',
|
|
||||||
'ADFF2F',
|
|
||||||
'CD853F',
|
|
||||||
'48D1CC',
|
|
||||||
]
|
|
||||||
|
|
||||||
function simpleHash(str: string): number {
|
|
||||||
let hash = 0
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
hash = (hash << 5) - hash + str.charCodeAt(i)
|
|
||||||
hash |= 0
|
|
||||||
}
|
|
||||||
return Math.abs(hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
function createInitialAvatar(seed: string): string {
|
|
||||||
const hash = simpleHash(seed)
|
|
||||||
const color1 = colors[hash % colors.length]
|
|
||||||
const color2 = colors[(hash + 7) % colors.length]
|
|
||||||
const initial = (seed[0] || '?').toUpperCase()
|
|
||||||
const textColor = hash % 2 === 0 ? 'fff' : '000'
|
|
||||||
|
|
||||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="bg${hash}" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
||||||
<stop offset="0%" style="stop-color:#${color1}"/>
|
|
||||||
<stop offset="100%" style="stop-color:#${color2}"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<rect width="100" height="100" fill="url(#bg${hash})"/>
|
|
||||||
<text x="50" y="50" dy=".35em" text-anchor="middle" fill="#${textColor}" font-size="50" font-weight="800" font-family="sans-serif">${initial}</text>
|
|
||||||
</svg>`
|
|
||||||
}
|
|
||||||
|
|
||||||
const optimizeUrl = (
|
|
||||||
url: string | undefined,
|
|
||||||
res: number,
|
|
||||||
): string | undefined => {
|
|
||||||
if (url === undefined) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
const urlObj = new URL(url)
|
|
||||||
urlObj.searchParams.append('format', 'webp')
|
|
||||||
if (res > -1) {
|
|
||||||
urlObj.searchParams.append(
|
|
||||||
'thumbnail',
|
|
||||||
findClosestNumber(sizes, res).toString(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return urlObj.toString()
|
|
||||||
} catch {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
url: string | undefined
|
url?: string
|
||||||
alt?: string
|
alt?: string
|
||||||
title?: string
|
title?: string
|
||||||
circle?: boolean | null
|
circle?: boolean | null
|
||||||
width: number
|
width: number
|
||||||
res?: number | undefined
|
res?: number
|
||||||
style?: string
|
style?: string
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
}
|
}
|
||||||
@@ -95,7 +21,7 @@
|
|||||||
title = '',
|
title = '',
|
||||||
circle = true,
|
circle = true,
|
||||||
width,
|
width,
|
||||||
res = undefined,
|
res,
|
||||||
style = '',
|
style = '',
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
...rest
|
...rest
|
||||||
@@ -132,6 +58,36 @@
|
|||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{@html createInitialAvatar(alt)}
|
{@html createAvatar(initials, {
|
||||||
|
seed: alt,
|
||||||
|
backgroundType: ['gradientLinear'],
|
||||||
|
fontWeight: 800,
|
||||||
|
randomizeIds: true,
|
||||||
|
chars: 1,
|
||||||
|
scale: 125,
|
||||||
|
textColor: ['fff', '000'],
|
||||||
|
backgroundColor: [
|
||||||
|
'7B68EE',
|
||||||
|
'FF6347',
|
||||||
|
'20B2AA',
|
||||||
|
'DDA0DD',
|
||||||
|
'F0E68C',
|
||||||
|
'FF1493',
|
||||||
|
'4682B4',
|
||||||
|
'32CD32',
|
||||||
|
'FFB6C1',
|
||||||
|
'8B4513',
|
||||||
|
'00CED1',
|
||||||
|
'9370DB',
|
||||||
|
'FFA500',
|
||||||
|
'2E8B57',
|
||||||
|
'DC143C',
|
||||||
|
'BA55D3',
|
||||||
|
'708090',
|
||||||
|
'ADFF2F',
|
||||||
|
'CD853F',
|
||||||
|
'48D1CC',
|
||||||
|
],
|
||||||
|
}).toString()}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state'
|
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import { defaultSettings, settings } from '$lib/app/settings.svelte'
|
import { defaultSettings, settings } from '$lib/app/settings.svelte'
|
||||||
import { Header, Tabs } from '$lib/ui/layout'
|
import { Header } from '$lib/ui/layout'
|
||||||
import TabbedLayoutShell from '$lib/ui/layout/pages/TabbedLayoutShell.svelte'
|
import TabbedLayoutShell from '$lib/ui/layout/pages/TabbedLayoutShell.svelte'
|
||||||
import { action, Button, Modal, modal, TextArea, toast } from 'mono-svelte'
|
import { action, Button, Modal, modal, TextArea, toast } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
import { innerWidth } from 'svelte/reactivity/window'
|
import { innerWidth } from 'svelte/reactivity/window'
|
||||||
|
|
||||||
export function load({ url }) {
|
export function load() {
|
||||||
if ((innerWidth.current ?? 0) > 768) redirect(302, '/settings/app')
|
if ((innerWidth.current ?? 0) > 768) redirect(302, '/settings/app')
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user