feat(ui): light mode and new theming system (#1468)
This commit is contained in:
@@ -32,19 +32,31 @@ import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--icon-display-color, currentColor);
|
||||
}
|
||||
|
||||
.svg-icon-inline {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.svg-icon-inline :deep(svg) {
|
||||
.svg-icon-inline ::ng-deep svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Tint only paths without explicit paint so user-uploaded multi-colour SVGs survive. */
|
||||
.svg-icon-inline ::ng-deep svg:not([fill]),
|
||||
.svg-icon-inline ::ng-deep path:not([fill]) {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.svg-icon-inline ::ng-deep path[stroke]:not([stroke="none"]) {
|
||||
stroke: currentColor;
|
||||
}
|
||||
`],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 80dvh;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1.25rem 1.5rem;
|
||||
background: var(--overlay-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
flex-shrink: 0;
|
||||
|
||||
.header-content {
|
||||
@@ -30,12 +30,12 @@
|
||||
justify-content: center;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
background: var(--primary-color);
|
||||
background: var(--color-primary);
|
||||
border-radius: 10px;
|
||||
|
||||
i {
|
||||
font-size: 1.25rem;
|
||||
color: var(--primary-contrast-color);
|
||||
color: var(--color-primary-contrast);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.125rem 0 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,8 @@
|
||||
}
|
||||
|
||||
.p-tablist {
|
||||
background: var(--overlay-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
@@ -120,11 +120,11 @@
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
background: var(--color-border);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color);
|
||||
background: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
@@ -166,7 +166,7 @@
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
background: var(--ground-background);
|
||||
background: var(--color-page);
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
@@ -174,25 +174,25 @@
|
||||
|
||||
> i {
|
||||
font-size: 1.25rem;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--border-color);
|
||||
background: var(--overlay-background);
|
||||
border-color: var(--color-border);
|
||||
background: var(--color-page);
|
||||
|
||||
> i {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: var(--primary-color);
|
||||
background: rgb(var(--primary-color-rgb, 59, 130, 246), 10%);
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
||||
|
||||
> i {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
padding: 3rem;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.9rem;
|
||||
|
||||
i {
|
||||
@@ -247,10 +247,10 @@
|
||||
justify-content: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.875rem 1.25rem;
|
||||
background: var(--ground-background);
|
||||
border: 2px dashed var(--border-color);
|
||||
background: var(--color-page);
|
||||
border: 2px dashed var(--color-border);
|
||||
border-radius: 8px;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.875rem;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
@@ -268,8 +268,8 @@
|
||||
|
||||
// Form sections
|
||||
.form-section {
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
padding: 1.25rem;
|
||||
|
||||
@@ -282,11 +282,11 @@
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
|
||||
> i {
|
||||
font-size: 0.9rem;
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.section-badge {
|
||||
@@ -296,8 +296,8 @@
|
||||
min-width: 20px;
|
||||
height: 20px;
|
||||
padding: 0 0.375rem;
|
||||
background: var(--primary-color);
|
||||
color: var(--primary-contrast-color);
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-contrast);
|
||||
border-radius: 10px;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
@@ -328,7 +328,7 @@
|
||||
label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.input-full {
|
||||
@@ -348,8 +348,8 @@
|
||||
|
||||
// Preview
|
||||
.preview-card {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -359,9 +359,9 @@
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--text-secondary-color);
|
||||
background: var(--overlay-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-page);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.preview-content {
|
||||
@@ -404,7 +404,7 @@
|
||||
justify-content: flex-end;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--border-color);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
// Queue grid
|
||||
@@ -418,14 +418,14 @@
|
||||
}
|
||||
|
||||
.queue-item {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
&.has-error {
|
||||
@@ -437,14 +437,14 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0.625rem;
|
||||
background: var(--overlay-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: var(--color-page);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.queue-item-name {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -459,7 +459,7 @@
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
color: var(--text-secondary-color);
|
||||
color: var(--color-text-secondary);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
.live-border {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
background: var(--color-card);
|
||||
border: 1px solid var(--color-primary);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
.notification-timestamp {
|
||||
font-size: 0.75rem;
|
||||
color: #a1a1aa;
|
||||
color: var(--color-text-secondary);
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.notification-message {
|
||||
font-weight: 400;
|
||||
color: #e4e4e7;
|
||||
color: var(--color-text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<path d="M96.7715 113.077H43.5539V119.537H96.7715C98.5535 119.537 99.9964 118.092 99.9964 116.307C99.9964 114.522 98.5535 113.077 96.7715 113.077Z" fill="url(#login-logo-gradient-secondary)"/>
|
||||
<defs>
|
||||
<linearGradient id="login-logo-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--p-primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--p-primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="login-logo-gradient-secondary" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--p-primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--p-primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
.task-border {
|
||||
margin-top: 1rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
background: var(--color-card);
|
||||
border: 1px solid var(--color-primary);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
.task-title {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@
|
||||
|
||||
.task-message {
|
||||
font-size: 1rem;
|
||||
color: #e5e7eb;
|
||||
color: var(--color-text);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.task-progress-info {
|
||||
font-size: 0.875rem;
|
||||
color: #d1d5db;
|
||||
color: var(--color-text-secondary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@
|
||||
}
|
||||
|
||||
&-primary {
|
||||
background-color: color-mix(in srgb, var(--p-primary-500), transparent 82%);
|
||||
color: var(--p-primary-300);
|
||||
border: 1px solid color-mix(in srgb, var(--p-primary-500), transparent 65%);
|
||||
background-color: color-mix(in srgb, var(--color-primary-500), transparent 82%);
|
||||
color: var(--color-primary-700);
|
||||
border: 1px solid color-mix(in srgb, var(--color-primary-500), transparent 65%);
|
||||
}
|
||||
|
||||
$colors: (
|
||||
@@ -147,22 +147,42 @@
|
||||
|
||||
@each $name, $color in $colors {
|
||||
&-#{$name} {
|
||||
background-color: color-mix(in srgb, var(--p-#{$color}-500), transparent 82%);
|
||||
color: var(--p-#{$color}-300);
|
||||
border: 1px solid color-mix(in srgb, var(--p-#{$color}-500), transparent 65%);
|
||||
background-color: color-mix(in srgb, var(--color-#{$color}-500), transparent 82%);
|
||||
color: var(--color-#{$color}-700);
|
||||
border: 1px solid color-mix(in srgb, var(--color-#{$color}-500), transparent 65%);
|
||||
}
|
||||
}
|
||||
|
||||
&-dark {
|
||||
background-color: color-mix(in srgb, var(--p-gray-800), transparent 82%);
|
||||
color: var(--p-gray-300);
|
||||
border: 1px solid color-mix(in srgb, var(--p-gray-800), transparent 65%);
|
||||
background-color: color-mix(in srgb, var(--color-gray-800), transparent 82%);
|
||||
color: var(--color-gray-800);
|
||||
border: 1px solid color-mix(in srgb, var(--color-gray-800), transparent 65%);
|
||||
}
|
||||
|
||||
&-light {
|
||||
background-color: color-mix(in srgb, var(--p-gray-300), transparent 82%);
|
||||
color: var(--p-gray-600);
|
||||
border: 1px solid color-mix(in srgb, var(--p-gray-300), transparent 65%);
|
||||
background-color: color-mix(in srgb, var(--color-gray-300), transparent 82%);
|
||||
color: var(--color-gray-700);
|
||||
border: 1px solid color-mix(in srgb, var(--color-gray-300), transparent 65%);
|
||||
}
|
||||
|
||||
@at-root :host-context(.dark) .app-tag-primary {
|
||||
color: var(--color-primary-300);
|
||||
}
|
||||
|
||||
@at-root :host-context(.dark) {
|
||||
@each $name, $color in $colors {
|
||||
.app-tag-#{$name} {
|
||||
color: var(--color-#{$color}-300);
|
||||
}
|
||||
}
|
||||
|
||||
.app-tag-dark {
|
||||
color: var(--color-gray-300);
|
||||
}
|
||||
|
||||
.app-tag-light {
|
||||
color: var(--color-gray-400);
|
||||
}
|
||||
}
|
||||
|
||||
&-variant-pill {
|
||||
@@ -170,29 +190,29 @@
|
||||
padding: 0.125rem 0.375rem;
|
||||
|
||||
&.app-tag-primary {
|
||||
background-color: var(--p-primary-600);
|
||||
color: var(--p-primary-100);
|
||||
border-color: var(--p-primary-500);
|
||||
background-color: var(--color-primary-600);
|
||||
color: var(--color-primary-100);
|
||||
border-color: var(--color-primary-500);
|
||||
}
|
||||
|
||||
@each $name, $color in $colors {
|
||||
&.app-tag-#{$name} {
|
||||
background-color: var(--p-#{$color}-600);
|
||||
color: var(--p-#{$color}-100);
|
||||
border-color: var(--p-#{$color}-500);
|
||||
background-color: var(--color-#{$color}-600);
|
||||
color: var(--color-#{$color}-100);
|
||||
border-color: var(--color-#{$color}-500);
|
||||
}
|
||||
}
|
||||
|
||||
&.app-tag-dark {
|
||||
background-color: var(--p-gray-800);
|
||||
color: var(--p-gray-100);
|
||||
border-color: var(--p-gray-700);
|
||||
background-color: var(--color-gray-800);
|
||||
color: var(--color-gray-100);
|
||||
border-color: var(--color-gray-700);
|
||||
}
|
||||
|
||||
&.app-tag-light {
|
||||
background-color: var(--p-gray-300);
|
||||
color: var(--p-gray-800);
|
||||
border-color: var(--p-gray-400);
|
||||
background-color: var(--color-gray-300);
|
||||
color: var(--color-gray-800);
|
||||
border-color: var(--color-gray-400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
<path d="M96.7715 113.077H43.5539V119.537H96.7715C98.5535 119.537 99.9964 118.092 99.9964 116.307C99.9964 114.522 98.5535 113.077 96.7715 113.077Z" fill="url(#mobile-topbar-brand-secondary-gradient)"/>
|
||||
<defs>
|
||||
<linearGradient id="mobile-topbar-brand-primary-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="mobile-topbar-brand-secondary-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
+5
-6
@@ -13,8 +13,9 @@
|
||||
box-sizing: border-box;
|
||||
height: 3.5rem;
|
||||
z-index: 100;
|
||||
background-color: var(--surface-app);
|
||||
border-bottom: 1px solid var(--content-border-color);
|
||||
background-color: var(--color-app);
|
||||
color: var(--color-text);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
padding:
|
||||
0
|
||||
calc(0.75rem + env(safe-area-inset-right))
|
||||
@@ -32,7 +33,6 @@
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
gap: 0.4rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.mobile-topbar-brand-icon {
|
||||
@@ -63,16 +63,15 @@
|
||||
border: 0;
|
||||
background: none;
|
||||
border-radius: 6px;
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease, color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
|
||||
&:focus-within {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.sidebar-item-container:hover {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
|
||||
.sidebar-item-container:hover .sidebar-item-chevron {
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.sidebar-item-container:hover .entity-menu-icon {
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
|
||||
.sidebar-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
}
|
||||
|
||||
.sidebar-item-link {
|
||||
@@ -73,13 +73,13 @@ a.sidebar-item-link {
|
||||
}
|
||||
|
||||
.sidebar-item-container:has(.sidebar-item-link:focus-visible) {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
}
|
||||
|
||||
a.sidebar-item-link.active-route {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary-text);
|
||||
}
|
||||
|
||||
.sidebar-item-chrome {
|
||||
@@ -96,7 +96,7 @@ a.sidebar-item-link.active-route {
|
||||
|
||||
.sidebar-item-chevron {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
padding-right: var(--space-3);
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ a.sidebar-item-link.active-route {
|
||||
border: 0;
|
||||
border-radius: var(--radius-pill);
|
||||
background: transparent;
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: var(--text-sm);
|
||||
@@ -165,11 +165,11 @@ a.sidebar-item-link.active-route {
|
||||
|
||||
.entity-menu-button:hover {
|
||||
background-color: transparent;
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.entity-menu-button:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ a.sidebar-item-link.active-route {
|
||||
}
|
||||
|
||||
.book-count {
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--text-sm);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ a.sidebar-item-link.active-route {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background-color: #ef4444;
|
||||
background-color: var(--color-red-500);
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@@ -233,11 +233,11 @@ a.sidebar-item-link.active-route {
|
||||
}
|
||||
|
||||
.sidebar-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
}
|
||||
|
||||
.sidebar-item-container:has(:focus-visible) {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
color: inherit;
|
||||
|
||||
&:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
@@ -53,12 +53,12 @@
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
color: var(--surface-500);
|
||||
color: var(--color-surface-500);
|
||||
}
|
||||
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.expand-icon:hover {
|
||||
color: var(--surface-200);
|
||||
color: var(--color-surface-200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
.root-item-with-dropdown:focus-visible {
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,6 @@
|
||||
|
||||
.expand-icon {
|
||||
font-size: 1.125rem;
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
<path d="M96.7715 113.077H43.5539V119.537H96.7715C98.5535 119.537 99.9964 118.092 99.9964 116.307C99.9964 114.522 98.5535 113.077 96.7715 113.077Z" fill="url(#sidebar-brand-secondary-gradient)"/>
|
||||
<defs>
|
||||
<linearGradient id="sidebar-brand-primary-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sidebar-brand-secondary-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
@@ -22,9 +22,9 @@
|
||||
<svg class="sidebar-brand-wordmark" width="2500" height="350" viewBox="0 0 2500 350" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<g clip-path="url(#sidebar-brand-wordmark-clip)">
|
||||
<path d="M71.8311 296.149V314.103V332.047V350L89.7839 332.047L107.747 350V332.047V314.103V296.149H71.8311Z" fill="white"/>
|
||||
<path d="M1748.64 102.654H1701.96C1691.71 102.654 1683.37 110.983 1683.37 121.23V165.376C1683.37 175.622 1691.7 183.952 1701.96 183.952H1748.64C1757.49 183.952 1764.7 176.746 1764.7 167.895V118.721C1764.7 109.869 1757.49 102.664 1748.64 102.664V102.654Z" style="fill: var(--primary-400)"/>
|
||||
<path d="M896.673 102.654H852.504C842.263 102.654 833.919 110.983 833.919 121.23V167.885C833.919 176.736 841.128 183.942 849.984 183.942H899.184C908.039 183.942 915.249 176.736 915.249 167.885V121.23C915.249 110.983 906.915 102.654 896.663 102.654H896.673Z" style="fill: var(--primary-400)"/>
|
||||
<path d="M653.709 183.942H697.878C708.119 183.942 716.463 175.612 716.463 165.366V118.711C716.463 109.859 709.254 102.654 700.398 102.654H651.199C642.343 102.654 635.134 109.859 635.134 118.711V165.366C635.134 175.612 643.467 183.942 653.719 183.942H653.709Z" style="fill: var(--primary-400)"/>
|
||||
<path d="M1748.64 102.654H1701.96C1691.71 102.654 1683.37 110.983 1683.37 121.23V165.376C1683.37 175.622 1691.7 183.952 1701.96 183.952H1748.64C1757.49 183.952 1764.7 176.746 1764.7 167.895V118.721C1764.7 109.869 1757.49 102.664 1748.64 102.664V102.654Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
<path d="M896.673 102.654H852.504C842.263 102.654 833.919 110.983 833.919 121.23V167.885C833.919 176.736 841.128 183.942 849.984 183.942H899.184C908.039 183.942 915.249 176.736 915.249 167.885V121.23C915.249 110.983 906.915 102.654 896.663 102.654H896.673Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
<path d="M653.709 183.942H697.878C708.119 183.942 716.463 175.612 716.463 165.366V118.711C716.463 109.859 709.254 102.654 700.398 102.654H651.199C642.343 102.654 635.134 109.859 635.134 118.711V165.366C635.134 175.612 643.467 183.942 653.719 183.942H653.709Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
<path d="M107.747 80.7661H269.361C274.322 80.7661 278.338 76.7519 278.338 71.7944V8.97179C278.338 4.01422 274.322 0 269.361 0H35.9155C29.369 0 23.2442 1.75622 17.9527 4.81707C12.5007 7.96823 7.96226 12.5043 4.80949 17.9536C1.75712 23.2323 0 29.354 0 35.8972V296.149C0 315.979 16.0751 332.046 35.9155 332.046H58.8786V314.103H35.9155C25.9953 314.103 17.9527 306.064 17.9527 296.149C17.9527 286.234 25.9953 278.196 35.9155 278.196H260.385C270.305 278.196 278.348 270.157 278.348 260.242V116.663C278.348 106.748 270.305 98.7097 260.385 98.7097H107.747C102.786 98.7097 98.7702 102.724 98.7702 107.681V170.504C98.7702 175.462 102.786 179.476 107.747 179.476H188.554C193.514 179.476 197.53 183.49 197.53 188.448C197.53 193.405 193.514 197.419 188.554 197.419H107.747C92.8663 197.419 80.8074 185.367 80.8074 170.494V107.671C80.8074 92.7988 92.8663 80.7461 107.747 80.7461V80.7661Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
<path d="M269.361 314.103H121.231V332.046H269.361C274.322 332.046 278.338 328.032 278.338 323.075C278.338 318.117 274.322 314.103 269.361 314.103Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
<path d="M1620.14 3.3017C1600.16 3.3017 1583.98 19.489 1583.98 39.4498V248.099C1583.98 267.538 1599.74 283.294 1619.19 283.294H1847.17C1856.53 283.294 1864.11 275.717 1864.11 266.364V19.6898C1864.11 10.6377 1856.77 3.3017 1847.72 3.3017H1620.14ZM1782.77 167.885C1782.77 186.701 1767.46 202.006 1748.64 202.006H1701.96C1681.74 202.006 1665.3 185.567 1665.3 165.366V121.219C1665.3 101.018 1681.74 84.5796 1701.96 84.5796H1748.64C1767.46 84.5796 1782.77 99.8839 1782.77 118.701V167.885Z" fill="url(#sidebar-brand-wordmark-gradient)"/>
|
||||
@@ -38,8 +38,8 @@
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="sidebar-brand-wordmark-gradient" x1="1250.2" y1="0" x2="1250.2" y2="332.046" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--primary-500)"/>
|
||||
<stop offset="0" style="stop-color: var(--color-logo-start)"/>
|
||||
<stop offset="1" style="stop-color: var(--color-logo-end)"/>
|
||||
</linearGradient>
|
||||
<clipPath id="sidebar-brand-wordmark-clip">
|
||||
<rect width="2500" height="350" fill="white"/>
|
||||
@@ -148,7 +148,7 @@
|
||||
<div class="sidebar-nav-top">
|
||||
<button
|
||||
type="button"
|
||||
class="sidebar-action-link sidebar-search-button"
|
||||
class="sidebar-action-link sidebar-search-button bg-surface-200 hover:bg-surface-300 dark:bg-surface-800 dark:hover:bg-surface-700"
|
||||
[pTooltip]="t('search')"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
@@ -172,7 +172,7 @@
|
||||
<div class="sidebar-footer-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="sidebar-action-link sidebar-footer-action sidebar-toolbar-button"
|
||||
class="sidebar-action-link sidebar-footer-action sidebar-toolbar-button hover:bg-surface-hover"
|
||||
[pTooltip]="t('add')"
|
||||
[tooltipDisabled]="!layoutService.isDesktop()"
|
||||
tooltipPosition="top"
|
||||
@@ -188,7 +188,7 @@
|
||||
@if (canUploadBooks()) {
|
||||
<button
|
||||
type="button"
|
||||
class="sidebar-action-link sidebar-footer-action"
|
||||
class="sidebar-action-link sidebar-footer-action hover:bg-surface-hover"
|
||||
[attr.aria-label]="t('uploadBook')"
|
||||
[pTooltip]="t('uploadBook')"
|
||||
[tooltipDisabled]="!layoutService.isDesktop()"
|
||||
@@ -204,7 +204,7 @@
|
||||
type="button"
|
||||
cdkOverlayOrigin
|
||||
#notificationsFooterOrigin="cdkOverlayOrigin"
|
||||
class="sidebar-action-link sidebar-footer-action sidebar-notification-button"
|
||||
class="sidebar-action-link sidebar-footer-action sidebar-notification-button hover:bg-surface-hover"
|
||||
[attr.aria-label]="t('notifications')"
|
||||
[pTooltip]="t('notifications')"
|
||||
[tooltipDisabled]="!layoutService.isDesktop()"
|
||||
@@ -223,7 +223,7 @@
|
||||
</button>
|
||||
|
||||
<a
|
||||
class="sidebar-action-link sidebar-footer-action"
|
||||
class="sidebar-action-link sidebar-footer-action hover:bg-surface-hover"
|
||||
[class.active-route]="isSettingsActive()"
|
||||
[attr.aria-current]="isSettingsActive() ? 'page' : null"
|
||||
[routerLink]="['/settings']"
|
||||
|
||||
@@ -36,16 +36,16 @@
|
||||
min-width: 0;
|
||||
min-height: var(--sidebar-row-min-height);
|
||||
padding: var(--sidebar-row-padding-block) var(--sidebar-row-padding-inline-end) var(--sidebar-row-padding-block) var(--sidebar-row-padding-inline-start);
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
letter-spacing: 0.02em;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
@@ -108,10 +108,10 @@
|
||||
}
|
||||
|
||||
.sidebar-action-link.sidebar-toolbar-button {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
|
||||
&:hover {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,18 +127,18 @@
|
||||
border: 0;
|
||||
background: none;
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: background-color var(--transition-fast), color var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
color: var(--text-color);
|
||||
background-color: var(--color-surface-hover);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
@@ -170,8 +170,8 @@
|
||||
height: 1rem;
|
||||
padding: 0 0.25rem;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--primary-color);
|
||||
color: var(--primary-color-text);
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-contrast);
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
line-height: 1rem;
|
||||
@@ -203,7 +203,7 @@
|
||||
gap: var(--space-2);
|
||||
padding-top: var(--space-2);
|
||||
margin-top: var(--space-2);
|
||||
border-top: 1px solid var(--border-color);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.sidebar-action-link {
|
||||
@@ -217,9 +217,8 @@
|
||||
min-width: 0;
|
||||
padding: var(--sidebar-row-padding-block) var(--sidebar-row-padding-inline-end) var(--sidebar-row-padding-block) var(--sidebar-row-padding-inline-start);
|
||||
border: 0;
|
||||
background: none;
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-size: var(--text-base);
|
||||
text-align: left;
|
||||
@@ -227,19 +226,14 @@
|
||||
cursor: pointer;
|
||||
transition: background-color var(--transition-fast), padding var(--transition-base);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.active-route {
|
||||
color: var(--primary-color);
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--color-primary-text);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
|
||||
.sidebar-footer-action-label {
|
||||
color: inherit;
|
||||
@@ -298,11 +292,6 @@
|
||||
|
||||
.sidebar-search-button {
|
||||
padding-inline-end: var(--space-2);
|
||||
background-color: var(--surface-hover);
|
||||
|
||||
&:hover {
|
||||
background-color: color-mix(in srgb, var(--surface-hover), white 15%);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-search-shortcut {
|
||||
@@ -314,7 +303,7 @@
|
||||
border: 0;
|
||||
background: transparent;
|
||||
margin-left: auto;
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
font-family: inherit;
|
||||
font-size: var(--text-xs);
|
||||
line-height: 1;
|
||||
@@ -335,18 +324,18 @@
|
||||
border: 0;
|
||||
background: none;
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background-color var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
box-shadow: var(--sidebar-focus-ring);
|
||||
outline: none;
|
||||
}
|
||||
@@ -370,8 +359,8 @@
|
||||
width: 1.75rem;
|
||||
height: 1.75rem;
|
||||
border-radius: var(--radius-pill);
|
||||
background-color: color-mix(in srgb, var(--primary-color) 18%, transparent);
|
||||
color: var(--primary-color);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 18%, transparent);
|
||||
color: var(--color-primary);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
@@ -402,7 +391,7 @@
|
||||
|
||||
.sidebar-user-handle {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -440,11 +429,11 @@
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: var(--radius-pill);
|
||||
background-color: var(--surface-hover);
|
||||
color: var(--text-color);
|
||||
background-color: var(--color-card);
|
||||
color: var(--color-text);
|
||||
|
||||
&:hover {
|
||||
background-color: color-mix(in srgb, var(--surface-hover), white 15%);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,10 +476,10 @@
|
||||
min-height: 4.75rem;
|
||||
padding: var(--space-2) var(--space-1);
|
||||
border-radius: var(--radius-lg);
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-card);
|
||||
|
||||
&:hover {
|
||||
background-color: color-mix(in srgb, var(--surface-hover), white 15%);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +491,7 @@
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
text-wrap: balance;
|
||||
color: var(--text-color-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@@ -569,7 +558,7 @@
|
||||
background: none;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +573,7 @@
|
||||
background: none;
|
||||
|
||||
.sidebar-user-avatar {
|
||||
background-color: color-mix(in srgb, var(--primary-color) 24%, transparent);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 24%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,15 +591,15 @@
|
||||
height: 3rem;
|
||||
border-radius: var(--radius-pill);
|
||||
background: none;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
background-color: var(--color-surface-hover);
|
||||
}
|
||||
|
||||
&.active-route {
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--primary-color);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
color: var(--color-primary-text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
import {provideHttpClient} from '@angular/common/http';
|
||||
import {HttpTestingController, provideHttpClientTesting} from '@angular/common/http/testing';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {BackgroundUploadService} from './background-upload.service';
|
||||
|
||||
describe('BackgroundUploadService', () => {
|
||||
let service: BackgroundUploadService;
|
||||
let httpTestingController: HttpTestingController;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
provideHttpClient(),
|
||||
provideHttpClientTesting(),
|
||||
BackgroundUploadService,
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(BackgroundUploadService);
|
||||
httpTestingController = TestBed.inject(HttpTestingController);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
httpTestingController.verify();
|
||||
TestBed.resetTestingModule();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('uploads a file as multipart form data and maps the returned URL', () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
||||
const file = new File(['image-bytes'], 'background.png', {type: 'image/png'});
|
||||
let result: string | undefined;
|
||||
|
||||
service.uploadFile(file).subscribe(value => {
|
||||
result = value;
|
||||
});
|
||||
|
||||
const request = httpTestingController.expectOne(req => req.url.endsWith('/api/v1/background/upload'));
|
||||
expect(request.request.method).toBe('POST');
|
||||
expect(request.request.body instanceof FormData).toBe(true);
|
||||
expect((request.request.body as FormData).get('file')).toBe(file);
|
||||
request.flush({url: 'https://example.test/background.png'});
|
||||
|
||||
expect(result).toBe('https://example.test/background.png');
|
||||
expect(logSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uploads a background URL and maps the returned URL', () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
||||
let result: string | undefined;
|
||||
|
||||
service.uploadUrl('https://example.test/source.jpg').subscribe(value => {
|
||||
result = value;
|
||||
});
|
||||
|
||||
const request = httpTestingController.expectOne(req => req.url.endsWith('/api/v1/background/url'));
|
||||
expect(request.request.method).toBe('POST');
|
||||
expect(request.request.body).toEqual({url: 'https://example.test/source.jpg'});
|
||||
request.flush({url: 'https://example.test/normalized.jpg'});
|
||||
|
||||
expect(result).toBe('https://example.test/normalized.jpg');
|
||||
expect(logSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,26 +0,0 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, map, tap} from 'rxjs';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class BackgroundUploadService {
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1/background`;
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
uploadFile(file: File): Observable<string> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return this.http.post<{ url: string }>(`${this.baseUrl}/upload`, formData).pipe(
|
||||
tap(response => console.log('File upload response:', response)),
|
||||
map(resp => resp?.url)
|
||||
);
|
||||
}
|
||||
|
||||
uploadUrl(url: string): Observable<string> {
|
||||
return this.http.post<{ url: string }>(`${this.baseUrl}/url`, {url}).pipe(
|
||||
tap(response => console.log('URL upload response:', response)),
|
||||
map(resp => resp?.url)
|
||||
);
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
<ng-container *transloco="let t; prefix: 'layout.uploadDialog'">
|
||||
<div class="upload-dialog-content">
|
||||
<div class="upload-section">
|
||||
<div class="file-selector">
|
||||
<label class="file-label" for="upload-dialog-file-input">{{ t('chooseFile') }}</label>
|
||||
<p-button
|
||||
[label]="t('selectImage')"
|
||||
icon="pi pi-upload"
|
||||
(click)="fileInput.click()"
|
||||
outlined
|
||||
severity="info">
|
||||
</p-button>
|
||||
</div>
|
||||
<input
|
||||
id="upload-dialog-file-input"
|
||||
#fileInput
|
||||
type="file"
|
||||
accept=".jpg,.jpeg,.png,image/jpeg,image/png"
|
||||
(change)="onFileSelected($event)"
|
||||
style="display: none;">
|
||||
<small class="file-note">{{ t('fileNote') }}</small>
|
||||
@if (uploadFile) {
|
||||
<small class="selected-file">{{ uploadFile.name }}</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-divider align="center" type="solid">
|
||||
<span class="or-text">{{ t('or') }}</span>
|
||||
</p-divider>
|
||||
|
||||
<div class="url-section">
|
||||
<label for="urlInput" class="url-label">{{ t('imageUrl') }}</label>
|
||||
<input
|
||||
id="urlInput"
|
||||
type="text"
|
||||
[(ngModel)]="uploadImageUrl"
|
||||
[placeholder]="t('urlPlaceholder')"
|
||||
class="url-input"
|
||||
pInputText>
|
||||
<small class="url-note">{{ t('urlNote') }}</small>
|
||||
</div>
|
||||
|
||||
@if (uploadError) {
|
||||
<p-message severity="error">{{uploadError}}</p-message>
|
||||
}
|
||||
|
||||
<div class="dialog-footer">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
icon="pi pi-times"
|
||||
(click)="cancel()"
|
||||
severity="secondary"
|
||||
outlined>
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="'common.submit' | transloco"
|
||||
icon="pi pi-check"
|
||||
(click)="submit()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
.upload-dialog-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
padding: 1rem 0;
|
||||
|
||||
.upload-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
.file-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.file-label {
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.file-input {
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--p-border-radius);
|
||||
background: var(--ground-background);
|
||||
}
|
||||
|
||||
.file-note {
|
||||
color: var(--text-secondary-color);
|
||||
font-size: 0.875rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.selected-file {
|
||||
color: var(--text-secondary-color);
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
.url-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
|
||||
.url-label {
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.url-input {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.url-note {
|
||||
color: var(--text-secondary-color);
|
||||
font-size: 0.875rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.or-text {
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
p-message {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: flex-end;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
}
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {of, throwError} from 'rxjs';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
|
||||
import {BackgroundUploadService} from '../background-upload.service';
|
||||
import {UploadDialogComponent} from './upload-dialog.component';
|
||||
|
||||
describe('UploadDialogComponent', () => {
|
||||
let fixture: ComponentFixture<UploadDialogComponent>;
|
||||
let component: UploadDialogComponent;
|
||||
let dialogRef: {close: ReturnType<typeof vi.fn>};
|
||||
let backgroundUploadService: {
|
||||
uploadFile: ReturnType<typeof vi.fn>;
|
||||
uploadUrl: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
let translocoService: TranslocoService;
|
||||
|
||||
beforeEach(async () => {
|
||||
dialogRef = {
|
||||
close: vi.fn(),
|
||||
};
|
||||
backgroundUploadService = {
|
||||
uploadFile: vi.fn(() => of('https://example.com/uploaded.png')),
|
||||
uploadUrl: vi.fn(() => of('https://example.com/from-url.png')),
|
||||
};
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [UploadDialogComponent, getTranslocoModule()],
|
||||
providers: [
|
||||
{provide: DynamicDialogRef, useValue: dialogRef},
|
||||
{provide: BackgroundUploadService, useValue: backgroundUploadService},
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UploadDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
translocoService = TestBed.inject(TranslocoService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('stores the selected file and clears the URL field', () => {
|
||||
const file = new File(['image'], 'cover.png', {type: 'image/png'});
|
||||
const event = {
|
||||
target: {
|
||||
files: [file],
|
||||
},
|
||||
} as unknown as Event;
|
||||
component.uploadImageUrl = 'https://example.com/old.png';
|
||||
|
||||
component.onFileSelected(event);
|
||||
|
||||
expect(component.uploadFile).toBe(file);
|
||||
expect(component.uploadImageUrl).toBe('');
|
||||
});
|
||||
|
||||
it('requires either a file or a URL before uploading', () => {
|
||||
component.submit();
|
||||
|
||||
expect(component.uploadError).toBe(
|
||||
translocoService.translate('layout.uploadDialog.errorNoInput')
|
||||
);
|
||||
expect(backgroundUploadService.uploadFile).not.toHaveBeenCalled();
|
||||
expect(backgroundUploadService.uploadUrl).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uploads a selected file and closes the dialog with the returned URL', () => {
|
||||
const file = new File(['image'], 'cover.png', {type: 'image/png'});
|
||||
component.uploadFile = file;
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(backgroundUploadService.uploadFile).toHaveBeenCalledWith(file);
|
||||
expect(dialogRef.close).toHaveBeenCalledWith({
|
||||
imageUrl: 'https://example.com/uploaded.png',
|
||||
});
|
||||
});
|
||||
|
||||
it('uploads a trimmed URL and closes the dialog with the returned value', () => {
|
||||
component.uploadImageUrl = ' https://example.com/bg.png ';
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(backgroundUploadService.uploadUrl).toHaveBeenCalledWith('https://example.com/bg.png');
|
||||
expect(dialogRef.close).toHaveBeenCalledWith({
|
||||
imageUrl: 'https://example.com/from-url.png',
|
||||
});
|
||||
});
|
||||
|
||||
it('shows an error when the upload succeeds without returning an image URL', () => {
|
||||
backgroundUploadService.uploadUrl.mockReturnValueOnce(of(''));
|
||||
component.uploadImageUrl = 'https://example.com/bg.png';
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.uploadError).toBe('Failed to upload image.');
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('shows a generic upload error when the upload request fails', () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
backgroundUploadService.uploadFile.mockReturnValueOnce(
|
||||
throwError(() => new Error('boom'))
|
||||
);
|
||||
component.uploadFile = new File(['image'], 'cover.png', {type: 'image/png'});
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.uploadError).toBe('Upload failed. Please try again.');
|
||||
expect(console.error).toHaveBeenCalled();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('closes the dialog when cancel is clicked', () => {
|
||||
component.cancel();
|
||||
|
||||
expect(dialogRef.close).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Message} from 'primeng/message';
|
||||
import {BackgroundUploadService} from '../background-upload.service';
|
||||
import {take} from 'rxjs';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-upload-dialog',
|
||||
standalone: true,
|
||||
templateUrl: './upload-dialog.component.html',
|
||||
styleUrls: ['./upload-dialog.component.scss'],
|
||||
imports: [
|
||||
FormsModule,
|
||||
Button,
|
||||
InputText,
|
||||
Divider,
|
||||
Message,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
]
|
||||
})
|
||||
export class UploadDialogComponent {
|
||||
private readonly dialogRef = inject(DynamicDialogRef);
|
||||
private readonly backgroundUploadService = inject(BackgroundUploadService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
uploadImageUrl = '';
|
||||
uploadFile: File | null = null;
|
||||
uploadError = '';
|
||||
|
||||
onFileSelected(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
if (input.files && input.files.length > 0) {
|
||||
this.uploadFile = input.files[0];
|
||||
this.uploadImageUrl = '';
|
||||
}
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.uploadError = '';
|
||||
let upload$;
|
||||
if (this.uploadFile) {
|
||||
upload$ = this.backgroundUploadService.uploadFile(this.uploadFile);
|
||||
} else if (this.uploadImageUrl.trim()) {
|
||||
upload$ = this.backgroundUploadService.uploadUrl(this.uploadImageUrl.trim());
|
||||
} else {
|
||||
this.uploadError = this.t.translate('layout.uploadDialog.errorNoInput');
|
||||
return;
|
||||
}
|
||||
|
||||
upload$.pipe(take(1)).subscribe({
|
||||
next: (imageUrl) => {
|
||||
if (imageUrl) {
|
||||
this.dialogRef.close({ imageUrl });
|
||||
} else {
|
||||
this.uploadError = 'Failed to upload image.';
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Upload failed:', err);
|
||||
this.uploadError = 'Upload failed. Please try again.';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import ExtendedAura from './theme-palette-extend';
|
||||
|
||||
interface AppThemePreset {
|
||||
primitive?: Record<string, Record<string, string>>;
|
||||
semantic?: AppThemeSemantic;
|
||||
}
|
||||
|
||||
interface AppThemeSemantic {
|
||||
colorScheme?: {
|
||||
light?: AppThemeColorScheme;
|
||||
dark?: AppThemeColorScheme;
|
||||
};
|
||||
}
|
||||
|
||||
interface AppThemeColorScheme {
|
||||
content?: {
|
||||
background?: string;
|
||||
};
|
||||
}
|
||||
|
||||
describe('theme-palette-extend', () => {
|
||||
it('extends Aura with custom primitive palettes and app content surfaces', () => {
|
||||
const auraPrimitive = Aura.primitive as Record<string, Record<string, string>>;
|
||||
const preset = ExtendedAura as AppThemePreset;
|
||||
|
||||
expect(auraPrimitive).toBeTruthy();
|
||||
expect(auraPrimitive['coralSunset']['500']).toBe('#ef7550');
|
||||
expect(auraPrimitive['skyBlue']['700']).toBe('#2e88e6');
|
||||
expect(auraPrimitive['dustyNeutral']['950']).toBe('#2f2821');
|
||||
expect(preset.primitive?.['coralSunset']['500']).toBe('#ef7550');
|
||||
expect(preset.semantic?.colorScheme?.light?.content?.background).toBe('var(--surface-page)');
|
||||
expect(preset.semantic?.colorScheme?.dark?.content?.background).toBe('var(--surface-page)');
|
||||
});
|
||||
});
|
||||
@@ -1,241 +0,0 @@
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import { definePreset } from '@primeuix/themes';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
|
||||
/*
|
||||
* PrimeNG theme bridge.
|
||||
*
|
||||
* App-owned CSS tokens define the native shell/page foundation. This file only
|
||||
* extends Prime's Aura preset so Prime components can use the same app-selected
|
||||
* palettes and the same app-owned page background.
|
||||
*/
|
||||
|
||||
/* Extra primary palettes exposed to the theme configurator and Prime runtime. */
|
||||
const customPalettes: Record<string, ColorPalette> = {
|
||||
coralSunset: {
|
||||
50: '#fef7f0',
|
||||
100: '#feede1',
|
||||
200: '#fcd9c2',
|
||||
300: '#f9be9e',
|
||||
400: '#f59673',
|
||||
500: '#ef7550',
|
||||
600: '#de5a3a',
|
||||
700: '#b94730',
|
||||
800: '#943a2e',
|
||||
900: '#78322a',
|
||||
950: '#401814'
|
||||
},
|
||||
roseBlush: {
|
||||
50: '#fef7f7',
|
||||
100: '#feebeb',
|
||||
200: '#fddcdc',
|
||||
300: '#fbbfbf',
|
||||
400: '#f69393',
|
||||
500: '#ed6767',
|
||||
600: '#d93f3f',
|
||||
700: '#b73030',
|
||||
800: '#982d2d',
|
||||
900: '#7f2d2d',
|
||||
950: '#451313'
|
||||
},
|
||||
melonBlush: {
|
||||
50: '#fffafb',
|
||||
100: '#fff2f4',
|
||||
200: '#ffdfe7',
|
||||
300: '#ffcbd4',
|
||||
400: '#ffaebb',
|
||||
500: '#ff90a2',
|
||||
600: '#ff6f88',
|
||||
700: '#e8506b',
|
||||
800: '#b7384d',
|
||||
900: '#7f2231',
|
||||
950: '#3f1118'
|
||||
},
|
||||
cottonCandy: {
|
||||
50: '#fff9fb',
|
||||
100: '#fff0f6',
|
||||
200: '#ffdfee',
|
||||
300: '#ffc0e0',
|
||||
400: '#ffa3cf',
|
||||
500: '#ff86bf',
|
||||
600: '#ff69ad',
|
||||
700: '#e14f93',
|
||||
800: '#b93a72',
|
||||
900: '#86284f',
|
||||
950: '#42142a'
|
||||
},
|
||||
apricotSunrise: {
|
||||
50: '#fffaf7',
|
||||
100: '#fff1e8',
|
||||
200: '#ffe2c9',
|
||||
300: '#ffd2a8',
|
||||
400: '#ffbf88',
|
||||
500: '#ffad68',
|
||||
600: '#ff974f',
|
||||
700: '#e67a3b',
|
||||
800: '#b6572b',
|
||||
900: '#7f351b',
|
||||
950: '#3f190f'
|
||||
},
|
||||
antiqueBronze: {
|
||||
50: '#faf7f2',
|
||||
100: '#f4ede0',
|
||||
200: '#e8d9c0',
|
||||
300: '#d9c199',
|
||||
400: '#c8a56f',
|
||||
500: '#b8904f',
|
||||
600: '#a67c44',
|
||||
700: '#8a6439',
|
||||
800: '#715233',
|
||||
900: '#5c442c',
|
||||
950: '#302316'
|
||||
},
|
||||
butteryYellow: {
|
||||
50: '#fffef7',
|
||||
100: '#fffceb',
|
||||
200: '#fff7d1',
|
||||
300: '#ffeea7',
|
||||
400: '#ffe072',
|
||||
500: '#ffcf45',
|
||||
600: '#ffb61f',
|
||||
700: '#ff9b0a',
|
||||
800: '#cc7606',
|
||||
900: '#a35f0c',
|
||||
950: '#633204'
|
||||
},
|
||||
vanillaCream: {
|
||||
50: '#fefdfb',
|
||||
100: '#fefbf6',
|
||||
200: '#fdf5ea',
|
||||
300: '#fbecd5',
|
||||
400: '#f7dbb5',
|
||||
500: '#f1c589',
|
||||
600: '#e8a95c',
|
||||
700: '#d88d3e',
|
||||
800: '#b47134',
|
||||
900: '#915c2e',
|
||||
950: '#4e2f17'
|
||||
},
|
||||
citrusMint: {
|
||||
50: '#fbfff9',
|
||||
100: '#f4fff2',
|
||||
200: '#e8ffd9',
|
||||
300: '#d1ffbc',
|
||||
400: '#b7ffa0',
|
||||
500: '#96ff84',
|
||||
600: '#76e96e',
|
||||
700: '#4fb84c',
|
||||
800: '#2f7f32',
|
||||
900: '#1a4f20',
|
||||
950: '#0a2410'
|
||||
},
|
||||
freshMint: {
|
||||
50: '#f8fff9',
|
||||
100: '#f0fff3',
|
||||
200: '#dcffea',
|
||||
300: '#bfffd6',
|
||||
400: '#99ffc2',
|
||||
500: '#7fffae',
|
||||
600: '#5fe592',
|
||||
700: '#3fbf75',
|
||||
800: '#2d8f55',
|
||||
900: '#1e5f39',
|
||||
950: '#0f2f1d'
|
||||
},
|
||||
sagePearl: {
|
||||
50: '#fbfdfb',
|
||||
100: '#f4f8f4',
|
||||
200: '#e6efe6',
|
||||
300: '#d1e6d1',
|
||||
400: '#bcdcbf',
|
||||
500: '#9fcfa8',
|
||||
600: '#84b792',
|
||||
700: '#5f8f6e',
|
||||
800: '#3f6648',
|
||||
900: '#25442e',
|
||||
950: '#0f2118'
|
||||
},
|
||||
skyBlue: {
|
||||
50: '#f7fbff',
|
||||
100: '#eef6ff',
|
||||
200: '#dceefd',
|
||||
300: '#c1e8ff',
|
||||
400: '#99dfff',
|
||||
500: '#6fc8ff',
|
||||
600: '#48afff',
|
||||
700: '#2e88e6',
|
||||
800: '#2360b3',
|
||||
900: '#153d80',
|
||||
950: '#071d40'
|
||||
},
|
||||
periwinkleCream: {
|
||||
50: '#fbfbff',
|
||||
100: '#f2f3ff',
|
||||
200: '#e7eaff',
|
||||
300: '#d2dcff',
|
||||
400: '#b9c9ff',
|
||||
500: '#9fb2ff',
|
||||
600: '#7f97ff',
|
||||
700: '#5f78e6',
|
||||
800: '#4559b3',
|
||||
900: '#2b387f',
|
||||
950: '#151c40'
|
||||
},
|
||||
pastelRoyalBlue: {
|
||||
50: '#f6fbff',
|
||||
100: '#eef6ff',
|
||||
200: '#dbeeff',
|
||||
300: '#b9ddff',
|
||||
400: '#92c7ff',
|
||||
500: '#63aaff',
|
||||
600: '#3b88ff',
|
||||
700: '#2e66cc',
|
||||
800: '#235099',
|
||||
900: '#183366',
|
||||
950: '#0d1a33'
|
||||
},
|
||||
lavenderDream: {
|
||||
50: '#fbf7ff',
|
||||
100: '#f6eeff',
|
||||
200: '#ebdcff',
|
||||
300: '#dcc0ff',
|
||||
400: '#caa1ff',
|
||||
500: '#b47fff',
|
||||
600: '#9366e6',
|
||||
700: '#6f45b3',
|
||||
800: '#4c2f80',
|
||||
900: '#2d1b4f',
|
||||
950: '#15082a'
|
||||
},
|
||||
dustyNeutral: {
|
||||
50: '#faf9f7',
|
||||
100: '#f3f1ed',
|
||||
200: '#e8e3db',
|
||||
300: '#d8cfc2',
|
||||
400: '#c4b5a3',
|
||||
500: '#b39c85',
|
||||
600: '#a28a70',
|
||||
700: '#87725d',
|
||||
800: '#6f5e4e',
|
||||
900: '#5a4e42',
|
||||
950: '#2f2821'
|
||||
}
|
||||
};
|
||||
|
||||
if (!Aura.primitive) {
|
||||
Aura.primitive = {};
|
||||
}
|
||||
|
||||
Object.assign(Aura.primitive, customPalettes);
|
||||
|
||||
const AppPrimePreset = definePreset(Aura, {
|
||||
semantic: {
|
||||
colorScheme: {
|
||||
light: { content: { background: 'var(--surface-page)' } },
|
||||
dark: { content: { background: 'var(--surface-page)' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default AppPrimePreset;
|
||||
@@ -0,0 +1,76 @@
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import ExtendedAura, {primeThemeTokenPalettes} from './theme-palette-extend';
|
||||
|
||||
interface AppThemePreset {
|
||||
semantic?: AppThemeSemantic;
|
||||
}
|
||||
|
||||
interface AppThemeSemantic {
|
||||
colorScheme?: {
|
||||
light?: AppThemeColorScheme;
|
||||
dark?: AppThemeColorScheme;
|
||||
};
|
||||
}
|
||||
|
||||
interface AppThemeColorScheme {
|
||||
content?: {
|
||||
background?: string;
|
||||
};
|
||||
primary?: {
|
||||
color?: string;
|
||||
contrastColor?: string;
|
||||
hoverColor?: string;
|
||||
activeColor?: string;
|
||||
};
|
||||
highlight?: {
|
||||
background?: string;
|
||||
color?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface AppThemePresetComponents {
|
||||
components?: {
|
||||
button?: {
|
||||
colorScheme?: {
|
||||
light?: {
|
||||
outlined?: Record<string, { borderColor?: string; color?: string }>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
describe('theme-palette-extend', () => {
|
||||
it('bridges app content surfaces', () => {
|
||||
const preset = ExtendedAura as AppThemePreset;
|
||||
|
||||
expect(preset.semantic?.colorScheme?.light?.content?.background).toBe('var(--color-page)');
|
||||
expect(preset.semantic?.colorScheme?.dark?.content?.background).toBe('var(--color-page)');
|
||||
});
|
||||
|
||||
it('uses balanced light outlined button tokens', () => {
|
||||
const outlined = (ExtendedAura as AppThemePreset & AppThemePresetComponents)
|
||||
.components?.button?.colorScheme?.light?.outlined;
|
||||
|
||||
expect(outlined?.['primary']).toMatchObject({
|
||||
borderColor: 'var(--color-primary)',
|
||||
color: 'var(--color-primary)',
|
||||
});
|
||||
expect(outlined?.['info']).toMatchObject({ borderColor: '{sky.400}', color: '{sky.600}' });
|
||||
expect(outlined?.['help']).toMatchObject({ borderColor: '{purple.400}', color: '{purple.600}' });
|
||||
expect(outlined?.['secondary']).toMatchObject({
|
||||
borderColor: '{surface.400}',
|
||||
color: '{surface.600}',
|
||||
});
|
||||
});
|
||||
|
||||
it('defines Prime palettes from app CSS tokens', () => {
|
||||
const palettes = primeThemeTokenPalettes();
|
||||
|
||||
expect(palettes.primary['0']).toBeUndefined();
|
||||
expect(palettes.primary['500']).toBe('var(--color-primary-500)');
|
||||
expect(palettes.surface['0']).toBe('var(--color-surface-0)');
|
||||
expect(palettes.surface['950']).toBe('var(--color-surface-950)');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import {$t, definePreset} from '@primeuix/themes';
|
||||
|
||||
export type ColorPalette = Record<string, string>;
|
||||
|
||||
export interface ResolvedThemePalettes {
|
||||
primary: ColorPalette;
|
||||
surface: ColorPalette;
|
||||
}
|
||||
|
||||
const COLOR_STOPS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'] as const;
|
||||
const SURFACE_STOPS = ['0', ...COLOR_STOPS] as const;
|
||||
|
||||
/*
|
||||
* PrimeNG theme bridge.
|
||||
*
|
||||
* App-owned CSS tokens define the native shell/page foundation. This file only
|
||||
* extends Prime's Aura preset so Prime components can use the same app-selected
|
||||
* palettes and the same Tailwind-owned page background.
|
||||
*/
|
||||
|
||||
/** Popup menu surfaces use card elevation, not page canvas. */
|
||||
const menuRoot = { background: 'var(--color-card)' };
|
||||
|
||||
/*
|
||||
* Aura light outlined buttons default to *-200 borders — too faint on --color-card.
|
||||
* Use *-400 borders and *-600 text: readable without feeling heavy.
|
||||
*/
|
||||
const lightOutlinedButton = {
|
||||
primary: { borderColor: 'var(--color-primary)', color: 'var(--color-primary)' },
|
||||
secondary: { borderColor: '{surface.400}', color: '{surface.600}' },
|
||||
plain: { borderColor: '{surface.400}', color: '{surface.600}' },
|
||||
success: { borderColor: '{green.400}', color: '{green.600}' },
|
||||
info: { borderColor: '{sky.400}', color: '{sky.600}' },
|
||||
warn: { borderColor: '{orange.400}', color: '{orange.600}' },
|
||||
danger: { borderColor: '{red.400}', color: '{red.600}' },
|
||||
help: { borderColor: '{purple.400}', color: '{purple.600}' },
|
||||
};
|
||||
|
||||
const appPrimary = {
|
||||
color: 'var(--color-primary)',
|
||||
contrastColor: 'var(--color-primary-contrast)',
|
||||
hoverColor: 'var(--color-primary-hover)',
|
||||
activeColor: 'var(--color-primary-active)',
|
||||
};
|
||||
|
||||
const appHighlight = {
|
||||
background: 'color-mix(in srgb, var(--color-primary), transparent 84%)',
|
||||
focusBackground: 'color-mix(in srgb, var(--color-primary), transparent 76%)',
|
||||
color: 'var(--color-primary-text)',
|
||||
focusColor: 'var(--color-primary-text)',
|
||||
};
|
||||
|
||||
function buildAppTokenPalette(prefix: 'primary' | 'surface', stops: readonly string[]): ColorPalette {
|
||||
return Object.fromEntries(
|
||||
stops.map((stop) => [stop, `var(--color-${prefix}-${stop})`])
|
||||
);
|
||||
}
|
||||
|
||||
const appTokenPalettes: ResolvedThemePalettes = {
|
||||
primary: buildAppTokenPalette('primary', COLOR_STOPS),
|
||||
surface: buildAppTokenPalette('surface', SURFACE_STOPS),
|
||||
};
|
||||
|
||||
export function primeThemeTokenPalettes(): ResolvedThemePalettes {
|
||||
return appTokenPalettes;
|
||||
}
|
||||
|
||||
function buildPrimePalettePreset(theme: ResolvedThemePalettes): object {
|
||||
return {
|
||||
semantic: {
|
||||
primary: theme.primary,
|
||||
colorScheme: {
|
||||
light: {
|
||||
primary: appPrimary,
|
||||
highlight: appHighlight,
|
||||
},
|
||||
dark: {
|
||||
primary: appPrimary,
|
||||
highlight: appHighlight,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const AppPrimePreset = definePreset(Aura, {
|
||||
semantic: {
|
||||
colorScheme: {
|
||||
light: { content: { background: 'var(--color-page)' } },
|
||||
dark: {
|
||||
content: { background: 'var(--color-page)' },
|
||||
// Card menus are surface.800; Aura default hover is also 800 — use app surface-hover mix.
|
||||
navigation: {
|
||||
item: {
|
||||
focusBackground: 'color-mix(in srgb, {text.color}, transparent 92%)',
|
||||
activeBackground: 'color-mix(in srgb, {text.color}, transparent 92%)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
menu: { root: menuRoot },
|
||||
tieredmenu: { root: menuRoot },
|
||||
contextmenu: { root: menuRoot },
|
||||
menubar: { submenu: menuRoot },
|
||||
button: {
|
||||
colorScheme: {
|
||||
light: { outlined: lightOutlinedButton },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export function applyPrimeTheme(theme: ResolvedThemePalettes): void {
|
||||
$t()
|
||||
.preset(AppPrimePreset)
|
||||
.preset(buildPrimePalettePreset(theme))
|
||||
.surfacePalette(theme.surface)
|
||||
.use({useDefaultOptions: true});
|
||||
}
|
||||
|
||||
export default AppPrimePreset;
|
||||
@@ -1,21 +1,34 @@
|
||||
import {describe, expect, expectTypeOf, it} from 'vitest';
|
||||
|
||||
import {AppState} from './app-state.model';
|
||||
import {
|
||||
APP_THEME_OPTIONS,
|
||||
AppearancePreference,
|
||||
AppState,
|
||||
AppTheme,
|
||||
CustomPrimary,
|
||||
DEFAULT_APP_THEME,
|
||||
THEME_REGISTRY,
|
||||
} from './app-state.model';
|
||||
|
||||
describe('app-state.model', () => {
|
||||
it('supports partially specified visual state presets', () => {
|
||||
it('supports partially specified visual theme state', () => {
|
||||
const appState: AppState = {
|
||||
preset: 'midnight',
|
||||
primary: '#112233'
|
||||
themePreference: DEFAULT_APP_THEME,
|
||||
appearancePreference: 'system',
|
||||
};
|
||||
|
||||
expect(appState.preset).toBe('midnight');
|
||||
expect(appState.surface).toBeUndefined();
|
||||
expect(appState.themePreference).toBe(DEFAULT_APP_THEME);
|
||||
expect(appState.appearancePreference).toBe('system');
|
||||
});
|
||||
|
||||
it('keeps each field optional and string-based', () => {
|
||||
expectTypeOf<AppState['preset']>().toEqualTypeOf<string | undefined>();
|
||||
expectTypeOf<AppState['primary']>().toEqualTypeOf<string | undefined>();
|
||||
expectTypeOf<AppState['surface']>().toEqualTypeOf<string | undefined>();
|
||||
it('keeps each field optional and constrained to supported values', () => {
|
||||
expectTypeOf<AppState['themePreference']>().toEqualTypeOf<AppTheme | undefined>();
|
||||
expectTypeOf<AppState['appearancePreference']>().toEqualTypeOf<AppearancePreference | undefined>();
|
||||
expectTypeOf<AppState['customPrimary']>().toEqualTypeOf<CustomPrimary | undefined>();
|
||||
});
|
||||
|
||||
it('derives theme options from the registry', () => {
|
||||
expect(APP_THEME_OPTIONS).toBe(THEME_REGISTRY);
|
||||
expect(APP_THEME_OPTIONS.some(option => option.name === DEFAULT_APP_THEME)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import type {AppTheme, CustomPrimary} from './theme-registry';
|
||||
|
||||
export type AppearancePreference = 'light' | 'dark' | 'system';
|
||||
|
||||
export {
|
||||
APP_THEME_OPTIONS,
|
||||
CUSTOM_PRIMARY_OPTIONS,
|
||||
DEFAULT_APP_THEME,
|
||||
DEFAULT_CUSTOM_PRIMARY,
|
||||
THEME_REGISTRY,
|
||||
} from './theme-registry';
|
||||
export type {AppTheme, CustomPrimary} from './theme-registry';
|
||||
|
||||
export interface AppState {
|
||||
preset?: string;
|
||||
primary?: string;
|
||||
surface?: string;
|
||||
themePreference?: AppTheme;
|
||||
appearancePreference?: AppearancePreference;
|
||||
customPrimary?: CustomPrimary;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
export const THEME_REGISTRY = [
|
||||
{name: 'grimmory', labelKey: 'layout.theme.options.grimmory'},
|
||||
{name: 'cobalt', labelKey: 'layout.theme.options.cobalt'},
|
||||
{name: 'ember', labelKey: 'layout.theme.options.ember'},
|
||||
{name: 'crimson', labelKey: 'layout.theme.options.crimson'},
|
||||
{name: 'rose', labelKey: 'layout.theme.options.rose'},
|
||||
{name: 'forest', labelKey: 'layout.theme.options.forest'},
|
||||
{name: 'meadow', labelKey: 'layout.theme.options.meadow'},
|
||||
{name: 'teal', labelKey: 'layout.theme.options.teal'},
|
||||
{name: 'lagoon', labelKey: 'layout.theme.options.lagoon'},
|
||||
{name: 'violet', labelKey: 'layout.theme.options.violet'},
|
||||
{name: 'fuchsia', labelKey: 'layout.theme.options.fuchsia'},
|
||||
{name: 'slate', labelKey: 'layout.theme.options.slate'},
|
||||
{name: 'custom', labelKey: 'layout.theme.options.custom'},
|
||||
] as const;
|
||||
|
||||
export type AppTheme = (typeof THEME_REGISTRY)[number]['name'];
|
||||
|
||||
export const DEFAULT_APP_THEME: AppTheme = 'grimmory';
|
||||
export const APP_THEME_OPTIONS = THEME_REGISTRY;
|
||||
|
||||
export const CUSTOM_PRIMARY_OPTIONS = [
|
||||
'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal',
|
||||
'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose',
|
||||
] as const;
|
||||
|
||||
export type CustomPrimary = (typeof CUSTOM_PRIMARY_OPTIONS)[number];
|
||||
|
||||
export const DEFAULT_CUSTOM_PRIMARY: CustomPrimary = 'orange';
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
import { FaviconService } from '../layout/theme-configurator/favicon-service';
|
||||
import { FaviconService } from '../layout/theme/favicon-service';
|
||||
|
||||
function createLocalStorageMock() {
|
||||
const store = new Map<string, string>();
|
||||
@@ -20,11 +20,36 @@ function createLocalStorageMock() {
|
||||
};
|
||||
}
|
||||
|
||||
function createThemeComputedStyle(): CSSStyleDeclaration {
|
||||
const values = new Map<string, string>();
|
||||
|
||||
['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'].forEach((stop) => {
|
||||
values.set(`--color-primary-${stop}`, `primary-${stop}`);
|
||||
});
|
||||
['0', '50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'].forEach((stop) => {
|
||||
values.set(`--color-surface-${stop}`, `surface-${stop}`);
|
||||
});
|
||||
|
||||
return {
|
||||
getPropertyValue: (propertyName: string) => values.get(propertyName) ?? '',
|
||||
} as CSSStyleDeclaration;
|
||||
}
|
||||
|
||||
function createMatchMediaMock(matches: boolean) {
|
||||
return vi.fn().mockImplementation((query: string) => ({
|
||||
matches,
|
||||
media: query,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
}) as unknown as MediaQueryList);
|
||||
}
|
||||
|
||||
describe('AppConfigService', () => {
|
||||
let service: AppConfigService;
|
||||
let localStorageMock: ReturnType<typeof createLocalStorageMock>;
|
||||
let faviconServiceMock: { updateFavicon: ReturnType<typeof vi.fn> };
|
||||
const rootStyle = document.documentElement.style;
|
||||
const root = document.documentElement;
|
||||
const rootStyle = root.style;
|
||||
|
||||
beforeEach(() => {
|
||||
localStorageMock = createLocalStorageMock();
|
||||
@@ -32,7 +57,16 @@ describe('AppConfigService', () => {
|
||||
updateFavicon: vi.fn(),
|
||||
};
|
||||
vi.stubGlobal('localStorage', localStorageMock);
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: createMatchMediaMock(false),
|
||||
});
|
||||
rootStyle.cssText = '';
|
||||
const computedStyle = createThemeComputedStyle();
|
||||
vi.spyOn(globalThis, 'getComputedStyle').mockReturnValue(computedStyle);
|
||||
vi.spyOn(window, 'getComputedStyle').mockReturnValue(computedStyle);
|
||||
root.classList.remove('dark');
|
||||
delete root.dataset['appTheme'];
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
@@ -48,55 +82,76 @@ describe('AppConfigService', () => {
|
||||
afterEach(() => {
|
||||
localStorageMock.clear();
|
||||
rootStyle.cssText = '';
|
||||
root.classList.remove('dark');
|
||||
delete root.dataset['appTheme'];
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('applies the default app-owned tokens on init', () => {
|
||||
expect(rootStyle.getPropertyValue('--primary-300')).toBe('#fdba74');
|
||||
expect(rootStyle.getPropertyValue('--primary-400')).toBe('#fb923c');
|
||||
expect(rootStyle.getPropertyValue('--primary-500')).toBe('#f97316');
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#fb923c');
|
||||
expect(rootStyle.getPropertyValue('--surface-app')).toBe('#0d1012');
|
||||
expect(rootStyle.getPropertyValue('--surface-page')).toBe('color-mix(in srgb, #1a1e21 82%, #0d1012)');
|
||||
expect(rootStyle.getPropertyValue('--surface-content')).toBe('#1a1e21');
|
||||
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--surface-app)');
|
||||
expect(rootStyle.getPropertyValue('--content-border-color')).toBe('var(--border-subtle)');
|
||||
expect(faviconServiceMock.updateFavicon).toHaveBeenCalledWith('#fdba74', '#f97316');
|
||||
});
|
||||
|
||||
it('updates app-owned tokens for custom palettes', () => {
|
||||
service.appState.set({
|
||||
preset: 'Aura',
|
||||
primary: 'coralSunset',
|
||||
surface: 'midnight-blue',
|
||||
it('applies the default curated theme and system appearance on init', () => {
|
||||
expect(service.appState()).toEqual({
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'system',
|
||||
customPrimary: 'orange',
|
||||
});
|
||||
service.onPresetChange();
|
||||
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f59673');
|
||||
expect(rootStyle.getPropertyValue('--primary-300')).toBe('#f9be9e');
|
||||
expect(rootStyle.getPropertyValue('--primary-500')).toBe('#ef7550');
|
||||
expect(rootStyle.getPropertyValue('--primary-color-rgb')).toBe('239, 117, 80');
|
||||
expect(rootStyle.getPropertyValue('--surface-app')).toBe('#121518');
|
||||
expect(rootStyle.getPropertyValue('--surface-page')).toBe('color-mix(in srgb, #1f252c 82%, #121518)');
|
||||
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--surface-app)');
|
||||
expect(rootStyle.getPropertyValue('--surface-card')).toBe('color-mix(in srgb, #1f252c 62%, #38424d)');
|
||||
expect(rootStyle.getPropertyValue('--card-background')).toBe('var(--surface-card)');
|
||||
expect(faviconServiceMock.updateFavicon).toHaveBeenLastCalledWith('#f9be9e', '#ef7550');
|
||||
expect(localStorageMock.getItem('appConfigState')).toBeNull();
|
||||
expect(root.dataset['appTheme']).toBe('grimmory');
|
||||
expect(root.classList.contains('dark')).toBe(false);
|
||||
expect(rootStyle.getPropertyValue('color-scheme')).toBe('light');
|
||||
expect(rootStyle.getPropertyValue('--primary-300')).toBe('');
|
||||
expect(rootStyle.getPropertyValue('--color-app')).toBe('');
|
||||
expect(rootStyle.getPropertyValue('--color-card')).toBe('');
|
||||
expect(faviconServiceMock.updateFavicon).toHaveBeenCalledWith(
|
||||
'primary-300',
|
||||
'primary-500'
|
||||
);
|
||||
});
|
||||
|
||||
it('maps noir to the selected surface palette', () => {
|
||||
service.appState.set({
|
||||
it('updates the root theme attributes without writing palette tokens inline', () => {
|
||||
service.setThemePreference('grimmory');
|
||||
service.setAppearancePreference('light');
|
||||
|
||||
expect(root.dataset['appTheme']).toBe('grimmory');
|
||||
expect(root.classList.contains('dark')).toBe(false);
|
||||
expect(rootStyle.getPropertyValue('color-scheme')).toBe('light');
|
||||
expect(rootStyle.getPropertyValue('--color-primary')).toBe('');
|
||||
expect(rootStyle.getPropertyValue('--primary-300')).toBe('');
|
||||
expect(rootStyle.getPropertyValue('--color-card')).toBe('');
|
||||
expect(faviconServiceMock.updateFavicon).toHaveBeenLastCalledWith(
|
||||
'primary-300',
|
||||
'primary-500'
|
||||
);
|
||||
});
|
||||
|
||||
it('resets legacy saved palette state to the default theme and dark appearance', () => {
|
||||
localStorageMock.setItem('appConfigState', JSON.stringify({
|
||||
preset: 'Aura',
|
||||
primary: 'noir',
|
||||
primary: 'blue',
|
||||
surface: 'charcoal',
|
||||
});
|
||||
service.onPresetChange();
|
||||
colorScheme: 'light',
|
||||
}));
|
||||
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f0f0f0');
|
||||
expect(rootStyle.getPropertyValue('--primary-300')).toBe('#b8b8b8');
|
||||
expect(rootStyle.getPropertyValue('--primary-500')).toBe('#7d7d7d');
|
||||
expect(rootStyle.getPropertyValue('--primary-contrast-color')).toBe('#141414');
|
||||
expect(rootStyle.getPropertyValue('--primary-hover-color')).toBe('#d1d1d1');
|
||||
expect(faviconServiceMock.updateFavicon).toHaveBeenLastCalledWith('#f0f0f0', '#b8b8b8');
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
AppConfigService,
|
||||
{ provide: FaviconService, useValue: faviconServiceMock },
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(AppConfigService);
|
||||
|
||||
expect(service.appState()).toEqual({
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'dark',
|
||||
customPrimary: 'orange',
|
||||
});
|
||||
expect(root.dataset['appTheme']).toBe('grimmory');
|
||||
expect(root.classList.contains('dark')).toBe(true);
|
||||
expect(localStorageMock.getItem('appConfigState')).toBe(JSON.stringify({
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'dark',
|
||||
customPrimary: 'orange',
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
||||
import { effect, inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
|
||||
import { $t } from '@primeuix/themes';
|
||||
import { FaviconService } from '../layout/theme-configurator/favicon-service';
|
||||
import Aura from '../layout/theme-palette-extend';
|
||||
import { AppState } from '../model/app-state.model';
|
||||
import { inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
|
||||
import { FaviconService } from '../layout/theme/favicon-service';
|
||||
import {applyPrimeTheme, primeThemeTokenPalettes} from '../layout/theme/theme-palette-extend';
|
||||
import {
|
||||
APP_THEME_OPTIONS,
|
||||
AppearancePreference,
|
||||
AppState,
|
||||
AppTheme,
|
||||
CUSTOM_PRIMARY_OPTIONS,
|
||||
CustomPrimary,
|
||||
DEFAULT_APP_THEME,
|
||||
DEFAULT_CUSTOM_PRIMARY,
|
||||
} from '../model/app-state.model';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
const PRIMARY_COLOR_STOPS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
|
||||
const DEFAULT_APPEARANCE_PREFERENCE: AppearancePreference = 'system';
|
||||
const LEGACY_APPEARANCE_PREFERENCE: AppearancePreference = 'dark';
|
||||
|
||||
const COLOR_STOPS = ['0', '50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
|
||||
type StoredAppState = Partial<AppState> & {
|
||||
preset?: unknown;
|
||||
primary?: unknown;
|
||||
surface?: unknown;
|
||||
};
|
||||
|
||||
interface Palette {
|
||||
name: string;
|
||||
palette: ColorPalette;
|
||||
}
|
||||
|
||||
interface ResolvedThemePalettes {
|
||||
primary: ColorPalette;
|
||||
surface: ColorPalette;
|
||||
appPrimary: ColorPalette;
|
||||
isNoir: boolean;
|
||||
interface LoadedAppState {
|
||||
state: AppState;
|
||||
shouldPersist: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -26,539 +33,193 @@ interface ResolvedThemePalettes {
|
||||
})
|
||||
export class AppConfigService {
|
||||
private readonly STORAGE_KEY = 'appConfigState';
|
||||
appState = signal<AppState>({});
|
||||
readonly themes = APP_THEME_OPTIONS;
|
||||
private readonly appStateSignal = signal<AppState>({});
|
||||
readonly appState = this.appStateSignal.asReadonly();
|
||||
document = inject(DOCUMENT);
|
||||
platformId = inject(PLATFORM_ID);
|
||||
faviconService = inject(FaviconService);
|
||||
private initialized = false;
|
||||
|
||||
readonly surfaces: Palette[] = [
|
||||
{
|
||||
name: 'slate',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f8fafc',
|
||||
100: '#f1f5f9',
|
||||
200: '#e2e8f0',
|
||||
300: '#cbd5e1',
|
||||
400: '#94a3b8',
|
||||
500: '#64748b',
|
||||
600: '#475569',
|
||||
700: '#334155',
|
||||
800: '#283548',
|
||||
900: '#0f172a',
|
||||
950: '#020617'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'gray',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafafa',
|
||||
100: '#f4f4f5',
|
||||
200: '#e4e4e7',
|
||||
300: '#d4d4d8',
|
||||
400: '#a1a1aa',
|
||||
500: '#71717a',
|
||||
600: '#52525b',
|
||||
700: '#3f3f46',
|
||||
800: '#313136',
|
||||
900: '#18181b',
|
||||
950: '#09090b'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'neutral',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafafa',
|
||||
100: '#f5f5f5',
|
||||
200: '#e5e5e5',
|
||||
300: '#d4d4d4',
|
||||
400: '#a3a3a3',
|
||||
500: '#737373',
|
||||
600: '#525252',
|
||||
700: '#404040',
|
||||
800: '#303030',
|
||||
900: '#171717',
|
||||
950: '#0a0a0a'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'zinc',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafafa',
|
||||
100: '#f4f4f5',
|
||||
200: '#e4e4e7',
|
||||
300: '#d4d4d8',
|
||||
400: '#a1a1aa',
|
||||
500: '#71717a',
|
||||
600: '#52525b',
|
||||
700: '#3f3f46',
|
||||
800: '#313136',
|
||||
900: '#18181b',
|
||||
950: '#09090b'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'stone',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fafaf9',
|
||||
100: '#f5f5f4',
|
||||
200: '#e7e5e4',
|
||||
300: '#d6d3d1',
|
||||
400: '#a8a29e',
|
||||
500: '#78716c',
|
||||
600: '#57534e',
|
||||
700: '#44403c',
|
||||
800: '#342f2b',
|
||||
900: '#1c1917',
|
||||
950: '#0c0a09'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'iron',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f1f3f4',
|
||||
100: '#e3e5e6',
|
||||
200: '#d2d4d6',
|
||||
300: '#b8bbc0',
|
||||
400: '#9ca0a6',
|
||||
500: '#7d8288',
|
||||
600: '#646a70',
|
||||
700: '#4c5258',
|
||||
800: '#353a40',
|
||||
900: '#1a1d20',
|
||||
950: '#0d0f11'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'steel',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f3f4f6',
|
||||
100: '#e5e7eb',
|
||||
200: '#d1d5db',
|
||||
300: '#b0b7c3',
|
||||
400: '#8b93a6',
|
||||
500: '#6b7280',
|
||||
600: '#545861',
|
||||
700: '#3f4347',
|
||||
800: '#2c2f33',
|
||||
900: '#16181b',
|
||||
950: '#0b0d0e'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'carbon',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#eef0f2',
|
||||
100: '#dde1e6',
|
||||
200: '#c7cdd5',
|
||||
300: '#a8b0bc',
|
||||
400: '#8691a0',
|
||||
500: '#697080',
|
||||
600: '#545a66',
|
||||
700: '#41464f',
|
||||
800: '#303439',
|
||||
900: '#181a1d',
|
||||
950: '#0c0e10'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'ash',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f4f6f8',
|
||||
100: '#e6e9ed',
|
||||
200: '#d3d8de',
|
||||
300: '#b4bcc7',
|
||||
400: '#919ca9',
|
||||
500: '#71808a',
|
||||
600: '#5a666f',
|
||||
700: '#464f56',
|
||||
800: '#34393e',
|
||||
900: '#1a1e21',
|
||||
950: '#0d1012'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'smoke',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f6f6f7',
|
||||
100: '#ebebed',
|
||||
200: '#dadadd',
|
||||
300: '#bbbcc1',
|
||||
400: '#989aa1',
|
||||
500: '#797c84',
|
||||
600: '#63666d',
|
||||
700: '#4f5257',
|
||||
800: '#3a3d42',
|
||||
900: '#1d2023',
|
||||
950: '#0e1011'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'midnight-blue',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fcfcfd',
|
||||
100: '#f7f8fb',
|
||||
200: '#f0f2f7',
|
||||
300: '#e5e8f0',
|
||||
400: '#d3d8e3',
|
||||
500: '#5c6b7a',
|
||||
600: '#4a5866',
|
||||
700: '#3b4651',
|
||||
800: '#38424d',
|
||||
900: '#1f252c',
|
||||
950: '#121518'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'charcoal',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f0f0f0',
|
||||
100: '#e5e5e5',
|
||||
200: '#d1d1d1',
|
||||
300: '#b8b8b8',
|
||||
400: '#9a9a9a',
|
||||
500: '#7d7d7d',
|
||||
600: '#666666',
|
||||
700: '#525252',
|
||||
800: '#3d3d3d',
|
||||
900: '#242424',
|
||||
950: '#141414'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'soho',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#ececec',
|
||||
100: '#dedfdf',
|
||||
200: '#c4c4c6',
|
||||
300: '#adaeb0',
|
||||
400: '#97979b',
|
||||
500: '#7f8084',
|
||||
600: '#6a6b70',
|
||||
700: '#55565b',
|
||||
800: '#3f4046',
|
||||
900: '#252530',
|
||||
950: '#16161d'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'viva',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#f3f3f3',
|
||||
100: '#e7e7e8',
|
||||
200: '#cfd0d0',
|
||||
300: '#b7b8b9',
|
||||
400: '#9fa1a1',
|
||||
500: '#87898a',
|
||||
600: '#6e7173',
|
||||
700: '#565a5b',
|
||||
800: '#3e4244',
|
||||
900: '#1e2324',
|
||||
950: '#0e1315'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'ocean',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fbfcfc',
|
||||
100: '#F7F9F8',
|
||||
200: '#EFF3F2',
|
||||
300: '#DADEDD',
|
||||
400: '#B1B7B6',
|
||||
500: '#828787',
|
||||
600: '#5F7274',
|
||||
700: '#415B61',
|
||||
800: '#324f5a',
|
||||
900: '#183240',
|
||||
950: '#0c1920'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'light-slate',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fcfcfd',
|
||||
100: '#f8fafc',
|
||||
200: '#f1f5f9',
|
||||
300: '#e2e8f0',
|
||||
400: '#cbd5e1',
|
||||
500: '#94a3b8',
|
||||
600: '#64748b',
|
||||
700: '#475569',
|
||||
800: '#3d5068',
|
||||
900: '#1e293b',
|
||||
950: '#0f172a'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'olive',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fcfcfb',
|
||||
100: '#f8f9f6',
|
||||
200: '#f1f4ed',
|
||||
300: '#e6eadc',
|
||||
400: '#d4dfc5',
|
||||
500: '#6a755e',
|
||||
600: '#555d4c',
|
||||
700: '#434a3d',
|
||||
800: '#3d4438',
|
||||
900: '#232824',
|
||||
950: '#131614'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'crimson',
|
||||
palette: {
|
||||
0: '#ffffff',
|
||||
50: '#fcfbfb',
|
||||
100: '#f8f5f5',
|
||||
200: '#f1ebeb',
|
||||
300: '#e6d9d9',
|
||||
400: '#d4c3c3',
|
||||
500: '#755e5e',
|
||||
600: '#5d4c4c',
|
||||
700: '#4a3d3d',
|
||||
800: '#423838',
|
||||
900: '#242020',
|
||||
950: '#141212'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
constructor() {
|
||||
const initialState = this.loadAppState();
|
||||
this.appState.set({ ...initialState });
|
||||
this.document.documentElement.classList.add('p-dark');
|
||||
this.appStateSignal.set(initialState.state);
|
||||
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
this.onPresetChange();
|
||||
if (initialState.shouldPersist) {
|
||||
this.saveAppState(initialState.state);
|
||||
}
|
||||
|
||||
effect(() => {
|
||||
const state = this.appState();
|
||||
if (!this.initialized || !state) {
|
||||
this.initialized = true;
|
||||
return;
|
||||
}
|
||||
this.saveAppState(state);
|
||||
this.onPresetChange();
|
||||
});
|
||||
this.applyAppState(initialState.state);
|
||||
}
|
||||
|
||||
private loadAppState(): AppState {
|
||||
setThemePreference(themePreference: AppTheme): void {
|
||||
this.updateAppState({themePreference});
|
||||
}
|
||||
|
||||
setCustomPrimary(customPrimary: CustomPrimary): void {
|
||||
this.updateAppState({customPrimary});
|
||||
}
|
||||
|
||||
setAppearancePreference(appearancePreference: AppearancePreference): void {
|
||||
this.updateAppState({appearancePreference});
|
||||
}
|
||||
|
||||
private updateAppState(patch: AppState): void {
|
||||
const state = this.withDefaults({
|
||||
...this.appStateSignal(),
|
||||
...patch,
|
||||
});
|
||||
this.appStateSignal.set(state);
|
||||
this.saveAppState(state);
|
||||
this.applyAppState(state);
|
||||
}
|
||||
|
||||
private loadAppState(): LoadedAppState {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
const storedState = localStorage.getItem(this.STORAGE_KEY);
|
||||
if (storedState) {
|
||||
return JSON.parse(storedState);
|
||||
try {
|
||||
const parsedState = JSON.parse(storedState) as StoredAppState;
|
||||
return {
|
||||
state: this.normalizeStoredState(parsedState),
|
||||
shouldPersist: this.isLegacyPaletteState(parsedState),
|
||||
};
|
||||
} catch {
|
||||
return {state: this.withDefaults({}), shouldPersist: false};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {state: this.withDefaults({}), shouldPersist: false};
|
||||
}
|
||||
|
||||
private normalizeStoredState(state: StoredAppState): AppState {
|
||||
if (this.isLegacyPaletteState(state)) {
|
||||
return this.withDefaults({
|
||||
themePreference: DEFAULT_APP_THEME,
|
||||
appearancePreference: LEGACY_APPEARANCE_PREFERENCE,
|
||||
customPrimary: DEFAULT_CUSTOM_PRIMARY,
|
||||
});
|
||||
}
|
||||
|
||||
return this.withDefaults({
|
||||
themePreference: state.themePreference,
|
||||
appearancePreference: state.appearancePreference,
|
||||
customPrimary: state.customPrimary,
|
||||
});
|
||||
}
|
||||
|
||||
private isLegacyPaletteState(state: StoredAppState): boolean {
|
||||
return 'preset' in state || 'primary' in state || 'surface' in state;
|
||||
}
|
||||
|
||||
private withDefaults(state: AppState): AppState {
|
||||
return {
|
||||
preset: 'Aura',
|
||||
primary: 'orange',
|
||||
surface: 'ash',
|
||||
themePreference: this.resolveThemePreference(state.themePreference),
|
||||
appearancePreference: this.resolveAppearancePreference(state.appearancePreference),
|
||||
customPrimary: this.resolveCustomPrimary(state.customPrimary),
|
||||
};
|
||||
}
|
||||
|
||||
private resolveCustomPrimary(customPrimary: AppState['customPrimary']): CustomPrimary {
|
||||
if (customPrimary && CUSTOM_PRIMARY_OPTIONS.includes(customPrimary)) {
|
||||
return customPrimary;
|
||||
}
|
||||
return DEFAULT_CUSTOM_PRIMARY;
|
||||
}
|
||||
|
||||
private resolveThemePreference(themePreference: AppState['themePreference']): AppTheme {
|
||||
if (themePreference && this.themes.some((option) => option.name === themePreference)) {
|
||||
return themePreference;
|
||||
}
|
||||
|
||||
return DEFAULT_APP_THEME;
|
||||
}
|
||||
|
||||
private resolveAppearancePreference(appearancePreference: AppState['appearancePreference']): AppearancePreference {
|
||||
if (appearancePreference === 'light' || appearancePreference === 'dark' || appearancePreference === 'system') {
|
||||
return appearancePreference;
|
||||
}
|
||||
return DEFAULT_APPEARANCE_PREFERENCE;
|
||||
}
|
||||
|
||||
private effectiveAppearancePreference(appearancePreference: AppearancePreference): 'light' | 'dark' {
|
||||
if (appearancePreference !== 'system') {
|
||||
return appearancePreference;
|
||||
}
|
||||
if (isPlatformBrowser(this.platformId) && globalThis.window?.matchMedia) {
|
||||
return globalThis.window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
return 'dark';
|
||||
}
|
||||
|
||||
private saveAppState(state: AppState): void {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(state));
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(this.withDefaults(state)));
|
||||
}
|
||||
}
|
||||
|
||||
private getSurfacePalette(surface: string): ColorPalette {
|
||||
return this.surfaces.find(s => s.name === surface)?.palette ?? {};
|
||||
applyCurrentTheme(): void {
|
||||
this.applyAppState(this.withDefaults(this.appStateSignal()));
|
||||
}
|
||||
|
||||
private resolveThemePalettes(): ResolvedThemePalettes {
|
||||
const primaryName = this.appState().primary ?? 'orange';
|
||||
const surfaceName = this.appState().surface ?? 'ash';
|
||||
const presetPalette = (Aura.primitive ?? {}) as Record<string, ColorPalette>;
|
||||
const primary = presetPalette[primaryName] ?? presetPalette['orange'] ?? {};
|
||||
const surface = this.getSurfacePalette(surfaceName);
|
||||
const isNoir = primaryName === 'noir';
|
||||
private applyAppState(state: AppState): void {
|
||||
this.applyThemeAttributes(state);
|
||||
|
||||
return {
|
||||
primary,
|
||||
surface,
|
||||
appPrimary: isNoir ? surface : primary,
|
||||
isNoir,
|
||||
};
|
||||
}
|
||||
|
||||
private buildPrimePreset(theme: ResolvedThemePalettes): object {
|
||||
if (theme.isNoir) {
|
||||
return {
|
||||
semantic: {
|
||||
primary: { ...theme.surface },
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.50}',
|
||||
contrastColor: '{primary.950}',
|
||||
hoverColor: '{primary.200}',
|
||||
activeColor: '{primary.300}'
|
||||
},
|
||||
highlight: {
|
||||
background: '{primary.50}',
|
||||
focusBackground: '{primary.300}',
|
||||
color: '{primary.950}',
|
||||
focusColor: '{primary.950}'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
semantic: {
|
||||
primary: theme.primary,
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
color: '{primary.400}',
|
||||
contrastColor: '{surface.900}',
|
||||
hoverColor: '{primary.300}',
|
||||
activeColor: '{primary.200}'
|
||||
},
|
||||
highlight: {
|
||||
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
|
||||
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
|
||||
color: 'rgba(255,255,255,.87)',
|
||||
focusColor: 'rgba(255,255,255,.87)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private getFaviconGradient(theme: ResolvedThemePalettes): { start: string; end: string } {
|
||||
if (theme.isNoir) {
|
||||
return {
|
||||
start: theme.surface['50'] ?? theme.surface['0'] ?? '#f4f6f8',
|
||||
end: theme.surface['300'] ?? theme.surface['200'] ?? '#b4bcc7'
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
start: theme.primary['300'] ?? theme.primary['500'] ?? '#fdba74',
|
||||
end: theme.primary['500'] ?? theme.primary['700'] ?? '#f97316'
|
||||
};
|
||||
}
|
||||
|
||||
onPresetChange(): void {
|
||||
if (!isPlatformBrowser(this.platformId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const theme = this.resolveThemePalettes();
|
||||
this.applyPrimeTheme(theme);
|
||||
this.applyDesignTokens(theme);
|
||||
const faviconGradient = this.getFaviconGradient(theme);
|
||||
this.faviconService.updateFavicon(faviconGradient.start, faviconGradient.end);
|
||||
applyPrimeTheme(primeThemeTokenPalettes());
|
||||
this.updateFavicon();
|
||||
}
|
||||
|
||||
private applyPrimeTheme(theme: ResolvedThemePalettes): void {
|
||||
$t()
|
||||
.preset(Aura)
|
||||
.preset(this.buildPrimePreset(theme))
|
||||
.surfacePalette(theme.surface)
|
||||
.use({ useDefaultOptions: true });
|
||||
private applyThemeAttributes(state: AppState): void {
|
||||
const root = this.document.documentElement;
|
||||
const theme = this.resolveThemePreference(state.themePreference);
|
||||
const appearancePreference = this.resolveAppearancePreference(state.appearancePreference);
|
||||
const effective = this.effectiveAppearancePreference(appearancePreference);
|
||||
|
||||
root.dataset['appTheme'] = theme;
|
||||
root.classList.toggle('dark', effective === 'dark');
|
||||
root.style.setProperty('color-scheme', effective);
|
||||
this.applyCustomPrimary(root, theme, this.resolveCustomPrimary(state.customPrimary));
|
||||
this.syncSystemSchemeListener(appearancePreference);
|
||||
}
|
||||
|
||||
private applyDesignTokens(theme: ResolvedThemePalettes): void {
|
||||
const style = this.document.documentElement.style;
|
||||
const appBackground = theme.surface['950'] ?? '#0d1012';
|
||||
const surfaceContent = theme.surface['900'] ?? '#1a1e21';
|
||||
const pageBackground = `color-mix(in srgb, ${surfaceContent} 82%, ${appBackground})`;
|
||||
const surfaceCard = `color-mix(in srgb, ${surfaceContent} 62%, ${theme.surface['800'] ?? '#34393e'})`;
|
||||
const borderSubtle = theme.surface['800'] ?? '#34393e';
|
||||
const borderStrong = theme.surface['700'] ?? '#464f56';
|
||||
private applyCustomPrimary(root: HTMLElement, theme: AppTheme, customPrimary: CustomPrimary): void {
|
||||
if (theme === 'custom') {
|
||||
PRIMARY_COLOR_STOPS.forEach((stop) => {
|
||||
root.style.setProperty(`--color-primary-${stop}`, `var(--color-${customPrimary}-${stop})`);
|
||||
});
|
||||
} else {
|
||||
PRIMARY_COLOR_STOPS.forEach((stop) => root.style.removeProperty(`--color-primary-${stop}`));
|
||||
}
|
||||
}
|
||||
|
||||
const primary400 = theme.isNoir ? theme.surface['50'] : theme.primary['400'];
|
||||
const primary500 = theme.isNoir ? theme.surface['50'] : (theme.primary['500'] ?? theme.primary['400']);
|
||||
private systemSchemeMedia: MediaQueryList | null = null;
|
||||
private systemSchemeListener: ((event: MediaQueryListEvent) => void) | null = null;
|
||||
|
||||
style.setProperty('--primary-color', primary400 ?? '#fb923c');
|
||||
style.setProperty('--primary-color-rgb', this.toRgbChannels(primary500));
|
||||
style.setProperty('--primary-contrast-color', theme.isNoir ? (theme.surface['950'] ?? '#0d1012') : (theme.surface['900'] ?? '#1a1e21'));
|
||||
style.setProperty('--primary-hover-color', theme.isNoir ? (theme.surface['200'] ?? '#d3d8de') : (theme.primary['300'] ?? primary400 ?? '#fdba74'));
|
||||
style.setProperty('--primary-text-color', primary400 ?? '#fb923c');
|
||||
style.setProperty('--primary-text-color-dark', theme.isNoir ? (theme.surface['950'] ?? '#0d1012') : (theme.primary['900'] ?? '#9a3412'));
|
||||
|
||||
style.setProperty('--surface-app', appBackground);
|
||||
style.setProperty('--surface-page', pageBackground);
|
||||
style.setProperty('--surface-content', surfaceContent);
|
||||
style.setProperty('--surface-card', surfaceCard);
|
||||
style.setProperty('--surface-toolbar', `color-mix(in srgb, ${appBackground} 70%, ${surfaceContent})`);
|
||||
style.setProperty('--surface-overlay', surfaceContent);
|
||||
style.setProperty('--border-subtle', borderSubtle);
|
||||
style.setProperty('--border-strong', borderStrong);
|
||||
style.setProperty('--state-hover', 'color-mix(in srgb, var(--surface-400) 12%, transparent)');
|
||||
style.setProperty('--state-active', 'color-mix(in srgb, var(--primary-color) 8%, transparent)');
|
||||
|
||||
style.setProperty('--ground-background', 'var(--surface-app)');
|
||||
style.setProperty('--overlay-background', 'var(--surface-overlay)');
|
||||
style.setProperty('--card-background', 'var(--surface-card)');
|
||||
style.setProperty('--content-background', 'var(--surface-content)');
|
||||
style.setProperty('--code-background', 'var(--surface-content)');
|
||||
style.setProperty('--border-color', 'var(--border-subtle)');
|
||||
style.setProperty('--content-border-color', 'var(--border-subtle)');
|
||||
style.setProperty('--surface-hover', 'var(--state-hover)');
|
||||
style.setProperty('--surface-border', 'var(--border-subtle)');
|
||||
style.setProperty('--text-color', theme.surface['0'] ?? '#ffffff');
|
||||
style.setProperty('--text-color-secondary', theme.surface['300'] ?? '#b4bcc7');
|
||||
style.setProperty('--text-secondary-color', theme.surface['400'] ?? '#919ca9');
|
||||
style.setProperty('--text-muted-color', theme.surface['400'] ?? '#919ca9');
|
||||
style.setProperty('--high-contrast-text-color', theme.surface['0'] ?? '#ffffff');
|
||||
|
||||
Object.entries(theme.surface).forEach(([stop, value]) => {
|
||||
style.setProperty(`--surface-${stop}`, value);
|
||||
});
|
||||
|
||||
COLOR_STOPS.forEach((stop) => {
|
||||
const value = theme.appPrimary[stop];
|
||||
if (value) {
|
||||
style.setProperty(`--primary-${stop}`, value);
|
||||
private syncSystemSchemeListener(appearancePreference: AppearancePreference): void {
|
||||
if (!isPlatformBrowser(this.platformId) || !globalThis.window?.matchMedia) {
|
||||
return;
|
||||
}
|
||||
if (appearancePreference === 'system') {
|
||||
if (!this.systemSchemeMedia) {
|
||||
this.systemSchemeMedia = globalThis.window.matchMedia('(prefers-color-scheme: dark)');
|
||||
this.systemSchemeListener = () => this.applyCurrentTheme();
|
||||
this.systemSchemeMedia.addEventListener('change', this.systemSchemeListener);
|
||||
}
|
||||
});
|
||||
} else if (this.systemSchemeMedia && this.systemSchemeListener) {
|
||||
this.systemSchemeMedia.removeEventListener('change', this.systemSchemeListener);
|
||||
this.systemSchemeMedia = null;
|
||||
this.systemSchemeListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
private toRgbChannels(color: string | undefined): string {
|
||||
if (!color) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
const normalized = color.startsWith('#') ? color.slice(1) : color;
|
||||
const hex = normalized.length === 3
|
||||
? normalized.split('').map((char) => char + char).join('')
|
||||
: normalized;
|
||||
|
||||
if (hex.length !== 6) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
const value = Number.parseInt(hex, 16);
|
||||
if (Number.isNaN(value)) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
return `${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}`;
|
||||
private updateFavicon(): void {
|
||||
const styles = getComputedStyle(this.document.documentElement);
|
||||
this.faviconService.updateFavicon(
|
||||
styles.getPropertyValue('--color-primary-300').trim(),
|
||||
styles.getPropertyValue('--color-primary-500').trim(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
min-height: 100vh;
|
||||
min-width: 100vw;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, #1e3a8a 50%, #0f172a 100%);
|
||||
background: linear-gradient(135deg, var(--color-logo-start) 0%, var(--color-logo-end) 100%);
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
@@ -15,7 +15,7 @@
|
||||
left: -50%;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
background: radial-gradient(circle, rgb(59 130 246 / 10%) 0%, transparent 70%);
|
||||
background: radial-gradient(circle, color-mix(in srgb, var(--color-logo-start) 22%, transparent) 0%, transparent 70%);
|
||||
animation: float 20s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@
|
||||
width: 100%;
|
||||
border-radius: 2rem;
|
||||
padding: 2px;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, rgb(59 130 246 / 30%) 50%, transparent 100%);
|
||||
background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 70%, transparent) 0%, color-mix(in srgb, var(--color-primary) 30%, transparent) 50%, transparent 100%);
|
||||
box-shadow: 0 20px 60px rgb(0 0 0 / 40%);
|
||||
transition: all 0.3s ease;
|
||||
transition: box-shadow 0.3s ease, transform 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 25px 70px rgb(0 0 0 / 50%);
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
@mixin auth-card {
|
||||
width: 100%;
|
||||
background: rgb(17 24 39 / 95%);
|
||||
background: var(--color-card);
|
||||
backdrop-filter: blur(20px);
|
||||
border-radius: calc(2rem - 2px);
|
||||
padding: 3rem 2.5rem;
|
||||
@@ -79,7 +79,7 @@
|
||||
height: 4rem;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
filter: drop-shadow(0 4px 12px rgb(59 130 246 / 40%));
|
||||
filter: drop-shadow(0 4px 12px rgb(0 0 0 / 30%));
|
||||
transition: transform 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
@@ -95,8 +95,8 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
|
||||
box-shadow: 0 4px 12px rgb(59 130 246 / 40%);
|
||||
background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
|
||||
transition: transform 0.3s ease;
|
||||
|
||||
i {
|
||||
@@ -113,7 +113,7 @@
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 0.5rem;
|
||||
background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
|
||||
background: linear-gradient(135deg, var(--color-text-strong) 0%, var(--color-primary) 100%);
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
|
||||
@mixin auth-subtitle {
|
||||
font-size: 0.95rem;
|
||||
color: rgb(255 255 255 / 70%);
|
||||
color: var(--color-text-secondary);
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
max-width: 400px;
|
||||
@@ -149,19 +149,19 @@
|
||||
gap: 0.5rem;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
color: rgb(255 255 255 / 90%);
|
||||
color: var(--color-text);
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin form-input {
|
||||
transition: all 0.3s ease;
|
||||
transition: box-shadow 0.3s ease;
|
||||
|
||||
&:focus {
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 20%);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: #ef4444;
|
||||
color: var(--color-danger);
|
||||
font-size: 0.8rem;
|
||||
margin-top: -0.25rem;
|
||||
animation: fade-in 0.3s ease-out;
|
||||
@@ -186,13 +186,13 @@
|
||||
height: 3rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
|
||||
transition: box-shadow 0.3s ease, transform 0.3s ease;
|
||||
background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
|
||||
border: none;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 24px rgb(59 130 246 / 40%);
|
||||
box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
|
||||
}
|
||||
|
||||
&:active:not(:disabled) {
|
||||
|
||||
@@ -65,11 +65,11 @@ $settings-item-border-left-width: 3px;
|
||||
gap: 0.5rem;
|
||||
font-size: $settings-page-title-size;
|
||||
font-weight: $settings-page-title-weight;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
margin: 0 0 0.5rem;
|
||||
|
||||
.pi {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ $settings-item-border-left-width: 3px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $settings-card-gap;
|
||||
background: var(--card-background);
|
||||
background: var(--color-card);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: $settings-card-border-radius;
|
||||
padding: $settings-card-padding;
|
||||
@@ -114,11 +114,11 @@ $settings-item-border-left-width: 3px;
|
||||
gap: 0.5rem;
|
||||
font-size: $settings-section-title-size;
|
||||
font-weight: $settings-section-title-weight;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
margin: 0 0 0.5rem;
|
||||
|
||||
.pi {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
font-size: $settings-section-title-icon-size;
|
||||
}
|
||||
}
|
||||
@@ -152,12 +152,12 @@ $settings-item-border-left-width: 3px;
|
||||
@mixin settings-item {
|
||||
padding: $settings-item-padding;
|
||||
border-radius: $settings-item-border-radius;
|
||||
border-left: $settings-item-border-left-width solid var(--primary-color);
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-left: $settings-item-border-left-width solid var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-card) 35%, var(--color-page));
|
||||
transition: border-color 0.2s ease, background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
background: color-mix(in srgb, var(--color-card) 20%, var(--color-page));
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@@ -176,7 +176,7 @@ $settings-item-border-left-width: 3px;
|
||||
margin-bottom: 0.25rem;
|
||||
|
||||
.pi {
|
||||
color: var(--primary-color);
|
||||
color: var(--color-primary);
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ $settings-item-border-left-width: 3px;
|
||||
// ============================================================================
|
||||
@mixin settings-label {
|
||||
font-weight: $settings-label-weight;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
font-size: $settings-label-size;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ $settings-item-border-left-width: 3px;
|
||||
line-height: 1.5;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 6px;
|
||||
color: var(--text-color);
|
||||
color: var(--color-text);
|
||||
|
||||
strong {
|
||||
font-weight: 600;
|
||||
@@ -251,24 +251,20 @@ $settings-item-border-left-width: 3px;
|
||||
@mixin settings-warning-notice {
|
||||
@include settings-notice-base;
|
||||
|
||||
background: color-mix(in srgb, var(--ground-background) 85%, var(--p-red-600) 15%);
|
||||
border-left: 3px solid var(--p-red-500);
|
||||
background: color-mix(in srgb, var(--color-card) 85%, var(--color-red-600) 15%);
|
||||
border-left-width: 3px;
|
||||
border-left-style: solid;
|
||||
|
||||
.pi-exclamation-triangle {
|
||||
color: var(--p-red-400);
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: var(--p-red-300);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin settings-info-notice {
|
||||
@include settings-notice-base;
|
||||
|
||||
background: color-mix(in srgb, var(--ground-background) 90%, var(--p-blue-600) 10%);
|
||||
background: color-mix(in srgb, var(--color-card) 90%, var(--p-blue-600) 10%);
|
||||
border-left: 3px solid var(--p-blue-400);
|
||||
|
||||
.pi-info-circle {
|
||||
@@ -335,19 +331,19 @@ $settings-item-border-left-width: 3px;
|
||||
padding: 0.375rem 0.5rem;
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 4px;
|
||||
background: var(--ground-background);
|
||||
color: var(--text-color);
|
||||
background: var(--color-card);
|
||||
color: var(--color-text);
|
||||
font-size: $settings-section-description-size;
|
||||
text-align: center;
|
||||
transition: border-color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,14 +403,14 @@ $settings-item-border-left-width: 3px;
|
||||
.p-datatable-thead > tr > th {
|
||||
font-weight: 600;
|
||||
padding: 0.75rem;
|
||||
background: color-mix(in srgb, var(--text-color) 3%, transparent);
|
||||
background: color-mix(in srgb, var(--color-text) 3%, transparent);
|
||||
border-bottom: 1px solid var(--p-content-border-color);
|
||||
font-size: $settings-description-size;
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr {
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--text-color) 3%, transparent);
|
||||
background: color-mix(in srgb, var(--color-text) 3%, transparent);
|
||||
}
|
||||
|
||||
> td {
|
||||
@@ -448,7 +444,7 @@ $settings-item-border-left-width: 3px;
|
||||
gap: 1rem;
|
||||
padding: 1.5rem;
|
||||
border-radius: $settings-card-border-radius;
|
||||
background: color-mix(in srgb, var(--ground-background) 85%, var(--p-red-600) 15%);
|
||||
background: color-mix(in srgb, var(--color-card) 85%, var(--p-red-600) 15%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-red-500);
|
||||
max-width: 500px;
|
||||
@@ -492,9 +488,9 @@ $settings-item-border-left-width: 3px;
|
||||
gap: 0.375rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-radius: 0.375rem;
|
||||
border: 1.5px solid color-mix(in srgb, var(--text-color) 20%, transparent);
|
||||
background: color-mix(in srgb, var(--text-color) 5%, transparent);
|
||||
color: var(--text-color);
|
||||
border: 1.5px solid color-mix(in srgb, var(--color-text) 20%, transparent);
|
||||
background: color-mix(in srgb, var(--color-text) 5%, transparent);
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: $settings-description-size;
|
||||
@@ -512,14 +508,14 @@ $settings-item-border-left-width: 3px;
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
|
||||
border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
|
||||
border-color: color-mix(in srgb, var(--color-primary) 40%, transparent);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: var(--primary-color);
|
||||
background: color-mix(in srgb, var(--primary-color) 10%, transparent);
|
||||
color: var(--primary-color);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent);
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
||||
color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 15%, transparent);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
|
||||
Reference in New Issue
Block a user