first commit

This commit is contained in:
PeymanHonarjoo
2026-10-06 09:57:33 +03:30
parent fe4dfeb2ec
commit 268a431c1e
48 changed files with 10443 additions and 1782 deletions
+13 -1
View File
@@ -1,5 +1,8 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZonelessChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient } from '@angular/common/http';
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
import { routes } from './app.routes';
@@ -7,6 +10,15 @@ export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideZonelessChangeDetection(),
provideRouter(routes)
provideRouter(routes),
provideAnimations(),
provideHttpClient(),
{
provide: TOAST_CONFIG,
useValue: {
default: DefaultGlobalConfig,
config: {}
}
}
]
};
+1 -342
View File
@@ -1,342 +1 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * Delete the template below * * * * * * * * * -->
<!-- * * * * * * * to get started with your project! * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<style>
:host {
--bright-blue: oklch(51.01% 0.274 263.83);
--electric-violet: oklch(53.18% 0.28 296.97);
--french-violet: oklch(47.66% 0.246 305.88);
--vivid-pink: oklch(69.02% 0.277 332.77);
--hot-red: oklch(61.42% 0.238 15.34);
--orange-red: oklch(63.32% 0.24 31.68);
--gray-900: oklch(19.37% 0.006 300.98);
--gray-700: oklch(36.98% 0.014 302.71);
--gray-400: oklch(70.9% 0.015 304.04);
--red-to-pink-to-purple-vertical-gradient: linear-gradient(
180deg,
var(--orange-red) 0%,
var(--vivid-pink) 50%,
var(--electric-violet) 100%
);
--red-to-pink-to-purple-horizontal-gradient: linear-gradient(
90deg,
var(--orange-red) 0%,
var(--vivid-pink) 50%,
var(--electric-violet) 100%
);
--pill-accent: var(--bright-blue);
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1 {
font-size: 3.125rem;
color: var(--gray-900);
font-weight: 500;
line-height: 100%;
letter-spacing: -0.125rem;
margin: 0;
font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
}
p {
margin: 0;
color: var(--gray-700);
}
main {
width: 100%;
min-height: 100%;
display: flex;
justify-content: center;
align-items: center;
padding: 1rem;
box-sizing: inherit;
position: relative;
}
.angular-logo {
max-width: 9.2rem;
}
.content {
display: flex;
justify-content: space-around;
width: 100%;
max-width: 700px;
margin-bottom: 3rem;
}
.content h1 {
margin-top: 1.75rem;
}
.content p {
margin-top: 1.5rem;
}
.divider {
width: 1px;
background: var(--red-to-pink-to-purple-vertical-gradient);
margin-inline: 0.5rem;
}
.pill-group {
display: flex;
flex-direction: column;
align-items: start;
flex-wrap: wrap;
gap: 1.25rem;
}
.pill {
display: flex;
align-items: center;
--pill-accent: var(--bright-blue);
background: color-mix(in srgb, var(--pill-accent) 5%, transparent);
color: var(--pill-accent);
padding-inline: 0.75rem;
padding-block: 0.375rem;
border-radius: 2.75rem;
border: 0;
transition: background 0.3s ease;
font-family: var(--inter-font);
font-size: 0.875rem;
font-style: normal;
font-weight: 500;
line-height: 1.4rem;
letter-spacing: -0.00875rem;
text-decoration: none;
white-space: nowrap;
}
.pill:hover {
background: color-mix(in srgb, var(--pill-accent) 15%, transparent);
}
.pill-group .pill:nth-child(6n + 1) {
--pill-accent: var(--bright-blue);
}
.pill-group .pill:nth-child(6n + 2) {
--pill-accent: var(--electric-violet);
}
.pill-group .pill:nth-child(6n + 3) {
--pill-accent: var(--french-violet);
}
.pill-group .pill:nth-child(6n + 4),
.pill-group .pill:nth-child(6n + 5),
.pill-group .pill:nth-child(6n + 6) {
--pill-accent: var(--hot-red);
}
.pill-group svg {
margin-inline-start: 0.25rem;
}
.social-links {
display: flex;
align-items: center;
gap: 0.73rem;
margin-top: 1.5rem;
}
.social-links path {
transition: fill 0.3s ease;
fill: var(--gray-400);
}
.social-links a:hover svg path {
fill: var(--gray-900);
}
@media screen and (max-width: 650px) {
.content {
flex-direction: column;
width: max-content;
}
.divider {
height: 1px;
width: 100%;
background: var(--red-to-pink-to-purple-horizontal-gradient);
margin-block: 1.5rem;
}
}
</style>
<main class="main">
<div class="content">
<div class="left-side">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 982 239"
fill="none"
class="angular-logo"
>
<g clip-path="url(#a)">
<path
fill="url(#b)"
d="M388.676 191.625h30.849L363.31 31.828h-35.758l-56.215 159.797h30.848l13.174-39.356h60.061l13.256 39.356Zm-65.461-62.675 21.602-64.311h1.227l21.602 64.311h-44.431Zm126.831-7.527v70.202h-28.23V71.839h27.002v20.374h1.392c2.782-6.71 7.2-12.028 13.255-15.956 6.056-3.927 13.584-5.89 22.503-5.89 8.264 0 15.465 1.8 21.684 5.318 6.137 3.518 10.964 8.673 14.319 15.382 3.437 6.71 5.074 14.81 4.992 24.383v76.175h-28.23v-71.92c0-8.019-2.046-14.237-6.219-18.819-4.173-4.5-9.819-6.791-17.102-6.791-4.91 0-9.328 1.063-13.174 3.272-3.846 2.128-6.792 5.237-9.001 9.328-2.046 4.009-3.191 8.918-3.191 14.728ZM589.233 239c-10.147 0-18.82-1.391-26.103-4.091-7.282-2.7-13.092-6.382-17.511-10.964-4.418-4.582-7.528-9.655-9.164-15.219l25.448-6.136c1.145 2.372 2.782 4.663 4.991 6.954 2.209 2.291 5.155 4.255 8.837 5.81 3.683 1.554 8.428 2.291 14.074 2.291 8.019 0 14.647-1.964 19.884-5.81 5.237-3.845 7.856-10.227 7.856-19.064v-22.665h-1.391c-1.473 2.946-3.601 5.892-6.383 9.001-2.782 3.109-6.464 5.645-10.965 7.691-4.582 2.046-10.228 3.109-17.101 3.109-9.165 0-17.511-2.209-25.039-6.545-7.446-4.337-13.42-10.883-17.757-19.474-4.418-8.673-6.628-19.473-6.628-32.565 0-13.091 2.21-24.301 6.628-33.383 4.419-9.082 10.311-15.955 17.839-20.7 7.528-4.746 15.874-7.037 25.039-7.037 7.037 0 12.846 1.145 17.347 3.518 4.582 2.373 8.182 5.236 10.883 8.51 2.7 3.272 4.746 6.382 6.137 9.327h1.554v-19.8h27.821v121.749c0 10.228-2.454 18.737-7.364 25.447-4.91 6.709-11.538 11.7-20.048 15.055-8.509 3.355-18.165 4.991-28.884 4.991Zm.245-71.266c5.974 0 11.047-1.473 15.302-4.337 4.173-2.945 7.446-7.118 9.573-12.519 2.21-5.482 3.274-12.027 3.274-19.637 0-7.609-1.064-14.155-3.274-19.8-2.127-5.646-5.318-10.064-9.491-13.255-4.174-3.11-9.329-4.746-15.384-4.746s-11.537 1.636-15.792 4.91c-4.173 3.272-7.365 7.772-9.492 13.418-2.128 5.727-3.191 12.191-3.191 19.392 0 7.2 1.063 13.745 3.273 19.228 2.127 5.482 5.318 9.736 9.573 12.764 4.174 3.027 9.41 4.582 15.629 4.582Zm141.56-26.51V71.839h28.23v119.786h-27.412v-21.273h-1.227c-2.7 6.709-7.119 12.191-13.338 16.446-6.137 4.255-13.747 6.382-22.748 6.382-7.855 0-14.81-1.718-20.783-5.237-5.974-3.518-10.72-8.591-14.075-15.382-3.355-6.709-5.073-14.891-5.073-24.464V71.839h28.312v71.921c0 7.609 2.046 13.664 6.219 18.083 4.173 4.5 9.655 6.709 16.365 6.709 4.173 0 8.183-.982 12.111-3.028 3.927-2.045 7.118-5.072 9.655-9.082 2.537-4.091 3.764-9.164 3.764-15.218Zm65.707-109.395v159.796h-28.23V31.828h28.23Zm44.841 162.169c-7.61 0-14.402-1.391-20.457-4.091-6.055-2.7-10.883-6.791-14.32-12.109-3.518-5.319-5.237-11.946-5.237-19.801 0-6.791 1.228-12.355 3.765-16.773 2.536-4.419 5.891-7.937 10.228-10.637 4.337-2.618 9.164-4.664 14.647-6.055 5.4-1.391 11.046-2.373 16.856-3.027 7.037-.737 12.683-1.391 17.102-1.964 4.337-.573 7.528-1.555 9.574-2.782 1.963-1.309 3.027-3.273 3.027-5.973v-.491c0-5.891-1.718-10.391-5.237-13.664-3.518-3.191-8.51-4.828-15.056-4.828-6.955 0-12.356 1.473-16.447 4.5-4.009 3.028-6.71 6.546-8.183 10.719l-26.348-3.764c2.046-7.282 5.483-13.336 10.31-18.328 4.746-4.909 10.638-8.59 17.511-11.045 6.955-2.455 14.565-3.682 22.912-3.682 5.809 0 11.537.654 17.265 2.045s10.965 3.6 15.711 6.71c4.746 3.109 8.51 7.282 11.455 12.6 2.864 5.318 4.337 11.946 4.337 19.883v80.184h-27.166v-16.446h-.9c-1.719 3.355-4.092 6.464-7.201 9.328-3.109 2.864-6.955 5.237-11.619 6.955-4.828 1.718-10.229 2.536-16.529 2.536Zm7.364-20.701c5.646 0 10.556-1.145 14.729-3.354 4.173-2.291 7.364-5.237 9.655-9.001 2.292-3.763 3.355-7.854 3.355-12.273v-14.155c-.9.737-2.373 1.391-4.5 2.046-2.128.654-4.419 1.145-7.037 1.636-2.619.491-5.155.9-7.692 1.227-2.537.328-4.746.655-6.628.901-4.173.572-8.019 1.472-11.292 2.781-3.355 1.31-5.973 3.11-7.855 5.401-1.964 2.291-2.864 5.318-2.864 8.918 0 5.237 1.882 9.164 5.728 11.782 3.682 2.782 8.51 4.091 14.401 4.091Zm64.643 18.328V71.839h27.412v19.965h1.227c2.21-6.955 5.974-12.274 11.292-16.038 5.319-3.763 11.456-5.645 18.329-5.645 1.555 0 3.355.082 5.237.163 1.964.164 3.601.328 4.91.573v25.938c-1.227-.41-3.109-.819-5.646-1.146a58.814 58.814 0 0 0-7.446-.49c-5.155 0-9.738 1.145-13.829 3.354-4.091 2.209-7.282 5.236-9.655 9.164-2.373 3.927-3.519 8.427-3.519 13.5v70.448h-28.312ZM222.077 39.192l-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"
/>
<path
fill="url(#c)"
d="M388.676 191.625h30.849L363.31 31.828h-35.758l-56.215 159.797h30.848l13.174-39.356h60.061l13.256 39.356Zm-65.461-62.675 21.602-64.311h1.227l21.602 64.311h-44.431Zm126.831-7.527v70.202h-28.23V71.839h27.002v20.374h1.392c2.782-6.71 7.2-12.028 13.255-15.956 6.056-3.927 13.584-5.89 22.503-5.89 8.264 0 15.465 1.8 21.684 5.318 6.137 3.518 10.964 8.673 14.319 15.382 3.437 6.71 5.074 14.81 4.992 24.383v76.175h-28.23v-71.92c0-8.019-2.046-14.237-6.219-18.819-4.173-4.5-9.819-6.791-17.102-6.791-4.91 0-9.328 1.063-13.174 3.272-3.846 2.128-6.792 5.237-9.001 9.328-2.046 4.009-3.191 8.918-3.191 14.728ZM589.233 239c-10.147 0-18.82-1.391-26.103-4.091-7.282-2.7-13.092-6.382-17.511-10.964-4.418-4.582-7.528-9.655-9.164-15.219l25.448-6.136c1.145 2.372 2.782 4.663 4.991 6.954 2.209 2.291 5.155 4.255 8.837 5.81 3.683 1.554 8.428 2.291 14.074 2.291 8.019 0 14.647-1.964 19.884-5.81 5.237-3.845 7.856-10.227 7.856-19.064v-22.665h-1.391c-1.473 2.946-3.601 5.892-6.383 9.001-2.782 3.109-6.464 5.645-10.965 7.691-4.582 2.046-10.228 3.109-17.101 3.109-9.165 0-17.511-2.209-25.039-6.545-7.446-4.337-13.42-10.883-17.757-19.474-4.418-8.673-6.628-19.473-6.628-32.565 0-13.091 2.21-24.301 6.628-33.383 4.419-9.082 10.311-15.955 17.839-20.7 7.528-4.746 15.874-7.037 25.039-7.037 7.037 0 12.846 1.145 17.347 3.518 4.582 2.373 8.182 5.236 10.883 8.51 2.7 3.272 4.746 6.382 6.137 9.327h1.554v-19.8h27.821v121.749c0 10.228-2.454 18.737-7.364 25.447-4.91 6.709-11.538 11.7-20.048 15.055-8.509 3.355-18.165 4.991-28.884 4.991Zm.245-71.266c5.974 0 11.047-1.473 15.302-4.337 4.173-2.945 7.446-7.118 9.573-12.519 2.21-5.482 3.274-12.027 3.274-19.637 0-7.609-1.064-14.155-3.274-19.8-2.127-5.646-5.318-10.064-9.491-13.255-4.174-3.11-9.329-4.746-15.384-4.746s-11.537 1.636-15.792 4.91c-4.173 3.272-7.365 7.772-9.492 13.418-2.128 5.727-3.191 12.191-3.191 19.392 0 7.2 1.063 13.745 3.273 19.228 2.127 5.482 5.318 9.736 9.573 12.764 4.174 3.027 9.41 4.582 15.629 4.582Zm141.56-26.51V71.839h28.23v119.786h-27.412v-21.273h-1.227c-2.7 6.709-7.119 12.191-13.338 16.446-6.137 4.255-13.747 6.382-22.748 6.382-7.855 0-14.81-1.718-20.783-5.237-5.974-3.518-10.72-8.591-14.075-15.382-3.355-6.709-5.073-14.891-5.073-24.464V71.839h28.312v71.921c0 7.609 2.046 13.664 6.219 18.083 4.173 4.5 9.655 6.709 16.365 6.709 4.173 0 8.183-.982 12.111-3.028 3.927-2.045 7.118-5.072 9.655-9.082 2.537-4.091 3.764-9.164 3.764-15.218Zm65.707-109.395v159.796h-28.23V31.828h28.23Zm44.841 162.169c-7.61 0-14.402-1.391-20.457-4.091-6.055-2.7-10.883-6.791-14.32-12.109-3.518-5.319-5.237-11.946-5.237-19.801 0-6.791 1.228-12.355 3.765-16.773 2.536-4.419 5.891-7.937 10.228-10.637 4.337-2.618 9.164-4.664 14.647-6.055 5.4-1.391 11.046-2.373 16.856-3.027 7.037-.737 12.683-1.391 17.102-1.964 4.337-.573 7.528-1.555 9.574-2.782 1.963-1.309 3.027-3.273 3.027-5.973v-.491c0-5.891-1.718-10.391-5.237-13.664-3.518-3.191-8.51-4.828-15.056-4.828-6.955 0-12.356 1.473-16.447 4.5-4.009 3.028-6.71 6.546-8.183 10.719l-26.348-3.764c2.046-7.282 5.483-13.336 10.31-18.328 4.746-4.909 10.638-8.59 17.511-11.045 6.955-2.455 14.565-3.682 22.912-3.682 5.809 0 11.537.654 17.265 2.045s10.965 3.6 15.711 6.71c4.746 3.109 8.51 7.282 11.455 12.6 2.864 5.318 4.337 11.946 4.337 19.883v80.184h-27.166v-16.446h-.9c-1.719 3.355-4.092 6.464-7.201 9.328-3.109 2.864-6.955 5.237-11.619 6.955-4.828 1.718-10.229 2.536-16.529 2.536Zm7.364-20.701c5.646 0 10.556-1.145 14.729-3.354 4.173-2.291 7.364-5.237 9.655-9.001 2.292-3.763 3.355-7.854 3.355-12.273v-14.155c-.9.737-2.373 1.391-4.5 2.046-2.128.654-4.419 1.145-7.037 1.636-2.619.491-5.155.9-7.692 1.227-2.537.328-4.746.655-6.628.901-4.173.572-8.019 1.472-11.292 2.781-3.355 1.31-5.973 3.11-7.855 5.401-1.964 2.291-2.864 5.318-2.864 8.918 0 5.237 1.882 9.164 5.728 11.782 3.682 2.782 8.51 4.091 14.401 4.091Zm64.643 18.328V71.839h27.412v19.965h1.227c2.21-6.955 5.974-12.274 11.292-16.038 5.319-3.763 11.456-5.645 18.329-5.645 1.555 0 3.355.082 5.237.163 1.964.164 3.601.328 4.91.573v25.938c-1.227-.41-3.109-.819-5.646-1.146a58.814 58.814 0 0 0-7.446-.49c-5.155 0-9.738 1.145-13.829 3.354-4.091 2.209-7.282 5.236-9.655 9.164-2.373 3.927-3.519 8.427-3.519 13.5v70.448h-28.312ZM222.077 39.192l-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"
/>
</g>
<defs>
<radialGradient
id="c"
cx="0"
cy="0"
r="1"
gradientTransform="rotate(118.122 171.182 60.81) scale(205.794)"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#FF41F8" />
<stop offset=".707" stop-color="#FF41F8" stop-opacity=".5" />
<stop offset="1" stop-color="#FF41F8" stop-opacity="0" />
</radialGradient>
<linearGradient
id="b"
x1="0"
x2="982"
y1="192"
y2="192"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#F0060B" />
<stop offset="0" stop-color="#F0070C" />
<stop offset=".526" stop-color="#CC26D5" />
<stop offset="1" stop-color="#7702FF" />
</linearGradient>
<clipPath id="a"><path fill="#fff" d="M0 0h982v239H0z" /></clipPath>
</defs>
</svg>
<h1>Hello, {{ title() }}</h1>
<p>Congratulations! Your app is running. 🎉</p>
</div>
<div class="divider" role="separator" aria-label="Divider"></div>
<div class="right-side">
<div class="pill-group">
@for (item of [
{ title: 'Explore the Docs', link: 'https://angular.dev' },
{ title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' },
{ title: 'Prompt and best practices for AI', link: 'https://angular.dev/ai/develop-with-ai'},
{ title: 'CLI Docs', link: 'https://angular.dev/tools/cli' },
{ title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' },
{ title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' },
]; track item.title) {
<a
class="pill"
[href]="item.link"
target="_blank"
rel="noopener"
>
<span>{{ item.title }}</span>
<svg
xmlns="http://www.w3.org/2000/svg"
height="14"
viewBox="0 -960 960 960"
width="14"
fill="currentColor"
>
<path
d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"
/>
</svg>
</a>
}
</div>
<div class="social-links">
<a
href="https://github.com/angular/angular"
aria-label="Github"
target="_blank"
rel="noopener"
>
<svg
width="25"
height="24"
viewBox="0 0 25 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Github"
>
<path
d="M12.3047 0C5.50634 0 0 5.50942 0 12.3047C0 17.7423 3.52529 22.3535 8.41332 23.9787C9.02856 24.0946 9.25414 23.7142 9.25414 23.3871C9.25414 23.0949 9.24389 22.3207 9.23876 21.2953C5.81601 22.0377 5.09414 19.6444 5.09414 19.6444C4.53427 18.2243 3.72524 17.8449 3.72524 17.8449C2.61064 17.082 3.81137 17.0973 3.81137 17.0973C5.04697 17.1835 5.69604 18.3647 5.69604 18.3647C6.79321 20.2463 8.57636 19.7029 9.27978 19.3881C9.39052 18.5924 9.70736 18.0499 10.0591 17.7423C7.32641 17.4347 4.45429 16.3765 4.45429 11.6618C4.45429 10.3185 4.9311 9.22133 5.72065 8.36C5.58222 8.04931 5.16694 6.79833 5.82831 5.10337C5.82831 5.10337 6.85883 4.77319 9.2121 6.36459C10.1965 6.09082 11.2424 5.95546 12.2883 5.94931C13.3342 5.95546 14.3801 6.09082 15.3644 6.36459C17.7023 4.77319 18.7328 5.10337 18.7328 5.10337C19.3942 6.79833 18.9789 8.04931 18.8559 8.36C19.6403 9.22133 20.1171 10.3185 20.1171 11.6618C20.1171 16.3888 17.2409 17.4296 14.5031 17.7321C14.9338 18.1012 15.3337 18.8559 15.3337 20.0084C15.3337 21.6552 15.3183 22.978 15.3183 23.3779C15.3183 23.7009 15.5336 24.0854 16.1642 23.9623C21.0871 22.3484 24.6094 17.7341 24.6094 12.3047C24.6094 5.50942 19.0999 0 12.3047 0Z"
/>
</svg>
</a>
<a
href="https://twitter.com/angular"
aria-label="Twitter"
target="_blank"
rel="noopener"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Twitter"
>
<path
d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"
/>
</svg>
</a>
<a
href="https://www.youtube.com/channel/UCbn1OgGei-DV7aSRo_HaAiw"
aria-label="Youtube"
target="_blank"
rel="noopener"
>
<svg
width="29"
height="20"
viewBox="0 0 29 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Youtube"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M27.4896 1.52422C27.9301 1.96749 28.2463 2.51866 28.4068 3.12258C29.0004 5.35161 29.0004 10 29.0004 10C29.0004 10 29.0004 14.6484 28.4068 16.8774C28.2463 17.4813 27.9301 18.0325 27.4896 18.4758C27.0492 18.9191 26.5 19.2389 25.8972 19.4032C23.6778 20 14.8068 20 14.8068 20C14.8068 20 5.93586 20 3.71651 19.4032C3.11363 19.2389 2.56449 18.9191 2.12405 18.4758C1.68361 18.0325 1.36732 17.4813 1.20683 16.8774C0.613281 14.6484 0.613281 10 0.613281 10C0.613281 10 0.613281 5.35161 1.20683 3.12258C1.36732 2.51866 1.68361 1.96749 2.12405 1.52422C2.56449 1.08095 3.11363 0.76113 3.71651 0.596774C5.93586 0 14.8068 0 14.8068 0C14.8068 0 23.6778 0 25.8972 0.596774C26.5 0.76113 27.0492 1.08095 27.4896 1.52422ZM19.3229 10L11.9036 5.77905V14.221L19.3229 10Z"
/>
</svg>
</a>
</div>
</div>
</div>
</main>
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<router-outlet />
<app-layout></app-layout>
+9 -1
View File
@@ -1,3 +1,11 @@
import { Routes } from '@angular/router';
import { SettingsPage } from './pages/settings/settings.page';
export const routes: Routes = [];
export const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: '' },
{
path: 'settings',
title: 'تنظیمات',
component: SettingsPage,
},
];
-7
View File
@@ -15,11 +15,4 @@ describe('App', () => {
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it('should render title', () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, faq-chatbot');
});
});
+4 -6
View File
@@ -1,12 +1,10 @@
import { Component, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { Component } from '@angular/core';
import { LayoutComponent } from './layout/layout.component';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
imports: [LayoutComponent],
templateUrl: './app.html',
styleUrl: './app.css'
})
export class App {
protected readonly title = signal('faq-chatbot');
}
export class App {}
+59
View File
@@ -0,0 +1,59 @@
.header-bar {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
}
.app-logo {
height: 36px;
width: auto;
object-fit: contain;
}
.app-logo-link {
display: inline-flex;
align-items: center;
cursor: pointer;
}
.app-logo-link:hover .app-logo {
opacity: 0.85;
}
.menu-toggle {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border: none;
background: transparent;
color: var(--menu-toggle-color);
border-radius: 0.375rem;
cursor: pointer;
transition: background 0.2s;
flex-shrink: 0;
}
.menu-toggle:hover {
background: var(--menu-toggle-hover);
}
.main-content {
flex: 1;
overflow-y: auto;
background: var(--main-content-bg);
}
.main-area {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
transition: margin-right 0.3s ease;
}
.main-area.shifted {
margin-right: 260px;
}
+23
View File
@@ -0,0 +1,23 @@
<div class="app-layout">
<app-sidebar
[isOpen]="sidebarOpen()"
[chatHistory]="chatHistory()"
(close)="sidebarOpen.set(false)"
(navClick)="sidebarOpen.set(false)"
(open)="sidebarOpen.set(true)"
(profileClick)="onProfile()"
(logoutClick)="onLogout()"
></app-sidebar>
<div class="main-area" [class.shifted]="sidebarOpen()">
<!-- <div class="header-bar">
<a class="app-logo-link" routerLink="/">
<img class="app-logo" [src]="isDarkMode() ? 'assets/images/RaymandLogo.png' : 'assets/images/login.png'" alt="Raymand" />
</a>
</div> -->
<main class="main-content">
<router-outlet></router-outlet>
</main>
</div>
</div>
+33
View File
@@ -0,0 +1,33 @@
import { ChangeDetectionStrategy, Component, signal, inject } from '@angular/core';
import { RouterModule } from '@angular/router';
import { RouterOutlet } from '@angular/router';
import { SidebarComponent, ChatHistoryItem } from '../shared/ui/sidebar/sidebar.component';
import { AuthService } from '../services/auth/auth.service';
import { ThemeService } from '../services/theme/theme.service';
@Component({
selector: 'app-layout',
standalone: true,
imports: [RouterModule, RouterOutlet, SidebarComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './layout.component.html',
styleUrl: './layout.component.css',
})
export class LayoutComponent {
private readonly authService = inject(AuthService);
private readonly themeService = inject(ThemeService);
readonly sidebarOpen = signal(false);
readonly chatHistory = signal<ChatHistoryItem[]>([]);
readonly isDarkMode = this.themeService.isDarkMode;
onProfile(): void {
this.sidebarOpen.set(false);
}
onLogout(): void {
this.authService.logout();
this.sidebarOpen.set(false);
}
}
+376
View File
@@ -0,0 +1,376 @@
.settings-page {
min-height: 100vh;
}
.settings-header {
animation: fadeInDown 0.4s ease-out;
}
.settings-card {
animation: fadeInUp 0.5s ease-out;
}
.settings-tabs {
position: relative;
}
.tab-btn {
position: relative;
}
.tab-btn.tab-active {
color: var(--color-primary);
}
.tab-btn .tab-indicator {
animation: slideIn 0.3s ease-out;
}
.settings-content {
animation: fadeIn 0.3s ease-out;
}
.section-header {
animation: fadeInDown 0.3s ease-out;
}
.dropzone {
position: relative;
overflow: hidden;
}
.dropzone::before {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(135deg, var(--color-primary)/5 0%, transparent 50%);
opacity: 0;
transition: opacity 0.3s ease;
}
.dropzone:hover::before,
.dropzone-active::before {
opacity: 1;
}
.dropzone-active {
border-color: var(--color-primary) !important;
background-color: var(--color-primary)/10 !important;
transform: scale(1.01);
box-shadow: 0 0 0 3px var(--color-primary)/20, 0 10px 40px var(--color-primary)/10;
}
.dropzone-icon-wrapper {
animation: bounce 2s infinite;
}
.dropzone-active .dropzone-icon-wrapper {
animation: pulse 1s infinite;
}
.file-list {
animation: slideUp 0.4s ease-out;
}
.file-item {
animation: slideInRight 0.3s ease-out;
}
.file-item:nth-child(1) { animation-delay: 0.05s; }
.file-item:nth-child(2) { animation-delay: 0.1s; }
.file-item:nth-child(3) { animation-delay: 0.15s; }
.file-item:nth-child(4) { animation-delay: 0.2s; }
.file-item:nth-child(5) { animation-delay: 0.25s; }
.file-icon-wrapper {
transition: all 0.2s ease;
}
.file-item:hover .file-icon-wrapper {
background-color: var(--color-primary)/20;
transform: scale(1.05);
}
.file-remove-btn {
transition: all 0.2s ease;
}
.setting-item {
animation: fadeInUp 0.4s ease-out;
}
.setting-item:nth-child(1) { animation-delay: 0.05s; }
.setting-item:nth-child(2) { animation-delay: 0.1s; }
.setting-item:nth-child(3) { animation-delay: 0.15s; }
.setting-item:nth-child(4) { animation-delay: 0.2s; }
.form-select {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: left 0.75rem center;
padding-left: 2.5rem;
}
.form-select:focus {
box-shadow: 0 0 0 3px var(--color-primary)/20;
}
.toggle-switch {
position: relative;
display: inline-flex;
height: 1.5rem;
width: 2.75rem;
flex-shrink: 0;
cursor: pointer;
align-items: center;
justify-content: flex-start;
padding: 0.125rem;
border-radius: 9999px;
border: 2px solid transparent;
transition: all 0.2s ease-in-out;
background-color: var(--toggle-bg);
box-sizing: border-box;
}
.toggle-switch input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
pointer-events: none;
display: inline-block;
height: 1.25rem;
width: 1.25rem;
border-radius: 9999px;
background-color: var(--toggle-slider);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
}
.toggle-slider::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.5rem;
height: 0.5rem;
border-radius: 50%;
background-color: var(--toggle-slider);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
opacity: 1;
}
.toggle-switch input:checked + .toggle-slider {
transform: translateX(-1.25rem);
background-color: var(--toggle-slider);
box-shadow: 0 2px 8px var(--color-primary)/40, 0 0 0 2px var(--color-primary)/20;
}
.toggle-switch input:checked + .toggle-slider::after {
background-color: var(--toggle-slider);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.toggle-switch:has(input:checked) {
background-color: var(--color-primary);
border-color: var(--color-primary);
}
.toggle-switch.toggle-active {
background-color: var(--color-primary)/15;
border-color: var(--color-primary)/25;
}
.toggle-switch:focus-within {
outline: none;
box-shadow: 0 0 0 3px var(--color-primary)/30;
}
.toggle-switch:hover {
background-color: var(--color-primary)/10;
}
.toggle-switch:hover:has(input:checked) {
background-color: var(--color-primary);
}
.toggle-switch:hover.toggle-active {
background-color: var(--color-primary)/20;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes slideIn {
from {
width: 0;
opacity: 0;
}
to {
width: 1.5rem;
opacity: 1;
}
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-5px);
}
60% {
transform: translateY(-3px);
}
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
@media (max-width: 640px) {
.settings-page {
padding: 1rem;
}
.settings-card {
border-radius: 1rem;
}
.settings-tabs {
flex-direction: column;
}
.tab-btn {
justify-content: flex-start;
padding: 1rem;
}
.tab-btn .tab-indicator {
display: none;
}
.tab-btn.tab-active {
background-color: var(--color-primary)/10;
}
.dropzone {
padding: 2rem 1rem;
}
.setting-item {
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
.setting-control {
width: 100%;
justify-content: flex-end;
}
.form-select {
width: 100%;
}
}
[data-bs-theme="dark"] .dropzone-icon-wrapper svg,
[data-bs-theme="dark"] .file-icon-wrapper svg,
[data-bs-theme="dark"] .section-header svg {
stroke: var(--color-primary);
}
[data-bs-theme="dark"] .form-select {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .file-remove-btn:hover {
background-color: rgba(239, 68, 68, 0.15);
}
[data-bs-theme="dark"] .toggle-switch input:checked + .toggle-slider {
box-shadow: 0 1px 3px var(--color-primary)/40, 0 0 0 2px var(--color-primary)/30;
}
[data-bs-theme="dark"] .settings-card,
[data-bs-theme="dark"] .file-item,
[data-bs-theme="dark"] .setting-item {
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.2);
}
[data-bs-theme="dark"] .file-item:hover,
[data-bs-theme="dark"] .setting-item:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}
+326
View File
@@ -0,0 +1,326 @@
<div class="settings-page max-w-3xl mx-auto px-4 py-8">
<header class="settings-header mb-8">
<h1 class="text-3xl font-semibold text-[var(--text-primary)] mb-1">تنظیمات</h1>
<p class="text-sm text-[var(--text-muted)]">مدیریت FAQ و ترجیحات برنامه</p>
</header>
<div
class="settings-card bg-[var(--card-bg)] rounded-2xl overflow-hidden shadow-[0_10px_40px_rgba(0,0,0,0.08),_0_2px_10px_rgba(0,0,0,0.04)]"
>
<nav class="settings-tabs flex bg-[var(--sidebar-hover)]" role="tablist">
<button
type="button"
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
[class.tab-active]="activeTab() === 'faq'"
(click)="selectTab('faq')"
role="tab"
[attr.aria-selected]="activeTab() === 'faq'"
>
<svg
class="w-4 h-4 transition-colors duration-200"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
<span>آپلود FAQ</span>
@if (activeTab() === 'faq') {
<span
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
></span>
}
</button>
<button
type="button"
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
[class.tab-active]="activeTab() === 'app'"
(click)="selectTab('app')"
role="tab"
[attr.aria-selected]="activeTab() === 'app'"
>
<svg
class="w-4 h-4 transition-colors duration-200"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
<span>تنظیمات برنامه</span>
@if (activeTab() === 'app') {
<span
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
></span>
}
</button>
</nav>
<div class="settings-content p-6">
@if (activeTab() === 'faq') {
<section class="faq-section animate-fade-in">
<div class="section-header mb-6">
<h2
class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2"
>
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
آپلود سند FAQ
</h2>
<p class="text-sm text-[var(--text-muted)]">
فایل‌های PDF، DOCX یا TXT خود را بکشید و رها کنید یا برای آپلود کلیک کنید.
</p>
</div>
<div
class="dropzone relative flex flex-col items-center justify-center gap-3 p-8 border-2 border-dashed border-[var(--text-muted)]/20 rounded-xl bg-[var(--dropzone-bg)] cursor-pointer transition-all duration-300 hover:border-primary/50 hover:bg-primary/5 hover:shadow-[0_10px_30px_rgba(59,130,246,0.15)]"
[class.dropzone-active]="isDragging()"
(dragover)="onDragOver($event)"
(dragleave)="onDragLeave()"
(drop)="onDrop($event)"
(click)="fileInput.click()"
role="button"
tabindex="0"
(keydown.enter)="fileInput.click()"
(keydown.space)="$event.preventDefault(); fileInput.click()"
>
<input
#fileInput
id="faq-file-input"
type="file"
class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
accept=".pdf,.docx,.doc,.txt"
multiple
(change)="onFileSelected($event)"
/>
<div class="dropzone-icon-wrapper">
<svg
class="w-12 h-12 text-primary transition-transform duration-300"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
</div>
<div class="dropzone-text text-center">
<p class="text-sm font-medium text-[var(--text-secondary)]">
فایل‌ها را اینجا رها کنید
</p>
<p class="text-xs text-[var(--text-muted)] mt-1">یا کلیک کنید برای انتخاب</p>
<p class="text-xs text-[var(--text-muted)] mt-2">پشتیبانی: PDF، DOCX، TXT</p>
</div>
</div>
@if (fileCount > 0) {
<div class="file-list mt-6 animate-slide-up">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-[var(--text-primary)] flex items-center gap-2">
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
</svg>
فایل‌های انتخاب شده ({{ fileCount }})
</h3>
<button
type="button"
class="text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors duration-200"
(click)="clearAllFiles()"
>
پاک کردن همه
</button>
</div>
<ul class="space-y-2">
@for (file of uploadedFiles(); track $index) {
<li
class="file-item flex items-center justify-between gap-3 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="flex items-center gap-3 min-w-0">
<div class="file-icon-wrapper p-2 bg-primary/10 rounded-lg shrink-0">
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
</svg>
</div>
<div class="flex flex-col min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)] truncate">{{
file.name
}}</span>
<span class="text-xs text-[var(--text-muted)]">{{
formatFileSize(file.size)
}}</span>
</div>
</div>
<button
type="button"
class="file-remove-btn p-2 text-[var(--text-muted)] rounded-lg transition-all duration-200 hover:text-red-400 hover:bg-red-400/10 hover:scale-110 shrink-0"
(click)="removeFile($index)"
aria-label="حذف فایل {{ file.name }}"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</li>
}
</ul>
</div>
}
</section>
}
@if (activeTab() === 'app') {
<section class="app-section animate-fade-in">
<div class="section-header mb-6">
<h2
class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2"
>
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
تنظیمات کلی
</h2>
</div>
<div class="settings-grid space-y-3">
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]"
>زبان رابط کاربری</span
>
<span class="text-xs text-[var(--text-muted)]"
>زبان نمایش برنامه را انتخاب کنید</span
>
</div>
<div class="setting-control shrink-0">
<select
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-2 text-sm min-w-[140px] cursor-pointer transition-all duration-200 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 focus:shadow-[0_0_0_3px_var(--color-primary)/20]"
[(ngModel)]="language"
>
<option value="fa">فارسی</option>
<option value="en">English</option>
</select>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">اعلان‌ها</span>
<span class="text-xs text-[var(--text-muted)]">دریافت اعلان‌های برنامه</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="notificationsEnabled()">
<input type="checkbox" [(ngModel)]="notificationsEnabled" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">حالت تاریک</span>
<span class="text-xs text-[var(--text-muted)]">تغییر ظاهر برنامه به حالت تیره</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="isDarkMode()">
<input type="checkbox" [checked]="isDarkMode()" (change)="toggleDarkMode()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">حالت RTL</span>
<span class="text-xs text-[var(--text-muted)]"
>جهت متن راست‌به‌چپ (فارسی/عربی)</span
>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="isRTL()">
<input type="checkbox" [checked]="isRTL()" (change)="toggleRTL()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
</div>
</section>
}
</div>
</div>
</div>
+89
View File
@@ -0,0 +1,89 @@
import { ChangeDetectionStrategy, Component, signal, inject, computed, effect } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ThemeService } from '../../services/theme/theme.service';
type TabId = 'faq' | 'app';
@Component({
selector: 'app-settings',
standalone: true,
imports: [CommonModule, FormsModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './settings.page.html',
styleUrl: './settings.page.css',
})
export class SettingsPage {
private readonly themeService = inject(ThemeService);
readonly tabs: { id: TabId; label: string }[] = [
{ id: 'faq', label: 'آپلود FAQ' },
{ id: 'app', label: 'تنظیمات برنامه' },
];
readonly activeTab = signal<TabId>('faq');
readonly uploadedFiles = signal<File[]>([]);
readonly isDragging = signal(false);
readonly language = signal('fa');
readonly notificationsEnabled = signal(true);
readonly isDarkMode = this.themeService.isDarkMode;
readonly isRTL = signal(true);
selectTab(id: TabId): void {
this.activeTab.set(id);
}
onFileSelected(event: Event): void {
const input = event.target as HTMLInputElement;
const files = input.files ? Array.from(input.files) : [];
this.uploadedFiles.set(files);
}
onDragOver(event: DragEvent): void {
event.preventDefault();
this.isDragging.set(true);
}
onDragLeave(): void {
this.isDragging.set(false);
}
onDrop(event: DragEvent): void {
event.preventDefault();
this.isDragging.set(false);
const files = event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : [];
this.uploadedFiles.set(files);
}
removeFile(index: number): void {
this.uploadedFiles.update((files) => files.filter((_, i) => i !== index));
}
clearAllFiles(): void {
this.uploadedFiles.set([]);
}
formatFileSize(bytes: number): string {
if (bytes === 0) return '0 بایت';
const k = 1024;
const sizes = ['بایت', 'کیلوبایت', 'مگابایت', 'گیگابایت'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
toggleDarkMode(): void {
this.themeService.toggleDarkMode();
}
toggleRTL(): void {
this.isRTL.update(val => !val);
document.documentElement.dir = this.isRTL() ? 'rtl' : 'ltr';
document.body.style.direction = this.isRTL() ? 'rtl' : 'ltr';
}
get fileCount(): number {
return this.uploadedFiles().length;
}
}
+17
View File
@@ -0,0 +1,17 @@
import { TestBed } from '@angular/core/testing';
import { CanActivateFn } from '@angular/router';
import { authGuard } from './auth.guard';
describe('authGuard', () => {
const executeGuard: CanActivateFn = (...guardParameters) =>
TestBed.runInInjectionContext(() => authGuard(...guardParameters));
beforeEach(() => {
TestBed.configureTestingModule({});
});
it('should be created', () => {
expect(executeGuard).toBeTruthy();
});
});
+15
View File
@@ -0,0 +1,15 @@
import { CanActivateFn, Router } from '@angular/router';
import { inject } from '@angular/core';
import { AuthService } from './auth.service';
export const authGuard: CanActivateFn = () => {
const authService = inject(AuthService);
const router = inject(Router);
if (authService.isAuthenticated()) {
return true;
}
router.navigate(['/login']);
return false;
};
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+65
View File
@@ -0,0 +1,65 @@
import { Injectable } from '@angular/core';
import { Observable, BehaviorSubject, forkJoin, of } from 'rxjs';
import { tap, map, switchMap, catchError } from 'rxjs/operators';
import { HttpService } from '../http-request/http.service';
interface ApiResult<T> {
hasError: boolean;
messages: string[];
result: T;
}
interface LoginResponse {
auth: boolean;
token: string;
username: string;
}
interface LoginResult extends ApiResult<LoginResponse> {
licenseValid?: boolean;
}
@Injectable({
providedIn: 'root',
})
export class AuthService {
public currentUserSubject = new BehaviorSubject<string | null>(
localStorage.getItem('username'),
);
constructor(
private httpService: HttpService,
) {
let previousUser: string | null = this.currentUserSubject.value;
this.currentUserSubject.subscribe((username) => {
if (username !== previousUser) {
previousUser = username;
}
});
}
login(credentials: {
username: string;
password: string;
rememberMe: boolean;
}): Observable<LoginResult> {
return this.httpService.post<LoginResponse>('users/login', credentials).pipe(
tap((response: ApiResult<LoginResponse>) => {
if (!response.hasError && response.result?.auth) {
localStorage.setItem('access_token', response.result.token);
localStorage.setItem('username', response.result.username);
this.currentUserSubject.next(response.result.username);
}
}),
);
}
logout(): void {
localStorage.removeItem('access_token');
localStorage.removeItem('username');
this.currentUserSubject.next(null);
}
isAuthenticated(): boolean {
return !!localStorage.getItem('access_token');
}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { HttpService } from './http.service';
describe('HttpService', () => {
let service: HttpService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(HttpService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,304 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { Router } from '@angular/router';
import { catchError, Observable, throwError, map } from 'rxjs';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
export interface ApiResult<T> {
hasError: boolean;
messages: string[];
result: T;
}
export interface ApiResultArray<T> {
hasError: boolean;
messages: string[];
result: {
data: T[];
};
}
export interface HttpOptions {
params?: any;
skipToast?: boolean;
cooldownMs?: number;
skipHasErrorCheck?: boolean;
headers?: Record<string, string>;
}
export const EVENT_STREAM_HEADERS = {
Accept: 'text/event-stream',
'Cache-Control': 'no-cache',
'X-Requested-With': 'XMLHttpRequest',
};
@Injectable({
providedIn: 'root',
})
export class HttpService {
private readonly baseUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly backendUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly apiUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly imagesUrl = `${window.location.protocol}//${window.location.hostname}`;
constructor(
private readonly http: HttpClient,
private readonly router: Router,
private readonly toast: ToastrService,
private readonly modal: NgbModal,
) {
this.messageCooldowns = new Map();
this.DEFAULT_COOLDOWN_MS = 30000;
}
private readonly messageCooldowns: Map<string, number>;
private readonly DEFAULT_COOLDOWN_MS: number;
private getToken(): string | null {
return localStorage.getItem('access_token');
}
private getHeaders(): HttpHeaders {
const token = this.getToken();
let headers = new HttpHeaders();
if (token) {
headers = headers.set('Authorization', `Bearer ${token}`);
}
return headers;
}
private shouldDisplayMessage(message: string, customCooldown?: number): boolean {
const cooldown = customCooldown ?? this.DEFAULT_COOLDOWN_MS;
const now = Date.now();
const lastShown = this.messageCooldowns.get(message);
if (lastShown !== undefined && now - lastShown < cooldown) {
return false;
}
this.messageCooldowns.set(message, now);
return true;
}
private handleUnauthorized(): void {
this.toast.clear();
localStorage.removeItem('access_token');
this.modal.dismissAll();
this.toast.error('جلسه منقضی شده است. لطفاً دوباره وارد شوید.');
this.router.navigate(['/login']);
}
private handleError(error: HttpErrorResponse, skipToast = false): Observable<never> {
if (error.status === 401) {
this.handleUnauthorized();
return throwError(() => new Error('Unauthorized'));
}
if (error.status === 422 && error.error && !skipToast) {
try {
const apiError = error.error as ApiResult<any>;
if (apiError?.hasError && Array.isArray(apiError.messages)) {
apiError.messages.forEach((msg) => {
if (this.shouldDisplayMessage(msg)) {
this.toast.error(msg);
}
});
return throwError(() => new Error(apiError.messages.join('; ')));
}
} catch (e) {
if (this.shouldDisplayMessage('خطای نامشخص در پردازش پاسخ سرور.')) {
this.toast.error('خطای نامشخص در پردازش پاسخ سرور.');
}
return throwError(() => new Error('Invalid server response'));
}
}
return throwError(() => error);
}
private processResponse<T>(response: ApiResult<T>, options?: HttpOptions): ApiResult<T> {
if (!response || !Array.isArray(response.messages)) {
if (
!options?.skipToast &&
this.shouldDisplayMessage('پاسخ سرور نامعتبر است.', options?.cooldownMs)
) {
this.toast.error('پاسخ سرور نامعتبر است.');
}
throw new Error('Invalid server response');
}
if (!options?.skipToast) {
response.messages.forEach((message) => {
if (!this.shouldDisplayMessage(message, options?.cooldownMs)) {
return;
}
response.hasError ? this.toast.error(message) : this.toast.success(message);
});
}
if (response.hasError && !options?.skipHasErrorCheck) {
throw new Error(response.messages.join('; '));
}
return response;
}
get<T>(endpoint: string, options: HttpOptions = {}): Observable<ApiResult<T>> {
const url = `${this.baseUrl}/${endpoint}`;
const headers = this.mergeHeaders(options.headers);
return this.http
.get<ApiResult<T>>(url, {
headers,
params: options.params,
})
.pipe(
map((response) => this.processResponse(response, options)),
catchError((err) => this.handleError(err, options.skipToast)),
);
}
private getAuthHeaderObject(): Record<string, string> {
const token = this.getToken();
return token ? { Authorization: `Bearer ${token}` } : {};
}
private mergeHeaders(extra?: Record<string, string>): HttpHeaders {
let headers = this.getHeaders();
if (extra) {
Object.entries(extra).forEach(([key, value]) => {
headers = headers.set(key, value as string);
});
}
return headers;
}
getStream<T = any>(endpoint: string, headers: Record<string, string> = {}): Observable<T> {
const url = `${this.baseUrl}/${endpoint}`;
return new Observable<T>((observer) => {
const controller = new AbortController();
fetch(url, {
method: 'GET',
headers: {
...EVENT_STREAM_HEADERS,
...this.getAuthHeaderObject(),
...headers,
},
signal: controller.signal,
credentials: 'omit',
})
.then((response) => {
if (!response.ok || !response.body) {
throw new Error(`Stream request failed: ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
const pump = (): void => {
reader
.read()
.then(({ done, value }) => {
if (done) {
observer.complete();
return;
}
buffer += decoder.decode(value, { stream: true });
const frames = buffer.split('\n\n');
buffer = frames.pop() ?? '';
for (const frame of frames) {
const dataLines = frame
.split('\n')
.filter((line) => line.startsWith('data:'))
.map((line) => line.slice(5).trim());
if (dataLines.length === 0) continue;
const payload = dataLines.join('\n');
try {
observer.next(JSON.parse(payload) as T);
} catch {
observer.next(payload as unknown as T);
}
}
pump();
})
.catch((err) => {
if (!controller.signal.aborted) observer.error(err);
});
};
pump();
})
.catch((err) => observer.error(err));
return () => controller.abort();
});
}
post<T>(endpoint: string, data: any, options: HttpOptions = {}): Observable<ApiResult<T>> {
const url = `${this.baseUrl}/${endpoint}`;
return this.http
.post<ApiResult<T>>(url, data, {
headers: this.mergeHeaders(options.headers),
params: options.params,
})
.pipe(
map((response) => this.processResponse(response, options)),
catchError((err) => this.handleError(err, options.skipToast)),
);
}
put<T>(endpoint: string, data: any, options: HttpOptions = {}): Observable<ApiResult<T>> {
const url = `${this.baseUrl}/${endpoint}`;
return this.http
.put<ApiResult<T>>(url, data, {
headers: this.mergeHeaders(options.headers),
params: options.params,
})
.pipe(
map((response) => this.processResponse(response, options)),
catchError((err) => this.handleError(err, options.skipToast)),
);
}
patch<T>(endpoint: string, data: any, options: HttpOptions = {}): Observable<ApiResult<T>> {
const url = `${this.baseUrl}/${endpoint}`;
return this.http
.patch<ApiResult<T>>(url, data, {
headers: this.mergeHeaders(options.headers),
params: options.params,
})
.pipe(
map((response) => this.processResponse(response, options)),
catchError((err) => this.handleError(err, options.skipToast)),
);
}
delete<T>(endpoint: string, options: HttpOptions = {}): Observable<ApiResult<T>> {
const url = `${this.baseUrl}/${endpoint}`;
return this.http
.delete<ApiResult<T>>(url, {
headers: this.mergeHeaders(options.headers),
params: options.params,
})
.pipe(
map((response) => this.processResponse(response, options)),
catchError((err) => this.handleError(err, options.skipToast)),
);
}
downloadFile(endpoint: string): Observable<Blob> {
const url = `${this.baseUrl}/${endpoint}`;
return this.http
.get(url, {
headers: this.getHeaders(),
responseType: 'blob',
})
.pipe(catchError((err) => this.handleError(err, false)));
}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ThemeService } from './theme.service';
describe('ThemeService', () => {
let service: ThemeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ThemeService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+61
View File
@@ -0,0 +1,61 @@
import { Injectable } from '@angular/core';
import { signal } from '@angular/core';
import { HttpService } from '../http-request/http.service';
@Injectable({
providedIn: 'root'
})
export class ThemeService {
private readonly _isDarkMode = signal<boolean>(false);
readonly isDarkMode = this._isDarkMode.asReadonly();
constructor(private httpService: HttpService) {
this.initTheme();
}
initTheme(): void {
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
this.applyTheme(savedTheme);
} else {
this.applyTheme('light');
}
this.httpService.get('users/get-dark-mode').subscribe({
next: (res: any) => {
const isBackendDark = res.result.dark_mode;
const trueTheme = isBackendDark ? 'dark' : 'light';
if (savedTheme !== trueTheme) {
this.applyTheme(trueTheme);
localStorage.setItem('theme', trueTheme);
}
},
error: () => {}
});
}
toggleDarkMode(): void {
const isDark = !this._isDarkMode();
const theme = isDark ? 'dark' : 'light';
const payload = { dark_mode: isDark };
this.httpService.post('users/update-dark-mode', payload).subscribe({
next: () => {},
error: () => {}
});
this.applyTheme(theme);
localStorage.setItem('theme', theme);
}
private applyTheme(theme: string): void {
document.documentElement.setAttribute('data-bs-theme', theme);
this._isDarkMode.set(theme === 'dark');
}
get isDarkModeSync(): boolean {
return this._isDarkMode();
}
}
@@ -0,0 +1,519 @@
.sidebar {
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: 260px;
background: var(--sidebar-bg);
color: var(--sidebar-text);
transform: translateX(0);
transition: width 0.3s ease;
z-index: 40;
display: flex;
flex-direction: column;
border-left: 1px solid var(--sidebar-border);
}
.sidebar.open {
width: 260px;
}
.sidebar:not(.open) {
width: 72px;
padding-bottom: 0.5rem;
}
.sidebar-inner {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
}
.sidebar-top {
padding: 0.75rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5rem;
min-height: 48px;
position: relative;
overflow: hidden;
}
.sidebar-logo {
height: 32px;
width: auto;
object-fit: contain;
}
.sidebar-logo-link {
display: inline-flex;
align-items: center;
cursor: pointer;
position: relative;
overflow: hidden;
}
.sidebar-logo-link:hover .sidebar-logo {
opacity: 0.85;
}
.sidebar:not(.open) .sidebar-logo-link {
justify-content: center;
width: 100%;
}
.sidebar:not(.open) .sidebar-logo {
height: 36px;
}
.sidebar:not(.open) .sidebar-header {
justify-content: center;
padding: 0.5rem 0.25rem;
}
.sidebar:not(.open) .close-btn {
display: none;
}
.sidebar-open-icon {
position: absolute;
inset: 0;
margin: auto;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 0.5rem;
background: var(--surface-bg);
color: var(--sidebar-text);
border: 1px solid var(--sidebar-border);
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
opacity: 0;
visibility: hidden;
transition: opacity 0.2s, visibility 0.2s;
}
.sidebar:not(.open) .sidebar-logo-link:hover .sidebar-logo {
opacity: 0;
visibility: hidden;
}
.sidebar:not(.open) .sidebar-logo-link:hover .sidebar-open-icon {
opacity: 1;
visibility: visible;
}
.sidebar-title {
font-size: 1rem;
font-weight: 600;
margin: 0;
color: var(--sidebar-text);
}
.close-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: none;
background: transparent;
color: var(--sidebar-muted);
border-radius: 0.375rem;
cursor: pointer;
transition: background 0.2s;
flex-shrink: 0;
}
.close-btn:hover {
background: var(--sidebar-hover);
}
.sidebar:not(.open) .close-btn {
display: none;
}
.new-chat-btn {
display: flex;
align-items: center;
gap: 0.75rem;
width: 100%;
padding: 0.75rem;
border: 1px solid var(--sidebar-border);
background: transparent;
color: var(--sidebar-text);
border-radius: 0.5rem;
cursor: pointer;
font-size: 0.875rem;
transition: background 0.2s;
text-align: start;
}
.new-chat-btn:hover {
background: var(--sidebar-hover);
}
.nav-menu {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.nav-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
border-radius: 0.5rem;
color: var(--sidebar-muted);
text-decoration: none;
font-size: 0.875rem;
transition: background 0.2s;
}
.nav-item:hover {
background: var(--sidebar-hover);
}
.nav-item.active {
background: var(--sidebar-hover);
color: var(--sidebar-text);
font-weight: 500;
}
.sidebar:not(.open) .nav-item {
justify-content: center;
padding: 0.75rem 0;
}
.sidebar:not(.open) .nav-item svg {
margin: 0;
}
.sidebar:not(.open) .nav-label {
display: none;
}
.sidebar-divider {
height: 1px;
background: var(--sidebar-border);
margin: 0 0.75rem;
}
.sidebar:not(.open) .sidebar-divider {
margin: 0 0.5rem;
}
.sidebar-bottom {
flex: 1;
overflow-y: auto;
padding: 0.75rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.sidebar:not(.open) .sidebar-bottom {
display: none;
}
.history-header {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-weight: 500;
color: var(--sidebar-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.sidebar:not(.open) .history-header {
display: none;
}
.history-list {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.history-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
border: none;
background: transparent;
color: var(--sidebar-muted);
border-radius: 0.5rem;
cursor: pointer;
font-size: 0.875rem;
text-align: start;
transition: background 0.2s;
width: 100%;
}
.history-item:hover {
background: var(--sidebar-hover);
}
.sidebar:not(.open) .history-item {
justify-content: center;
padding: 0.75rem 0;
}
.sidebar:not(.open) .history-item svg {
margin: 0;
}
.history-icon {
flex-shrink: 0;
opacity: 0.7;
}
.history-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.sidebar:not(.open) .history-text {
display: none;
}
.history-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 1.5rem 0.75rem;
font-size: 0.875rem;
color: var(--sidebar-muted);
text-align: center;
}
.sidebar:not(.open) .history-empty {
display: none;
}
.history-empty-icon {
opacity: 0.5;
margin-bottom: 0.25rem;
}
.sidebar-footer {
padding: 0.75rem;
border-top: 1px solid var(--sidebar-border);
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-top: auto;
}
.sidebar:not(.open) .sidebar-footer {
align-items: center;
padding: 0.5rem;
margin-top: auto;
}
.sidebar:not(.open) .user-info {
display: none;
}
.sidebar:not(.open) .user-profile {
width: 56px;
height: 56px;
padding: 0;
border-radius: 50%;
justify-content: center;
}
.sidebar:not(.open) .theme-toggle span {
display: none;
}
.user-profile {
display: flex;
align-items: center;
gap: 0.75rem;
width: 100%;
padding: 0.5rem;
border: none;
border-radius: 0.75rem;
background: transparent;
color: var(--sidebar-text);
text-align: start;
cursor: pointer;
}
.user-profile:hover,
.user-profile.menu-open {
background: var(--sidebar-hover);
}
.user-profile:focus-visible,
.account-menu-item:focus-visible {
outline: 2px solid var(--sidebar-muted);
outline-offset: -2px;
}
.account-menu {
width: 236px;
max-width: calc(100vw - 24px);
padding: 0.5rem;
border: 1px solid var(--sidebar-border);
border-radius: 1.25rem;
background: var(--surface-bg);
color: var(--sidebar-text);
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}
.account-menu-header {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem;
}
.account-menu-divider {
height: 1px;
margin: 0.375rem 0.5rem;
background: var(--sidebar-border);
}
.account-menu-item {
display: flex;
align-items: center;
gap: 0.75rem;
width: 100%;
padding: 0.625rem 0.75rem;
border: none;
border-radius: 0.5rem;
background: transparent;
color: inherit;
font-size: 0.875rem;
text-align: start;
cursor: pointer;
}
.account-menu-item:hover,
.account-menu-item:focus {
background: var(--sidebar-hover);
}
.account-menu-item svg {
flex-shrink: 0;
}
.user-avatar {
width: 32px;
height: 32px;
border-radius: 50%;
background: var(--sidebar-hover);
color: var(--sidebar-text);
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 500;
flex-shrink: 0;
}
.user-info {
display: flex;
flex-direction: column;
gap: 0.125rem;
overflow: hidden;
}
.user-name {
font-size: 0.875rem;
font-weight: 500;
color: var(--sidebar-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.claim-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
width: 100%;
padding: 0.625rem;
border: 1px solid var(--sidebar-border);
background: transparent;
color: var(--sidebar-text);
border-radius: 0.5rem;
cursor: pointer;
font-size: 0.875rem;
transition: background 0.2s;
}
.claim-btn:hover {
background: var(--sidebar-hover);
}
.sidebar:not(.open) .claim-btn {
width: 40px;
height: 40px;
padding: 0;
border-radius: 0.5rem;
justify-content: center;
}
.sidebar:not(.open) .claim-btn svg {
margin: 0;
}
.sidebar:not(.open) .claim-btn span {
display: none;
}
.theme-toggle {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
width: 100%;
padding: 0.625rem;
border: 1px solid var(--sidebar-border);
background: transparent;
color: var(--sidebar-text);
border-radius: 0.5rem;
cursor: pointer;
font-size: 0.875rem;
transition: background 0.2s;
}
.theme-toggle:hover {
background: var(--sidebar-hover);
}
.sidebar:not(.open) .theme-toggle {
width: 56px;
height: 56px;
padding: 0;
border-radius: 0.5rem;
justify-content: center;
}
.sidebar:not(.open) .theme-toggle svg {
margin: 0;
}
.sidebar:not(.open) .theme-toggle span {
display: none;
}
@@ -0,0 +1,189 @@
<aside class="sidebar" [class.open]="isOpen()">
<div class="sidebar-inner">
<div class="sidebar-top">
<div class="sidebar-header">
<a
class="sidebar-logo-link"
[routerLink]="isOpen() ? '/' : null"
(click)="onLogoClick()"
>
<img class="sidebar-logo" [src]="isDarkMode() ? 'assets/images/RaymandLogo.png' : 'assets/images/login.png'" alt="Raymand" />
<span class="sidebar-open-icon" aria-hidden="true">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</span>
</a>
<button type="button" class="close-btn" (click)="close.emit()" aria-label="Close sidebar">
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path d="M18 6L6 18M6 6l12 12" />
</svg>
</button>
</div>
<nav class="nav-menu">
@for (item of navItems(); track item.label) {
<a
[routerLink]="item.route"
class="nav-item"
routerLinkActive="active"
(click)="onNavClick()"
>
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path [attr.d]="item.icon" />
</svg>
<span class="nav-label">{{ item.label }}</span>
</a>
}
</nav>
</div>
<div class="sidebar-divider"></div>
<div class="sidebar-bottom">
<div class="history-header">
<span class="history-title">گفتگوهای اخیر</span>
</div>
<div class="history-list">
@for (item of chatHistory(); track item.id) {
<button type="button" class="history-item">
<svg
class="history-icon"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z" />
</svg>
<span class="history-text">{{ item.title }}</span>
</button>
} @empty {
<div class="history-empty">
<svg
width="32"
height="32"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
class="history-empty-icon"
>
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z" />
</svg>
<span>گفتگویی ثبت نشده است</span>
</div>
}
</div>
</div>
<div class="sidebar-footer">
<button
type="button"
class="user-profile"
[cdkMenuTriggerFor]="accountMenu"
[cdkMenuPosition]="[
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -8 },
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 8 }
]"
#accountMenuTrigger="cdkMenuTriggerFor"
[class.menu-open]="accountMenuTrigger.isOpen()"
aria-label="Open account menu"
>
<div class="user-avatar">
{{ userInitials() }}
</div>
<div class="user-info">
<span class="user-name">{{ userName() }}</span>
</div>
</button>
<ng-template #accountMenu>
<div class="account-menu" cdkMenu aria-label="Account menu" dir="ltr">
<div class="account-menu-header">
<div class="user-avatar">{{ userInitials() }}</div>
<div class="user-info">
<span class="user-name">{{ userName() }}</span>
</div>
</div>
<div class="account-menu-divider" role="separator"></div>
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="profileClick.emit()">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<circle cx="12" cy="9" r="3" />
<path d="M6 18a6 6 0 0 1 12 0" />
</svg>
<span>Profile</span>
</button>
<div class="account-menu-divider" role="separator"></div>
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="logoutClick.emit()">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
</svg>
<span>Log out</span>
</button>
</div>
</ng-template>
<button
type="button"
class="theme-toggle"
(click)="toggleTheme()"
aria-label="Toggle dark mode"
>
@if (isDarkMode()) {
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="5" />
<line x1="12" y1="1" x2="12" y2="3" />
<line x1="12" y1="21" x2="12" y2="23" />
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
<line x1="1" y1="12" x2="3" y2="12" />
<line x1="21" y1="12" x2="23" y2="12" />
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
</svg>
<span>حالت روشن</span>
} @else {
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
</svg>
<span>حالت تاریک</span>
}
</button>
</div>
</div>
</aside>
@@ -0,0 +1,74 @@
import { ChangeDetectionStrategy, Component, input, output, computed, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CdkMenuModule } from '@angular/cdk/menu';
import { RouterModule } from '@angular/router';
import { ThemeService } from '../../../services/theme/theme.service';
export interface NavItem {
icon: string;
label: string;
route?: string;
}
export interface ChatHistoryItem {
id: string;
title: string;
}
@Component({
selector: 'app-sidebar',
standalone: true,
imports: [CommonModule, RouterModule, CdkMenuModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './sidebar.component.html',
styleUrl: './sidebar.component.css'
})
export class SidebarComponent {
private readonly themeService = inject(ThemeService);
readonly isOpen = input<boolean>(false);
readonly userName = input<string>('Peyman Honarjoo');
readonly navItems = input<NavItem[]>([
{
icon: 'M12 5v14M5 12h14',
label: 'چت جدید',
},
{
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
label: 'تنظیمات',
route: '/settings',
},
]);
readonly chatHistory = input<ChatHistoryItem[]>([]);
readonly close = output<void>();
readonly navClick = output<void>();
readonly open = output<void>();
readonly profileClick = output<void>();
readonly logoutClick = output<void>();
readonly userInitials = computed(() => {
const name = this.userName();
return name
.split(' ')
.map((n) => n[0])
.join('')
.slice(0, 2)
.toUpperCase();
});
readonly isDarkMode = this.themeService.isDarkMode;
toggleTheme(): void {
this.themeService.toggleDarkMode();
}
onNavClick(): void {
this.navClick.emit();
}
onLogoClick(): void {
if (!this.isOpen()) {
this.open.emit();
}
}
}
+82 -1
View File
@@ -1 +1,82 @@
/* You can add global styles to this file, and also import other style files */
@import "tailwindcss";
@import "@angular/cdk/overlay-prebuilt.css";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--color-success: #22c55e;
--color-warning: #f59e0b;
--color-danger: #ef4444;
--color-info: #06b6d4;
--color-card-bg: #ffffff;
--color-card-border: #e2e8f0;
--color-text-primary: #122033;
--color-text-secondary: #374151;
--color-text-muted: #64748b;
--color-input-bg: #ffffff;
--color-input-border: #d1d5db;
--color-dropzone-bg: #f8fafc;
--color-dropzone-border: #e2e8f0;
}
:root {
--app-bg: #f8fafc;
--app-text: #122033;
--sidebar-bg: #f8fafc;
--sidebar-text: #122033;
--sidebar-muted: #64748b;
--sidebar-border: #e2e8f0;
--sidebar-hover: #f1f5f9;
--surface-bg: #ffffff;
--surface-border: #e2e8f0;
--muted: #64748b;
--overlay: rgba(0, 0, 0, 0.5);
--menu-toggle-color: #122033;
--menu-toggle-hover: #f1f5f9;
--main-content-bg: #f8fafc;
--toggle-bg: #e5e7eb;
--toggle-slider: #ffffff;
}
[data-bs-theme="dark"] {
--app-bg: #212121;
--app-text: #ececec;
--sidebar-bg: #171717;
--sidebar-text: #ececec;
--sidebar-muted: #8e8e8e;
--sidebar-border: #2e2e2e;
--sidebar-hover: #2e2e2e;
--surface-bg: #171717;
--surface-border: #2e2e2e;
--muted: #8e8e8e;
--overlay: rgba(0, 0, 0, 0.6);
--menu-toggle-color: #ececec;
--menu-toggle-hover: #2e2e2e;
--main-content-bg: #212121;
--toggle-bg: #3e3e3e;
--toggle-slider: #f8fafc;
--color-card-bg: #171717;
--color-card-border: #2e2e2e;
--color-text-primary: #f8fafc;
--color-text-secondary: #cbd5e1;
--color-text-muted: #8e8e8e;
--color-input-bg: #171717;
--color-input-border: #3e3e3e;
--color-dropzone-bg: rgba(23, 23, 23, 0.6);
--color-dropzone-border: #3e3e3e;
}
* {
font-family: "Vazir", sans-serif;
}
body {
direction: rtl;
font-family: "Vazir", sans-serif;
text-align: right;
background: var(--app-bg);
color: var(--app-text);
margin: 0;
padding: 0;
}