slicejs-web-framework 1.0.6 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/Slice/Components/Structural/Router/Router.js +59 -33
  2. package/api/index.js +99 -0
  3. package/package.json +1 -1
  4. package/src/App/index.html +22 -0
  5. package/src/App/index.js +63 -0
  6. package/src/App/style.css +40 -0
  7. package/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.css +16 -0
  8. package/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.html +22 -0
  9. package/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.js +102 -0
  10. package/src/Components/AppComponents/CardDocumentation/CardDocumentation.css +15 -0
  11. package/src/Components/AppComponents/CardDocumentation/CardDocumentation.html +38 -0
  12. package/src/Components/AppComponents/CardDocumentation/CardDocumentation.js +113 -0
  13. package/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.css +21 -0
  14. package/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.html +35 -0
  15. package/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.js +103 -0
  16. package/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.css +130 -0
  17. package/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.html +4 -0
  18. package/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.js +263 -0
  19. package/src/Components/AppComponents/Documentation/Documentation.css +0 -0
  20. package/src/Components/AppComponents/Documentation/Documentation.html +30 -0
  21. package/src/Components/AppComponents/Documentation/Documentation.js +75 -0
  22. package/src/Components/AppComponents/DocumentationPage/DocumentationPage.css +62 -0
  23. package/src/Components/AppComponents/DocumentationPage/DocumentationPage.html +0 -0
  24. package/src/Components/AppComponents/DocumentationPage/DocumentationPage.js +283 -0
  25. package/src/Components/AppComponents/InputDocumentation/InputDocumentation.css +41 -0
  26. package/src/Components/AppComponents/InputDocumentation/InputDocumentation.html +95 -0
  27. package/src/Components/AppComponents/InputDocumentation/InputDocumentation.js +315 -0
  28. package/src/Components/AppComponents/LandingMenu/LandingMenu.css +108 -0
  29. package/src/Components/AppComponents/LandingMenu/LandingMenu.html +16 -0
  30. package/src/Components/AppComponents/LandingMenu/LandingMenu.js +33 -0
  31. package/src/Components/AppComponents/LandingPage/LandingPage.css +14 -0
  32. package/src/Components/AppComponents/LandingPage/LandingPage.html +0 -0
  33. package/src/Components/AppComponents/LandingPage/LandingPage.js +53 -0
  34. package/src/Components/AppComponents/MainMenu/MainMenu.css +80 -0
  35. package/src/Components/AppComponents/MainMenu/MainMenu.html +39 -0
  36. package/src/Components/AppComponents/MainMenu/MainMenu.js +42 -0
  37. package/src/Components/AppComponents/MyLayout/MyLayout.css +0 -0
  38. package/src/Components/AppComponents/MyLayout/MyLayout.html +0 -0
  39. package/src/Components/AppComponents/MyLayout/MyLayout.js +13 -0
  40. package/src/Components/AppComponents/MyNavigation/MyNavigation.css +49 -0
  41. package/src/Components/AppComponents/MyNavigation/MyNavigation.html +1 -0
  42. package/src/Components/AppComponents/MyNavigation/MyNavigation.js +60 -0
  43. package/src/Components/AppComponents/Playground/Playground.css +12 -0
  44. package/src/Components/AppComponents/Playground/Playground.html +0 -0
  45. package/src/Components/AppComponents/Playground/Playground.js +126 -0
  46. package/src/Components/AppComponents/RoutingDocumentation/RoutingDocumentation.css +89 -0
  47. package/src/Components/AppComponents/RoutingDocumentation/RoutingDocumentation.html +108 -0
  48. package/src/Components/AppComponents/RoutingDocumentation/RoutingDocumentation.js +177 -0
  49. package/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.css +104 -0
  50. package/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.html +12 -0
  51. package/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.js +74 -0
  52. package/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.css +21 -0
  53. package/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.html +35 -0
  54. package/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.js +103 -0
  55. package/src/Components/AppComponents/TheBuildMethod/TheBuildMethod.css +122 -0
  56. package/src/Components/AppComponents/TheBuildMethod/TheBuildMethod.html +70 -0
  57. package/src/Components/AppComponents/TheBuildMethod/TheBuildMethod.js +86 -0
  58. package/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.css +23 -0
  59. package/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.html +6 -0
  60. package/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.js +129 -0
  61. package/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.css +0 -0
  62. package/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.html +7 -0
  63. package/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.js +15 -0
  64. package/src/Components/Service/FetchManager/FetchManager.js +133 -0
  65. package/src/Components/Service/IndexedDbManager/IndexedDbManager.js +141 -0
  66. package/src/Components/Service/Link/Link.js +26 -0
  67. package/src/Components/Service/LocalStorageManager/LocalStorageManager.js +45 -0
  68. package/src/Components/Service/Translator/Translator.js +45 -0
  69. package/src/Components/Service/Translator/messages.json +58 -0
  70. package/src/Components/Visual/Button/Button.css +47 -0
  71. package/src/Components/Visual/Button/Button.html +5 -0
  72. package/src/Components/Visual/Button/Button.js +70 -0
  73. package/src/Components/Visual/Card/Card.css +68 -0
  74. package/src/Components/Visual/Card/Card.html +7 -0
  75. package/src/Components/Visual/Card/Card.js +107 -0
  76. package/src/Components/Visual/Checkbox/Checkbox.css +87 -0
  77. package/src/Components/Visual/Checkbox/Checkbox.html +8 -0
  78. package/src/Components/Visual/Checkbox/Checkbox.js +86 -0
  79. package/src/Components/Visual/Details/Details.css +70 -0
  80. package/src/Components/Visual/Details/Details.html +9 -0
  81. package/src/Components/Visual/Details/Details.js +76 -0
  82. package/src/Components/Visual/DropDown/DropDown.css +60 -0
  83. package/src/Components/Visual/DropDown/DropDown.html +5 -0
  84. package/src/Components/Visual/DropDown/DropDown.js +63 -0
  85. package/src/Components/Visual/Grid/Grid.css +7 -0
  86. package/src/Components/Visual/Grid/Grid.html +1 -0
  87. package/src/Components/Visual/Grid/Grid.js +57 -0
  88. package/src/Components/Visual/Icon/Icon.css +510 -0
  89. package/src/Components/Visual/Icon/Icon.html +1 -0
  90. package/src/Components/Visual/Icon/Icon.js +89 -0
  91. package/src/Components/Visual/Icon/slc.eot +0 -0
  92. package/src/Components/Visual/Icon/slc.json +555 -0
  93. package/src/Components/Visual/Icon/slc.styl +507 -0
  94. package/src/Components/Visual/Icon/slc.svg +1485 -0
  95. package/src/Components/Visual/Icon/slc.symbol.svg +1059 -0
  96. package/src/Components/Visual/Icon/slc.ttf +0 -0
  97. package/src/Components/Visual/Icon/slc.woff +0 -0
  98. package/src/Components/Visual/Icon/slc.woff2 +0 -0
  99. package/src/Components/Visual/Input/Input.css +91 -0
  100. package/src/Components/Visual/Input/Input.html +4 -0
  101. package/src/Components/Visual/Input/Input.js +215 -0
  102. package/src/Components/Visual/Layout/Layout.css +0 -0
  103. package/src/Components/Visual/Layout/Layout.html +0 -0
  104. package/src/Components/Visual/Layout/Layout.js +49 -0
  105. package/src/Components/Visual/Loading/Loading.css +56 -0
  106. package/src/Components/Visual/Loading/Loading.html +83 -0
  107. package/src/Components/Visual/Loading/Loading.js +38 -0
  108. package/src/Components/Visual/MultiRoute/MultiRoute.js +93 -0
  109. package/src/Components/Visual/Navbar/Navbar.css +115 -0
  110. package/src/Components/Visual/Navbar/Navbar.html +44 -0
  111. package/src/Components/Visual/Navbar/Navbar.js +141 -0
  112. package/src/Components/Visual/NotFound/NotFound.css +117 -0
  113. package/src/Components/Visual/NotFound/NotFound.html +24 -0
  114. package/src/Components/Visual/NotFound/NotFound.js +16 -0
  115. package/src/Components/Visual/Route/Route.js +93 -0
  116. package/src/Components/Visual/Select/Select.css +84 -0
  117. package/src/Components/Visual/Select/Select.html +8 -0
  118. package/src/Components/Visual/Select/Select.js +195 -0
  119. package/src/Components/Visual/Switch/Switch.css +76 -0
  120. package/src/Components/Visual/Switch/Switch.html +8 -0
  121. package/src/Components/Visual/Switch/Switch.js +102 -0
  122. package/src/Components/Visual/TreeItem/TreeItem.css +36 -0
  123. package/src/Components/Visual/TreeItem/TreeItem.html +1 -0
  124. package/src/Components/Visual/TreeItem/TreeItem.js +126 -0
  125. package/src/Components/Visual/TreeView/TreeView.css +8 -0
  126. package/src/Components/Visual/TreeView/TreeView.html +1 -0
  127. package/src/Components/Visual/TreeView/TreeView.js +48 -0
  128. package/src/Components/components.js +45 -0
  129. package/src/Styles/sliceStyles.css +34 -0
  130. package/src/Themes/Dark.css +42 -0
  131. package/src/Themes/Light.css +31 -0
  132. package/src/Themes/Slice.css +47 -0
  133. package/src/images/Slice.js-logo.png +0 -0
  134. package/src/images/favicon.ico +0 -0
  135. package/src/images/im2/Slice.js-logo.png +0 -0
  136. package/src/routes.js +77 -0
  137. package/src/sliceConfig.json +58 -0
@@ -1,4 +1,3 @@
1
-
2
1
  export default class Router {
3
2
  constructor(routes) {
4
3
  this.routes = routes;
@@ -11,16 +10,30 @@ export default class Router {
11
10
  window.addEventListener('popstate', this.onRouteChange.bind(this));
12
11
  }
13
12
 
14
- createPathToRouteMap(routes, basePath = '') {
13
+ createPathToRouteMap(routes, basePath = '', parentRoute = null) {
15
14
  const pathToRouteMap = new Map();
16
15
 
17
16
  for (const route of routes) {
18
- const fullPath = `${basePath}${route.path}`.replace(/\/+/g, '/'); // Normaliza las barras diagonales
19
- pathToRouteMap.set(fullPath, { ...route, fullPath });
17
+ const fullPath = `${basePath}${route.path}`.replace(/\/+/g, '/');
18
+
19
+ // Guardar la referencia a la ruta padre
20
+ const routeWithParent = {
21
+ ...route,
22
+ fullPath,
23
+ parentPath: parentRoute ? parentRoute.fullPath : null,
24
+ parentRoute: parentRoute
25
+ };
26
+
27
+ pathToRouteMap.set(fullPath, routeWithParent);
20
28
 
21
29
  // Si tiene rutas secundarias, también agregarlas al mapa
22
30
  if (route.children) {
23
- const childPathToRouteMap = this.createPathToRouteMap(route.children, fullPath);
31
+ const childPathToRouteMap = this.createPathToRouteMap(
32
+ route.children,
33
+ fullPath,
34
+ routeWithParent // Pasar la ruta actual como padre
35
+ );
36
+
24
37
  for (const [childPath, childRoute] of childPathToRouteMap.entries()) {
25
38
  pathToRouteMap.set(childPath, childRoute);
26
39
  }
@@ -28,7 +41,7 @@ export default class Router {
28
41
  }
29
42
 
30
43
  return pathToRouteMap;
31
- }
44
+ }
32
45
 
33
46
  async renderRoutesComponentsInPage() {
34
47
  const routeContainers = document.querySelectorAll('slice-route, slice-multi-route');
@@ -41,7 +54,6 @@ export default class Router {
41
54
  routerContainersFlag = true;
42
55
  }
43
56
  }
44
-
45
57
  return routerContainersFlag;
46
58
  }
47
59
 
@@ -66,7 +78,12 @@ export default class Router {
66
78
 
67
79
  async handleRoute(route, params) {
68
80
  const targetElement = document.querySelector('#app');
69
- const existingComponent = slice.controller.getComponent(`route-${route.component}`);
81
+
82
+ // Si tenemos una ruta con parentRoute, usamos el componente del padre
83
+ const componentName = route.parentRoute ? route.parentRoute.component : route.component;
84
+ const sliceId = `route-${componentName}`;
85
+
86
+ const existingComponent = slice.controller.getComponent(sliceId);
70
87
 
71
88
  if (slice.loading) {
72
89
  slice.loading.start();
@@ -80,9 +97,9 @@ export default class Router {
80
97
  }
81
98
  targetElement.appendChild(existingComponent);
82
99
  } else {
83
- const component = await slice.build(route.component, {
100
+ const component = await slice.build(componentName, {
84
101
  params,
85
- sliceId: `route-${route.component}`,
102
+ sliceId: sliceId,
86
103
  });
87
104
  targetElement.innerHTML = '';
88
105
  targetElement.appendChild(component);
@@ -100,7 +117,6 @@ export default class Router {
100
117
  const { route, params } = this.matchRoute(path);
101
118
 
102
119
  await this.handleRoute(route, params);
103
-
104
120
  await this.renderRoutesComponentsInPage();
105
121
  }
106
122
 
@@ -108,10 +124,19 @@ export default class Router {
108
124
  // 1. Buscar coincidencia exacta en el mapa
109
125
  const exactMatch = this.pathToRouteMap.get(path);
110
126
  if (exactMatch) {
127
+ // Si es una ruta hija y tiene un padre definido, devolvemos el padre en su lugar
128
+ if (exactMatch.parentRoute) {
129
+ // Mantenemos la información de parámetros que viene de la ruta actual
130
+ return {
131
+ route: exactMatch.parentRoute,
132
+ params: {},
133
+ childRoute: exactMatch // Guardamos la referencia a la ruta hija original
134
+ };
135
+ }
111
136
  return { route: exactMatch, params: {} };
112
137
  }
113
138
 
114
- // 2. Buscar coincidencias en rutas con parámetros (que contengan la sintaxis `${...}`)
139
+ // 2. Buscar coincidencias en rutas con parámetros
115
140
  for (const [routePattern, route] of this.pathToRouteMap.entries()) {
116
141
  if (routePattern.includes('${')) {
117
142
  const { regex, paramNames } = this.compilePathPattern(routePattern);
@@ -119,34 +144,35 @@ export default class Router {
119
144
  if (match) {
120
145
  const params = {};
121
146
  paramNames.forEach((name, i) => {
122
- params[name] = match[i + 1]; // El grupo 0 es la coincidencia completa
147
+ params[name] = match[i + 1];
123
148
  });
149
+
150
+ // Si es una ruta hija, devolvemos el padre con los parámetros
151
+ if (route.parentRoute) {
152
+ return {
153
+ route: route.parentRoute,
154
+ params: params,
155
+ childRoute: route
156
+ };
157
+ }
158
+
124
159
  return { route, params };
125
160
  }
126
161
  }
127
162
  }
128
163
 
129
- // 3. Si no hay coincidencias, retornar la ruta 404 (suponiendo que exista)
164
+ // 3. Si no hay coincidencias, retornar la ruta 404
130
165
  const notFoundRoute = this.pathToRouteMap.get('/404');
131
166
  return { route: notFoundRoute, params: {} };
132
167
  }
133
168
 
134
- /**
135
- * Convierte un patrón de ruta con parámetros en una expresión regular.
136
- * Por ejemplo, el patrón "/User/${id}" se convertirá en:
137
- * - regex: /^\/User\/([^/]+)$/
138
- * - paramNames: ['id']
139
- */
140
- compilePathPattern(pattern) {
141
- const paramNames = [];
142
- // Reemplaza cada aparición de ${param} por un grupo capturador que coincida con cualquier cosa
143
- // que no sea una barra (para que solo capture hasta la siguiente barra)
144
- const regexPattern = '^' + pattern.replace(/\$\{([^}]+)\}/g, (_, paramName) => {
145
- paramNames.push(paramName);
146
- return '([^/]+)';
147
- }) + '$';
148
-
149
- return { regex: new RegExp(regexPattern), paramNames };
150
- }
151
-
152
- }
169
+ compilePathPattern(pattern) {
170
+ const paramNames = [];
171
+ const regexPattern = '^' + pattern.replace(/\$\{([^}]+)\}/g, (_, paramName) => {
172
+ paramNames.push(paramName);
173
+ return '([^/]+)';
174
+ }) + '$';
175
+
176
+ return { regex: new RegExp(regexPattern), paramNames };
177
+ }
178
+ }
package/api/index.js ADDED
@@ -0,0 +1,99 @@
1
+ import express from 'express';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname } from 'path';
5
+ import inquirer from 'inquirer';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ import sliceConfig from '../src/sliceConfig.json' with { type: 'json' };
10
+
11
+ let server;
12
+
13
+ const app = express();
14
+ const PORT = 3001;
15
+
16
+ const isProduction = sliceConfig.production === true;
17
+ const folderDeployed = isProduction ? 'dist' : 'src';
18
+
19
+ // Servir archivos estáticos desde la carpeta 'Slice'
20
+ app.use('/Slice/', express.static(path.join(__dirname, '..', 'node_modules', 'slicejs-web-framework', 'Slice')));
21
+ // Servir archivos estáticos desde la carpeta 'App'
22
+
23
+
24
+
25
+
26
+
27
+ app.get('/testing1', (req, res) => {
28
+ res.send(` Actual route in server: __dirname: ${__dirname} __filename: ${__filename} - checking if file exists: ${path.join(__dirname, '..', 'src','App', 'index.html')}`);
29
+ });
30
+
31
+
32
+ app.use(express.static(path.join(__dirname,'..', folderDeployed)));
33
+
34
+
35
+ app.get('/testing2', (req, res) => {
36
+ res.send(` Actual route in server: __dirname: ${__dirname} __filename: ${__filename} - checking if file exists: ${path.join(__dirname, '..', 'src','App', 'index.html')}`);
37
+ });
38
+
39
+ if(isProduction){
40
+
41
+ }
42
+
43
+
44
+ // Ruta para servir el index.html desde la carpeta 'App'
45
+ app.get('*', (req, res) => {
46
+ const filePath = path.join(__dirname, '..', 'src','App', 'index.html');
47
+ res.sendFile(filePath);
48
+ });
49
+
50
+ function startServer() {
51
+ server = app.listen(PORT, () => {
52
+ showMenu();
53
+ });
54
+ }
55
+
56
+ async function showMenu() {
57
+
58
+ console.clear();
59
+ console.log("\n=================================");
60
+ console.log(" SLICE SERVER MENU ");
61
+ console.log("=================================\n");
62
+
63
+ const url = `http://localhost:${PORT}`;
64
+ console.log(`Server is running on port ${PORT}, ${url}\n`);
65
+
66
+ while (true) {
67
+ const { action } = await inquirer.prompt([
68
+ {
69
+ type: 'list',
70
+ name: 'action',
71
+ message: 'Select an option:',
72
+ choices: ['Restart Server', 'Stop Server (Exit)']
73
+ }
74
+ ]);
75
+
76
+ if (action === 'Stop Server (Exit)') {
77
+ console.log('\nShutting down server...');
78
+ server.close(() => {
79
+ console.log('Server stopped.');
80
+ process.exit(0);
81
+ });
82
+ break;
83
+ } else if (action === 'Restart Server') {
84
+ console.log('\nRestarting server...');
85
+ server.close(() => {
86
+ console.log('Server stopped. Restarting...');
87
+ startServer();
88
+ });
89
+ break;
90
+ }
91
+ }
92
+ }
93
+
94
+ startServer();
95
+
96
+
97
+ export default app;
98
+
99
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-web-framework",
3
- "version": "1.0.6",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": "20.x"
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Slice - Documentation</title>
7
+ <link rel="icon" type="image/x-icon" href="/../../images/favicon.ico" />
8
+ <link rel="stylesheet" type="text/css" href="/App/style.css" />
9
+
10
+ <!-- Prism -->
11
+
12
+
13
+
14
+ <!-- Eliminar Prism despues-->
15
+ </head>
16
+
17
+ <body>
18
+ <div id="app">
19
+ <script src="/App/index.js" type="module"></script>
20
+ </div>
21
+ </body>
22
+ </html>
@@ -0,0 +1,63 @@
1
+ import Slice from '/Slice/Slice.js';
2
+
3
+ const CACHE_NAME = 'slice-cache-v1';
4
+ const urlsToCache = [
5
+ // Añade aquí las rutas de los archivos que deseas almacenar
6
+ './Slice/Slice.js',
7
+ './Slice/Components/Structural/Logger/Logger.js',
8
+ './Slice/Components/Structural/Debugger/Debugger.js',
9
+ './Slice/Components/Structural/Router/Router.js',
10
+ './Slice/Components/Structural/Router/routes.js',
11
+ './Slice/Components/Structural/Controller/Controller.js',
12
+ './Slice/Components/Structural/StylesManager/StylesManager.js',
13
+ './Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js',
14
+ ];
15
+
16
+ self.addEventListener('install', (event) => {
17
+ event.waitUntil(
18
+ caches.open(CACHE_NAME).then((cache) => {
19
+ console.log('Opened cache');
20
+ return cache.addAll(urlsToCache);
21
+ })
22
+ );
23
+ });
24
+
25
+ self.addEventListener('fetch', (event) => {
26
+ event.respondWith(
27
+ caches.match(event.request).then((response) => {
28
+ if (response) {
29
+ return response;
30
+ }
31
+ return fetch(event.request);
32
+ })
33
+ );
34
+ });
35
+
36
+ self.addEventListener('activate', (event) => {
37
+ const cacheWhitelist = [CACHE_NAME];
38
+
39
+ event.waitUntil(
40
+ caches.keys().then((cacheNames) => {
41
+ return Promise.all(
42
+ cacheNames.map((cacheName) => {
43
+ if (cacheWhitelist.indexOf(cacheName) === -1) {
44
+ return caches.delete(cacheName);
45
+ }
46
+ })
47
+ );
48
+ })
49
+ );
50
+ });
51
+
52
+ if ('serviceWorker' in navigator) {
53
+ window.addEventListener('load', () => {
54
+ navigator.serviceWorker
55
+ .register('/service-worker.js')
56
+ .then((registration) => {
57
+ console.log('Service Worker registrado con éxito:', registration);
58
+ })
59
+ .catch((error) => {
60
+ console.log('Error al registrar el Service Worker:', error);
61
+ });
62
+ });
63
+ }
@@ -0,0 +1,40 @@
1
+ /* :root {
2
+ --docs-width: 64%;
3
+ }
4
+ slice-layout {
5
+ display: flex;
6
+ justify-content: center;
7
+ }
8
+
9
+ p {
10
+ text-align: justify;
11
+ }
12
+ h1 {
13
+ padding-top: 10px;
14
+ padding-bottom: 10px;
15
+ border-bottom: 1px solid var(--secondary-background-color);
16
+ }
17
+ h2 {
18
+ padding-top: 10px;
19
+ }
20
+ .grid-container {
21
+ overflow-x: auto;
22
+ }
23
+ @media only screen and (max-width: 770px) {
24
+ :root {
25
+ --docs-width: 100%;
26
+ }
27
+ }
28
+ * {
29
+ font-family: var(--font-family);
30
+ }
31
+ .docs_container {
32
+ color: var(--font-primary-color);
33
+ margin-top: 100px;
34
+ overflow-y: scroll;
35
+ overflow-x: hidden;
36
+ width: var(--docs-width);
37
+ padding-left: 10px;
38
+ padding-right: 10px;
39
+ padding-bottom: 25px;
40
+ } */
@@ -0,0 +1,16 @@
1
+ .buttonsGrid {
2
+ width: 100%;
3
+ }
4
+ .buttons {
5
+ width: 100%;
6
+ display: flex;
7
+ flex-direction: row;
8
+ justify-content: center;
9
+ align-items: center;
10
+ }
11
+ .buttonsContainer {
12
+ display: flex;
13
+ flex-direction: column;
14
+ justify-content: space-evenly;
15
+ /* width: 100%; */
16
+ }
@@ -0,0 +1,22 @@
1
+ <h1 id="sliceButton">Slice Button</h1>
2
+ <div class="myButton">
3
+ <p>
4
+ To build a simple Slice Button you only need to use the "slice.build"
5
+ method, just like that you have a Slice Button that you can customize with a
6
+ value prop.
7
+ </p>
8
+ </div>
9
+ <div class="colorButton">
10
+ <h2 id="customization">Customization</h2>
11
+ <p>
12
+ You can also cutomize your Slice Button specifying it's background color
13
+ with "customColor.button" and it's font color with "customColor.label".
14
+ </p>
15
+ </div>
16
+ <div class="onClick">
17
+ <h2 id="onClickCallback">onClickCallback</h2>
18
+ <p>
19
+ At last but not least you can add a function to your button with the prop
20
+ "onClickCallback".
21
+ </p>
22
+ </div>
@@ -0,0 +1,102 @@
1
+ export default class ButtonDocumentation extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+
6
+ slice.controller.setComponentProps(this, props);
7
+ this.debuggerProps = [];
8
+ }
9
+
10
+ async init() {
11
+ const grid = await slice.build('Grid', { columns: 2, rows: 1 });
12
+ grid.classList.add('buttonsGrid');
13
+
14
+ const simpleButton = await this.createButton(null, {});
15
+ const myButton = await this.createButton(
16
+ null,
17
+ {
18
+ value: 'Slice Button',
19
+ },
20
+ `{
21
+ value: "Slice Button",
22
+ }`
23
+ );
24
+
25
+ if (window.screen.width <= 770) {
26
+ grid.columns = 1;
27
+ }
28
+
29
+ await grid.setItem(simpleButton);
30
+ await grid.setItem(myButton);
31
+
32
+ this.querySelector('.myButton').appendChild(grid);
33
+
34
+ await this.createButton(
35
+ this.querySelector('.colorButton'),
36
+ {
37
+ value: 'Color Button',
38
+ customColor: { label: 'black', button: 'red' },
39
+ },
40
+ `{
41
+ value: "Color Button",
42
+ customColor: { label: "black", button: "red" },
43
+ }`
44
+ );
45
+ const clickButton = await this.createButton(
46
+ this.querySelector('.onClick'),
47
+ {
48
+ value: 'Click',
49
+ onClickCallback: () => {
50
+ if (clickButton.value === 'Click') {
51
+ clickButton.value = 'Clicked';
52
+ } else {
53
+ clickButton.value = 'Click';
54
+ }
55
+ },
56
+ },
57
+ `{
58
+ value: "Click",
59
+ onClickCallback: () => {
60
+ if (myButton.value === "Click") {
61
+ myButton.value = "Clicked";
62
+ } else {
63
+ myButton.value = "Click";
64
+ }
65
+ },
66
+ }`
67
+ );
68
+ }
69
+
70
+ async createButton(appendTo, buttonProps, codeProps) {
71
+ if (!codeProps) {
72
+ codeProps = '{}';
73
+ }
74
+ const myButton = await slice.build('Button', buttonProps);
75
+
76
+ const componentCode = await slice.build('CodeVisualizer', {
77
+ value: `const myButton = await slice.build("Button", ${codeProps});
78
+
79
+ `,
80
+ language: 'javascript',
81
+ });
82
+
83
+ const div = document.createElement('div');
84
+ const buttonDiv = document.createElement('div');
85
+ buttonDiv.classList.add('buttons');
86
+ buttonDiv.appendChild(myButton);
87
+ div.classList.add('buttonsContainer');
88
+ div.appendChild(buttonDiv);
89
+ div.appendChild(componentCode);
90
+
91
+ if (appendTo) {
92
+ appendTo.appendChild(div);
93
+ }
94
+ if (buttonProps.onClickCallback) {
95
+ return myButton;
96
+ }
97
+
98
+ return div;
99
+ }
100
+ }
101
+
102
+ customElements.define('slice-buttondocumentation', ButtonDocumentation);
@@ -0,0 +1,15 @@
1
+ :root {
2
+ --cards-padding: 30%;
3
+ }
4
+ .cards {
5
+ padding-left: var(--cards-padding);
6
+ padding-right: var(--cards-padding);
7
+ margin-top: 50px;
8
+ margin-bottom: 50px;
9
+ }
10
+
11
+ @media only screen and (max-width: 770px) {
12
+ :root {
13
+ --cards-padding: 20px;
14
+ }
15
+ }
@@ -0,0 +1,38 @@
1
+ <h1 id="sliceCard">Slice Card</h1>
2
+ <div class="sliceCard">
3
+ <p>
4
+ When building a "Card" component, by default it's created with the Slice
5
+ logo, and with a default title and text.
6
+ </p>
7
+ </div>
8
+ <div class="myCard">
9
+ <h2 id="myCard">Title and Text</h2>
10
+ <p>
11
+ To build your own Slice Card with your information it's as simple as just
12
+ adding "title" and "text" props to your component.
13
+ </p>
14
+ </div>
15
+ <div class="cardClick">
16
+ <h2 id="cardClick">Click Event | "isOpen" prop</h2>
17
+ <p>
18
+ The Slice Card component has an click eventListener. While the card is
19
+ uncovered and shows the information inside, it's cover can be clicked to
20
+ keep open. Changing it's "isOpen" prop to true. That same eventListener can
21
+ change it back to false, and cover up the card again.
22
+ </p>
23
+ </div>
24
+ <h1 id="customization">Customization</h1>
25
+ <div class="cardIcon">
26
+ <h2 id="icon">Icon</h2>
27
+ <p>
28
+ You can start your Slice Card customization by assignin another icon to it.
29
+ </p>
30
+ </div>
31
+ <div class="cardColor">
32
+ <h2 id="customColor">Custom Color</h2>
33
+ <p>
34
+ You can also change card color by using "customColor" props, using
35
+ "customColor.card" to change it's background, and "customColor.icon" to
36
+ change the icon's color.
37
+ </p>
38
+ </div>