@3ddv/software-division-components 1.0.0-alpha.3 → 1.0.0-alpha.3.10
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/README.md +51 -297
- package/backoffice/table/table.component.d.ts +2 -15
- package/backoffice/table/table.component.d.ts.map +1 -1
- package/backoffice/table/types.d.ts.map +1 -1
- package/dvm/public-api.d.ts +0 -1
- package/dvm/public-api.d.ts.map +1 -1
- package/esm2022/backoffice/table/components/body-row/body-row.component.mjs +26 -8
- package/esm2022/backoffice/table/components/header-row/header-row.component.mjs +56 -7
- package/esm2022/backoffice/table/table.component.mjs +73 -31
- package/esm2022/backoffice/table/table.service.mjs +9 -9
- package/esm2022/backoffice/table/types.mjs +1 -1
- package/esm2022/dvm/cart/cart.component.mjs +15 -7
- package/esm2022/dvm/cart/cart.service.mjs +9 -9
- package/esm2022/dvm/cart-item/cart-item.component.mjs +15 -7
- package/esm2022/dvm/cart-item/cart-item.service.mjs +9 -9
- package/esm2022/dvm/legend/legend.component.mjs +15 -7
- package/esm2022/dvm/legend/legend.service.mjs +9 -9
- package/esm2022/dvm/loader/loader.component.mjs +15 -7
- package/esm2022/dvm/loader/loader.service.mjs +9 -9
- package/esm2022/dvm/popover/popover.component.mjs +15 -7
- package/esm2022/dvm/popover/popover.service.mjs +9 -9
- package/esm2022/dvm/public-api.mjs +1 -2
- package/esm2022/dvm/stepper/stepper.component.mjs +15 -7
- package/esm2022/dvm/stepper/stepper.service.mjs +9 -9
- package/esm2022/dvm/ticket-info-item/ticket-info-item.component.mjs +15 -7
- package/esm2022/dvm/ticket-info-item/ticket-info-item.service.mjs +9 -9
- package/esm2022/generic/button/button.component.mjs +22 -15
- package/esm2022/generic/button/types.mjs +1 -5
- package/esm2022/generic/drawer/drawer.component.mjs +15 -7
- package/esm2022/generic/drawer/drawer.service.mjs +9 -9
- package/esm2022/generic/modal/modal.component.mjs +15 -7
- package/esm2022/generic/modal/modal.service.mjs +9 -9
- package/esm2022/public-api.mjs +3 -4
- package/esm2022/shared/format-value.pipe.mjs +11 -11
- package/esm2022/shared/theme-provider.directive.mjs +31 -0
- package/esm2022/shared/theme.service.mjs +6 -0
- package/esm2022/shared/types.mjs +1 -1
- package/esm2022/utils/validate-styles-for-component.mjs +5 -19
- package/fesm2022/3ddv-software-division-components.mjs +417 -584
- package/fesm2022/3ddv-software-division-components.mjs.map +1 -1
- package/generic/button/button.component.d.ts +5 -7
- package/generic/button/button.component.d.ts.map +1 -1
- package/package.json +4 -29
- package/public-api.d.ts +2 -1
- package/public-api.d.ts.map +1 -1
- package/shared/{theme-provider/theme-provider.directive.d.ts → theme-provider.directive.d.ts} +1 -1
- package/shared/theme-provider.directive.d.ts.map +1 -0
- package/shared/theme.service.d.ts +9 -0
- package/shared/theme.service.d.ts.map +1 -0
- package/shared/types.d.ts +0 -4
- package/shared/types.d.ts.map +1 -1
- package/utils/validate-styles-for-component.d.ts +1 -1
- package/utils/validate-styles-for-component.d.ts.map +1 -1
- package/backoffice/table/directives/table.directive.d.ts +0 -10
- package/backoffice/table/directives/table.directive.d.ts.map +0 -1
- package/dvm/neighbours/index.d.ts +0 -2
- package/dvm/neighbours/index.d.ts.map +0 -1
- package/dvm/neighbours/neighbours.component.d.ts +0 -126
- package/dvm/neighbours/neighbours.component.d.ts.map +0 -1
- package/dvm/neighbours/public-api.d.ts +0 -2
- package/dvm/neighbours/public-api.d.ts.map +0 -1
- package/dvm/neighbours/styles/side-button.tokens.d.ts +0 -16
- package/dvm/neighbours/styles/side-button.tokens.d.ts.map +0 -1
- package/dvm/neighbours/types.d.ts +0 -7
- package/dvm/neighbours/types.d.ts.map +0 -1
- package/esm2022/backoffice/table/directives/table.directive.mjs +0 -99
- package/esm2022/dvm/neighbours/index.mjs +0 -2
- package/esm2022/dvm/neighbours/neighbours.component.mjs +0 -170
- package/esm2022/dvm/neighbours/public-api.mjs +0 -2
- package/esm2022/dvm/neighbours/styles/side-button.tokens.mjs +0 -19
- package/esm2022/dvm/neighbours/types.mjs +0 -2
- package/esm2022/private-exports.mjs +0 -2
- package/esm2022/shared/index.mjs +0 -2
- package/esm2022/shared/lib-provider/config-token.mjs +0 -3
- package/esm2022/shared/lib-provider/index.mjs +0 -2
- package/esm2022/shared/lib-provider/provide-sdc.mjs +0 -36
- package/esm2022/shared/lib-provider/public-api.mjs +0 -2
- package/esm2022/shared/public-api.mjs +0 -5
- package/esm2022/shared/theme-provider/generic-theme.mjs +0 -10
- package/esm2022/shared/theme-provider/index.mjs +0 -2
- package/esm2022/shared/theme-provider/public-api.mjs +0 -3
- package/esm2022/shared/theme-provider/theme-provider.directive.mjs +0 -29
- package/esm2022/utils/index.mjs +0 -2
- package/esm2022/utils/public-api.mjs +0 -2
- package/private-exports.d.ts +0 -2
- package/private-exports.d.ts.map +0 -1
- package/shared/index.d.ts +0 -2
- package/shared/index.d.ts.map +0 -1
- package/shared/lib-provider/config-token.d.ts +0 -4
- package/shared/lib-provider/config-token.d.ts.map +0 -1
- package/shared/lib-provider/index.d.ts +0 -2
- package/shared/lib-provider/index.d.ts.map +0 -1
- package/shared/lib-provider/provide-sdc.d.ts +0 -11
- package/shared/lib-provider/provide-sdc.d.ts.map +0 -1
- package/shared/lib-provider/public-api.d.ts +0 -2
- package/shared/lib-provider/public-api.d.ts.map +0 -1
- package/shared/public-api.d.ts +0 -5
- package/shared/public-api.d.ts.map +0 -1
- package/shared/theme-provider/generic-theme.d.ts +0 -2
- package/shared/theme-provider/generic-theme.d.ts.map +0 -1
- package/shared/theme-provider/index.d.ts +0 -2
- package/shared/theme-provider/index.d.ts.map +0 -1
- package/shared/theme-provider/public-api.d.ts +0 -3
- package/shared/theme-provider/public-api.d.ts.map +0 -1
- package/shared/theme-provider/theme-provider.directive.d.ts.map +0 -1
- package/utils/index.d.ts +0 -2
- package/utils/index.d.ts.map +0 -1
- package/utils/public-api.d.ts +0 -2
- package/utils/public-api.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Software Division Components
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Overview
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
The Software Division Components library is a wrapper around the [PrimeNG](https://v18.primeng.org/installation) component library
|
|
9
|
+
The Software Division Components library is a wrapper around the [PrimeNG](https://v18.primeng.org/installation) component library that provides extra functionality based on common needs within the Software Division department applications. It also uses [Angular](https://v18.angular.dev/) and [Storybook](https://storybook.js.org/).
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Installation
|
|
12
12
|
|
|
13
13
|
To install the library, use npm:
|
|
14
14
|
|
|
@@ -16,216 +16,88 @@ To install the library, use npm:
|
|
|
16
16
|
npm install @3ddv/software-division-components
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
> **Note: This is a temporary workflow for reporting issues. As the usage of the library increases, we will reassess and scale the issue reporting system accordingly.**
|
|
22
|
-
|
|
23
|
-
To report an issue, please visit [the following ticket](https://mmcbcn.atlassian.net/browse/TICKETING-598) and create a **Bug** ticket. Ensure that your report includes a clear and detailed description of the issue you are encountering..
|
|
24
|
-
|
|
25
|
-
## **Project summary**
|
|
26
|
-
|
|
27
|
-
The source folder of this project contains multiple subfolders. Below are the most important ones:
|
|
28
|
-
|
|
29
|
-
- **Backoffice**
|
|
30
|
-
This folder contains components that are **exclusive to the backoffice setting**, such as tables or sidebars. These components do **not** receive any styling from the theme class passed on initialization (be it `generic` or `backoffice`).
|
|
31
|
-
|
|
32
|
-
Some components from the Generic folder can also be used in the backoffice, but in such cases, the backoffice theme must be passed to the library provider. This ensures that no additional styles are applied, keeping the default PrimeNG design intact.
|
|
33
|
-
|
|
34
|
-
- **DVM**
|
|
35
|
-
This folder includes components specific to applications that use **DVM**. Many of these components share both style and functionality, and this module is designed to **maximize reusability**. Examples include the **section navigator buttons** and the **minimap**.
|
|
36
|
-
|
|
37
|
-
- **Generic**
|
|
38
|
-
This folder contains components which can be used in **any** setting. The appearance of these components relies heavily on the parameter that is passed to the library provider (generic or backoffice).
|
|
39
|
-
|
|
40
|
-
- **Shared**
|
|
41
|
-
This folder contains **initialization methods, directives and shared utilities, which are exposed to the library API**, like methods to aid with the usage of the library or debugging of the library.
|
|
42
|
-
|
|
43
|
-
- **Utils**
|
|
44
|
-
This folder contains **internal tools** which can also be shared across the library, but this is more directed to functions used by the developer to **streamline processes and reuse common logic**.
|
|
45
|
-
|
|
46
|
-
## **Common library errors**
|
|
47
|
-
|
|
48
|
-
**❌ Error: `Invalid CSS class string found on ...`**
|
|
49
|
-
|
|
50
|
-
This indicates that the `stylesClasses` input that you provided to the component does not have a valid format.
|
|
51
|
-
|
|
52
|
-
**✅ Solution:**
|
|
53
|
-
Ensure that the value assigned to `styleClasses` follows the correct format as documented in the respective component's guidelines.
|
|
54
|
-
|
|
55
|
-
If the issue persists, refer to the documentation or check for any unintended modifications in the `styleClasses` input.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
> Any future errors will be documented here
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## **How to use the library from the consuming application**
|
|
19
|
+
## Usage
|
|
64
20
|
|
|
65
21
|
### Theming and styling
|
|
66
22
|
|
|
67
|
-
This library is a wrapper to an already existing component library
|
|
23
|
+
This library is a wrapper to an already existing component library, so there are some styles which are already present in all the components. These styles are kept intact whenever the `backoffice` theme parameter is passed. You also have the option of passing the `generic` parameter, which in turn makes the component align to the design that several ticketing applications share. You can check that design [here](https://xd.adobe.com/view/0ea7033e-8fdf-4fcd-8215-546d1df20d37-5bf4/) and [here](https://xd.adobe.com/view/c640d5a1-b5d3-4379-8684-fb860f95f052-9313/grid).
|
|
68
24
|
|
|
69
|
-
Styling components
|
|
25
|
+
Styling components works as if you were styling a usual HTML element. Every component has a `styleClasses` input which accepts a single or several whitespace-separated CSS class/classes declared within the using application.
|
|
70
26
|
|
|
71
27
|
```css
|
|
72
28
|
.my-class {
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```html
|
|
78
|
-
<sdc-button styleClasses="my-class"></sdc-button>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### Specifity issues
|
|
82
|
-
|
|
83
|
-
If you are facing any specifity problems, each component also has an ID reference so you can later add them on your styles composition, giving advantage to the specifity algorithm to prioritize your styles:
|
|
84
|
-
|
|
85
|
-
```css
|
|
86
|
-
#sdc-button.my-class {
|
|
87
|
-
--p-button-primary-background: red;
|
|
29
|
+
background-color: red;
|
|
88
30
|
}
|
|
89
31
|
```
|
|
90
32
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Depending on the Encapsulation option that you are using in your component, some styles will not apply. In that scenario, declare the style as follows:
|
|
96
|
-
|
|
97
|
-
```css
|
|
98
|
-
::ng-deep.my-class {
|
|
99
|
-
--p-button-primary-background: red;
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
You also have the option with SCSS to nest:
|
|
104
|
-
|
|
105
|
-
```css
|
|
106
|
-
::ng-deep {
|
|
107
|
-
&.my-class-1 {
|
|
108
|
-
--p-button-primary-background: red;
|
|
109
|
-
}
|
|
110
|
-
&.my-class-2 {
|
|
111
|
-
--p-button-primary-background: green;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&.my-class-3 {
|
|
115
|
-
--p-button-primary-background: blue;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Or declare the style in your root stylesheet to avoid any view encapsulation to affect your custom styles. (not recommended)
|
|
121
|
-
|
|
122
|
-
#### Several styleClasses inputs
|
|
123
|
-
|
|
124
|
-
Some components are composed of several underlying components, so a single `styleClass` input will not be enough. For those scenarios, some components require the `styleClasses` paramater to be composed of an object, with each key targetting different parts of the component:
|
|
33
|
+
```typescript
|
|
34
|
+
<sdc-button
|
|
35
|
+
styleClasses='my-class'
|
|
36
|
+
></sdc-button>
|
|
125
37
|
|
|
126
|
-
```html
|
|
127
|
-
<sdc-neighbours
|
|
128
|
-
[currentSection]="..."
|
|
129
|
-
[sectionsMmcToTdc]="..."
|
|
130
|
-
[neigboursData]="..."
|
|
131
|
-
[styleClasses]=`{
|
|
132
|
-
sideButtonsClass: 'mock-side-button',
|
|
133
|
-
middleDivClass: 'mock-middle-div'
|
|
134
|
-
}`
|
|
135
|
-
></sdc-neighbours>
|
|
136
38
|
```
|
|
137
39
|
|
|
138
|
-
With this method, we are able to apply certain styles for the buttons on the sides ( with `sideButtonsClass`) and a different one for the `div` on the middle of the component template (with `middleDivClass`).
|
|
139
|
-
|
|
140
40
|
Styles will pierce through the PrimeNG layer and directly style the underlying HTML element. If you are facing any problem styling any component, please check the [official PrimeNG documentation on theming](https://v18.primeng.org/theming) or the individual webpage for styling each component [as in this example for the button component](https://v18.primeng.org/button).
|
|
141
41
|
|
|
142
|
-
###
|
|
42
|
+
### Importing the library
|
|
143
43
|
|
|
144
|
-
|
|
44
|
+
#### Setting a theme
|
|
145
45
|
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@tailwind components;
|
|
150
|
-
}
|
|
46
|
+
```ts
|
|
47
|
+
import { ApplicationConfig } from '@angular/core';
|
|
48
|
+
import { provideSdComponentsTheme } from '@3ddv/software-division-components';
|
|
151
49
|
|
|
152
|
-
|
|
50
|
+
export const appConfig: ApplicationConfig = {
|
|
51
|
+
// this can be generic or backoffice
|
|
52
|
+
providers: [provideSdComponentsTheme({ theme: 'generic' })],
|
|
53
|
+
};
|
|
153
54
|
```
|
|
154
55
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
### Passing inputs to components that have a lot of props
|
|
158
|
-
|
|
159
|
-
Besides all the documented inputs that components have, some components also have the option to pass all components in an object to end up with a more concise template markup, instead of using individual bindings.
|
|
56
|
+
#### Import from main entry
|
|
160
57
|
|
|
161
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
import { TableComponent, ButtonComponent } from '@3ddv/software-division-components';
|
|
60
|
+
```
|
|
162
61
|
|
|
163
|
-
|
|
62
|
+
#### Import from secondary entry
|
|
164
63
|
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
type="button"
|
|
168
|
-
label="Hover to trigger"
|
|
169
|
-
ariaLabel="Hover to trigger"
|
|
170
|
-
tooltip="You triggered the tooltip"
|
|
171
|
-
tooltipPos="right"
|
|
172
|
-
severity="primary"
|
|
173
|
-
styleClasses="tooltip-padding" />
|
|
64
|
+
```typescript
|
|
65
|
+
import { ButtonComponent } from '@3ddv/software-division-components/generic/button';
|
|
174
66
|
```
|
|
175
67
|
|
|
176
|
-
|
|
68
|
+
## **Reporting issues**
|
|
177
69
|
|
|
178
|
-
|
|
179
|
-
import { ButtonProps } from '@3ddv/software-division-components';
|
|
70
|
+
> **This is a temporary workflow to report issues until the usage of the library grows and we find ourselves in the need to scale this issue reporting system.**
|
|
180
71
|
|
|
181
|
-
|
|
182
|
-
// You can of course declare, this where it better suits your use case
|
|
183
|
-
protected props = {
|
|
184
|
-
type: 'button',
|
|
185
|
-
label: 'Hover to trigger',
|
|
186
|
-
ariaLabel: 'Hover to trigger',
|
|
187
|
-
severity: 'primary',
|
|
188
|
-
tooltip: 'You triggered the tooltip',
|
|
189
|
-
tooltipPos: 'right',
|
|
190
|
-
styleClasses: 'tooltip-padding',
|
|
191
|
-
} satisfies ButtonProps;
|
|
192
|
-
}
|
|
193
|
-
```
|
|
72
|
+
To report an issue, please visit [the following ticket](https://mmcbcn.atlassian.net/browse/TICKETING-598) and open a Bug ticket with a clear description of the issue you are facing.
|
|
194
73
|
|
|
195
|
-
|
|
74
|
+
## **Project summary**
|
|
196
75
|
|
|
197
|
-
|
|
198
|
-
<sdc-button [props]="{props}" />
|
|
199
|
-
```
|
|
76
|
+
This project source folder contains multiple folders, the most important are the following:
|
|
200
77
|
|
|
201
|
-
|
|
78
|
+
- **Backoffice**
|
|
79
|
+
This folder contains components that are exclusive to the backoffice setting, such as tables or sidebars. These components do not receive any styling from the theme class passed on initialization (be it `generic` or `backoffice`). There are some components in the Generic folder which can also be used in the backoffice, but please do so by passing the `backoffice` theme to the library provider. The `backoffice` parameter tells the system to not apply any styles to the components, keeping the design to the one PrimeNG already has by default.
|
|
202
80
|
|
|
203
|
-
|
|
81
|
+
- **DVM**
|
|
82
|
+
This folder contains components that are exclusive to an application that uses DVM. There are a lot of components that are common both in style and functionality, and this module aims to reuse those as much as posible. Some examples of these components are the section navigator buttons or the minimap.
|
|
204
83
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
import { provideSdc } from '@3ddv/software-division-components';
|
|
84
|
+
- **Generic**
|
|
85
|
+
This folder contains components which can be used in any setting. The appearance of these components relies heavily on the parameter that is passed to the library provider (generic or backoffice).
|
|
208
86
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// to make it work
|
|
212
|
-
providers: [provideSdc({ theme: 'generic' })],
|
|
213
|
-
};
|
|
214
|
-
```
|
|
87
|
+
- **Shared**
|
|
88
|
+
This folder contains initialization methods, directives and other methods to aid with the usage and debugging of the library.
|
|
215
89
|
|
|
216
|
-
|
|
90
|
+
- **Utils**
|
|
91
|
+
This folder contains internal tools which can also be shared across the library, but this is more directed to functions used by the developer to streamline processes and reuse common logic.
|
|
217
92
|
|
|
218
|
-
|
|
219
|
-
import { TableComponent, ButtonComponent } from '@3ddv/software-division-components';
|
|
220
|
-
```
|
|
93
|
+
### Common @3ddv/software-division-components errors
|
|
221
94
|
|
|
222
|
-
####
|
|
95
|
+
#### Error console `Invalid CSS class string found on ...`
|
|
223
96
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```
|
|
97
|
+
This indicates that the `stylesClasses` input that you provided to the component does not have a valid format. Please make sure
|
|
98
|
+
to adhere to a valid format documented in the component.
|
|
227
99
|
|
|
228
|
-
## **How to collaborate
|
|
100
|
+
## **How to collaborate**
|
|
229
101
|
|
|
230
102
|
### Semantic versioning
|
|
231
103
|
|
|
@@ -264,6 +136,8 @@ If the commit message does not adhere to the Conventional Commits format, Commit
|
|
|
264
136
|
|
|
265
137
|
- Rinse and repeat.
|
|
266
138
|
|
|
139
|
+
## **How to document your changes**
|
|
140
|
+
|
|
267
141
|
### Documenting component files
|
|
268
142
|
|
|
269
143
|
When documenting your code changes, we use JSDoc to ensure that all JavaScript functions and components are described comprehensively. This helps maintain clarity and understandability throughout the codebase.
|
|
@@ -303,132 +177,12 @@ export class ButtonComponent extends Button {
|
|
|
303
177
|
*/
|
|
304
178
|
public handleClick(event: MouseEvent): void {
|
|
305
179
|
// Implementation should document any steps that cannot be easily explained
|
|
306
|
-
// with variable names. Another scenario
|
|
180
|
+
// with variable names. Another scenario might be on documenting why things
|
|
307
181
|
// are done the way they are done (there might be some framework or language limitation).
|
|
308
182
|
}
|
|
309
183
|
}
|
|
310
184
|
```
|
|
311
185
|
|
|
312
|
-
### Internally overriding PrimeNG styles with component scope
|
|
313
|
-
|
|
314
|
-
> First of all, we would like to clarify that this is a different feature from the previously mentioned `styleClasses` feature. Style classes are thought of as a styling interface for the users of the library. This feature is to be used for developers working on component development and wanting to override any styles of PrimeNG components, so custom components adhere to the styling required.
|
|
315
|
-
|
|
316
|
-
In some cases, specially if we are developing a component placed within the `generic` scope, we will need to override any required native styles from PrimeNG to be able to adhere to the design provided by our design team.
|
|
317
|
-
|
|
318
|
-
PrimeNG provides us with a tool called [Design Tokens](https://v18.primeng.org/theming), which consists of a CSS-in-JS solution that composes a nested object which targets several styles of each component. Here is an example corresponding to the Neighbours component:
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
// Import types from PrimeNG module
|
|
322
|
-
import { ButtonDesignTokens } from '@primeng/themes/types/button';
|
|
323
|
-
|
|
324
|
-
// Create an export an object which will later by used in neighbours.components.ts
|
|
325
|
-
export const sideButtonTokens = {
|
|
326
|
-
root: {
|
|
327
|
-
primary: {
|
|
328
|
-
// Overwrite the theme variables with PrimeNG existing variables
|
|
329
|
-
// Button text
|
|
330
|
-
color: '',
|
|
331
|
-
borderColor: '{zinc.50}',
|
|
332
|
-
hoverColor: '',
|
|
333
|
-
activeColor: '',
|
|
334
|
-
// Button background
|
|
335
|
-
background: '{zinc.50}',
|
|
336
|
-
hoverBackground: '{zinc.50}',
|
|
337
|
-
activeBackground: '{zinc.50}',
|
|
338
|
-
// Button border
|
|
339
|
-
activeBorderColor: '{zinc.50}',
|
|
340
|
-
hoverBorderColor: '{zinc.50}',
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
} satisfies ButtonDesignTokens;
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
And we pass in the styles within the component template
|
|
347
|
-
|
|
348
|
-
```ts
|
|
349
|
-
import { sideButtonTokens } from './styles/side-button.tokens';
|
|
350
|
-
....
|
|
351
|
-
export class NeighboursComponent {
|
|
352
|
-
...
|
|
353
|
-
protected readonly sideButtonStyle = sideButtonTokens;
|
|
354
|
-
...
|
|
355
|
-
}
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
Template example:
|
|
359
|
-
|
|
360
|
-
```html
|
|
361
|
-
<!-- [dt] is a default input which is present in all components to declare PrimeNG design tokens -->
|
|
362
|
-
<sdc-button [dt]="sideButtonStyle" />
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
This way, we accomplished adhering to the styling that this component needed, which brings this result:
|
|
366
|
-
|
|
367
|
-
<div style="display: flex; align-items: center; gap: 20px;">
|
|
368
|
-
<div style="text-align: center;">
|
|
369
|
-
<p>Before Styling</p>
|
|
370
|
-
<img src="./projects/software-division-components/public/neighbours-before.png" alt="Before styling neighbours." width="300">
|
|
371
|
-
</div>
|
|
372
|
-
<div style="text-align: center;">
|
|
373
|
-
<p>After Styling</p>
|
|
374
|
-
<img src="./projects/software-division-components/public/neighbours-after.png" alt="After styling neighbours." width="300">
|
|
375
|
-
</div>
|
|
376
|
-
</div>
|
|
377
|
-
|
|
378
|
-
### Styling native HTML elements
|
|
379
|
-
|
|
380
|
-
For styling native HTML elements in our project, we adhere to the **Block-Element-Modifier (BEM)** methodology. This ensures that our styles remain modular, maintainable, and predictable.
|
|
381
|
-
|
|
382
|
-
#### Guidelines for Using BEM
|
|
383
|
-
|
|
384
|
-
- **Use BEM for anything that is not a design token.**
|
|
385
|
-
|
|
386
|
-
- Design tokens (e.g., colors, typography, spacing) should be handled via variables, custom properties, or a design system, not through BEM class names.
|
|
387
|
-
|
|
388
|
-
- **Use design tokens for everything that involves styling a native PrimeNG component.**
|
|
389
|
-
|
|
390
|
-
- PrimeNG components already use design tokens, so we must align with them instead of defining custom BEM classes.
|
|
391
|
-
|
|
392
|
-
- **Native HTML elements must always be styled using BEM classes.**
|
|
393
|
-
- Avoid styling elements directly by tag selectors (e.g., button {} or input {}), as this can lead to specificity conflicts and unintended side effects.
|
|
394
|
-
- **Structure your class names properly:**
|
|
395
|
-
- Use meaningful blocks that represent standalone components.
|
|
396
|
-
- Define elements as child parts of blocks.
|
|
397
|
-
- Use modifiers to indicate variations in style or behavior.
|
|
398
|
-
|
|
399
|
-
By following this approach, we ensure that:
|
|
400
|
-
|
|
401
|
-
- Styles are reusable and scoped properly.
|
|
402
|
-
- We avoid unnecessary global overrides.
|
|
403
|
-
- We maintain consistency across the project.
|
|
404
|
-
- PrimeNG components remain compatible with design tokens.
|
|
405
|
-
|
|
406
|
-
Any further information regarding the BEM methodology can be found through the following links:
|
|
407
|
-
|
|
408
|
-
- https://css-tricks.com/bem-101/
|
|
409
|
-
- https://getbem.com/introduction/
|
|
410
|
-
- https://stackoverflow.com/questions/36703546/what-is-bem-methodology
|
|
411
|
-
- https://gauravmahlawat.github.io/online-bem-generator.html#google_vignette
|
|
412
|
-
|
|
413
|
-
#### Why are we not internally using Tailwind or SCSS?
|
|
414
|
-
|
|
415
|
-
###### Why no Tailwind?
|
|
416
|
-
|
|
417
|
-
We are not internally using Tailwind because this project has the intention of having a long lifespan, we do not want to introduce an extra dependency that could cause compatibility issues with PrimeNG, Angular, and Storybook.
|
|
418
|
-
Since our project already relies on component libraries that define their own styles and classes, Tailwind’s utility-based approach could lead to conflicts and unnecessary complexity. For all we know, Tailwind is more likely to not be that popular in the near future than native CSS :).
|
|
419
|
-
|
|
420
|
-
However, we have included in the roadmap the ability to pass Tailwind classes within the `styleClasses` prop, present in most components so you can use Tailwind from your consuming application.
|
|
421
|
-
|
|
422
|
-
###### Why no SCSS?
|
|
423
|
-
|
|
424
|
-
We are not using SCSS because modern CSS now provides most of SCSS’s features natively.
|
|
425
|
-
With CSS evolving rapidly (e.g., CSS variables, nesting, container queries, @layer, @scope, and :has()), there is little need for a preprocessor like SCSS.
|
|
426
|
-
Additionally, relying on native CSS ensures:
|
|
427
|
-
|
|
428
|
-
- Better browser compatibility.
|
|
429
|
-
- No build-step dependencies.
|
|
430
|
-
- Future-proof styling that aligns with upcoming CSS standards.
|
|
431
|
-
|
|
432
186
|
### Properly exporting a newly added component
|
|
433
187
|
|
|
434
188
|
Whenever a newly added component is added, do not forget to add a secondary entrypoint to be able to uniquely import that component in the consuming app:
|
|
@@ -3,25 +3,12 @@ import { MenuItem } from 'primeng/api';
|
|
|
3
3
|
import { Table } from 'primeng/table';
|
|
4
4
|
import { ObjectColumnData } from './types';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
|
-
/**
|
|
7
|
-
* A customizable table component built on PrimeNG's Table.
|
|
8
|
-
*
|
|
9
|
-
* This component extends the PrimeNG Table by introducing additional configurations and styling
|
|
10
|
-
* capabilities. It supports defining column data, enabling sorting, exporting data, and integrating
|
|
11
|
-
* context menu options for enhanced user interactions. Additionally, the component allows for dynamic
|
|
12
|
-
* styling through custom CSS classes and leverages Angular's standalone component pattern with OnPush
|
|
13
|
-
* change detection for performance optimization.
|
|
14
|
-
*
|
|
15
|
-
* @since 1.0.0-alpha.2
|
|
16
|
-
* @updated 1.0.0-alpha.2
|
|
17
|
-
*/
|
|
18
6
|
export declare class TableComponent extends Table implements OnInit {
|
|
19
|
-
props: import("@angular/core").InputSignal<typeof Table | undefined>;
|
|
20
7
|
/**
|
|
21
8
|
* Single string or whitespace-separated string of additional style classes for the button.
|
|
22
9
|
* Only accepts valid whitespace-separated class names.
|
|
23
10
|
*/
|
|
24
|
-
styleClasses: import("@angular/core").InputSignalWithTransform<string
|
|
11
|
+
styleClasses: import("@angular/core").InputSignalWithTransform<string, string>;
|
|
25
12
|
columnData: import("@angular/core").InputSignal<ObjectColumnData[]>;
|
|
26
13
|
sortable: import("@angular/core").InputSignal<boolean | undefined>;
|
|
27
14
|
export: import("@angular/core").InputSignal<boolean | undefined>;
|
|
@@ -31,6 +18,6 @@ export declare class TableComponent extends Table implements OnInit {
|
|
|
31
18
|
protected selectedRow: (typeof this.value)[number];
|
|
32
19
|
protected cb(event: any): void;
|
|
33
20
|
static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent, never>;
|
|
34
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent, "sdc-table", never, { "
|
|
21
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent, "sdc-table", never, { "styleClasses": { "alias": "styleClasses"; "required": false; "isSignal": true; }; "columnData": { "alias": "columnData"; "required": true; "isSignal": true; }; "sortable": { "alias": "sortable"; "required": false; "isSignal": true; }; "export": { "alias": "export"; "required": false; "isSignal": true; }; "exportButtonLabel": { "alias": "exportButtonLabel"; "required": false; "isSignal": true; }; "contextMenuOptions": { "alias": "contextMenuOptions"; "required": false; "isSignal": true; }; "projectedElementIdArray": { "alias": "projectedElementIdArray"; "required": false; "isSignal": true; }; }, {}, never, ["*", "*"], true, never>;
|
|
35
22
|
}
|
|
36
23
|
//# sourceMappingURL=table.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../projects/software-division-components/src/backoffice/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../projects/software-division-components/src/backoffice/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,MAAM,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,OAAO,EAAE,KAAK,EAA6B,MAAM,eAAe,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;AAE3C,qBAkBa,cAAe,SAAQ,KAAM,YAAW,MAAM;IACzD;;;OAGG;IACI,YAAY,mEAA+E;IAC3F,UAAU,0DAAwC;IAClD,QAAQ,2DAAoB;IAC5B,MAAM,2DAAoB;IAC1B,iBAAiB,8CAA2B;IAC5C,kBAAkB,8DAAuB;IACzC,uBAAuB,4DAAqB;IAEnD,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG;yCAfZ,cAAc;2CAAd,cAAc;CAgB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../projects/software-division-components/src/backoffice/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../projects/software-division-components/src/backoffice/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AACxD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IAEjB,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AACD,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B"}
|
package/dvm/public-api.d.ts
CHANGED
package/dvm/public-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../projects/software-division-components/src/dvm/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../projects/software-division-components/src/dvm/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { Component, input } from '@angular/core';
|
|
2
|
-
import { FormatValuePipe } from '
|
|
2
|
+
import { FormatValuePipe } from '../../../../../shared/format-value.pipe.js';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
+
const _c0 = ["app-body-row", ""];
|
|
5
|
+
const _forTrack0 = ($index, $item) => $item.field;
|
|
6
|
+
function BodyRowComponent_For_1_Template(rf, ctx) { if (rf & 1) {
|
|
7
|
+
i0.ɵɵelementStart(0, "td");
|
|
8
|
+
i0.ɵɵtext(1);
|
|
9
|
+
i0.ɵɵpipe(2, "formatValue");
|
|
10
|
+
i0.ɵɵelementEnd();
|
|
11
|
+
} if (rf & 2) {
|
|
12
|
+
const col_r1 = ctx.$implicit;
|
|
13
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
14
|
+
i0.ɵɵadvance();
|
|
15
|
+
i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r1.rows()[col_r1.field], col_r1 == null ? null : col_r1.options == null ? null : col_r1.options.pipe), " ");
|
|
16
|
+
} }
|
|
4
17
|
export class BodyRowComponent {
|
|
5
18
|
rows = input.required();
|
|
6
19
|
columns = input.required();
|
|
7
|
-
static ɵfac =
|
|
8
|
-
static ɵcmp = i0.ɵɵ
|
|
20
|
+
static ɵfac = function BodyRowComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BodyRowComponent)(); };
|
|
21
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BodyRowComponent, selectors: [["", "app-body-row", ""]], inputs: { rows: [1, "rows"], columns: [1, "columns"] }, standalone: true, features: [i0.ɵɵStandaloneFeature], attrs: _c0, decls: 2, vars: 0, template: function BodyRowComponent_Template(rf, ctx) { if (rf & 1) {
|
|
22
|
+
i0.ɵɵrepeaterCreate(0, BodyRowComponent_For_1_Template, 3, 4, "td", null, _forTrack0);
|
|
23
|
+
} if (rf & 2) {
|
|
24
|
+
i0.ɵɵrepeater(ctx.columns());
|
|
25
|
+
} }, dependencies: [FormatValuePipe] });
|
|
9
26
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BodyRowComponent, [{
|
|
28
|
+
type: Component,
|
|
29
|
+
args: [{ standalone: true, selector: '[app-body-row]', imports: [FormatValuePipe], template: "@for (col of columns(); track col.field) {\n <td>\n {{ rows()[col.field] | formatValue: col?.options?.pipe }}\n </td>\n}\n" }]
|
|
30
|
+
}], null, null); })();
|
|
31
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BodyRowComponent, { className: "BodyRowComponent", filePath: "backoffice/table/components/body-row/body-row.component.ts", lineNumber: 12 }); })();
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm9keS1yb3cuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvc29mdHdhcmUtZGl2aXNpb24tY29tcG9uZW50cy9zcmMvYmFja29mZmljZS90YWJsZS9jb21wb25lbnRzL2JvZHktcm93L2JvZHktcm93LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3NvZnR3YXJlLWRpdmlzaW9uLWNvbXBvbmVudHMvc3JjL2JhY2tvZmZpY2UvdGFibGUvY29tcG9uZW50cy9ib2R5LXJvdy9ib2R5LXJvdy5jb21wb25lbnQuaHRtbCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNqRCxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7Ozs7O0lDQTFELDBCQUFJO0lBQ0YsWUFDRjs7SUFBQSxpQkFBSzs7OztJQURILGNBQ0Y7SUFERSwrSkFDRjs7QURRRixNQUFNLE9BQU8sZ0JBQWdCO0lBQ3BCLElBQUksR0FBRyxLQUFLLENBQUMsUUFBUSxFQUF1QixDQUFDO0lBQzdDLE9BQU8sR0FBRyxLQUFLLENBQUMsUUFBUSxFQUFzQixDQUFDOzBHQUYzQyxnQkFBZ0I7NkRBQWhCLGdCQUFnQjtZQ1g3QixxRkFJQzs7WUFKRCxjQUFBLGFBQVMsQ0FJUjs0QkRLVyxlQUFlOztpRkFFZCxnQkFBZ0I7Y0FQNUIsU0FBUzs2QkFDSSxJQUFJLFlBQ04sZ0JBQWdCLFdBR2pCLENBQUMsZUFBZSxDQUFDOztrRkFFZixnQkFBZ0IiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb21wb25lbnQsIGlucHV0IH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5pbXBvcnQgeyBGb3JtYXRWYWx1ZVBpcGUgfSBmcm9tICdAc2hhcmVkL2Zvcm1hdC12YWx1ZS5waXBlJztcbmltcG9ydCB7IE9iamVjdENvbHVtbkRhdGEgfSBmcm9tICcuLi8uLi90eXBlcyc7XG5cbkBDb21wb25lbnQoe1xuICBzdGFuZGFsb25lOiB0cnVlLFxuICBzZWxlY3RvcjogJ1thcHAtYm9keS1yb3ddJyxcbiAgdGVtcGxhdGVVcmw6ICcuL2JvZHktcm93LmNvbXBvbmVudC5odG1sJyxcbiAgc3R5bGVVcmxzOiBbJy4vYm9keS1yb3cuY29tcG9uZW50LmNzcyddLFxuICBpbXBvcnRzOiBbRm9ybWF0VmFsdWVQaXBlXSxcbn0pXG5leHBvcnQgY2xhc3MgQm9keVJvd0NvbXBvbmVudCB7XG4gIHB1YmxpYyByb3dzID0gaW5wdXQucmVxdWlyZWQ8UmVjb3JkPHN0cmluZywgYW55Pj4oKTtcbiAgcHVibGljIGNvbHVtbnMgPSBpbnB1dC5yZXF1aXJlZDxPYmplY3RDb2x1bW5EYXRhW10+KCk7XG59XG4iLCJAZm9yIChjb2wgb2YgY29sdW1ucygpOyB0cmFjayBjb2wuZmllbGQpIHtcbiAgPHRkPlxuICAgIHt7IHJvd3MoKVtjb2wuZmllbGRdIHwgZm9ybWF0VmFsdWU6IGNvbD8ub3B0aW9ucz8ucGlwZSB9fVxuICA8L3RkPlxufVxuIl19
|