23 Commits

Author SHA1 Message Date
fa47188898 feat: add ReutilizablesTestPageComponent to showcase and validate shared button and input component variants 2026-06-26 16:58:14 -03:00
e074aeb199 feat: implement tenant branding injection and SSR bootstrap logic with comprehensive testing 2026-06-26 16:25:31 -03:00
86680fc976 feat: refactor routing and enhance tenant service integration
- Updated app routing to redirect to the store feature and load children routes correctly.
- Enhanced app styles with tenant-specific branding and loading states.
- Improved app component to dynamically set CSS variables based on tenant colors.
- Refactored store layout components to simplify logo handling and improve accessibility.
- Updated tenant service to manage state more effectively and handle SSR scenarios.
- Added tests for tenant service and layout components to ensure proper functionality.
- Introduced a new SSR cache store for tenant state management.
- Enhanced button styles to utilize tenant colors for better branding consistency.
2026-06-26 15:55:45 -03:00
7ee103b77b feat: enhance store layout with dynamic logo handling and loading states 2026-06-26 14:27:14 -03:00
4e2dccd2e3 feat: implement useMutation hook for managing asynchronous operations with loading and error states 2026-06-26 14:19:10 -03:00
da01745732 feat: implement store layout with header and footer components, update tenant service URL 2026-06-26 14:02:35 -03:00
ac9ba12045 feat: implement tenant service with bootstrap functionality and error handling 2026-06-26 13:43:39 -03:00
23e8da345a feat: implement store layout and home page components with routing 2026-06-26 13:42:23 -03:00
236a3772a4 feat: standardize font size and weight for input component and labels 2026-06-26 10:35:12 -03:00
bccb1b565f feat: refactor input component to use model binding for value management 2026-06-26 10:22:25 -03:00
0d46172325 feat: enhance input component layout with labels and improve styling 2026-06-26 10:18:43 -03:00
f1a4f51695 feat: add user input type with icon support in input component 2026-06-26 10:09:06 -03:00
d58445e199 feat: implement password toggle functionality in input component 2026-06-26 10:06:41 -03:00
455b7c8506 feat: add search input type with icon support and update styles 2026-06-26 09:56:09 -03:00
a0c35c76a7 style: add min-width to button styles for improved layout consistency 2026-06-26 09:15:18 -03:00
6086070891 style: enhance button showcase layout and add disabled state examples 2026-06-26 08:57:15 -03:00
3c163e672b feat: add Gotham font files and integrate into styles 2026-06-26 08:52:40 -03:00
def3a04548 style: refactor button styles and theme variables for improved consistency 2026-06-26 08:43:04 -03:00
a6a9f4e5e3 style: reorganize and enhance button styles with additional variables 2026-06-25 17:02:05 -03:00
5e25c00240 style: add root font family variable for consistent typography 2026-06-25 16:27:11 -03:00
6b4fccbdbb feat: add input component and integrate FontAwesome icons 2026-06-24 09:57:24 -03:00
e608b31b93 fix: update button component styles for consistent height 2026-06-24 09:43:56 -03:00
d108cf1ee2 feat: add routing for componentes-test and create reusable button component
- Implemented lazy loading for the componentes-test feature module.
- Created a redirect route to componentes-test as the default path.
- Added a new ReutilizablesTestPageComponent to showcase reusable components.
- Developed a reusable ButtonComponent with various styles and states.
- Updated global styles to include Bootstrap.
- Added SCSS styles for the new components and pages.
2026-06-24 09:31:37 -03:00
64 changed files with 3050 additions and 363 deletions

10
package-lock.json generated
View File

@@ -16,6 +16,7 @@
"@angular/platform-server": "^22.0.0",
"@angular/router": "^22.0.0",
"@angular/ssr": "^22.0.4",
"@fortawesome/fontawesome-free": "^7.2.0",
"bootstrap": "^5.3.8",
"express": "^5.1.0",
"rxjs": "~7.8.0",
@@ -1616,6 +1617,15 @@
}
}
},
"node_modules/@fortawesome/fontawesome-free": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-7.2.0.tgz",
"integrity": "sha512-3DguDv/oUE+7vjMeTSOjCSG+KeawgVQOHrKRnvUuqYh1mfArrh7s+s8hXW3e4RerBA1+Wh+hBqf8sJNpqNrBWg==",
"license": "(CC-BY-4.0 AND OFL-1.1 AND MIT)",
"engines": {
"node": ">=6"
}
},
"node_modules/@gar/promise-retry": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@gar/promise-retry/-/promise-retry-1.0.3.tgz",

View File

@@ -20,6 +20,7 @@
"@angular/platform-server": "^22.0.0",
"@angular/router": "^22.0.0",
"@angular/ssr": "^22.0.4",
"@fortawesome/fontawesome-free": "^7.2.0",
"bootstrap": "^5.3.8",
"express": "^5.1.0",
"rxjs": "~7.8.0",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,188 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="refresh" content="5;url=https://fontsgeek.com/gotham-font?ref=readme">
<title>GothamFontsgeek</title>
<style>
/* -------------------------------------
GLOBAL
------------------------------------- */
* {
margin:0;
padding:0;
font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;
font-size: 100%;
line-height: 1.6;
}
img {
max-width: 100%;
}
body {
-webkit-font-smoothing:antialiased;
-webkit-text-size-adjust:none;
width: 100%!important;
height: 100%;
background:#DDD;
}
/* -------------------------------------
ELEMENTS
------------------------------------- */
a {
color: #348eda;
}
.btn-primary, .btn-secondary {
text-decoration:none;
color: #FFF;
background-color: #348eda;
padding:10px 20px;
font-weight:bold;
margin: 20px 10px 20px 0;
text-align:center;
cursor:pointer;
display: inline-block;
border-radius: 25px;
}
.btn-secondary{
background: #aaa;
}
.last {
margin-bottom: 0;
}
.first{
margin-top: 0;
}
/* -------------------------------------
BODY
------------------------------------- */
table.body-wrap {
width: 100%;
padding: 20px;
}
table.body-wrap .container{
border: 1px solid #f0f0f0;
}
/* -------------------------------------
FOOTER
------------------------------------- */
table.footer-wrap {
width: 100%;
clear:both!important;
}
.footer-wrap .container p {
font-size:12px;
color:#666;
}
table.footer-wrap a{
color: #999;
}
/* -------------------------------------
TYPOGRAPHY
------------------------------------- */
h1,h2,h3{
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; line-height: 1.1; margin-bottom:15px; color:#000;
margin: 40px 0 10px;
line-height: 1.2;
font-weight:200;
}
h1 {
font-size: 36px;
}
h2 {
font-size: 28px;
}
h3 {
font-size: 22px;
}
p, ul {
margin-bottom: 10px;
font-weight: normal;
font-size:14px;
}
ul li {
margin-left:5px;
list-style-position: inside;
}
/* ---------------------------------------------------
RESPONSIVENESS
Nuke it from orbit. It's the only way to be sure.
------------------------------------------------------ */
/* Set a max-width, and make it display as block so it will automatically stretch to that width, but will also shrink down on a phone or something */
.container {
display:block!important;
max-width:600px!important;
margin:0 auto!important; /* makes it centered */
clear:both!important;
}
/* This should also be a block element, so that it will fill 100% of the .container */
.content {
padding:20px;
max-width:600px;
margin:0 auto;
display:block;
}
/* Let's make sure tables in the content area are 100% wide */
.content table {
width: 100%;
}
</style>
</head>
<body bgcolor="#f6f6f6">
<!-- body -->
<table class="body-wrap">
<tr>
<td></td>
<td class="container" bgcolor="#FFFFFF">
<!-- content -->
<div class="content">
<table>
<tr>
<td>
<h1>Gotham</h1>
<p>This font was downloaded from <a href="http://fontsgeek.com?ref=readme">fontsgeek.com</a> . You can visit <a href="http://fontsgeek.com?ref=readme">fontsgeek.com</a> for thousands of free fonts.</p>
<p><a href="http://fontsgeek.com/gotham-font?ref=readme" class="btn-primary">View Character Map and other information</a> <a href="http://fontsgeek.com?ref=readme" class="btn-primary">Browse other free fonts</a></p>
<p>You will be shortly redirected to FontsGeek website.</p>
</td>
</tr>
</table>
</div>
<!-- /content -->
</td>
<td></td>
</tr>
</table>
<!-- /body -->
</body>
</html>

71
src/_fonts.scss Normal file
View File

@@ -0,0 +1,71 @@
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Thin.otf") format("opentype");
font-weight: 100;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Extra Light.otf") format("opentype");
font-weight: 200;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Light.otf") format("opentype");
font-weight: 300;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Book.otf") format("opentype");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Italic.otf") format("opentype");
font-weight: 400;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Medium.otf") format("opentype");
font-weight: 500 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Bold.otf") format("opentype");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Bold Italic.ttf") format("truetype");
font-weight: 700;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: "Gotham";
src: url("/fonts/Gotham/Gotham Black.otf") format("opentype");
font-weight: 900;
font-style: normal;
font-display: swap;
}

10
src/_theme.scss Normal file
View File

@@ -0,0 +1,10 @@
$primary:#6376F3;
$danger: #FF8888;
$secondary:#A0A0A0;
$primary-button-hover-shade-amount: 40%;
$primary-button-disabled-tint-amount: 50%;
$secondary-button-hover-active-shade-amount: 25.625%;
$secondary-button-disabled-alpha: 0.5;
$danger-button-hover-active-bg: #9D5252;
$danger-button-disabled-alpha: 0.5;

View File

@@ -1,12 +1,17 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { ApplicationConfig, provideAppInitializer, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideClientHydration } from '@angular/platform-browser';
import { routes } from './app.routes';
import { provideClientHydration } from '@angular/platform-browser';
import { tenantBootstrap } from './core/services/tenant-bootstrap';
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes), provideClientHydration()
provideRouter(routes),
provideClientHydration(),
provideHttpClient(withFetch()),
provideAppInitializer(tenantBootstrap)
]
};

View File

@@ -1,344 +1,17 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * 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;
display: block;
height: 100dvh;
}
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://x.com/angular"
aria-label="X"
target="_blank"
rel="noopener"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="X"
>
<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 * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
@if (status() === 'ready') {
<router-outlet />
} @else if (status() === 'not-found') {
<section class="tenant-status">
<div class="tenant-status__card">
<span class="tenant-status__code">404</span>
<h1 class="tenant-status__title">No encontramos una tienda para este dominio</h1>
<p class="tenant-status__description">
Verifica la configuracion del tenant o intenta nuevamente con un dominio valido.
</p>
</div>
</section>
} @else {
<section class="tenant-status tenant-status--loading" aria-hidden="true">
<div class="tenant-status__spinner"></div>
</section>
}

View File

@@ -3,6 +3,6 @@ import { RenderMode, ServerRoute } from '@angular/ssr';
export const serverRoutes: ServerRoute[] = [
{
path: '**',
renderMode: RenderMode.Prerender
renderMode: RenderMode.Server
}
];

100
src/app/app.routes.spec.ts Normal file
View File

@@ -0,0 +1,100 @@
import { signal } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideRouter, Router } from '@angular/router';
import { App } from './app';
import { routes } from './app.routes';
import { Tenant } from './core/services/tenant.interface';
import { TenantService } from './core/services/tenant.service';
const tenant: Tenant = {
id: 1,
codigo: 'test',
nombre: 'Test Tenant',
dominio: 'localhost',
primary_color: '#6376F3',
secondary_color: '#A0A0A0',
danger_color: '#FF8888',
header_footer_bg_color: '#313131',
header_logo: 'https://example.com/header.png',
footer_logo: 'https://example.com/footer.png'
};
function createTenantServiceStub(
status: 'ready' | 'not-found' = 'ready',
currentTenant: Tenant | null = tenant
) {
const tenantState = signal(currentTenant);
const statusState = signal(status);
return {
tenant: tenantState.asReadonly(),
status: statusState.asReadonly(),
getTenant: () => tenantState(),
bootstrap: vi.fn().mockResolvedValue(undefined)
};
}
async function renderAppAt(
url: string,
tenantService: ReturnType<typeof createTenantServiceStub> = createTenantServiceStub()
) {
TestBed.resetTestingModule();
await TestBed.configureTestingModule({
imports: [App],
providers: [
provideRouter(routes),
{
provide: TenantService,
useValue: tenantService
}
]
}).compileComponents();
const router = TestBed.inject(Router);
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
await router.navigateByUrl(url);
await fixture.whenStable();
fixture.detectChanges();
return { fixture, router };
}
describe('app routes', () => {
it('loads the store layout at /', async () => {
const { fixture, router } = await renderAppAt('/');
const compiled = fixture.nativeElement as HTMLElement;
expect(router.url).toBe('/');
expect(compiled.querySelector('.store-layout')).not.toBeNull();
expect(compiled.querySelector('.store-home')).not.toBeNull();
expect(compiled.textContent).toContain('Tienda en construccion');
expect(compiled.style.getPropertyValue('--tenant-primary')).toBe(tenant.primary_color);
});
it('loads componentes-test under a valid tenant', async () => {
const { fixture, router } = await renderAppAt('/');
await router.navigateByUrl('/componentes-test/reutilizables');
await fixture.whenStable();
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(router.url).toBe('/componentes-test/reutilizables');
expect(compiled.textContent).toContain('Componentes reutilizables');
});
it('renders the tenant not found screen for any route when the tenant is missing', async () => {
const { fixture } = await renderAppAt(
'/componentes-test/reutilizables',
createTenantServiceStub('not-found', null)
);
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.tenant-status')).not.toBeNull();
expect(compiled.textContent).toContain('No encontramos una tienda para este dominio');
});
});

View File

@@ -1,3 +1,18 @@
import { Routes } from '@angular/router';
export const routes: Routes = [];
export const routes: Routes = [
{
path: 'componentes-test',
loadChildren: () =>
import('./features/componentes-test/componentes-test.routes').then((m) => m.routes)
},
{
path: 'store',
pathMatch: 'full',
redirectTo: ''
},
{
path: '',
loadChildren: () => import('./features/store/store.routes').then((m) => m.routes)
}
];

View File

@@ -0,0 +1,68 @@
:host {
display: block;
min-height: 100dvh;
}
.tenant-status {
min-height: 100dvh;
display: grid;
place-items: center;
padding: 2rem;
background:
radial-gradient(circle at top, color-mix(in srgb, white 82%, var(--tenant-primary)) 0%, transparent 55%),
linear-gradient(180deg, #f8f8f8 0%, #efefef 100%);
color: #202020;
}
.tenant-status__card {
width: min(100%, 34rem);
padding: 2rem;
border: 1px solid rgba(32, 32, 32, 0.1);
border-radius: 1.5rem;
background-color: rgba(255, 255, 255, 0.92);
box-shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.1);
}
.tenant-status__code {
display: inline-block;
margin-bottom: 1rem;
font-size: 0.8rem;
font-weight: 700;
letter-spacing: 0.24em;
text-transform: uppercase;
color: var(--tenant-primary);
}
.tenant-status__title {
margin: 0 0 0.75rem;
font-size: clamp(2rem, 4vw, 2.75rem);
line-height: 1.05;
}
.tenant-status__description {
margin: 0;
font-size: 1rem;
line-height: 1.6;
color: rgba(32, 32, 32, 0.72);
}
.tenant-status--loading {
background:
radial-gradient(circle at center, color-mix(in srgb, white 88%, var(--tenant-primary)) 0%, transparent 60%),
#f5f5f5;
}
.tenant-status__spinner {
width: 3rem;
height: 3rem;
border: 0.25rem solid rgba(32, 32, 32, 0.08);
border-top-color: var(--tenant-primary);
border-radius: 999px;
animation: tenant-status-spin 0.8s linear infinite;
}
@keyframes tenant-status-spin {
to {
transform: rotate(360deg);
}
}

View File

@@ -1,23 +1,88 @@
import { signal } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { App } from './app';
import { Tenant } from './core/services/tenant.interface';
import { TenantService } from './core/services/tenant.service';
const tenant: Tenant = {
id: 1,
codigo: 'test',
nombre: 'Test Tenant',
dominio: 'localhost',
primary_color: '#6376F3',
secondary_color: '#A0A0A0',
danger_color: '#FF8888',
header_footer_bg_color: '#313131',
header_logo: 'https://example.com/header.png',
footer_logo: 'https://example.com/footer.png'
};
function createTenantServiceStub(status: 'ready' | 'not-found', currentTenant: Tenant | null) {
const tenantState = signal(currentTenant);
const statusState = signal(status);
return {
tenant: tenantState.asReadonly(),
status: statusState.asReadonly(),
getTenant: () => tenantState(),
bootstrap: vi.fn().mockResolvedValue(undefined)
};
}
describe('App', () => {
beforeEach(async () => {
it('creates the app when the tenant is ready', async () => {
await TestBed.configureTestingModule({
imports: [App],
providers: [
provideRouter([]),
{
provide: TenantService,
useValue: createTenantServiceStub('ready', tenant)
}
]
}).compileComponents();
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
expect(fixture.componentInstance).toBeTruthy();
expect(fixture.nativeElement.style.getPropertyValue('--tenant-primary')).toBe(
tenant.primary_color
);
expect(fixture.nativeElement.style.getPropertyValue('--tenant-secondary')).toBe(
tenant.secondary_color
);
expect(fixture.nativeElement.style.getPropertyValue('--tenant-danger')).toBe(
tenant.danger_color
);
expect(fixture.nativeElement.style.getPropertyValue('--tenant-primary-rgb')).toBe(
'99, 118, 243'
);
expect(fixture.nativeElement.style.getPropertyValue('--tenant-secondary-rgb')).toBe(
'160, 160, 160'
);
expect(fixture.nativeElement.style.getPropertyValue('--tenant-danger-rgb')).toBe(
'255, 136, 136'
);
});
it('should create the app', () => {
const fixture = TestBed.createComponent(App);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it('renders the tenant not found screen when the tenant is missing', async () => {
await TestBed.configureTestingModule({
imports: [App],
providers: [
provideRouter([]),
{
provide: TenantService,
useValue: createTenantServiceStub('not-found', null)
}
]
}).compileComponents();
it('should render title', async () => {
const fixture = TestBed.createComponent(App);
await fixture.whenStable();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, shopit-front');
fixture.detectChanges();
expect(fixture.nativeElement.textContent).toContain('No encontramos una tienda para este dominio');
});
});

View File

@@ -1,12 +1,66 @@
import { Component, signal } from '@angular/core';
import { Component, computed, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { TenantService } from './core/services/tenant.service';
import { DEFAULT_TENANT_BRANDING } from './core/services/tenant-ssr-cache.store';
function hexToRgb(hex: string): string {
const cleanHex = hex.replace('#', '').trim();
let r = 0, g = 0, b = 0;
if (cleanHex.length === 3) {
r = parseInt(cleanHex[0] + cleanHex[0], 16);
g = parseInt(cleanHex[1] + cleanHex[1], 16);
b = parseInt(cleanHex[2] + cleanHex[2], 16);
} else if (cleanHex.length >= 6) {
r = parseInt(cleanHex.slice(0, 2), 16);
g = parseInt(cleanHex.slice(2, 4), 16);
b = parseInt(cleanHex.slice(4, 6), 16);
}
return `${r}, ${g}, ${b}`;
}
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.html',
styleUrl: './app.scss'
styleUrl: './app.scss',
host: {
'[style.--tenant-primary]': 'tenantPrimaryColor()',
'[style.--tenant-secondary]': 'tenantSecondaryColor()',
'[style.--tenant-danger]': 'tenantDangerColor()',
'[style.--tenant-primary-rgb]': 'tenantPrimaryColorRgb()',
'[style.--tenant-secondary-rgb]': 'tenantSecondaryColorRgb()',
'[style.--tenant-danger-rgb]': 'tenantDangerColorRgb()',
'[style.--tenant-header-footer-bg]': 'tenantHeaderFooterBgColor()'
}
})
export class App {
protected readonly title = signal('shopit-front');
private readonly tenantService = inject(TenantService);
protected readonly status = this.tenantService.status;
protected readonly tenantPrimaryColor = computed(
() => this.tenantService.tenant()?.primary_color ?? DEFAULT_TENANT_BRANDING.primaryColor
);
protected readonly tenantSecondaryColor = computed(
() => this.tenantService.tenant()?.secondary_color ?? DEFAULT_TENANT_BRANDING.secondaryColor
);
protected readonly tenantDangerColor = computed(
() => this.tenantService.tenant()?.danger_color ?? DEFAULT_TENANT_BRANDING.dangerColor
);
protected readonly tenantPrimaryColorRgb = computed(() =>
hexToRgb(this.tenantPrimaryColor())
);
protected readonly tenantSecondaryColorRgb = computed(() =>
hexToRgb(this.tenantSecondaryColor())
);
protected readonly tenantDangerColorRgb = computed(() =>
hexToRgb(this.tenantDangerColor())
);
protected readonly tenantHeaderFooterBgColor = computed(
() =>
this.tenantService.tenant()?.header_footer_bg_color ??
DEFAULT_TENANT_BRANDING.headerFooterBgColor
);
}

View File

@@ -0,0 +1,57 @@
<footer class="store-layout__footer mt-auto text-light">
<div class="container-xl px-3 px-md-4 py-4 py-md-5">
<div class="row g-4">
<div class="col-12 col-md-6 col-xl-5 d-grid gap-3 align-content-start">
<div
class="store-layout__brand-slot d-inline-flex align-items-center gap-3"
data-testid="store-footer-brand-slot"
aria-label="Logo del comercio"
>
@if (logoUrl) {
<img class="store-layout__brand-logo" [src]="logoUrl" alt="Logo del comercio" />
} @else {
<div class="store-layout__brand-logo-shell" aria-hidden="true">
<span class="store-layout__brand-logo-skeleton"></span>
</div>
}
</div>
<div class="d-grid gap-2">
<div class="d-flex align-items-center gap-2 text-light-emphasis">
<i class="fa-solid fa-location-dot" aria-hidden="true"></i>
<span>Av. San Lorenzo 1542, Rosario</span>
</div>
<div class="d-flex align-items-center gap-2 text-light-emphasis">
<i class="fa-solid fa-phone" aria-hidden="true"></i>
<span>54 9 (0341) 6658247</span>
</div>
</div>
<p class="mb-0 small store-layout__muted-text">Copyright &copy; {{ currentYear }} - Sonder</p>
</div>
@for (section of footerSections; track section.heading) {
<div class="col-12 col-md-6 col-xl-2 d-grid gap-3 align-content-start">
<h2 class="store-layout__footer-heading">{{ section.heading }}</h2>
<div class="d-grid gap-2">
@for (link of section.links; track link) {
<span class="store-layout__muted-text">{{ link }}</span>
}
</div>
</div>
}
<div class="col-12 col-md-6 col-xl-3 d-grid gap-3 align-content-start">
<h2 class="store-layout__footer-heading">Seguinos:</h2>
<div class="d-flex align-items-center gap-3">
@for (social of socialLinks; track social.label) {
<span class="fs-5 text-white">
<i [class]="social.iconClass" aria-hidden="true"></i>
<span class="visually-hidden">{{ social.label }}</span>
</span>
}
</div>
</div>
</div>
</div>
</footer>

View File

@@ -0,0 +1,87 @@
.store-layout__footer {
background-color: var(--tenant-header-footer-bg);
}
.store-layout__brand-slot {
min-width: 10rem;
}
.store-layout__brand-logo-shell {
position: relative;
width: min(100%, 12rem);
height: 2.75rem;
}
.store-layout__brand-logo {
display: block;
width: 100%;
height: 100%;
max-height: 2.75rem;
object-fit: contain;
}
.store-layout__brand-logo-skeleton {
display: block;
width: 100%;
height: 100%;
border-radius: 0.75rem;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0.12) 0%,
rgba(255, 255, 255, 0.24) 50%,
rgba(255, 255, 255, 0.12) 100%
);
background-size: 200% 100%;
animation: store-footer-logo-skeleton 1.2s ease-in-out infinite;
}
.store-layout__brand-mark {
display: grid;
place-items: center;
width: 2.75rem;
height: 2.75rem;
border: 1px dashed rgba(255, 255, 255, 0.35);
border-radius: 999px;
font-size: 1.05rem;
font-weight: 700;
letter-spacing: 0.04em;
color: #ffffff;
}
.store-layout__brand-text {
font-size: 1.8rem;
font-weight: 700;
letter-spacing: -0.08em;
color: #ffffff;
}
.store-layout__footer-heading {
margin: 0;
font-size: 0.95rem;
font-weight: 500;
color: #f8f8f8;
}
.store-layout__muted-text {
color: rgba(255, 255, 255, 0.72);
}
@keyframes store-footer-logo-skeleton {
from {
background-position: 200% 0;
}
to {
background-position: -200% 0;
}
}
@media (max-width: 767.98px) {
.store-layout__brand-slot {
min-width: 0;
}
.store-layout__brand-text {
font-size: 1.45rem;
}
}

View File

@@ -0,0 +1,24 @@
import { Component, Input } from '@angular/core';
export type StoreFooterSection = {
heading: string;
links: string[];
};
export type StoreSocialLink = {
label: string;
iconClass: string;
};
@Component({
selector: 'app-store-footer',
imports: [],
templateUrl: './store-footer.component.html',
styleUrl: './store-footer.component.scss'
})
export class StoreFooterComponent {
@Input({ required: true }) currentYear = new Date().getFullYear();
@Input({ required: true }) footerSections: StoreFooterSection[] = [];
@Input({ required: true }) socialLinks: StoreSocialLink[] = [];
@Input() logoUrl: string | null = null;
}

View File

@@ -0,0 +1,64 @@
<header class="store-layout__header">
<div class="store-layout__header-main">
<div class="container-xl px-3 px-md-4 py-3 py-lg-4 d-flex flex-wrap align-items-center justify-content-between gap-3">
<div
class="store-layout__brand-slot d-inline-flex align-items-center gap-3 flex-shrink-0"
data-testid="store-header-brand-slot"
aria-label="Logo del comercio"
>
@if (logoUrl) {
<img class="store-layout__brand-logo" [src]="logoUrl" alt="Logo del comercio" />
} @else {
<div class="store-layout__brand-logo-shell" aria-hidden="true">
<span class="store-layout__brand-logo-skeleton"></span>
</div>
}
</div>
<div class="d-flex flex-column flex-md-row align-items-stretch align-items-md-center gap-3 ms-auto w-100 w-lg-auto">
<div class="input-group store-layout__search" role="search">
<label class="visually-hidden" for="store-search-input">Buscar productos</label>
<input
id="store-search-input"
type="search"
class="form-control store-layout__search-input border-end-0 rounded-start"
placeholder="Buscar productos"
/>
<button
type="button"
class="btn store-layout__search-button border-start-0 rounded-end px-3"
aria-label="Buscar"
>
<i class="fa-solid fa-magnifying-glass" aria-hidden="true"></i>
</button>
</div>
<div class="d-flex align-items-center justify-content-end gap-1" aria-label="Acciones de usuario">
@for (action of headerActions; track action.label) {
<button
type="button"
class="btn btn-link store-layout__action-button p-2 text-decoration-none"
[attr.aria-label]="action.label"
[attr.title]="action.label"
>
<i [class]="action.iconClass" aria-hidden="true"></i>
</button>
}
</div>
</div>
</div>
</div>
<div>
<div class="container-xl px-3 px-md-4">
<button
type="button"
class="btn btn-link d-inline-flex align-items-center gap-2 px-0 py-2 text-uppercase fw-bold text-decoration-none store-layout__category-trigger"
aria-label="Categorias"
>
<span>Categorias</span>
<i class="fa-solid fa-chevron-down" aria-hidden="true"></i>
</button>
</div>
</div>
</header>

View File

@@ -0,0 +1,109 @@
.store-layout__header {
color: #ffffff;
background-color: var(--tenant-header-footer-bg);
box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}
.store-layout__header-main {
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.store-layout__brand-slot {
min-width: 10rem;
}
.store-layout__brand-logo-shell {
position: relative;
width: min(100%, 12rem);
height: 2.75rem;
}
.store-layout__brand-logo {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
}
.store-layout__brand-logo-skeleton {
display: block;
width: 100%;
height: 100%;
border-radius: 0.75rem;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0.12) 0%,
rgba(255, 255, 255, 0.22) 50%,
rgba(255, 255, 255, 0.12) 100%
);
background-size: 200% 100%;
animation: store-header-logo-skeleton 1.2s ease-in-out infinite;
}
.store-layout__search {
width: min(100%, 24rem);
min-width: 18rem;
}
.store-layout__search-input {
border-color: rgba(255, 255, 255, 0.2);
background-color: rgba(255, 255, 255, 0.96);
}
.store-layout__search-input:focus {
border-color: var(--tenant-primary);
box-shadow: 0 0 0 0.25rem color-mix(in srgb, white 70%, var(--tenant-primary));
}
.store-layout__search-button {
color: #ffffff;
border-color: rgba(255, 255, 255, 0.2);
background-color: color-mix(in srgb, white 10%, var(--tenant-header-footer-bg));
}
.store-layout__search-button:hover,
.store-layout__search-button:focus-visible {
color: #ffffff;
border-color: rgba(255, 255, 255, 0.28);
background-color: color-mix(in srgb, white 16%, var(--tenant-header-footer-bg));
}
.store-layout__action-button {
color: #ffffff;
}
.store-layout__action-button:hover,
.store-layout__action-button:focus-visible {
color: color-mix(in srgb, white 84%, var(--tenant-primary));
}
.store-layout__category-trigger {
font-size: 0.8rem;
letter-spacing: 0.02em;
color: #ffffff;
}
.store-layout__category-trigger:hover,
.store-layout__category-trigger:focus-visible {
color: color-mix(in srgb, white 84%, var(--tenant-primary));
}
@keyframes store-header-logo-skeleton {
from {
background-position: 200% 0;
}
to {
background-position: -200% 0;
}
}
@media (max-width: 767.98px) {
.store-layout__brand-slot {
min-width: 0;
}
.store-layout__search {
min-width: 0;
}
}

View File

@@ -0,0 +1,17 @@
import { Component, Input } from '@angular/core';
export type StoreHeaderAction = {
label: string;
iconClass: string;
};
@Component({
selector: 'app-store-header',
imports: [],
templateUrl: './store-header.component.html',
styleUrl: './store-header.component.scss'
})
export class StoreHeaderComponent {
@Input({ required: true }) headerActions: StoreHeaderAction[] = [];
@Input() logoUrl: string | null = null;
}

View File

@@ -0,0 +1,14 @@
<div class="store-layout d-flex flex-column flex-grow-1">
<app-store-header [headerActions]="headerActions" [logoUrl]="tenant()?.header_logo ?? null" />
<main class="flex-grow-1 d-block">
<router-outlet />
</main>
<app-store-footer
[currentYear]="currentYear"
[footerSections]="footerSections"
[socialLinks]="socialLinks"
[logoUrl]="tenant()?.footer_logo ?? null"
/>
</div>

View File

@@ -0,0 +1,12 @@
:host {
display: flex;
min-height: 100dvh;
background:
radial-gradient(
circle at top,
color-mix(in srgb, white 88%, var(--tenant-primary)) 0%,
transparent 58%
),
#f6f6f6;
color: #202020;
}

View File

@@ -0,0 +1,76 @@
import { signal } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { Tenant } from '../../services/tenant.interface';
import { TenantService } from '../../services/tenant.service';
import { StoreLayoutComponent } from './store-layout.component';
const tenant: Tenant = {
id: 1,
codigo: 'test',
nombre: 'Test Tenant',
dominio: 'localhost',
primary_color: '#6376F3',
secondary_color: '#A0A0A0',
danger_color: '#FF8888',
header_footer_bg_color: '#313131',
header_logo: 'https://example.com/header.png',
footer_logo: 'https://example.com/footer.png'
};
describe('StoreLayoutComponent', () => {
beforeEach(async () => {
const tenantState = signal(tenant);
await TestBed.configureTestingModule({
imports: [StoreLayoutComponent],
providers: [
provideRouter([]),
{
provide: TenantService,
useValue: {
tenant: tenantState.asReadonly(),
status: signal<'ready'>('ready').asReadonly(),
getTenant: () => tenantState(),
bootstrap: vi.fn().mockResolvedValue(undefined)
}
}
]
}).compileComponents();
});
it('renders the main layout sections', () => {
const fixture = TestBed.createComponent(StoreLayoutComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('app-store-header .store-layout__header')).not.toBeNull();
expect(compiled.querySelector('.store-layout__category-trigger')).not.toBeNull();
expect(compiled.querySelector('router-outlet')).not.toBeNull();
expect(compiled.querySelector('app-store-footer .store-layout__footer')).not.toBeNull();
});
it('renders the tenant branding and action icons', () => {
const fixture = TestBed.createComponent(StoreLayoutComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('[data-testid="store-header-brand-slot"]')).not.toBeNull();
expect(compiled.querySelector('[data-testid="store-footer-brand-slot"]')).not.toBeNull();
expect(
compiled.querySelector(`app-store-header img.store-layout__brand-logo[src="${tenant.header_logo}"]`)
).not.toBeNull();
expect(
compiled.querySelector(`app-store-footer img.store-layout__brand-logo[src="${tenant.footer_logo}"]`)
).not.toBeNull();
expect(compiled.querySelector('.fa-cart-shopping')).not.toBeNull();
expect(compiled.querySelector('.fa-circle-user')).not.toBeNull();
expect(compiled.querySelector('.fa-instagram')).not.toBeNull();
expect(compiled.querySelector('.fa-whatsapp')).not.toBeNull();
expect(compiled.querySelector('.fa-facebook')).not.toBeNull();
expect(compiled.querySelector('.fa-linkedin-in')).not.toBeNull();
});
});

View File

@@ -0,0 +1,59 @@
import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { TenantService } from '../../services/tenant.service';
import { StoreFooterComponent, StoreFooterSection, StoreSocialLink } from './store-footer/store-footer.component';
import { StoreHeaderComponent, StoreHeaderAction } from './store-header/store-header.component';
@Component({
selector: 'app-store-layout',
imports: [RouterOutlet, StoreHeaderComponent, StoreFooterComponent],
templateUrl: './store-layout.component.html',
styleUrl: './store-layout.component.scss'
})
export class StoreLayoutComponent {
private readonly tenantService = inject(TenantService);
protected readonly currentYear = new Date().getFullYear();
protected readonly tenant = this.tenantService.tenant;
protected readonly headerActions: StoreHeaderAction[] = [
{
label: 'Carrito',
iconClass: 'fa-solid fa-cart-shopping'
},
{
label: 'Mi cuenta',
iconClass: 'fa-solid fa-circle-user'
}
];
protected readonly footerSections: StoreFooterSection[] = [
{
heading: 'Cuenta',
links: ['Mi cuenta', 'Mis compras', 'Cerrar sesion']
},
{
heading: 'Ayuda',
links: ['Contacto', 'Ayuda', 'Preguntas frecuentes']
}
];
protected readonly socialLinks: StoreSocialLink[] = [
{
label: 'Instagram',
iconClass: 'fa-brands fa-instagram'
},
{
label: 'WhatsApp',
iconClass: 'fa-brands fa-whatsapp'
},
{
label: 'Facebook',
iconClass: 'fa-brands fa-facebook'
},
{
label: 'LinkedIn',
iconClass: 'fa-brands fa-linkedin-in'
}
];
}

View File

@@ -0,0 +1,44 @@
import { TestBed } from '@angular/core/testing';
import { tenantBootstrap } from './tenant-bootstrap';
import { TenantService } from './tenant.service';
describe('tenantBootstrap', () => {
it('waits for TenantService.bootstrap to resolve', async () => {
const bootstrapSpy = vi.fn().mockResolvedValue(undefined);
TestBed.configureTestingModule({
providers: [
{
provide: TenantService,
useValue: {
bootstrap: bootstrapSpy
}
}
]
});
await expect(TestBed.runInInjectionContext(() => tenantBootstrap())).resolves.toBeUndefined();
expect(bootstrapSpy).toHaveBeenCalledTimes(1);
});
it('propagates tenant bootstrap failures', async () => {
const bootstrapSpy = vi.fn().mockRejectedValue(new Error('bootstrap failed'));
TestBed.configureTestingModule({
providers: [
{
provide: TenantService,
useValue: {
bootstrap: bootstrapSpy
}
}
]
});
await expect(TestBed.runInInjectionContext(() => tenantBootstrap())).rejects.toThrow(
'bootstrap failed'
);
expect(bootstrapSpy).toHaveBeenCalledTimes(1);
});
});

View File

@@ -0,0 +1,9 @@
import { inject } from '@angular/core';
import { TenantService } from './tenant.service';
export function tenantBootstrap(): Promise<void> {
const tenantService = inject(TenantService);
return tenantService.bootstrap();
}

View File

@@ -0,0 +1,23 @@
import { makeStateKey } from '@angular/core';
import { Tenant } from './tenant.interface';
export type TenantBootstrapStatus = 'idle' | 'ready' | 'not-found';
export type TenantSsrState =
| {
status: 'ready';
tenant: Tenant;
}
| {
status: 'not-found';
};
export const DEFAULT_TENANT_BRANDING = {
primaryColor: '#102bda',
secondaryColor: '#9e9e9e',
dangerColor: '#fd4c4c',
headerFooterBgColor: '#313131'
} as const;
export const TENANT_SSR_STATE_KEY = makeStateKey<TenantSsrState | null>('tenant-ssr-state');

View File

@@ -0,0 +1,16 @@
export interface Tenant {
id: number;
codigo: string;
nombre: string;
dominio: string;
primary_color: string;
secondary_color: string;
danger_color: string;
header_footer_bg_color: string;
header_logo: string;
footer_logo: string;
}
export interface TenantBootstrapResponse {
data: Tenant;
}

View File

@@ -0,0 +1,223 @@
import { PLATFORM_ID, REQUEST, RESPONSE_INIT, TransferState } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { environment } from '../../../environments/environment';
import { Tenant, TenantBootstrapResponse } from './tenant.interface';
import { TENANT_SSR_STATE_KEY } from './tenant-ssr-cache.store';
import { TenantService } from './tenant.service';
const tenant: Tenant = {
id: 1,
codigo: 'test',
nombre: 'Test Tenant',
dominio: 'localhost',
primary_color: '#6376F3',
secondary_color: '#A0A0A0',
danger_color: '#FF8888',
header_footer_bg_color: '#313131',
header_logo: 'https://example.com/header.png',
footer_logo: 'https://example.com/footer.png'
};
const tenantResponse: TenantBootstrapResponse = {
data: tenant
};
describe('TenantService', () => {
beforeEach(() => {
try {
window.history.replaceState({}, '', 'http://localhost:4200/');
} catch (e) {
// Ignore SecurityError under test environments
}
});
it('requests the tenant bootstrap endpoint using the current hostname and stores the response', async () => {
TestBed.configureTestingModule({
providers: [provideHttpClient(), provideHttpClientTesting(), TenantService]
});
const service = TestBed.inject(TenantService);
const httpController = TestBed.inject(HttpTestingController);
const bootstrapPromise = service.bootstrap();
const request = httpController.expectOne(`${environment.url}tenants/bootstrap/localhost`);
expect(request.request.method).toBe('GET');
request.flush(tenantResponse);
await expect(bootstrapPromise).resolves.toBeUndefined();
expect(service.status()).toBe('ready');
expect(service.tenant()).toEqual(tenant);
expect(service.getTenant()).toEqual(tenant);
httpController.verify();
});
it('hydrates the tenant from TransferState without performing HTTP on the browser', async () => {
TestBed.configureTestingModule({
providers: [provideHttpClient(), provideHttpClientTesting(), TenantService]
});
const service = TestBed.inject(TenantService);
const transferState = TestBed.inject(TransferState);
const httpController = TestBed.inject(HttpTestingController);
transferState.set(TENANT_SSR_STATE_KEY, {
status: 'ready',
tenant
});
await expect(service.bootstrap()).resolves.toBeUndefined();
expect(service.status()).toBe('ready');
expect(service.tenant()).toEqual(tenant);
expect(transferState.get(TENANT_SSR_STATE_KEY, null)).toBeNull();
httpController.expectNone(() => true);
httpController.verify();
});
it('uses the forwarded host during SSR and stores the resolved tenant in TransferState', async () => {
const responseInit: ResponseInit = {};
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClientTesting(),
TenantService,
{ provide: PLATFORM_ID, useValue: 'server' },
{
provide: REQUEST,
useValue: new Request('https://internal.example/render', {
headers: {
'x-forwarded-host': 'STORE.EXAMPLE.COM:443, proxy.internal',
host: 'ignored.example.com'
}
})
},
{ provide: RESPONSE_INIT, useValue: responseInit }
]
});
const service = TestBed.inject(TenantService);
const transferState = TestBed.inject(TransferState);
const httpController = TestBed.inject(HttpTestingController);
const bootstrapPromise = service.bootstrap();
const request = httpController.expectOne(`${environment.url}tenants/bootstrap/store.example.com`);
request.flush(tenantResponse);
await expect(bootstrapPromise).resolves.toBeUndefined();
expect(service.status()).toBe('ready');
expect(service.tenant()).toEqual(tenant);
expect(transferState.get(TENANT_SSR_STATE_KEY, null)).toEqual({
status: 'ready',
tenant
});
expect(responseInit.status).toBeUndefined();
httpController.verify();
});
it('stores a not-found state and sets the SSR response status to 404 when the tenant does not exist', async () => {
const responseInit: ResponseInit = {};
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClientTesting(),
TenantService,
{ provide: PLATFORM_ID, useValue: 'server' },
{
provide: REQUEST,
useValue: new Request('https://internal.example/render', {
headers: {
host: 'missing.example.com:8443'
}
})
},
{ provide: RESPONSE_INIT, useValue: responseInit }
]
});
const service = TestBed.inject(TenantService);
const transferState = TestBed.inject(TransferState);
const httpController = TestBed.inject(HttpTestingController);
const bootstrapPromise = service.bootstrap();
const request = httpController.expectOne(`${environment.url}tenants/bootstrap/missing.example.com`);
request.flush({ message: 'Not Found' }, { status: 404, statusText: 'Not Found' });
await expect(bootstrapPromise).resolves.toBeUndefined();
expect(service.status()).toBe('not-found');
expect(service.tenant()).toBeNull();
expect(service.getTenant()).toBeNull();
expect(transferState.get(TENANT_SSR_STATE_KEY, null)).toEqual({
status: 'not-found'
});
expect(responseInit.status).toBe(404);
httpController.verify();
});
it('rejects when the bootstrap response does not contain tenant data', async () => {
TestBed.configureTestingModule({
providers: [provideHttpClient(), provideHttpClientTesting(), TenantService]
});
const service = TestBed.inject(TenantService);
const httpController = TestBed.inject(HttpTestingController);
const bootstrapPromise = service.bootstrap();
const request = httpController.expectOne(`${environment.url}tenants/bootstrap/localhost`);
request.flush({});
await expect(bootstrapPromise).rejects.toThrow('Tenant bootstrap returned no data');
expect(service.status()).toBe('idle');
expect(service.tenant()).toBeNull();
httpController.verify();
});
it('propagates non-404 backend failures', async () => {
const responseInit: ResponseInit = {};
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClientTesting(),
TenantService,
{ provide: PLATFORM_ID, useValue: 'server' },
{
provide: REQUEST,
useValue: new Request('https://internal.example/render', {
headers: {
host: 'broken.example.com'
}
})
},
{ provide: RESPONSE_INIT, useValue: responseInit }
]
});
const service = TestBed.inject(TenantService);
const httpController = TestBed.inject(HttpTestingController);
const bootstrapPromise = service.bootstrap();
const request = httpController.expectOne(`${environment.url}tenants/bootstrap/broken.example.com`);
request.flush({ message: 'Boom' }, { status: 500, statusText: 'Server Error' });
await expect(bootstrapPromise).rejects.toThrow('Http failure response');
expect(service.status()).toBe('idle');
expect(responseInit.status).toBeUndefined();
httpController.verify();
});
});

View File

@@ -0,0 +1,166 @@
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import {
inject,
Injectable,
PLATFORM_ID,
REQUEST,
RESPONSE_INIT,
signal,
TransferState
} from '@angular/core';
import { IS_DISCOVERING_ROUTES } from '@angular/ssr';
import { firstValueFrom } from 'rxjs';
import { environment } from '../../../environments/environment';
import { Tenant, TenantBootstrapResponse } from './tenant.interface';
import {
TENANT_SSR_STATE_KEY,
TenantBootstrapStatus,
TenantSsrState
} from './tenant-ssr-cache.store';
@Injectable({
providedIn: 'root'
})
export class TenantService {
private readonly http = inject(HttpClient);
private readonly platformId = inject(PLATFORM_ID);
private readonly request = inject(REQUEST, { optional: true });
private readonly responseInit = inject(RESPONSE_INIT, { optional: true });
private readonly transferState = inject(TransferState);
private readonly isDiscoveringRoutes = inject(IS_DISCOVERING_ROUTES, { optional: true }) ?? false;
private readonly tenantState = signal<Tenant | null>(null);
private readonly statusState = signal<TenantBootstrapStatus>('idle');
readonly tenant = this.tenantState.asReadonly();
readonly status = this.statusState.asReadonly();
getTenant(): Tenant | null {
return this.tenantState();
}
async bootstrap(): Promise<void> {
if (this.statusState() !== 'idle') {
return;
}
if (this.isDiscoveringRoutes) {
this.statusState.set('ready');
return;
}
const transferredState = this.transferState.get(TENANT_SSR_STATE_KEY, null);
if (transferredState) {
this.transferState.remove(TENANT_SSR_STATE_KEY);
this.applyState(transferredState);
return;
}
const domain = this.resolveDomain();
try {
const response = await firstValueFrom(
this.http.get<TenantBootstrapResponse>(`${environment.url}tenants/bootstrap/${domain}`)
);
if (!response?.data) {
throw new Error(`Tenant bootstrap returned no data for domain "${domain}".`);
}
this.setReady(response.data);
this.persistSsrState({
status: 'ready',
tenant: response.data
});
} catch (error) {
if (this.isNotFoundError(error)) {
this.setNotFound();
this.persistSsrState({ status: 'not-found' });
if (this.responseInit) {
this.responseInit.status = 404;
}
return;
}
throw error;
}
}
private resolveDomain(): string {
if (isPlatformBrowser(this.platformId)) {
const domain = window.location.hostname;
if (!domain) {
throw new Error('Tenant bootstrap could not resolve the current domain.');
}
return this.normalizeHost(domain);
}
const requestHost =
this.request?.headers.get('x-forwarded-host') ??
this.request?.headers.get('host') ??
(this.request ? new URL(this.request.url).host : null);
if (!requestHost) {
throw new Error('Tenant bootstrap could not resolve the current domain.');
}
return this.normalizeHost(requestHost);
}
private normalizeHost(host: string): string {
const [firstHost = ''] = host.split(',');
const normalizedHost = firstHost.trim().toLowerCase();
if (!normalizedHost) {
throw new Error('Tenant bootstrap could not resolve the current domain.');
}
if (normalizedHost.startsWith('[')) {
const closingBracketIndex = normalizedHost.indexOf(']');
if (closingBracketIndex >= 0) {
return normalizedHost.slice(1, closingBracketIndex);
}
}
return normalizedHost.replace(/:\d+$/, '');
}
private applyState(state: TenantSsrState): void {
if (state.status === 'ready') {
this.setReady(state.tenant);
return;
}
this.setNotFound();
}
private setReady(tenant: Tenant): void {
this.tenantState.set(tenant);
this.statusState.set('ready');
}
private setNotFound(): void {
this.tenantState.set(null);
this.statusState.set('not-found');
}
private persistSsrState(state: TenantSsrState): void {
if (isPlatformServer(this.platformId)) {
this.transferState.set(TENANT_SSR_STATE_KEY, state);
}
}
private isNotFoundError(error: unknown): error is HttpErrorResponse {
return error instanceof HttpErrorResponse && error.status === 404;
}
}

View File

@@ -0,0 +1,31 @@
import { of, throwError } from 'rxjs';
import { describe, expect, it, vi } from 'vitest';
import { useMutation } from './use-mutation';
describe('useMutation', () => {
it('stores the resolved value and clears loading after a successful execution', async () => {
const mutation = useMutation<{ id: number }, { ok: boolean; id: number }>();
const factory = vi.fn((payload: { id: number }) => of({ ok: true, id: payload.id }));
await expect(mutation.execute(factory, { id: 7 })).resolves.toEqual({ ok: true, id: 7 });
expect(factory).toHaveBeenCalledWith({ id: 7 });
expect(mutation.loading()).toBe(false);
expect(mutation.error()).toBeNull();
expect(mutation.data()).toEqual({ ok: true, id: 7 });
});
it('stores the thrown error and clears loading after a failed execution', async () => {
const mutation = useMutation<{ id: number }, { ok: boolean }>();
const failure = new Error('request failed');
const factory = vi.fn(() => throwError(() => failure));
await expect(mutation.execute(factory, { id: 7 })).rejects.toThrow('request failed');
expect(factory).toHaveBeenCalledWith({ id: 7 });
expect(mutation.loading()).toBe(false);
expect(mutation.error()).toBe(failure);
expect(mutation.data()).toBeNull();
});
});

View File

@@ -0,0 +1,42 @@
import { signal, WritableSignal } from '@angular/core';
import { Observable, firstValueFrom } from 'rxjs';
export interface UseMutationResult<TData, TResult> {
loading: WritableSignal<boolean>;
error: WritableSignal<unknown | null>;
data: WritableSignal<TResult | null>;
execute: (factory: (payload: TData) => Observable<TResult>, payload: TData) => Promise<TResult>;
}
export function useMutation<TData, TResult>(): UseMutationResult<TData, TResult> {
const loading = signal(false);
const error = signal<unknown | null>(null);
const data = signal<TResult | null>(null);
async function execute(
factory: (payload: TData) => Observable<TResult>,
payload: TData
): Promise<TResult> {
loading.set(true);
error.set(null);
try {
const result = await firstValueFrom(factory(payload));
data.set(result);
return result;
} catch (err) {
error.set(err);
throw err;
} finally {
loading.set(false);
}
}
return {
loading,
error,
data,
execute
};
}

View File

@@ -0,0 +1,14 @@
import { Routes } from '@angular/router';
import { ReutilizablesTestPageComponent } from './pages/reutilizables-test-page/reutilizables-test-page.component';
export const routes: Routes = [
{
path: 'reutilizables',
component: ReutilizablesTestPageComponent
},
{
path: '',
pathMatch: 'full',
redirectTo: 'reutilizables'
}
];

View File

@@ -0,0 +1,259 @@
<main class="app-shell">
<section class="component-demo card shadow-sm">
<div class="card-body">
<span class="eyebrow">Componentes reutilizables</span>
<h1>Button + Input</h1>
<p class="lead mb-4">
Pagina dedicada a probar variantes de los componentes compartidos.
</p>
<div class="button-showcase">
<div class="button-group">
<h2>Comunes</h2>
<div class="button-grid">
<app-button>Primary</app-button>
<app-button variant="secondary">Secondary</app-button>
<app-button variant="danger">Danger</app-button>
<app-button variant="danger-secondary">Danger secondary</app-button>
<app-button variant="cancel">Cancel</app-button>
</div>
</div>
<div class="button-group">
<h2>Disabled</h2>
<div class="button-grid">
<app-button [disabled]="true">Primary</app-button>
<app-button variant="secondary" [disabled]="true">Secondary</app-button>
<app-button variant="danger" [disabled]="true">Danger</app-button>
<app-button variant="danger-secondary" [disabled]="true">Danger secondary</app-button>
<app-button variant="cancel" [disabled]="true">Cancel</app-button>
</div>
</div>
<div class="button-group">
<h2>Una letra</h2>
<div class="button-grid button-grid--single-char">
<app-button>A</app-button>
<app-button variant="secondary">B</app-button>
<app-button variant="danger">C</app-button>
<app-button variant="danger-secondary">D</app-button>
<app-button variant="cancel">E</app-button>
</div>
</div>
</div>
<hr class="section-divider" />
<div class="input-grid">
<div class="input-field">
<label for="search-input">Texto</label>
<app-input
id="search-input"
type="search"
placeholder="Buscar producto"
[(value)]="textValue"
[maxlength]="24"
/>
</div>
<div class="input-field">
<label for="number-input">Numero</label>
<app-input
id="number-input"
type="number"
placeholder="0"
[(value)]="numberValue"
/>
</div>
<div class="input-field">
<label for="email-input">Email</label>
<app-input
id="email-input"
type="email"
placeholder="mail@empresa.com"
[(value)]="email"
/>
</div>
<div class="input-field">
<label for="user-input">Usuario</label>
<app-input
id="user-input"
type="user"
placeholder="Nombre de usuario"
[(value)]="user"
/>
</div>
<div class="input-field">
<label for="password-input">Password</label>
<app-input
id="password-input"
type="password-toggle"
placeholder="********"
[(value)]="password"
/>
</div>
<div class="input-field">
<label for="date-input">Fecha</label>
<app-input id="date-input" type="date" [(value)]="date" />
</div>
<div class="input-field">
<label for="period-input">Periodo</label>
<app-input id="period-input" type="period" [(value)]="period" />
</div>
<div class="input-field">
<label for="amount-input">Moneda</label>
<app-input
id="amount-input"
type="currency"
placeholder="0"
[(value)]="amount"
/>
</div>
<div class="input-field">
<label for="percent-input">Porcentaje</label>
<app-input
id="percent-input"
type="percent"
placeholder="0"
[(value)]="percent"
/>
</div>
<div class="input-field">
<label for="disabled-input">Deshabilitado</label>
<app-input
id="disabled-input"
placeholder="Campo deshabilitado"
[value]="disabledValue"
[disabled]="true"
/>
</div>
<div class="input-field">
<label for="editable-input">Editable</label>
<app-input
id="editable-input"
type="editable"
[(value)]="editableValue"
[disabled]="editableDisabled"
(disabledChange)="editableDisabled = $event"
/>
</div>
<div class="input-field">
<label for="invalid-input">Invalido</label>
<app-input
id="invalid-input"
type="email"
placeholder="mail@empresa.com"
[(value)]="invalidEmail"
[invalid]="true"
/>
</div>
<div class="file-field">
<div class="input-field">
<label for="file-input">Archivo</label>
<app-input
id="file-input"
type="file"
accept=".pdf,.png,.jpg"
[fileName]="fileName"
[clearTrigger]="clearTrigger"
(fileChange)="onFileChange($event)"
/>
</div>
<app-button variant="secondary" (click)="clearFile()">Limpiar archivo</app-button>
</div>
</div>
</div>
</section>
<section class="component-demo card shadow-sm mt-4 configuracion-tennant">
<div class="card-body">
<span class="eyebrow">Tenant Configuration</span>
<h2 class="mb-4">Configuración Tenant</h2>
<!-- Logos section -->
<div class="row mb-4">
<div class="col-md-6 mb-3 mb-md-0">
<div class="tenant-logo-card">
<div class="tenant-logo-card__label">Logo del Header</div>
<div class="tenant-logo-card__container header-footer-bg">
@if (tenant()?.header_logo) {
<img [src]="tenant()?.header_logo" alt="Header Logo" class="tenant-logo-card__img" />
} @else {
<div class="tenant-logo-card__placeholder">
<i class="fa-solid fa-image mb-2"></i>
<span>Sin Logo de Header</span>
</div>
}
</div>
</div>
</div>
<div class="col-md-6">
<div class="tenant-logo-card">
<div class="tenant-logo-card__label">Logo del Footer</div>
<div class="tenant-logo-card__container header-footer-bg">
@if (tenant()?.footer_logo) {
<img [src]="tenant()?.footer_logo" alt="Footer Logo" class="tenant-logo-card__img" />
} @else {
<div class="tenant-logo-card__placeholder">
<i class="fa-solid fa-image mb-2"></i>
<span>Sin Logo de Footer</span>
</div>
}
</div>
</div>
</div>
</div>
<hr class="section-divider" />
<!-- Colors section -->
<div class="colors-section">
<h3 class="mb-3">Colores de Marca</h3>
<div class="row">
<div class="col-md-4 mb-3">
<div class="color-swatch-card shadow-sm">
<div class="color-swatch-card__preview" [style.background-color]="'var(--tenant-primary)'"></div>
<div class="color-swatch-card__body">
<span class="color-swatch-card__title">Primario</span>
<code class="color-swatch-card__value">{{ tenant()?.primary_color || 'Default' }}</code>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="color-swatch-card shadow-sm">
<div class="color-swatch-card__preview" [style.background-color]="'var(--tenant-secondary)'"></div>
<div class="color-swatch-card__body">
<span class="color-swatch-card__title">Secundario</span>
<code class="color-swatch-card__value">{{ tenant()?.secondary_color || 'Default' }}</code>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="color-swatch-card shadow-sm">
<div class="color-swatch-card__preview" [style.background-color]="'var(--tenant-danger)'"></div>
<div class="color-swatch-card__body">
<span class="color-swatch-card__title">Danger</span>
<code class="color-swatch-card__value">{{ tenant()?.danger_color || 'Default' }}</code>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>

View File

@@ -0,0 +1,200 @@
:host {
display: block;
min-height: 100dvh;
}
.app-shell {
display: grid;
place-items: center;
min-height: 100dvh;
padding: 1.5rem;
}
.component-demo {
width: min(100%, 64rem);
border: 0;
}
.eyebrow {
display: inline-block;
margin-bottom: 0.75rem;
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #6c757d;
}
h1 {
margin-bottom: 0.75rem;
}
.button-grid {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.button-showcase {
display: grid;
gap: 1.25rem;
}
.button-group {
display: grid;
gap: 0.75rem;
}
.button-group h2 {
margin: 0;
font-size: 1rem;
font-weight: 700;
}
.button-grid--single-char app-button {
min-width: 3rem;
}
.section-divider {
margin: 2rem 0;
}
.input-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1rem;
}
.input-field {
display: grid;
gap: 0;
}
.file-field {
display: grid;
gap: 0.75rem;
}
.file-field {
display: grid;
gap: 0.75rem;
}
@media (max-width: 991.98px) {
.input-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 767.98px) {
.input-grid {
grid-template-columns: minmax(0, 1fr);
}
}
.configuracion-tennant {
margin-top: 2rem;
.tenant-logo-card {
display: flex;
flex-direction: column;
gap: 0.5rem;
&__label {
font-size: 0.875rem;
font-weight: 600;
color: #495057;
}
&__container {
display: flex;
align-items: center;
justify-content: center;
height: 120px;
border-radius: 8px;
border: 1px solid #dee2e6;
padding: 1rem;
overflow: hidden;
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:hover {
transform: translateY(-2px);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.08);
}
}
&__img {
max-height: 100%;
max-width: 100%;
object-fit: contain;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}
&__placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #6c757d;
font-size: 0.875rem;
i {
font-size: 2rem;
opacity: 0.6;
}
}
}
.header-footer-bg {
background-color: var(--tenant-header-footer-bg, #f8f9fa);
}
.color-swatch-card {
display: flex;
flex-direction: column;
border-radius: 8px;
border: 1px solid #dee2e6;
overflow: hidden;
background-color: #ffffff;
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:hover {
transform: translateY(-3px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important;
}
&__preview {
height: 80px;
width: 100%;
border-bottom: 1px solid #dee2e6;
transition: opacity 0.2s ease;
&:hover {
opacity: 0.95;
}
}
&__body {
padding: 0.75rem 1rem;
display: flex;
flex-direction: column;
gap: 0.25rem;
}
&__title {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 700;
color: #6c757d;
}
&__value {
font-size: 0.875rem;
color: #212529;
font-family: var(--bs-font-monospace);
}
}
}

View File

@@ -0,0 +1,66 @@
import { signal } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { ReutilizablesTestPageComponent } from './reutilizables-test-page.component';
import { Tenant } from '../../../../core/services/tenant.interface';
import { TenantService } from '../../../../core/services/tenant.service';
const tenant: Tenant = {
id: 1,
codigo: 'test',
nombre: 'Test Tenant',
dominio: 'localhost',
primary_color: '#6376F3',
secondary_color: '#A0A0A0',
danger_color: '#FF8888',
header_footer_bg_color: '#313131',
header_logo: 'https://example.com/header.png',
footer_logo: 'https://example.com/footer.png'
};
function createTenantServiceStub(currentTenant: Tenant | null) {
const tenantState = signal(currentTenant);
const statusState = signal<'ready' | 'not-found'>('ready');
return {
tenant: tenantState.asReadonly(),
status: statusState.asReadonly(),
getTenant: () => tenantState(),
bootstrap: vi.fn().mockResolvedValue(undefined)
};
}
describe('ReutilizablesTestPageComponent', () => {
it('renders the tenant configuration section with logo sources and swatch colors', async () => {
await TestBed.configureTestingModule({
imports: [ReutilizablesTestPageComponent],
providers: [
{
provide: TenantService,
useValue: createTenantServiceStub(tenant)
}
]
}).compileComponents();
const fixture = TestBed.createComponent(ReutilizablesTestPageComponent);
fixture.detectChanges();
const element = fixture.nativeElement as HTMLElement;
// Check section title
const sectionTitle = element.querySelector('.configuracion-tennant h2');
expect(sectionTitle?.textContent).toContain('Configuración Tenant');
// Check header logo source
const headerImg = element.querySelector('.tenant-logo-card img[alt="Header Logo"]') as HTMLImageElement;
expect(headerImg?.src).toBe(tenant.header_logo);
// Check footer logo source
const footerImg = element.querySelector('.tenant-logo-card img[alt="Footer Logo"]') as HTMLImageElement;
expect(footerImg?.src).toBe(tenant.footer_logo);
// Check color hex values
expect(element.textContent).toContain(tenant.primary_color);
expect(element.textContent).toContain(tenant.secondary_color);
expect(element.textContent).toContain(tenant.danger_color);
});
});

View File

@@ -0,0 +1,39 @@
import { Component, inject } from '@angular/core';
import { ButtonComponent } from '../../../../shared/components/button/button.component';
import { InputComponent } from '../../../../shared/components/input/input.component';
import { TenantService } from '../../../../core/services/tenant.service';
@Component({
selector: 'app-reutilizables-test-page',
imports: [ButtonComponent, InputComponent],
templateUrl: './reutilizables-test-page.component.html',
styleUrl: './reutilizables-test-page.component.scss'
})
export class ReutilizablesTestPageComponent {
private readonly tenantService = inject(TenantService);
protected readonly tenant = this.tenantService.tenant;
protected textValue = 'Auriculares';
protected numberValue = '24';
protected email = 'usuario@empresa.com';
protected user = 'Juan Perez';
protected password = '12345678';
protected date = '2026-06-24';
protected amount = '125000';
protected percent = '12';
protected period = '2026-06';
protected editableValue = 'Solo lectura al cargar';
protected disabledValue = 'No editable';
protected invalidEmail = 'correo-invalido';
protected fileName = '';
protected clearTrigger = 0;
protected editableDisabled = true;
protected onFileChange(file: File | null): void {
this.fileName = file?.name ?? '';
}
protected clearFile(): void {
this.fileName = '';
this.clearTrigger += 1;
}
}

View File

@@ -0,0 +1,21 @@
<section class="store-home">
<div class="store-home__inner">
<div class="store-home__hero">
<span class="store-home__eyebrow">Store Layout</span>
<h1>Tienda en construccion</h1>
<p class="store-home__lead">
Esta pagina placeholder deja visible el shell del store mientras se conectan categorias,
catalogo y acciones reales.
</p>
</div>
<div class="store-home__highlights">
@for (highlight of highlights; track highlight) {
<article class="store-home__card">
<span class="store-home__card-index" aria-hidden="true">0{{ $index + 1 }}</span>
<p>{{ highlight }}</p>
</article>
}
</div>
</div>
</section>

View File

@@ -0,0 +1,96 @@
:host {
display: block;
}
.store-home {
padding: 3rem 0 4rem;
}
.store-home__inner {
width: min(100% - 3rem, 75rem);
margin: 0 auto;
display: grid;
gap: 1.5rem;
}
.store-home__hero {
padding: clamp(2rem, 4vw, 3rem);
border: 1px solid #e4e4e4;
border-radius: 1.5rem;
background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
box-shadow: 0 1.2rem 2.2rem rgba(17, 17, 17, 0.06);
}
.store-home__eyebrow {
display: inline-block;
margin-bottom: 0.75rem;
font-size: 0.78rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #666666;
}
h1 {
margin-bottom: 0.75rem;
font-size: clamp(2rem, 4vw, 3.25rem);
font-weight: 700;
letter-spacing: -0.05em;
}
.store-home__lead {
max-width: 42rem;
margin: 0;
font-size: 1rem;
line-height: 1.6;
color: #4a4a4a;
}
.store-home__highlights {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1rem;
}
.store-home__card {
display: grid;
gap: 0.9rem;
padding: 1.5rem;
border: 1px solid #e4e4e4;
border-radius: 1.25rem;
background-color: #ffffff;
box-shadow: 0 0.75rem 1.5rem rgba(17, 17, 17, 0.04);
}
.store-home__card-index {
font-size: 0.85rem;
font-weight: 700;
letter-spacing: 0.08em;
color: #707070;
}
.store-home__card p {
margin: 0;
line-height: 1.6;
color: #333333;
}
@media (max-width: 991.98px) {
.store-home__highlights {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 767.98px) {
.store-home {
padding: 2rem 0 3rem;
}
.store-home__inner {
width: min(100% - 1.5rem, 75rem);
}
.store-home__highlights {
grid-template-columns: minmax(0, 1fr);
}
}

View File

@@ -0,0 +1,14 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-store-home-page',
templateUrl: './store-home-page.component.html',
styleUrl: './store-home-page.component.scss'
})
export class StoreHomePageComponent {
protected readonly highlights = [
'Header y footer listos para conectar con datos reales.',
'Barra de categorias reservada para sumar dropdown despues.',
'Placeholder inicial para validar layout, espaciados y responsive.'
];
}

View File

@@ -0,0 +1,17 @@
import { Routes } from '@angular/router';
import { StoreLayoutComponent } from '../../core/layout/store-layout/store-layout.component';
import { StoreHomePageComponent } from './pages/store-home-page/store-home-page.component';
export const routes: Routes = [
{
path: '',
component: StoreLayoutComponent,
children: [
{
path: '',
component: StoreHomePageComponent
}
]
}
];

View File

@@ -0,0 +1,7 @@
<button
[type]="type()"
[disabled]="disabled()"
[ngClass]="buttonClasses()"
>
<ng-content />
</button>

View File

@@ -0,0 +1,88 @@
:host {
display: inline-block;
}
.btn {
min-height: 40px;
font-weight: 700;
font-size: 15px;
min-width: 216px;
}
.btn-primary,
.btn-secondary,
.btn-danger {
--bs-btn-bg: transparent;
--bs-btn-border-color: transparent;
--bs-btn-color: #fff;
--bs-btn-hover-color: #fff;
--bs-btn-active-color: #fff;
}
.btn-outline-primary,
.btn-outline-danger {
--bs-btn-bg: transparent;
--bs-btn-hover-color: #fff;
--bs-btn-active-color: #fff;
}
.btn-primary {
--bs-btn-bg: var(--tenant-primary);
--bs-btn-border-color: var(--tenant-primary);
--bs-btn-hover-bg: color-mix(in srgb, black 40%, var(--tenant-primary));
--bs-btn-hover-border-color: color-mix(in srgb, black 40%, var(--tenant-primary));
--bs-btn-active-bg: color-mix(in srgb, black 44%, var(--tenant-primary));
--bs-btn-active-border-color: color-mix(in srgb, black 44%, var(--tenant-primary));
--bs-btn-disabled-color: #fff;
--bs-btn-disabled-bg: color-mix(in srgb, white 50%, var(--tenant-primary));
--bs-btn-disabled-border-color: color-mix(in srgb, white 50%, var(--tenant-primary));
--bs-btn-disabled-opacity: 1;
}
.btn-secondary {
--bs-btn-bg: var(--tenant-secondary);
--bs-btn-border-color: var(--tenant-secondary);
--bs-btn-hover-bg: color-mix(in srgb, black 26%, var(--tenant-secondary));
--bs-btn-hover-border-color: color-mix(in srgb, black 26%, var(--tenant-secondary));
--bs-btn-active-bg: color-mix(in srgb, black 30%, var(--tenant-secondary));
--bs-btn-active-border-color: color-mix(in srgb, black 30%, var(--tenant-secondary));
--bs-btn-disabled-color: #fff;
--bs-btn-disabled-bg: color-mix(in srgb, transparent 50%, var(--tenant-secondary));
--bs-btn-disabled-border-color: color-mix(in srgb, transparent 50%, var(--tenant-secondary));
--bs-btn-disabled-opacity: 1;
}
.btn-danger {
--bs-btn-bg: var(--tenant-danger);
--bs-btn-border-color: var(--tenant-danger);
--bs-btn-hover-bg: color-mix(in srgb, black 38%, var(--tenant-danger));
--bs-btn-hover-border-color: color-mix(in srgb, black 38%, var(--tenant-danger));
--bs-btn-active-bg: color-mix(in srgb, black 44%, var(--tenant-danger));
--bs-btn-active-border-color: color-mix(in srgb, black 44%, var(--tenant-danger));
--bs-btn-disabled-color: #fff;
--bs-btn-disabled-bg: color-mix(in srgb, transparent 50%, var(--tenant-danger));
--bs-btn-disabled-border-color: color-mix(in srgb, transparent 50%, var(--tenant-danger));
--bs-btn-disabled-opacity: 1;
}
.btn-outline-primary {
--bs-btn-color: var(--tenant-primary);
--bs-btn-border-color: var(--tenant-primary);
--bs-btn-hover-bg: var(--tenant-primary);
--bs-btn-hover-border-color: var(--tenant-primary);
--bs-btn-active-bg: color-mix(in srgb, black 12%, var(--tenant-primary));
--bs-btn-active-border-color: color-mix(in srgb, black 12%, var(--tenant-primary));
--bs-btn-disabled-color: color-mix(in srgb, transparent 35%, var(--tenant-primary));
--bs-btn-disabled-border-color: color-mix(in srgb, transparent 35%, var(--tenant-primary));
}
.btn-outline-danger {
--bs-btn-color: var(--tenant-danger);
--bs-btn-border-color: var(--tenant-danger);
--bs-btn-hover-bg: var(--tenant-danger);
--bs-btn-hover-border-color: var(--tenant-danger);
--bs-btn-active-bg: color-mix(in srgb, black 12%, var(--tenant-danger));
--bs-btn-active-border-color: color-mix(in srgb, black 12%, var(--tenant-danger));
--bs-btn-disabled-color: color-mix(in srgb, transparent 35%, var(--tenant-danger));
--bs-btn-disabled-border-color: color-mix(in srgb, transparent 35%, var(--tenant-danger));
}

View File

@@ -0,0 +1,34 @@
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
import { NgClass } from '@angular/common';
export type ButtonVariant =
| 'primary'
| 'secondary'
| 'danger'
| 'danger-secondary'
| 'cancel';
@Component({
selector: 'app-button',
imports: [NgClass],
templateUrl: './button.component.html',
styleUrl: './button.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ButtonComponent {
readonly variant = input<ButtonVariant>('primary');
readonly type = input<'button' | 'submit' | 'reset'>('button');
readonly disabled = input(false);
protected readonly buttonClasses = computed(() => {
const variants: Record<ButtonVariant, string> = {
primary: 'btn-primary',
secondary: 'btn-outline-primary',
danger: 'btn-danger',
'danger-secondary': 'btn-outline-danger',
cancel: 'btn-secondary'
};
return ['btn', variants[this.variant()]];
});
}

View File

@@ -0,0 +1,81 @@
<div
class="input-control"
[ngClass]="{
'input-control-currency': type() === 'currency',
'input-control-percent': type() === 'percent',
'input-control-file': type() === 'file',
'input-control-editable': type() === 'editable',
'input-control-password-toggle': type() === 'password-toggle',
'input-control-disabled': isInputDisabled(),
'input-control-editable-active': isEditableActive()
}"
>
@if (type() === 'currency') {
<span class="input-prefix">$</span>
}
<input
#inputElement
[id]="id()"
[name]="id()"
[type]="inputType()"
[ngClass]="inputClasses()"
[disabled]="isInputDisabled()"
[placeholder]="placeholder()"
[value]="type() !== 'file' ? value() : null"
(input)="type() !== 'file' ? onValueChange($event) : null"
(change)="type() === 'file' ? onFileChange($event) : null"
[attr.maxlength]="type() !== 'file' ? maxlength() : null"
[attr.accept]="type() === 'file' ? accept() : null"
/>
@if (type() === 'search') {
<span class="input-search-icon" aria-hidden="true">
<i class="fa-solid fa-magnifying-glass"></i>
</span>
}
@if (type() === 'user') {
<span class="input-user-icon" aria-hidden="true">
<i class="fa-solid fa-user"></i>
</span>
}
@if (type() === 'password-toggle') {
<button
type="button"
class="input-icon"
[disabled]="disabled()"
[attr.aria-label]="isPasswordVisible() ? 'Ocultar contrasena' : 'Mostrar contrasena'"
(click)="togglePasswordVisibility()"
>
<i
class="fa-solid"
[ngClass]="isPasswordVisible() ? 'fa-eye' : 'fa-eye-slash'"
aria-hidden="true"
></i>
</button>
}
@if (type() === 'file') {
<span class="input-file-name" [class.input-file-name-empty]="!resolvedFileName()">
{{ resolvedFileName() || 'Sin archivo...' }}
</span>
}
@if (type() === 'percent') {
<span class="input-suffix">%</span>
}
@if (type() === 'editable') {
<button
type="button"
class="input-icon"
[class.input-icon-active]="isEditableActive()"
[attr.aria-label]="isEditableActive() ? 'Deshabilitar edición' : 'Habilitar edición'"
(click)="toggleEditableState()"
>
<i class="fa-solid fa-pen" aria-hidden="true"></i>
</button>
}
</div>

View File

@@ -0,0 +1,156 @@
:host {
display: block;
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
.input-control {
position: relative;
}
.input-search-icon,
.input-user-icon {
position: absolute;
right: 1rem;
top: 50%;
z-index: 1;
color: #495057;
transform: translateY(-50%);
pointer-events: none;
}
.form-control {
min-height: 40px;
padding: 0.625rem 1rem;
border-radius: 0.5rem;
color: #212529;
font-size: 15px;
font-weight: 400;
&:focus {
box-shadow: none;
}
&:disabled {
opacity: 1;
}
}
.input-with-search-icon {
padding-right: 2.5rem;
}
.input-with-action-icon {
padding-right: 2.5rem;
}
input[type='file'].form-control {
padding-right: 1rem;
color: transparent;
&::file-selector-button {
height: 2.25rem;
margin-right: 1rem;
padding: 0 1rem;
border: 0;
border-radius: 0.375rem;
background-color: var(--bs-secondary-bg);
color: #212529;
cursor: pointer;
}
}
.input-control-file {
.form-control {
position: relative;
}
}
.input-file-name {
position: absolute;
top: 50%;
left: 11.5rem;
right: 1rem;
color: #495057;
font-size: 0.875rem;
line-height: 1.4;
transform: translateY(-50%);
pointer-events: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.input-file-name-empty {
color: #6c757d;
}
.input-control-currency {
.input-prefix {
position: absolute;
left: 1rem;
top: 50%;
z-index: 1;
color: #495057;
transform: translateY(-50%);
pointer-events: none;
}
.input-with-prefix {
padding-left: 2rem;
}
}
.input-control-editable,
.input-control-password-toggle {
.input-icon {
position: absolute;
right: 0.875rem;
top: 50%;
z-index: 1;
display: inline-flex;
align-items: center;
justify-content: center;
width: 1.5rem;
height: 1.5rem;
padding: 0;
border: 0;
background: transparent;
color: #495057;
transform: translateY(-50%);
cursor: pointer;
transition: color 0.2s ease;
&:focus {
outline: none;
}
}
.input-icon-active {
color: #adb5bd;
&:hover {
color: #495057;
}
}
.input-with-icon {
padding-right: 2.5rem;
}
}
.input-control-percent {
.input-suffix {
position: absolute;
right: 1rem;
top: 50%;
z-index: 1;
color: #495057;
transform: translateY(-50%);
pointer-events: none;
}
.input-with-suffix {
padding-right: 2rem;
}
}

View File

@@ -0,0 +1,207 @@
import {
ChangeDetectionStrategy,
Component,
ElementRef,
computed,
effect,
input,
model,
output,
signal,
untracked,
viewChild
} from '@angular/core';
import { NgClass } from '@angular/common';
export type AppInputType =
| 'search'
| 'user'
| 'text'
| 'number'
| 'email'
| 'password'
| 'password-toggle'
| 'currency'
| 'percent'
| 'date'
| 'period'
| 'editable'
| 'file';
const DEFAULT_TYPE: AppInputType = 'text';
const INPUT_TYPES = new Set<AppInputType>([
'search',
'user',
'text',
'number',
'email',
'password',
'password-toggle',
'currency',
'percent',
'date',
'period',
'editable',
'file'
]);
function normalizeType(value: AppInputType | string | undefined): AppInputType {
return value && INPUT_TYPES.has(value as AppInputType)
? (value as AppInputType)
: DEFAULT_TYPE;
}
@Component({
selector: 'app-input',
imports: [NgClass],
templateUrl: './input.component.html',
styleUrl: './input.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'form-group'
}
})
export class InputComponent {
private readonly inputElement = viewChild<ElementRef<HTMLInputElement>>('inputElement');
private readonly selectedFileName = signal('');
private readonly editableDisabled = signal(false);
private readonly passwordVisible = signal(false);
private lastClearTrigger = 0;
private readonly defaultId = `app-input-${globalThis.crypto.randomUUID()}`;
readonly invalid = input(false);
readonly id = input(this.defaultId);
readonly placeholder = input('');
readonly value = model<string | number>('');
readonly maxlength = input<number | null>(null);
readonly accept = input('');
readonly fileName = input('');
readonly clearTrigger = input(0);
readonly disabled = input(false);
readonly visible = input<boolean | null>(null);
readonly type = input<AppInputType, AppInputType | string>(DEFAULT_TYPE, {
transform: normalizeType
});
readonly disabledChange = output<boolean>();
readonly fileChange = output<File | null>();
readonly visibleChange = output<boolean>();
protected readonly inputType = computed(() => {
const type = this.type();
if (type === 'password-toggle') {
return this.isPasswordVisible() ? 'text' : 'password';
}
if (
type === 'search' ||
type === 'user' ||
type === 'currency' ||
type === 'percent' ||
type === 'editable'
) {
return 'text';
}
if (type === 'period') {
return 'month';
}
return type;
});
protected readonly inputClasses = computed(() => ({
'form-control': true,
'is-invalid': this.invalid(),
'input-with-search-icon': this.type() === 'search',
'input-with-action-icon': this.type() === 'user' || this.type() === 'password-toggle',
'input-with-prefix': this.type() === 'currency',
'input-with-suffix': this.type() === 'percent',
'input-with-icon': this.type() === 'editable'
}));
protected readonly isInputDisabled = computed(() =>
this.type() === 'editable' ? this.editableDisabled() : this.disabled()
);
protected readonly isEditableActive = computed(
() => this.type() === 'editable' && !this.editableDisabled()
);
protected readonly isPasswordVisible = computed(() => {
const visible = this.visible();
return visible === null ? this.passwordVisible() : visible;
});
protected readonly resolvedFileName = computed(
() => this.selectedFileName() || this.fileName() || ''
);
constructor() {
effect(() => {
this.editableDisabled.set(this.disabled());
});
effect(() => {
if (this.type() !== 'file') {
return;
}
const clearTrigger = this.clearTrigger();
const value = this.value();
const fileName = this.fileName();
untracked(() => {
if (clearTrigger !== this.lastClearTrigger) {
this.lastClearTrigger = clearTrigger;
this.clearFileInput();
return;
}
if (!value && !fileName) {
this.clearFileInput();
}
});
});
}
protected onValueChange(event: Event): void {
this.value.set((event.target as HTMLInputElement).value);
}
protected onFileChange(event: Event): void {
const file = (event.target as HTMLInputElement).files?.[0] ?? null;
this.selectedFileName.set(file?.name ?? '');
this.fileChange.emit(file);
}
protected toggleEditableState(): void {
if (this.type() !== 'editable') {
return;
}
const nextState = !this.editableDisabled();
this.editableDisabled.set(nextState);
this.disabledChange.emit(nextState);
}
protected togglePasswordVisibility(): void {
if (this.type() !== 'password-toggle' || this.disabled()) {
return;
}
const nextState = !this.isPasswordVisible();
if (this.visible() === null) {
this.passwordVisible.set(nextState);
}
this.visibleChange.emit(nextState);
}
private clearFileInput(): void {
this.inputElement()?.nativeElement && (this.inputElement()!.nativeElement.value = '');
this.selectedFileName.set('');
}
}

View File

@@ -0,0 +1,6 @@
export const environment = {
production: false,
nombre:"Desarrollo - activo",
url:"http://localhost:8000/api/",
urlDescarga:"url/"
};

View File

@@ -0,0 +1,6 @@
export const environment = {
production: false,
nombre:"Desarrollo - activo",
url:"http://localhost:8000/api/",
urlDescarga:"url/"
};

View File

@@ -2,5 +2,24 @@ import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { App } from './app/app';
function renderBootstrapError(error: unknown): void {
const message = error instanceof Error ? error.message : 'No se pudo cargar la configuracion del tenant.';
const root = document.querySelector('app-root');
if (root) {
root.innerHTML = `
<section style="font-family: Arial, sans-serif; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #f5f5f5; color: #1f1f1f;">
<div style="max-width: 480px; width: 100%; background: #ffffff; border: 1px solid #d9d9d9; border-radius: 12px; padding: 24px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);">
<h1 style="margin: 0 0 12px; font-size: 24px;">Error al cargar el tenant</h1>
<p style="margin: 0; line-height: 1.5;">${message}</p>
</div>
</section>
`;
}
}
bootstrapApplication(App, appConfig)
.catch((err) => console.error(err));
.catch((err) => {
console.error(err);
renderBootstrapError(err);
});

View File

@@ -1 +1,25 @@
/* You can add global styles to this file, and also import other style files */
@use "./fonts";
@import "@fortawesome/fontawesome-free/css/all.min.css";
@import "./theme";
@import "../node_modules/bootstrap/scss/bootstrap";
:root {
--bs-body-font-family: "Gotham", sans-serif;
--bs-primary: var(--tenant-primary);
--bs-primary-rgb: var(--tenant-primary-rgb);
--bs-secondary: var(--tenant-secondary);
--bs-secondary-rgb: var(--tenant-secondary-rgb);
--bs-danger: var(--tenant-danger);
--bs-danger-rgb: var(--tenant-danger-rgb);
}
label {
display: block;
margin-bottom: 0.375rem;
font-size: 13px;
font-weight: 400;
}