@genexus/mercury 0.13.2 → 0.13.4
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 +393 -103
- package/dist/assets/MERCURY_ASSETS.d.ts +933 -51
- package/dist/assets/MERCURY_ASSETS.js +1 -1
- package/dist/assets/MERCURY_ASSETS.ts +1482 -600
- package/dist/assets/icons/system/dark/accessibility-new.svg +1 -0
- package/dist/assets/icons/system/dark/arrow-drop-down.svg +1 -0
- package/dist/assets/icons/system/dark/arrow-drop-left.svg +1 -0
- package/dist/assets/icons/system/dark/arrow-drop-right.svg +1 -0
- package/dist/assets/icons/system/dark/arrow-drop-up.svg +1 -0
- package/dist/assets/icons/system/dark/chevron-down.svg +1 -1
- package/dist/assets/icons/system/dark/chevron-pag-left.svg +1 -0
- package/dist/assets/icons/system/dark/chevron-pag-right.svg +1 -0
- package/dist/assets/icons/system/dark/chevron-small-down.svg +1 -0
- package/dist/assets/icons/system/dark/chevron-small-up.svg +1 -0
- package/dist/assets/icons/system/dark/chevron-up.svg +1 -1
- package/dist/assets/icons/system/dark/help-variant.svg +1 -1
- package/dist/assets/icons/system/dark/link-off.svg +1 -0
- package/dist/assets/icons/system/dark/mic-off.svg +1 -1
- package/dist/assets/icons/system/dark/text-compare.svg +1 -0
- package/dist/assets/icons/system/light/accessibility-new.svg +1 -0
- package/dist/assets/icons/system/light/arrow-drop-down.svg +1 -0
- package/dist/assets/icons/system/light/arrow-drop-left.svg +1 -0
- package/dist/assets/icons/system/light/arrow-drop-right.svg +1 -0
- package/dist/assets/icons/system/light/arrow-drop-up.svg +1 -0
- package/dist/assets/icons/system/light/chevron-down.svg +1 -1
- package/dist/assets/icons/system/light/chevron-pag-left.svg +1 -0
- package/dist/assets/icons/system/light/chevron-pag-right.svg +1 -0
- package/dist/assets/icons/system/light/chevron-small-down.svg +1 -0
- package/dist/assets/icons/system/light/chevron-small-up.svg +1 -0
- package/dist/assets/icons/system/light/chevron-up.svg +1 -1
- package/dist/assets/icons/system/light/help-variant.svg +1 -1
- package/dist/assets/icons/system/light/link-off.svg +1 -0
- package/dist/assets/icons/system/light/mic-off.svg +1 -1
- package/dist/assets/icons/system/light/text-compare.svg +1 -0
- package/dist/bundles/css/all.css +1 -1
- package/dist/bundles/css/base/base-globant.css +1 -1
- package/dist/bundles/css/base/base.css +1 -1
- package/dist/bundles/css/base/icons.css +1 -1
- package/dist/bundles/css/components/edit.css +1 -1
- package/dist/bundles/css/utils/form--full.css +1 -1
- package/dist/bundles/js/all.js +1 -1
- package/dist/bundles/js/base/base-globant.js +1 -1
- package/dist/bundles/js/base/base.js +1 -1
- package/dist/bundles/js/base/icons.js +1 -1
- package/dist/bundles/js/components/edit.js +1 -1
- package/dist/bundles/js/utils/form--full.js +1 -1
- package/dist/mercury.scss +630 -197
- package/package.json +2 -2
- package/LICENSE +0 -21
- package/dist/assets/icons/system/dark/chevron-close-treeview.svg +0 -1
- package/dist/assets/icons/system/dark/chevron-open-treeview.svg +0 -1
- package/dist/assets/icons/system/light/chevron-close-treeview.svg +0 -1
- package/dist/assets/icons/system/light/chevron-open-treeview.svg +0 -1
- /package/dist/assets/icons/system/dark/{keyboard-arrow-left.svg → chevron-small-left.svg} +0 -0
- /package/dist/assets/icons/system/dark/{keyboard-arrow-right.svg → chevron-small-right.svg} +0 -0
- /package/dist/assets/icons/system/light/{keyboard-arrow-left.svg → chevron-small-left.svg} +0 -0
- /package/dist/assets/icons/system/light/{keyboard-arrow-right.svg → chevron-small-right.svg} +0 -0
package/README.md
CHANGED
|
@@ -10,101 +10,92 @@ Mercury Design System is a robust and scalable solution designed to improve prod
|
|
|
10
10
|
- Full RTL and internationalization support.
|
|
11
11
|
- Open source.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Contents
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
npm i @genexus/mercury
|
|
17
|
-
```
|
|
15
|
+
- [1. Installation](#1-installation)
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
- [2. Usage](#2-usage)
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
- [2.1. Before starting, define the path for the CSS bundles, custom fonts and icons](#21-before-starting-define-the-path-for-the-css-bundles-custom-fonts-and-icons)
|
|
22
20
|
|
|
23
|
-
-
|
|
24
|
-
- Icons
|
|
25
|
-
- CSS to style Chameleon component.
|
|
21
|
+
- [2.2. Create the CSS bundles](#22-create-the-css-bundles)
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
- [2.2.1. Using the CLI to create the CSS bundles](#221-using-the-cli-to-create-the-css-bundles)
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
- [2.2.2. Using SASS to transpile the CSS bundles](#222-using-sass-to-transpile-the-css-bundles)
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
- [2.2.3. Using already generated CSS bundles](#223-using-already-generated-css-bundles)
|
|
32
28
|
|
|
33
|
-
-
|
|
34
|
-
- `<path to node_modules>/@genexus/mercury/dist/assets/icons`
|
|
29
|
+
- [2.3. Copy the CSS bundles, custom fonts and icons to the dev and prod builds](#23-copy-the-css-bundles-custom-fonts-and-icons-to-the-dev-and-prod-builds)
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
- [2.3.1. Copying assets with Angular](#231-copying-assets-with-angular)
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
- [2.3.2. Copying assets with StencilJS](#232-copying-assets-with-stenciljs)
|
|
39
34
|
|
|
40
|
-
|
|
35
|
+
- [2.3.3. Copying assets with Vite](#233-copying-assets-with-vite)
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
- [2.4. Register Mercury and Chameleon utilities to use the icons](#24-register-mercury-and-chameleon-utilities-to-use-the-icons)
|
|
38
|
+
|
|
39
|
+
- [2.5. Style the base application](#25-style-the-base-application)
|
|
40
|
+
|
|
41
|
+
- [2.5.1. Adding base styles using Vite](#251-adding-base-styles-using-vite)
|
|
42
|
+
|
|
43
|
+
- [2.5.2. Adding base styles using React](#252-adding-base-styles-using-react)
|
|
44
|
+
|
|
45
|
+
- [2.5.3. Adding base styles using normal HTML](#253-adding-base-styles-using-normal-html)
|
|
46
|
+
|
|
47
|
+
- [2.6. Style the components with the CSS bundles](#26-style-the-components-with-the-css-bundles)
|
|
48
|
+
|
|
49
|
+
- [2.6.1 How to style a component in Angular](#261-how-to-style-a-component-in-angular)
|
|
50
|
+
|
|
51
|
+
- [2.6.2. How to style a component in React](#262-how-to-style-a-component-in-react)
|
|
52
|
+
|
|
53
|
+
- [2.6.3. How to style a component in StencilJS](#263-how-to-style-a-component-in-stenciljs)
|
|
54
|
+
|
|
55
|
+
- [2.7. Set the dark and light mode](#27-set-the-darklight-mode)
|
|
56
|
+
|
|
57
|
+
- [3. CSS bundles mapping](#3-css-bundles-mapping)
|
|
58
|
+
|
|
59
|
+
- [4. CLI flags](#4-cli-flags)
|
|
60
|
+
|
|
61
|
+
## 1. Installation
|
|
43
62
|
|
|
44
63
|
```bash
|
|
45
|
-
npm i
|
|
64
|
+
npm i @genexus/mercury
|
|
46
65
|
```
|
|
47
66
|
|
|
48
|
-
|
|
49
|
-
// vite.config.ts
|
|
50
|
-
import { defineConfig } from "vite";
|
|
51
|
-
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
67
|
+
## 2. Usage
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
plugins: [
|
|
55
|
-
viteStaticCopy({
|
|
56
|
-
targets: [
|
|
57
|
-
{
|
|
58
|
-
src: "node_modules/@genexus/mercury/dist/assets",
|
|
59
|
-
dest: "./" // Path to your assets folder
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
})
|
|
63
|
-
]
|
|
64
|
-
});
|
|
65
|
-
```
|
|
69
|
+
This repository provides the following assets to implement the Mercury DS:
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
- CSS to style the [Chameleon](https://github.com/genexuslabs/chameleon-controls-library) components.
|
|
72
|
+
- Custom fonts.
|
|
73
|
+
- Icons.
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
The CSS is divided by bundles, where each bundle contains the CSS to style a component. For example, to style a `button` we have the `components/button` bundle, to style the `ch-checkbox` we have the `components/checkbox`, and so on.
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
// stencil.config.ts
|
|
73
|
-
import { Config } from "@stencil/core";
|
|
77
|
+
Check out to the [CSS bundles mapping](#3-css-bundles-mapping) section to see how each component in the Mercury DS Figma maps to a CSS bundle. This mapping is also present on every page of [showcase](https://mercury-showcase.genexus.com/).
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
type: "dist",
|
|
80
|
-
copy: [
|
|
81
|
-
{
|
|
82
|
-
src: "../node_modules/@genexus/mercury/dist/assets",
|
|
83
|
-
dest: "assets" // Path to your assets folder
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
type: "www",
|
|
89
|
-
serviceWorker: null,
|
|
90
|
-
copy: [
|
|
91
|
-
{
|
|
92
|
-
src: "../node_modules/@genexus/mercury/dist/assets",
|
|
93
|
-
dest: "assets" // Path to your assets folder
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
};
|
|
99
|
-
```
|
|
79
|
+
### 2.1. Before starting, define the path for the CSS bundles, custom fonts and icons
|
|
80
|
+
|
|
81
|
+
First of all, you must define the path where the CSS bundles, custom fonts, and icons will be contained in the `dist` folder of your final application.
|
|
100
82
|
|
|
101
|
-
|
|
83
|
+
We will refer to those paths with the following names:
|
|
102
84
|
|
|
103
|
-
|
|
85
|
+
| Reference | Meaning | Example |
|
|
86
|
+
| ------------------------------ | -------------------------------------------------------------------------------------- | -------------------------- |
|
|
87
|
+
| `{{ CSS outDir path }}` | An untracked folder for generating the CSS of the application. | `/src/assets/mercury-css/` |
|
|
88
|
+
| `{{ CSS bundles final path }}` | Path in the final application (`dist` folder) where the CSS bundles will be consumed. | `/assets/css/` |
|
|
89
|
+
| `{{ Fonts final path }}` | Path in the final application (`dist` folder) where the custom fonts will be consumed. | `/assets/fonts/` |
|
|
90
|
+
| `{{ Icons final path }}` | Path in the final application (`dist` folder) where the icons will be consumed. | `/assets/icons/` |
|
|
104
91
|
|
|
105
|
-
|
|
92
|
+
### 2.2. Create the CSS bundles
|
|
106
93
|
|
|
107
|
-
|
|
94
|
+
After you have defined the path for assets, you must create the CSS bundles with the path to those assets.
|
|
95
|
+
|
|
96
|
+
In the following sections we provide examples of how to create those CSS bundles.
|
|
97
|
+
|
|
98
|
+
#### 2.2.1. Using the CLI to create the CSS bundles
|
|
108
99
|
|
|
109
100
|
> [!IMPORTANT]
|
|
110
101
|
> This is the way we recommend to create the bundles.
|
|
@@ -121,7 +112,7 @@ npx mercury <flags>
|
|
|
121
112
|
"build.scss": "mercury <flags>"
|
|
122
113
|
```
|
|
123
114
|
|
|
124
|
-
Consult the [CLI flags](#cli-flags) section to read the complete documentation for the CLI.
|
|
115
|
+
Consult the [CLI flags](#4-cli-flags) section to read the complete documentation for the CLI.
|
|
125
116
|
|
|
126
117
|
Using the CLI:
|
|
127
118
|
|
|
@@ -130,7 +121,7 @@ Using the CLI:
|
|
|
130
121
|
For example:
|
|
131
122
|
|
|
132
123
|
```json
|
|
133
|
-
"build.scss": "mercury --i
|
|
124
|
+
"build.scss": "mercury --i={{ Icons final path }} --f={{ Fonts path final }} --outDir={{ CSS outDir path }}"
|
|
134
125
|
```
|
|
135
126
|
|
|
136
127
|
2. Use the `"build.scss"` script before building your application (dev server and prod build).
|
|
@@ -143,24 +134,22 @@ Using the CLI:
|
|
|
143
134
|
"build": "npm run build.scss && ..."
|
|
144
135
|
```
|
|
145
136
|
|
|
146
|
-
3. Before using any Mercury or Chameleon utility, you must register the bundle mapping. This mapping allows Mercury to map the bundle names
|
|
137
|
+
3. Before using any Mercury or [Chameleon](https://github.com/genexuslabs/chameleon-controls-library) utility, you must register the bundle mapping. This mapping allows Mercury to map the bundle names with the real name of the CSS file (for example, `bundleToHashMappings["components/button"] --> components/button-9f82641938b85445`).
|
|
147
138
|
|
|
148
|
-
**IMPORTANT**: Run this JavaScript before using any Mercury or Chameleon utilities.
|
|
139
|
+
**IMPORTANT**: Run this JavaScript before using any Mercury or [Chameleon](https://github.com/genexuslabs/chameleon-controls-library) utilities.
|
|
149
140
|
|
|
150
141
|
```ts
|
|
151
142
|
import { setBundleMapping } from "@genexus/mercury/dist/bundles";
|
|
152
|
-
|
|
153
|
-
// This path is generated in the same directory as the one specified in the CLI --outDir flag
|
|
154
|
-
import { bundleToHashMappings } from "<path to the file>/bundle-to-hash-mappings";
|
|
143
|
+
import { bundleToHashMappings } from "{{ CSS outDir path }}/bundle-to-hash-mappings";
|
|
155
144
|
|
|
156
145
|
setBundleMapping(bundleToHashMappings);
|
|
157
146
|
|
|
158
147
|
// Other Mercury and Chameleon utilities...
|
|
159
148
|
```
|
|
160
149
|
|
|
161
|
-
|
|
150
|
+
#### 2.2.2. Using SASS to transpile the CSS bundles
|
|
162
151
|
|
|
163
|
-
> [!
|
|
152
|
+
> [!WARNING]
|
|
164
153
|
> We don't recommend this way, because the CLI does this under the hood in a much better and faster way. Also, this way does not hash the generated CSS, which leads to cache issues when re-deploying your application after updating your version of Mercury.
|
|
165
154
|
|
|
166
155
|
1. Install `sass` dependency to transpile the bundles.
|
|
@@ -173,34 +162,148 @@ Using the CLI:
|
|
|
173
162
|
Include the following configuration:
|
|
174
163
|
|
|
175
164
|
```scss
|
|
176
|
-
$
|
|
177
|
-
$
|
|
165
|
+
$font-face-path: "{{ Fonts final path }}";
|
|
166
|
+
$icons-path: "{{ Icons final path }}";
|
|
178
167
|
$globant-colors: false;
|
|
179
168
|
```
|
|
180
169
|
|
|
181
170
|
3. Run the following command to transpile the bundles with the new path for the assets:
|
|
182
171
|
|
|
183
172
|
```bash
|
|
184
|
-
npx sass --load-path=<path to config.scss directory> --no-source-map --style compressed node_modules
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
For example:
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
npx sass --load-path=src --no-source-map --style compressed node_modules/@genexus/mercury/dist/bundles/scss:src/assets/generated
|
|
173
|
+
npx sass --load-path=<path to config.scss directory> --no-source-map --style compressed <path to node_modules>/@genexus/mercury/dist/bundles/scss:{{ CSS outDir path }}
|
|
191
174
|
```
|
|
192
175
|
|
|
193
|
-
|
|
176
|
+
#### 2.2.3. Using already generated CSS bundles
|
|
194
177
|
|
|
195
|
-
> [!
|
|
178
|
+
> [!WARNING]
|
|
196
179
|
> We don't recommend this way, because the generated CSS contains fixed paths for the assets and the CSS names don't contain a hash, which leads to cache issues when re-deploying your application after updating your version of Mercury.
|
|
197
180
|
> We only include this case, because in some scenarios it can facilitate the initialization with Mercury.
|
|
198
181
|
|
|
199
|
-
1. Copy the `<path to node_modules>/@genexus/mercury/dist/bundles/css` content to the `outDir` where the CSS will be.
|
|
182
|
+
1. Copy the `<path to node_modules>/@genexus/mercury/dist/bundles/css` content to the `{{ CSS outDir path }}` where the CSS will be.
|
|
183
|
+
|
|
184
|
+
### 2.3. Copy the CSS bundles, custom fonts and icons to the dev and prod builds
|
|
185
|
+
|
|
186
|
+
Custom fonts and icons are distributed under the following folders:
|
|
187
|
+
|
|
188
|
+
- `<path to node_modules>/@genexus/mercury/dist/assets/fonts`
|
|
189
|
+
- `<path to node_modules>/@genexus/mercury/dist/assets/icons`
|
|
190
|
+
|
|
191
|
+
To use these assets with the CSS bundles, we recommend copying them statically, that is, do not track these assets in your repository sources, only copy them to the dev server and prod builds.
|
|
192
|
+
|
|
193
|
+
In the following sections we provide examples of how to copy the assets with different build tools and frameworks.
|
|
194
|
+
|
|
195
|
+
#### 2.3.1. Copying assets with Angular
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"projects": {
|
|
200
|
+
"<app name>": {
|
|
201
|
+
"architect": {
|
|
202
|
+
"build": {
|
|
203
|
+
"options": {
|
|
204
|
+
"assets": [
|
|
205
|
+
{
|
|
206
|
+
"glob": "**/*",
|
|
207
|
+
"input": "{{ CSS outDir path }}",
|
|
208
|
+
"output": "{{ CSS bundles final path }}"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"glob": "**/*",
|
|
212
|
+
"input": "<path to node_modules>/@genexus/mercury/dist/assets/fonts",
|
|
213
|
+
"output": "{{ Fonts final path }}"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"glob": "**/*",
|
|
217
|
+
"input": "<path to node_modules>/@genexus/mercury/dist/assets/icons",
|
|
218
|
+
"output": "{{ Icons final path }}"
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### 2.3.2. Copying assets with StencilJS
|
|
230
|
+
|
|
231
|
+
When building web components with the StencilJS compiler, the assets can be copied using the copy tasks that provides StencilJS:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// stencil.config.ts
|
|
235
|
+
import { Config } from "@stencil/core";
|
|
236
|
+
import { CopyTask } from "@stencil/core/internal";
|
|
237
|
+
|
|
238
|
+
const copyTasks = [
|
|
239
|
+
{
|
|
240
|
+
src: "{{ CSS outDir path }}",
|
|
241
|
+
dest: "{{ CSS bundles final path }}"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
src: "<path to node_modules>/@genexus/mercury/dist/assets/fonts",
|
|
245
|
+
dest: "{{ Fonts final path }}"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
src: "<path to node_modules>/@genexus/mercury/dist/assets/icons",
|
|
249
|
+
dest: "{{ Icons final path }}"
|
|
250
|
+
}
|
|
251
|
+
] as const satisfies CopyTask[];
|
|
252
|
+
|
|
253
|
+
export const config: Config = {
|
|
254
|
+
namespace: "your-name-space",
|
|
255
|
+
outputTargets: [
|
|
256
|
+
{
|
|
257
|
+
type: "dist",
|
|
258
|
+
copy: copyTasks
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: "www",
|
|
262
|
+
serviceWorker: null,
|
|
263
|
+
copy: copyTasks
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
};
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### 2.3.3. Copying assets with Vite
|
|
200
270
|
|
|
201
|
-
|
|
271
|
+
First, install `vite-plugin-static-copy`:
|
|
202
272
|
|
|
203
|
-
|
|
273
|
+
```bash
|
|
274
|
+
npm i vite-plugin-static-copy --save-dev
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
// vite.config.ts
|
|
279
|
+
import { defineConfig } from "vite";
|
|
280
|
+
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
281
|
+
|
|
282
|
+
export default defineConfig({
|
|
283
|
+
plugins: [
|
|
284
|
+
viteStaticCopy({
|
|
285
|
+
targets: [
|
|
286
|
+
{
|
|
287
|
+
src: "{{ CSS outDir path }}",
|
|
288
|
+
dest: "{{ CSS bundles final path }}"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
src: "<path to node_modules>/@genexus/mercury/dist/assets/fonts",
|
|
292
|
+
dest: "{{ Fonts final path }}"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
src: "<path to node_modules>/@genexus/mercury/dist/assets/icons",
|
|
296
|
+
dest: "{{ Icons final path }}"
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 2.4. Register Mercury and Chameleon utilities to use the icons
|
|
305
|
+
|
|
306
|
+
[Chameleon](https://github.com/genexuslabs/chameleon-controls-library) and Mercury export utilities to facilitate the usage of icons. If you are using Mercury icons, do the following:
|
|
204
307
|
|
|
205
308
|
```ts
|
|
206
309
|
import { registryProperty } from "@genexus/chameleon-controls-library/dist/collection";
|
|
@@ -216,17 +319,204 @@ registryProperty("getImagePathCallback", getImagePathCallbackDefinitions);
|
|
|
216
319
|
registerMercury();
|
|
217
320
|
```
|
|
218
321
|
|
|
219
|
-
### 2.
|
|
322
|
+
### 2.5. Style the base application
|
|
323
|
+
|
|
324
|
+
> [!TIP]
|
|
325
|
+
> For performance reason, we recommend to style the base application, using a `link` tag in the `head` of the HTML, or even inlining the base CSS into the HTML.
|
|
326
|
+
|
|
327
|
+
#### 2.5.1. Adding base styles using Vite
|
|
220
328
|
|
|
221
|
-
|
|
329
|
+
In Vite we can inline the base styles to improve the initial load performance.
|
|
330
|
+
|
|
331
|
+
> [!TIP]
|
|
332
|
+
> If the CSS bundles were created using the CLI, we recommend adding the `--avoid-hash=base/base` to avoid hashing the base CSS bundle and thus make the path to the base CSS bundle simpler.
|
|
333
|
+
|
|
334
|
+
```html
|
|
335
|
+
<!DOCTYPE html>
|
|
336
|
+
<html lang="en" dir="ltr">
|
|
337
|
+
<head>
|
|
338
|
+
<style>
|
|
339
|
+
@import "{{ CSS outDir path }}/base/base.css";
|
|
340
|
+
</style>
|
|
341
|
+
</head>
|
|
342
|
+
<body></body>
|
|
343
|
+
</html>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### 2.5.2. Adding base styles using React
|
|
347
|
+
|
|
348
|
+
> [!TIP]
|
|
349
|
+
> If the CSS bundles were created using the CLI, we recommend adding the `--avoid-hash=base/base` to avoid hashing the base CSS bundle and thus make the path to the base CSS bundle simpler.
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
// App.tsx
|
|
353
|
+
import "{{ CSS outDir path }}/base/base.css";
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### 2.5.3. Adding base styles using normal HTML
|
|
357
|
+
|
|
358
|
+
```html
|
|
359
|
+
<!DOCTYPE html>
|
|
360
|
+
<html lang="en" dir="ltr">
|
|
361
|
+
<head>
|
|
362
|
+
<link
|
|
363
|
+
rel="stylesheet"
|
|
364
|
+
crossorigin
|
|
365
|
+
href="{{ CSS bundles final path }}/base/base-<hash>.css"
|
|
366
|
+
/>
|
|
367
|
+
</head>
|
|
368
|
+
<body></body>
|
|
369
|
+
</html>
|
|
370
|
+
```
|
|
222
371
|
|
|
223
|
-
|
|
372
|
+
### 2.6. Style the components with the CSS bundles
|
|
373
|
+
|
|
374
|
+
[Chameleon](https://github.com/genexuslabs/chameleon-controls-library) provides the `ch-theme` component, a component for downloading and using the CSS bundles in the application.
|
|
375
|
+
|
|
376
|
+
In the following sections we provide examples of how to use these CSS bundles. Check out to the [showcase](https://mercury-showcase.genexus.com/) to see all use cases.
|
|
377
|
+
|
|
378
|
+
#### 2.6.1 How to style a component in Angular
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
import {
|
|
382
|
+
ChangeDetectionStrategy,
|
|
383
|
+
Component,
|
|
384
|
+
CUSTOM_ELEMENTS_SCHEMA
|
|
385
|
+
} from "@angular/core";
|
|
386
|
+
import { getBundles } from "@genexus/mercury/bundles.js";
|
|
387
|
+
|
|
388
|
+
@Component({
|
|
389
|
+
selector: "custom-dialog",
|
|
390
|
+
styleUrl: "./custom-dialog.scss",
|
|
391
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
392
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
393
|
+
template: `<ch-theme model="bundles"></ch-theme>
|
|
394
|
+
<button class="button-primary" type="button">Caption</button>`
|
|
395
|
+
})
|
|
396
|
+
export class CustomDialogComponent {
|
|
397
|
+
bundles = getBundles("components/button", "{{ CSS bundles final path }}");
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### 2.6.2. How to style a component in React
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
import { ChTheme } from "<path to Chameleon web components wrappers>";
|
|
405
|
+
import { getBundles } from "@genexus/mercury/bundles.js";
|
|
406
|
+
|
|
407
|
+
const bundles = getBundles("components/button", "{{ CSS bundles final path }}");
|
|
408
|
+
|
|
409
|
+
const CustomDialog = () => {
|
|
410
|
+
return (
|
|
411
|
+
<>
|
|
412
|
+
<ChTheme model={bundles}></ChTheme>
|
|
413
|
+
<button className="button-primary" type="button">
|
|
414
|
+
Caption
|
|
415
|
+
</button>
|
|
416
|
+
</>
|
|
417
|
+
);
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export default CustomDialog;
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
#### 2.6.3. How to style a component in StencilJS
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
import { Component, Host } from "@stencil/core";
|
|
427
|
+
import { getBundles } from "@genexus/mercury/bundles.js";
|
|
428
|
+
|
|
429
|
+
const bundles = getBundles("components/button", "{{ CSS bundles final path }}");
|
|
430
|
+
|
|
431
|
+
@Component({
|
|
432
|
+
shadow: true,
|
|
433
|
+
styleUrl: "custom-dialog.scss",
|
|
434
|
+
tag: "custom-dialog"
|
|
435
|
+
})
|
|
436
|
+
export class CustomDialog {
|
|
437
|
+
render() {
|
|
438
|
+
return (
|
|
439
|
+
<Host>
|
|
440
|
+
<ch-theme model={bundles}></ch-theme>
|
|
441
|
+
<button class="button-primary" type="button">
|
|
442
|
+
Caption
|
|
443
|
+
</button>
|
|
444
|
+
</Host>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### 2.7. Set the dark/light mode
|
|
451
|
+
|
|
452
|
+
Mercury's implementation is designed from the ground up to support both dark and light modes. To set the dark/light mode, add the `light` or `dark` class in the `<html>` tag. This will toggle the color scheme for all components and even the icons!
|
|
453
|
+
|
|
454
|
+
```html
|
|
455
|
+
// index.html (dark)
|
|
456
|
+
<!DOCTYPE html>
|
|
457
|
+
<html lang="en" dir="ltr" class="dark">
|
|
458
|
+
<head></head>
|
|
459
|
+
<body></body>
|
|
460
|
+
</html>
|
|
461
|
+
|
|
462
|
+
// index.html (light)
|
|
463
|
+
<!DOCTYPE html>
|
|
464
|
+
<html lang="en" dir="ltr" class="light">
|
|
465
|
+
<head></head>
|
|
466
|
+
<body></body>
|
|
467
|
+
</html>
|
|
468
|
+
```
|
|
224
469
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
470
|
+
## 3. CSS bundles mapping
|
|
471
|
+
|
|
472
|
+
The CSS for the Mercury's implementation is split into bundles to give explicit control over the downloaded CSS and allow developers to optimize performance by only using the CSS needed for each page.
|
|
473
|
+
|
|
474
|
+
Each CSS bundle contains a set of classes to style the [Chameleon](https://github.com/genexuslabs/chameleon-controls-library) components and traditional HTML elements. The classes defined for each bundle can be seen in the [showcase](https://mercury-showcase.genexus.com/).
|
|
475
|
+
|
|
476
|
+
The following table describes all CSS bundles.
|
|
477
|
+
|
|
478
|
+
| Bundle name | Content |
|
|
479
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
480
|
+
| `chameleon/scrollbar` | Styles for the scrollbar of the components |
|
|
481
|
+
| `components/accordion` | Styles for the [accordion](https://mercury-showcase.genexus.com/mercury/components/accordion) component |
|
|
482
|
+
| `components/button` | Styles for the [button](https://mercury-showcase.genexus.com/mercury/components/button) button |
|
|
483
|
+
| `components/chat` | Styles for the chat component |
|
|
484
|
+
| `components/checkbox` | Styles for the [checkbox](https://mercury-showcase.genexus.com/mercury/components/checkbox) component |
|
|
485
|
+
| `components/code` | Styles for the code block component |
|
|
486
|
+
| `components/combo-box` | Styles for the [combo-box](https://mercury-showcase.genexus.com/mercury/components/combo-box) component |
|
|
487
|
+
| `components/dialog` | Styles for the [dialog](https://mercury-showcase.genexus.com/mercury/components/dialog) component |
|
|
488
|
+
| `components/dropdown` | Styles for the dropdown component |
|
|
489
|
+
| `components/edit` | Styles for the [input](https://mercury-showcase.genexus.com/mercury/components/input) and [search](https://mercury-showcase.genexus.com/mercury/components/search) components |
|
|
490
|
+
| `components/flexible-layout` | Styles for the flexible layout component |
|
|
491
|
+
| `components/icon` | Styles for the [icon](https://mercury-showcase.genexus.com/mercury/components/icon) component |
|
|
492
|
+
| `components/layout-splitter` | Styles for the layout splitter component |
|
|
493
|
+
| `components/list-box` | Styles for the [list box](https://mercury-showcase.genexus.com/mercury/components/list-box) component |
|
|
494
|
+
| `components/markdown-viewer` | Styles for the markdown viewer component |
|
|
495
|
+
| `components/navigation-list` | Styles for the navigation list component |
|
|
496
|
+
| `components/pills` | Styles for the [pills](https://mercury-showcase.genexus.com/mercury/components/pills) component |
|
|
497
|
+
| `components/radio-group` | Styles for the [radio group](https://mercury-showcase.genexus.com/mercury/components/radio-group) component |
|
|
498
|
+
| `components/segmented-control` | Styles for the segmented control component |
|
|
499
|
+
| `components/sidebar` | Styles for the sidebar component |
|
|
500
|
+
| `components/slider` | Styles for the [slider](https://mercury-showcase.genexus.com/mercury/components/slider) component |
|
|
501
|
+
| `components/switch` | Styles for the switch component |
|
|
502
|
+
| `components/tab` | Styles for the [tab](https://mercury-showcase.genexus.com/mercury/components/tab) component |
|
|
503
|
+
| `components/tabular-grid` | Styles for the [tabular grid](https://mercury-showcase.genexus.com/mercury/components/tabular-grid) and [property grid](https://mercury-showcase.genexus.com/mercury/components/tabular-grid) components |
|
|
504
|
+
| `components/ticket-list` | Styles for the ticket list component |
|
|
505
|
+
| `components/tooltip` | Styles for the [tooltip](https://mercury-showcase.genexus.com/mercury/components/tooltip) component |
|
|
506
|
+
| `components/tree-view` | Styles for the [tree view](https://mercury-showcase.genexus.com/mercury/components/tree-view) component |
|
|
507
|
+
| `components/widget` | Styles for the [widget](https://mercury-showcase.genexus.com/mercury/components/widget) component |
|
|
508
|
+
| `utils/elevation` | Styles to apply [elevations](https://mercury-showcase.genexus.com/mercury/utility-classes/elevation) on any component |
|
|
509
|
+
| `utils/form` | Styles for the [label](https://mercury-showcase.genexus.com/mercury/components/label) component and to build layouts for [forms](https://mercury-showcase.genexus.com/mercury/utility-classes/form) |
|
|
510
|
+
| `utils/layout` | Styles to build common [layouts](https://mercury-showcase.genexus.com/mercury/utility-classes/layout) |
|
|
511
|
+
| `utils/spacing` | Styles to apply [spacing](https://mercury-showcase.genexus.com/mercury/utility-classes/spacing) in different components that are used as containers |
|
|
512
|
+
| `utils/typography` | Styles for using the different [typographies](https://mercury-showcase.genexus.com/mercury/utility-classes/typography) |
|
|
513
|
+
|
|
514
|
+
## 4. CLI flags
|
|
515
|
+
|
|
516
|
+
| Flag | Description |
|
|
517
|
+
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
518
|
+
| `--globant` <br/><br/> `--gl` <br/><br/> `-gl` | If specified, the generated CSS will use the tokens for the Mercury Globant variant. |
|
|
519
|
+
| `--icons-path=path` <br/><br/>`--icons=path` <br/><br/>`--i=path` <br/><br/>`-i=path` | Allows you to customize the base path for the icons. If not specified, `./assets/icons/` will be used. |
|
|
520
|
+
| `--font-face-path=path` <br/><br/>`--font-face=path` <br/><br/>`--f=path` <br/><br/>`-f=path` | Allows you to customize the base path for the custom fonts. If not specified, `./assets/fonts/` will be used. |
|
|
231
521
|
| `--avoid-hash=bundle1,bundle2,...` <br/><br/>`--ah=bundle1,bundle2,...` <br/><br/>`-ah=bundle1,bundle2,...` | Receives a set of comma-separated values, where each value is a bundle. Allows you to avoid the creating the hash for the provided bundles. |
|
|
232
|
-
| `--outDir=path` <br/><br/>`--outdir=path` <br/><br/>`--o=path` <br/><br/>`-o=path`
|
|
522
|
+
| `--outDir=path` <br/><br/>`--outdir=path` <br/><br/>`--o=path` <br/><br/>`-o=path` | Allows you to customize the path where the CSS files will be created. If not specified, `./mercury/` will be used. |
|