@pushengineering/umg-web-components 2.0.0 → 2.0.2
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 +2 -2
- package/readme.md +1 -186
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushengineering/umg-web-components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/packages/web-components/components/index.js",
|
|
6
6
|
"files": [
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"./media": "./dist/packages/web-components/components/media/media.js",
|
|
34
34
|
"./media-text": "./dist/packages/web-components/components/media-text/media-text.js",
|
|
35
35
|
"./menu": "./dist/packages/web-components/components/menu/menu.js",
|
|
36
|
+
"./menu-bar": "./dist/packages/web-components/components/menu-bar/menu-bar.js",
|
|
36
37
|
"./modal": "./dist/packages/web-components/components/overlay/overlay.js",
|
|
37
38
|
"./number-field": "./dist/packages/web-components/components/number-field/number-field.js",
|
|
38
39
|
"./overlay": "./dist/packages/web-components/components/page/page.js",
|
|
@@ -59,7 +60,6 @@
|
|
|
59
60
|
"gr": "rollup -c"
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@umg-components/design-tokens": "workspace:^",
|
|
63
63
|
"lit": "^2.7.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -9,18 +9,7 @@
|
|
|
9
9
|
- [Build scripts](#build-scripts)
|
|
10
10
|
- [Lit - Lightning-Fast Components](#lit---lightning-fast-components)
|
|
11
11
|
- [Storybook Integration for Component Previews and Documentation](#storybook-integration-for-component-previews-and-documentation)
|
|
12
|
-
|
|
13
|
-
- [Package installation](#package-installation)
|
|
14
|
-
- [Importing components](#importing-components)
|
|
15
|
-
- [Theme Styling](#theme-styling)
|
|
16
|
-
- [Design Tokens](#design-tokens)
|
|
17
|
-
- [Installing the default theme and system tokens](#installing-the-default-theme-and-system-tokens)
|
|
18
|
-
- [Types of Design Tokens](#types-of-design-tokens)
|
|
19
|
-
- [Leveraging Design Tokens](#leveraging-design-tokens)
|
|
20
|
-
- [More Ways to Customise](#more-ways-to-customise)
|
|
21
|
-
- [CSS Selector Rules](#css-selector-rules)
|
|
22
|
-
- [CSS Selectors Cheatsheet](#css-selectors-cheatsheet)
|
|
23
|
-
- [Chromatic notes](#chromatic-notes)
|
|
12
|
+
|
|
24
13
|
# UMG UX Components Library README
|
|
25
14
|
Welcome to the UMG UX Components Library! This library provides a collection of UX frontend components designed to be fast, reusable, and highly customisable for any project, without relying on proprietary technologies or frameworks. These components leverage standard Web APIs and are compatible with all modern browsers.
|
|
26
15
|
|
|
@@ -90,177 +79,3 @@ With Storybook, you can easily navigate and explore our components:
|
|
|
90
79
|
- Interactive Documentation: Access detailed documentation and usage examples for each component, making it easier to implement them effectively in your project.
|
|
91
80
|
|
|
92
81
|
The Storybook application can be loaded into a browser by running `pnpm dev-storybook` in `node_modules/@pushengineering/umg-components`.
|
|
93
|
-
|
|
94
|
-
# Integrating UMG Components into Your Project
|
|
95
|
-
## Package installation
|
|
96
|
-
|
|
97
|
-
To integrate UMG Components into your project, follow these steps:
|
|
98
|
-
|
|
99
|
-
1. Ensure you have [Node v16.14^](https://nodejs.org/en/download) installed globally or locally within your project.
|
|
100
|
-
2. In your project's source folder, create a `package.json` file with a minimum configuration like this:
|
|
101
|
-
```
|
|
102
|
-
{
|
|
103
|
-
"name": "project-name",
|
|
104
|
-
"target": "web",
|
|
105
|
-
"type": "module",
|
|
106
|
-
"sideEffects": false,
|
|
107
|
-
"dependencies": {
|
|
108
|
-
"@pushengineering/umg-components": "^1.0.0"
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
3. In the root of your project's source folder, run the following command:
|
|
113
|
-
```
|
|
114
|
-
npm run install
|
|
115
|
-
```
|
|
116
|
-
If you've previously installed Node packages in your project, skip this step and run:
|
|
117
|
-
```
|
|
118
|
-
npm install @pushengineering/umg-components --save-dev
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Importing components
|
|
122
|
-
Our components are written as ES6 modules for seamless integration into your project without the need for transpilation through tools like Webpack or Babel. You can still use pre-processors like Vite, Webpack, or Roll-up for tree shaking and minification while preserving ES modules.
|
|
123
|
-
|
|
124
|
-
To initialise a web component and render it in your HTML and the DOM, simply import the component script within your page's entry scripts or as a script tag directly inside your page.
|
|
125
|
-
|
|
126
|
-
For example, to import the slider web component and its internal component dependencies, add the following to your main script or as a script tag in your page:
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
import '@pushengineering/umg-web-components/slider'
|
|
130
|
-
```
|
|
131
|
-
Or use a script tag like this:
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
<script async type="module" src="path-to-component-modules/slider.js">
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
If the slider component contains additional web components, such as image banners, you'll also need to import them:
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
import '@pushengineering/umg-web-components/banner'
|
|
141
|
-
import '@pushengineering/umg-web-components/image'
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
If these banner image components require captions with text and buttons, import them as well:
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
import '@pushengineering/umg-web-components/button-group'
|
|
148
|
-
import '@pushengineering/umg-web-components/button'
|
|
149
|
-
import '@pushengineering/umg-web-components/text'
|
|
150
|
-
``````
|
|
151
|
-
|
|
152
|
-
Once imported, you can use these components throughout your page without further imports.
|
|
153
|
-
|
|
154
|
-
## Theme Styling
|
|
155
|
-
|
|
156
|
-
### Design Tokens
|
|
157
|
-
Our UMG UX Components Library is designed on top of a design system that uses custom CSS variables also known as design tokens. These design tokens are mapped to default values assigned to various elements within our components and at the document level. They empower you to customize the theme in a cascading, controlled manner, ensuring consistent design and behavior throughout your application.
|
|
158
|
-
|
|
159
|
-
#### Installing the default theme and system tokens
|
|
160
|
-
To ensure that unthemed components display as intended, it's crucial to include the default design tokens in your application.
|
|
161
|
-
|
|
162
|
-
Follow these steps to integrate the default design tokens into your application:
|
|
163
|
-
|
|
164
|
-
1. Navigate to the following directory in your application: `/your-local-source-folder/node_modules/@pushengineering/umg-web-components/packages/web-components/public`.
|
|
165
|
-
2. In your code editor open the `design-tokens.css` file.
|
|
166
|
-
3. Copy the contents of this file.
|
|
167
|
-
4. Paste the copied contents inside a `<style>` tag within the `<head>` section of your application's HTML page. This approach optimises page performance compared to linking to an external stylesheet.
|
|
168
|
-
|
|
169
|
-
#### Types of Design Tokens
|
|
170
|
-
We've organised our design tokens into two distinct groups, each serving a specific purpose:
|
|
171
|
-
|
|
172
|
-
1. **Theme Customisation Tokens**
|
|
173
|
-
The first group of design tokens empowers developers to freely theme the component library without compromising core behavior and design consistency. These tokens cover a wide range of areas, including:
|
|
174
|
-
|
|
175
|
-
- Typography
|
|
176
|
-
- Colour
|
|
177
|
-
- Shape
|
|
178
|
-
- Space
|
|
179
|
-
- And more
|
|
180
|
-
|
|
181
|
-
With these tokens, you have the flexibility to tailor the look and feel of our components to align perfectly with your project's unique visual identity. They allow you to adapt our components to your brand's colour scheme, typography, and spacing guidelines, among other things.
|
|
182
|
-
|
|
183
|
-
2. **Opinionated Design Tokens**
|
|
184
|
-
The second group of design tokens consists of opinionated values that solidify our components' expected behavior. These tokens are meticulously crafted to ensure accessibility and deliver an exceptional user experience. They are founded on a series of memorable visual scales governing:
|
|
185
|
-
|
|
186
|
-
- Type
|
|
187
|
-
- Grids
|
|
188
|
-
- Responsive Sizing and Spacing
|
|
189
|
-
- Borders
|
|
190
|
-
- And more
|
|
191
|
-
|
|
192
|
-
These opinionated tokens establish consistency in design and reduce decision-making overhead where it is least useful in terms of customisation. By adhering to these scales, you can rest assured that our components will consistently deliver a cohesive and user-friendly experience across your application.
|
|
193
|
-
|
|
194
|
-
#### Leveraging Design Tokens
|
|
195
|
-
To make use of these design tokens, simply customise their values to align with your design system's specifications. You can override the default values assigned to the tokens, tailoring them to your project's exact requirements.
|
|
196
|
-
|
|
197
|
-
By integrating our components with your design tokens, you'll be able to achieve a harmonious blend of visual consistency and user experience excellence in your application, while also benefiting from the flexibility to adapt our components to your unique brand identity.
|
|
198
|
-
|
|
199
|
-
### More Ways to Customise
|
|
200
|
-
Our component styles are encapsulated within web component shadow DOMs, to prevent external styles from inadvertantly targeting elements and creating unwanted side effects. You can safely use CSS variables or custom properties to style components, but we also provide the CSS `::part` and `::part()` selectors for more targeted styling within shadow DOMs.
|
|
201
|
-
|
|
202
|
-
If you need to apply external styles to web component elements when all the above fails to achieve your design needs, consider using [constructed stylesheets](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet). We've registered a constructed stylesheet named `umgtheme` that's adopted by each web component in the library.
|
|
203
|
-
|
|
204
|
-
To use this feature, add the following script to your theme template, updating the paths to match your project structure, and ensuring that it runs early in the script loading order:
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
<script type="module">
|
|
208
|
-
/* Local path './node_modules/@pushengineering/umg-web-components/lit' */
|
|
209
|
-
import { css, unsafeCSS } from '../node_modules/lit'
|
|
210
|
-
|
|
211
|
-
window.constructibleStyleSheets = {};
|
|
212
|
-
|
|
213
|
-
const styleSheetPromise = (cssPath, variableName) => fetch(cssPath)
|
|
214
|
-
.then(response => response.text())
|
|
215
|
-
.then(cssRaw => {
|
|
216
|
-
const cssResult = css`${unsafeCSS(cssRaw)}`;
|
|
217
|
-
window.constructibleStyleSheets[variableName] = cssResult;
|
|
218
|
-
return cssResult.styleSheet;
|
|
219
|
-
}).catch(error => console.error(`😡 [${variableName}]`, error));
|
|
220
|
-
|
|
221
|
-
Promise.all([
|
|
222
|
-
styleSheetPromise(
|
|
223
|
-
"/global.css", /* path-to-public-stylesheet */
|
|
224
|
-
"umgtheme", /* Do not edit */
|
|
225
|
-
)
|
|
226
|
-
]).then(styleSheets => {
|
|
227
|
-
document.adoptedStyleSheets = styleSheets;
|
|
228
|
-
});
|
|
229
|
-
</script>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### CSS Selector Rules
|
|
233
|
-
|
|
234
|
-
When styling web components from an external stylesheet, keep these rules in mind:
|
|
235
|
-
|
|
236
|
-
- Elements rendered in Light DOM are targetable as usual with standard CSS selectors.
|
|
237
|
-
|
|
238
|
-
- To target elements within shadow roots or the Shadow DOM, you can pass values via CSS variables registered for elements within the Shadow DOM. Combine standard CSS selectors with the `::part()` CSS pseudo-element selector by referencing the element's part name, e.g., `#section-name::part(button)`.
|
|
239
|
-
|
|
240
|
-
- To specifically target an element in the shadow root with a part name shared by other elements on the page, you can uniquely reference the element using a unique parent ID or class along with the `::part()` selector, e.g., `#section-name .slide-button::part(button)`.
|
|
241
|
-
|
|
242
|
-
### CSS Selectors Cheatsheet
|
|
243
|
-
|
|
244
|
-
| **Target**: | doc-root | custom-element | custom-element-root | shadow-root | light-dom |
|
|
245
|
-
|-----------------------------:|:--------:|:--------------:|:-------------------:|:-------------:|:--------------------------------:|
|
|
246
|
-
| selector path: | | | | | |
|
|
247
|
-
| stylesheet.css | ✓ | ✓ | ✓ | *::part(foo) | ✓ |
|
|
248
|
-
| doc-style > | ✓ | ✓ | ✓ | x | ✓ |
|
|
249
|
-
| doc-style > custom-element > | | ✓ | ✓ | *::part(foo) | ✓ |
|
|
250
|
-
| custom-element > | | :host | ✓ | ✓ | ::slotted(foo) NOT [root]class > |
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
# Chromatic notes
|
|
254
|
-
|
|
255
|
-
Please note that Chromatic requires Node.js to be at version 16.19.1 or lower. Versions higher than this may cause issues with the CLI.
|
|
256
|
-
|
|
257
|
-
To install Chromatic CLI, run the following command:
|
|
258
|
-
|
|
259
|
-
```
|
|
260
|
-
# npm
|
|
261
|
-
npm install --save-dev chromatic
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Make sure to set the `CHROMATIC_PROJECT_TOKEN` in your environment to enable the `npm run chromatic` command.
|
|
265
|
-
You can find your project token in Chromatic under Project → Manage.
|
|
266
|
-
|