@uxland/primary-shell 3.0.0 → 3.0.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -26,7 +26,8 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@uxland/harmonix": "^1.0.0",
29
- "axios": "^1.7.2"
29
+ "axios": "^1.7.2",
30
+ "@material/web": "^2.1.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "lit": "^3.1.0",
@@ -1,7 +1,7 @@
1
1
  import { IRegion, region } from "@uxland/regions";
2
2
  import { LitElement, css, html, unsafeCSS } from "lit";
3
3
  import { PrimariaRegionHost } from "../../../api/api";
4
- import { customElement } from "lit/decorators.js";
4
+ import { customElement, state } from "lit/decorators.js";
5
5
  import { shellRegions } from "../../../api/region-manager/regions";
6
6
  import styles from "./styles.scss?inline";
7
7
  import { template } from "./template";
@@ -34,4 +34,11 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
34
34
 
35
35
  @region({ targetId: "floating-region-container", name: shellRegions.floating })
36
36
  floatingRegion: IRegion | undefined;
37
+
38
+ @state()
39
+ sidebarExpanded = false;
40
+
41
+ _toggleSidebar() {
42
+ this.sidebarExpanded = !this.sidebarExpanded;
43
+ }
37
44
  }
@@ -36,12 +36,87 @@
36
36
  height: 100%;
37
37
  display: flex;
38
38
  .sidebar {
39
+ // padding: 24px 16px 24px 16px;
39
40
  @include layout-vertical;
40
41
  @include layout-justified;
42
+ @include layout-center;
41
43
  background: var(--color-primary-800);
42
- width: 15%;
44
+ width: 72px;
43
45
  height: 100%;
44
46
  color: white;
47
+ #menu-region-container {
48
+ min-height: 1px;
49
+ height: 100%;
50
+ width: 100%;
51
+ }
52
+ #quick-actions-region-container {
53
+ // min-height: 1px;
54
+ width: 100%;
55
+ // padding: 8px;
56
+ }
57
+ &[expanded] {
58
+ width: 252px;
59
+ @include layout-start;
60
+ }
61
+ primaria-menu {
62
+ margin-top: 24px;
63
+ }
64
+ md-menu {
65
+ cursor: pointer;
66
+ --md-menu-container-color: white;
67
+ min-width: 239px;
68
+ .menu-item {
69
+ @include layout-horizontal;
70
+ @include layout-center;
71
+ @include layout-justified;
72
+ padding: 1rem;
73
+ gap: 50px;
74
+ &:hover {
75
+ background-color: #f0f0f0;
76
+ }
77
+ }
78
+ color: var(--color-neutral-900);
79
+ }
80
+ .create-button-closed {
81
+ cursor: pointer;
82
+ background-color: #f0f0f0;
83
+ border-radius: 8px;
84
+ width: 40px;
85
+ height: 40px;
86
+ @include layout;
87
+ @include layout-horizontal;
88
+ @include layout-center;
89
+ @include layout-center-justified;
90
+ // &:hover {
91
+ // background-color: var(--color-primary-900);
92
+ // color: white;
93
+
94
+ // .dss-icon {
95
+ // color: white;
96
+ // }
97
+ // }
98
+ }
99
+ .create-button-opened {
100
+ padding: 1px;
101
+ cursor: pointer;
102
+ background-color: #f0f0f0;
103
+ border-radius: 8px;
104
+ gap: 8px;
105
+ font-weight: 600;
106
+ width: 220px;
107
+ height: 40px;
108
+ @include layout;
109
+ @include layout-horizontal;
110
+ @include layout-center;
111
+ // &:hover {
112
+ // background-color: var(--color-primary-900);
113
+ // color: white;
114
+
115
+ // .dss-icon {
116
+ // color: white;
117
+ // }
118
+ // }
119
+ }
45
120
  }
46
121
  .content {
47
122
  display: flex;
@@ -66,3 +141,43 @@
66
141
  align-self: center;
67
142
  }
68
143
  }
144
+ .divider-opened {
145
+ width: 220px;
146
+ }
147
+ .divider-closed {
148
+ width: 40px;
149
+ }
150
+ .actions-bottom {
151
+ display: flex;
152
+ flex-direction: column;
153
+ gap: 24px;
154
+ }
155
+ primaria-menu {
156
+ padding: 8px;
157
+ border-radius: 8px;
158
+ color: var(--color-primary-700);
159
+ }
160
+ .toggle-opened,
161
+ .toggle-closed {
162
+ cursor: pointer;
163
+ display: flex;
164
+ margin-bottom: 24px;
165
+ padding: 12px;
166
+ gap: 8px;
167
+ border-radius: 8px;
168
+ border: 1px;
169
+ transition: background-color 0.3s ease;
170
+ &:hover {
171
+ background-color: var(--color-primary-900);
172
+ }
173
+ }
174
+ .toggle-opened {
175
+ justify-content: flex-start;
176
+ }
177
+ .toggle-closed {
178
+ justify-content: center;
179
+ }
180
+ .close-menu {
181
+ @include layout-horizontal-reverse;
182
+ @include layout-center;
183
+ }
@@ -2,10 +2,13 @@ import "@salut/design-system-salut";
2
2
  import "@salut/design-system-salut/css/main.css";
3
3
  import "../../fonts/fonts.css";
4
4
  import "../../styles/index.css";
5
- import { html } from "lit";
5
+ import { html, nothing } from "lit";
6
6
  import gencatLogo from "../../../UI/images/Gencat_Logotip.svg";
7
7
  import salutLogo from "../../../UI/images/Salut_Logotip.svg";
8
8
  import { PrimariaShell } from "./primaria-shell";
9
+ import "@material/web/menu/menu.js";
10
+ import "@material/web/menu/menu-item.js";
11
+ import "@material/web/button/filled-button.js";
9
12
 
10
13
  export const template = (props: PrimariaShell) => html`
11
14
  <div class="container">
@@ -23,9 +26,40 @@ export const template = (props: PrimariaShell) => html`
23
26
  </div>
24
27
  </div>
25
28
  <div class="main-container">
26
- <div class="sidebar">
29
+ <div class="sidebar" ?expanded=${props.sidebarExpanded}>
30
+ <primaria-menu>
31
+ <div class="${props.sidebarExpanded ? "create-button-opened" : "create-button-closed"} " slot="anchor" id="usage-anchor">
32
+ <dss-container><span class="dss-icon dss-icon-button--md">add_circle_outline</span></dss-container>${props.sidebarExpanded ? "Crear" : nothing}
33
+ </div>
34
+ <md-menu slot="content" id="content" anchor="usage-anchor">
35
+ <div id="quick-actions-region-container"></div>
36
+ </md-menu>
37
+ </primaria-menu>
27
38
  <div id="menu-region-container"></div>
28
- <div id="quick-actions-region-container"></div>
39
+ <hr class="dss-divider--bold ${props.sidebarExpanded ? "divider-opened" : "divider-closed"}" />
40
+ <div class="actions-bottom">
41
+ <div>
42
+ <primaria-menu-item
43
+ icon="add_box"
44
+ label="Menu Item"
45
+ ></primaria-menu-item>
46
+ <primaria-menu-item
47
+ icon="add_box"
48
+ label="Menu Item"
49
+ ></primaria-menu-item>
50
+ <primaria-menu-item
51
+ icon="add_box"
52
+ label="Menu Item"
53
+ ></primaria-menu-item>
54
+ <primaria-menu-item
55
+ icon="add_box"
56
+ label="Menu Item"
57
+ ></primaria-menu-item>
58
+ </div>
59
+ <div @click=${() => props._toggleSidebar()} class="${props.sidebarExpanded ? "toggle-opened" : "toggle-closed"}">
60
+ ${!props.sidebarExpanded ? html`<dss-container><span class="dss-icon white dss-icon--fill dss-icon-button--md">expand_circle_right</span></dss-container>` : html`<dss-container class="close-menu"><span class="dss-icon white dss-icon--fill dss-icon-button--md" style="transform: rotate(180deg);">expand_circle_right</span>Tancar Menu</dss-container>`}
61
+ </div>
62
+ </div>
29
63
  </div>
30
64
  <div class="content">
31
65
  <div id="floating-region-container"></div>
@@ -1,5 +1,6 @@
1
1
  import "./primaria-content-switcher/primaria-content-switcher";
2
2
  import "./primaria-menu-item/primaria-menu-item";
3
+ import "./primaria-menu/primaria-menu";
3
4
  import "./primaria-text-editor/primaria-rich-text-editor";
4
5
  export * from "./primaria-interaction";
5
6
  import "./dss-container/dss-container";
@@ -0,0 +1,51 @@
1
+ import { LitElement, html, css, unsafeCSS } from "lit";
2
+ import { template } from "./template";
3
+ import styles from "./styles.scss?inline";
4
+ import { customElement, property, state } from "lit/decorators.js";
5
+
6
+ @customElement("primaria-menu")
7
+ export class PrimariaMenu extends LitElement {
8
+ render() {
9
+ return html`${template(this)}`;
10
+ }
11
+
12
+ static styles = css`
13
+ ${unsafeCSS(styles)}
14
+ `;
15
+
16
+ firstUpdated(p) {
17
+ super.firstUpdated(p);
18
+ // Escuchar por cambios en el contenido del slot
19
+ const slot = this.shadowRoot?.querySelector('slot[name="anchor"]');
20
+ slot?.addEventListener("slotchange", this.handleSlotChange.bind(this));
21
+ }
22
+
23
+ handleSlotChange(event) {
24
+ const slot = event.target;
25
+ const assignedElements = slot.assignedElements();
26
+
27
+ // Si hay algún elemento asignado al slot
28
+ if (assignedElements.length > 0) {
29
+ const element = assignedElements[0]; // Asumimos que el primer elemento es el botón
30
+ if (element.id === "usage-anchor") {
31
+ // Añadir el listener de evento
32
+ element.addEventListener("click", this._handleOpenMenu.bind(this));
33
+ }
34
+ }
35
+ }
36
+
37
+ _handleOpenMenu(e) {
38
+ // Obtener el otro slot (target-slot)
39
+ const targetSlot = this.shadowRoot?.querySelector('slot[name="content"]');
40
+
41
+ // Obtener los elementos asignados al otro slot
42
+ const assignedElements = targetSlot?.assignedElements();
43
+
44
+ // Hacer target al elemento que deseas (por ejemplo, un <p>)
45
+ const targetElement = assignedElements.find((el) => el.id === "content");
46
+ if (targetElement) {
47
+ // Modificar el contenido o estilo del elemento
48
+ targetElement.show();
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,9 @@
1
+ import { html } from "lit";
2
+ import { PrimariaMenu } from "./primaria-menu";
3
+
4
+ export const template = (props: PrimariaMenu) => html`
5
+ <span style="position: relative">
6
+ <slot name="anchor"></slot>
7
+ <slot name="content"></slot>
8
+ </span>
9
+ `;
@@ -1,7 +1,7 @@
1
1
  import { LitElement, html, css, unsafeCSS } from "lit";
2
2
  import { template } from "./template";
3
3
  import styles from "./styles.scss?inline";
4
- import { customElement } from "lit/decorators.js";
4
+ import { customElement, property, state } from "lit/decorators.js";
5
5
 
6
6
  @customElement("primaria-menu-item")
7
7
  export class PrimariaMenuItem extends LitElement {
@@ -11,6 +11,7 @@ export class PrimariaMenuItem extends LitElement {
11
11
  this.label = label;
12
12
  this.callbackFn = callbackFn;
13
13
  }
14
+
14
15
  render() {
15
16
  return html`${template(this)}`;
16
17
  }
@@ -19,7 +20,28 @@ export class PrimariaMenuItem extends LitElement {
19
20
  ${unsafeCSS(styles)}
20
21
  `;
21
22
 
22
- icon: string;
23
- label: string;
24
- callbackFn: () => void;
23
+ firstUpdated(p) {
24
+ super.firstUpdated(p);
25
+ this.observeHostResize();
26
+ }
27
+
28
+ observeHostResize() {
29
+ const parentElement = this.parentElement;
30
+ const observer = new ResizeObserver((entries) => {
31
+ for (const entry of entries) {
32
+ const width = entry.target.clientWidth; // Obtenemos el ancho del host
33
+ this.showText = width > 100; // Mostrar texto si el ancho del host es mayor que 150px
34
+ }
35
+ });
36
+
37
+ // Observamos el tamaño del padre host del componente
38
+ observer.observe(parentElement as HTMLElement);
39
+ }
40
+
41
+ @property({ type: Number }) containerWidth = 0;
42
+ @state() showText = false;
43
+
44
+ @property({ type: String }) icon = "";
45
+ @property({ type: String }) label = "";
46
+ @property({ type: Function }) callbackFn = () => {};
25
47
  }
@@ -1,10 +1,19 @@
1
1
  .item {
2
- display:flex;
3
- flex-direction:row;
2
+ display: flex;
3
+ flex-direction: row;
4
4
  cursor: pointer;
5
5
  border-radius: 8px;
6
6
  border: 1px;
7
7
  border-color: white;
8
- padding: 8px;
8
+ padding: 12px;
9
9
  gap: 8px;
10
+ box-sizing: border-box;
11
+ justify-content: center;
12
+ transition: background-color 0.3s ease;
13
+ &[expanded] {
14
+ justify-content: flex-start;
15
+ }
16
+ &:hover {
17
+ background-color: var(--color-primary-900);
18
+ }
10
19
  }
@@ -2,7 +2,17 @@ import { html } from "lit";
2
2
  import { PrimariaMenuItem } from "./primaria-menu-item";
3
3
 
4
4
  export const template = (props: PrimariaMenuItem) => html`
5
- <div class="item" @click=${props.callbackFn}>
5
+ <div class="item" @click=${props.callbackFn} ?expanded=${props.showText}>
6
6
  <dss-container><i class="dss-icon dss-icon--md">${props.icon}</i></dss-container>
7
- <span>${props.label}</span>
7
+ ${props.showText ? html`<span>${props.label}</span>` : ""}
8
+
9
+
10
+ <!-- <dss-container class="menu-item-container">
11
+ <i class="dss-icon dss-icon--md">${props.icon}</i>
12
+ ${props.showText ? html`<span>${props.label}</span>` : ""}
13
+
14
+ <dss-tooltip class="tooltip" position="right">
15
+ <span>${props.label} info</span>
16
+ </dss-tooltip>
17
+ </dss-container> -->
8
18
  </div>`;