@lukso/web-components 1.5.3 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.5.4](https://github.com/lukso-network/tools-web-components/compare/v1.5.3...v1.5.4) (2023-02-25)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * docs typo ([#56](https://github.com/lukso-network/tools-web-components/issues/56)) ([ea75e46](https://github.com/lukso-network/tools-web-components/commit/ea75e46887cd4a7bb35b2689ec99a6636a08d13e))
9
+
3
10
  ## [1.5.3](https://github.com/lukso-network/tools-web-components/compare/v1.5.2...v1.5.3) (2023-02-24)
4
11
 
5
12
 
package/README.md CHANGED
@@ -55,7 +55,7 @@ See example below:
55
55
 
56
56
  ### Styles (Tailwind CSS projects)
57
57
 
58
- 1. Add this preset in the config file
58
+ ##### 1. Add this preset in the config file
59
59
 
60
60
  ```js
61
61
  // tailwind.config.js
@@ -65,7 +65,7 @@ module.exports = {
65
65
  }
66
66
  ```
67
67
 
68
- 2. Include styles in your main file
68
+ ##### 2. Include styles in your main file
69
69
 
70
70
  ```scss
71
71
  // main.scss
@@ -74,7 +74,7 @@ $font-file-path: '/assets/fonts';
74
74
  @import '@lukso/web-components/sass/main.scss';
75
75
  ```
76
76
 
77
- 3. In your main js file load the CSS variables
77
+ ##### 3. In your main js file load the CSS variables
78
78
 
79
79
  ```javascript
80
80
  // app.vue
@@ -83,6 +83,19 @@ import { generateCssVariables } from '@/shared/styles/color-palette'
83
83
  generateCssVariables()
84
84
  ```
85
85
 
86
+ ##### 4. Add script to copy assets in your build config
87
+
88
+ In order to use other files like fonts or images from library we need to manually copy them to your project. This is ESM limitation that allow to import only `js` files.
89
+
90
+ ```ts
91
+ import { copyAssets } from '@lukso/web-components/tools/copy-assets'
92
+ import assets from '@lukso/web-components/assets'
93
+
94
+ copyAssets('./src/assets', assets)
95
+ ```
96
+
97
+ > Place this at the top of your build file ie. `vite.config.ts`
98
+
86
99
  ### Styles (non Tailwind CSS projects)
87
100
 
88
101
  Atm the only thing that you can benefit from non Tailwind CSS projects is loading the fonts
@@ -0,0 +1,19 @@
1
+ const i = {};
2
+ function r(n, c) {
3
+ let e = c;
4
+ i.existsSync(c) && i.lstatSync(c).isDirectory() && (e = i.join(c, i.basename(n))), i.writeFileSync(e, i.readFileSync(n));
5
+ }
6
+ function s(n, c) {
7
+ let e = [];
8
+ const t = i.join(c, i.basename(n));
9
+ i.existsSync(t) || i.mkdirSync(t), i.lstatSync(n).isDirectory() && (e = i.readdirSync(n), e.forEach(function(o) {
10
+ const y = i.join(n, o);
11
+ i.lstatSync(y).isDirectory() ? s(y, t) : r(y, t);
12
+ }));
13
+ }
14
+ const S = (n, c) => {
15
+ i.existsSync(n) || i.mkdirSync(n, { recursive: !0 }), s(c, n);
16
+ };
17
+ export {
18
+ S as copyAssets
19
+ };
@@ -0,0 +1 @@
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.web_component_copy_assets={}))})(this,function(t){"use strict";const e={};function f(n,i){let c=i;e.existsSync(i)&&e.lstatSync(i).isDirectory()&&(c=e.join(i,e.basename(n))),e.writeFileSync(c,e.readFileSync(n))}function y(n,i){let c=[];const o=e.join(i,e.basename(n));e.existsSync(o)||e.mkdirSync(o),e.lstatSync(n).isDirectory()&&(c=e.readdirSync(n),c.forEach(function(l){const s=e.join(n,l);e.lstatSync(s).isDirectory()?y(s,o):f(s,o)}))}const d=(n,i)=>{e.existsSync(n)||e.mkdirSync(n,{recursive:!0}),y(i,n)};t.copyAssets=d,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,2 @@
1
+ export declare const copyAssets: (assetDir: string, assets: any) => void;
2
+ //# sourceMappingURL=copy-assets.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukso/web-components",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**/*.{cjs,js,ts,css,woff2,scss}",
@@ -61,6 +61,7 @@
61
61
  "./custom-elements": "./custom-elements.json",
62
62
  "./custom-elements.json": "./custom-elements.json",
63
63
  "./package.json": "./package.json",
64
+ "./tools/copy-assets": "./tools/copy-assets.cjs",
64
65
  "./components": {
65
66
  "require": "./dist/components/index.umd.cjs",
66
67
  "import": "./dist/components/index.js",
@@ -0,0 +1,45 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+
4
+ function copyFileSync(source, target) {
5
+ let targetFile = target
6
+
7
+ // If target is a directory, a new file with the same name will be created
8
+ if (fs.existsSync(target)) {
9
+ if (fs.lstatSync(target).isDirectory()) {
10
+ targetFile = path.join(target, path.basename(source))
11
+ }
12
+ }
13
+
14
+ fs.writeFileSync(targetFile, fs.readFileSync(source))
15
+ }
16
+
17
+ function copyFolderRecursiveSync(source, target) {
18
+ let files = []
19
+
20
+ // Check if folder needs to be created or integrated
21
+ const targetFolder = path.join(target, path.basename(source))
22
+ if (!fs.existsSync(targetFolder)) {
23
+ fs.mkdirSync(targetFolder)
24
+ }
25
+
26
+ // Copy
27
+ if (fs.lstatSync(source).isDirectory()) {
28
+ files = fs.readdirSync(source)
29
+ files.forEach(function (file) {
30
+ const curSource = path.join(source, file)
31
+ if (fs.lstatSync(curSource).isDirectory()) {
32
+ copyFolderRecursiveSync(curSource, targetFolder)
33
+ } else {
34
+ copyFileSync(curSource, targetFolder)
35
+ }
36
+ })
37
+ }
38
+ }
39
+
40
+ export const copyAssets = (assetDir: string, assets: any) => {
41
+ if (!fs.existsSync(assetDir)) {
42
+ fs.mkdirSync(assetDir, { recursive: true })
43
+ }
44
+ copyFolderRecursiveSync(assets, assetDir)
45
+ }
@@ -12,7 +12,52 @@ module.exports = (function () {
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
- define("hslColorMap", ["require", "exports", "tinycolor2"], function (require, exports, tinycolor2_1) {
15
+ define("utils/copy-assets", ["require", "exports", "fs", "path"], function (require, exports, fs_1, path_1) {
16
+ "use strict";
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.copyAssets = void 0;
19
+ fs_1 = __importDefault(fs_1);
20
+ path_1 = __importDefault(path_1);
21
+ function copyFileSync(source, target) {
22
+ var targetFile = target;
23
+ // If target is a directory, a new file with the same name will be created
24
+ if (fs_1.default.existsSync(target)) {
25
+ if (fs_1.default.lstatSync(target).isDirectory()) {
26
+ targetFile = path_1.default.join(target, path_1.default.basename(source));
27
+ }
28
+ }
29
+ fs_1.default.writeFileSync(targetFile, fs_1.default.readFileSync(source));
30
+ }
31
+ function copyFolderRecursiveSync(source, target) {
32
+ var files = [];
33
+ // Check if folder needs to be created or integrated
34
+ var targetFolder = path_1.default.join(target, path_1.default.basename(source));
35
+ if (!fs_1.default.existsSync(targetFolder)) {
36
+ fs_1.default.mkdirSync(targetFolder);
37
+ }
38
+ // Copy
39
+ if (fs_1.default.lstatSync(source).isDirectory()) {
40
+ files = fs_1.default.readdirSync(source);
41
+ files.forEach(function (file) {
42
+ var curSource = path_1.default.join(source, file);
43
+ if (fs_1.default.lstatSync(curSource).isDirectory()) {
44
+ copyFolderRecursiveSync(curSource, targetFolder);
45
+ }
46
+ else {
47
+ copyFileSync(curSource, targetFolder);
48
+ }
49
+ });
50
+ }
51
+ }
52
+ var copyAssets = function (assetDir, assets) {
53
+ if (!fs_1.default.existsSync(assetDir)) {
54
+ fs_1.default.mkdirSync(assetDir, { recursive: true });
55
+ }
56
+ copyFolderRecursiveSync(assets, assetDir);
57
+ };
58
+ exports.copyAssets = copyAssets;
59
+ });
60
+ define("styles/hslColorMap", ["require", "exports", "tinycolor2"], function (require, exports, tinycolor2_1) {
16
61
  "use strict";
17
62
  Object.defineProperty(exports, "__esModule", { value: true });
18
63
  exports.hslColorMap = void 0;
@@ -35,7 +80,7 @@ module.exports = (function () {
35
80
  };
36
81
  exports.hslColorMap = hslColorMap;
37
82
  });
38
- define("color-palette", ["require", "exports", "tinycolor2", "hslColorMap"], function (require, exports, tinycolor2_2, hslColorMap_1) {
83
+ define("styles/color-palette", ["require", "exports", "tinycolor2", "styles/hslColorMap"], function (require, exports, tinycolor2_2, hslColorMap_1) {
39
84
  "use strict";
40
85
  Object.defineProperty(exports, "__esModule", { value: true });
41
86
  exports.neutral3 = exports.neutral2 = exports.neutral1 = exports.colorPalette = void 0;
@@ -1,4 +1,7 @@
1
- declare module "hslColorMap" {
1
+ declare module "utils/copy-assets" {
2
+ export const copyAssets: (assetDir: string, assets: any) => void;
3
+ }
4
+ declare module "styles/hslColorMap" {
2
5
  /**
3
6
  * Generates a color map for a given hue, saturation and lightness values
4
7
  *
@@ -9,7 +12,7 @@ declare module "hslColorMap" {
9
12
  */
10
13
  export const hslColorMap: (h: any, s: any, l: any) => {};
11
14
  }
12
- declare module "color-palette" {
15
+ declare module "styles/color-palette" {
13
16
  type ColorMap = {
14
17
  [key: string]: string;
15
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"color-palette.d.ts","sourceRoot":"","sources":["../src/shared/styles/hslColorMap.ts","../src/shared/styles/color-palette.ts"],"names":[],"mappings":";IAEA;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,WAAW,gCASvB,CAAA;;;ICfD,KAAK,QAAQ,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCxB,CAAA;IAoBD;;OAEG;IACH,MAAM,CAAC,MAAM,QAAQ,UAAyC,CAAA;IAC9D,MAAM,CAAC,MAAM,QAAQ,UAA0C,CAAA;IAC/D,MAAM,CAAC,MAAM,QAAQ,UAIpB,CAAA"}
1
+ {"version":3,"file":"color-palette.d.ts","sourceRoot":"","sources":["../src/shared/utils/copy-assets.ts","../src/shared/styles/hslColorMap.ts","../src/shared/styles/color-palette.ts"],"names":[],"mappings":";IAuCA,MAAM,CAAC,MAAM,UAAU,aAAc,MAAM,UAAU,GAAG,SAKvD,CAAA;;;IC1CD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,WAAW,gCASvB,CAAA;;;ICfD,KAAK,QAAQ,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCxB,CAAA;IAoBD;;OAEG;IACH,MAAM,CAAC,MAAM,QAAQ,UAAyC,CAAA;IAC9D,MAAM,CAAC,MAAM,QAAQ,UAA0C,CAAA;IAC/D,MAAM,CAAC,MAAM,QAAQ,UAIpB,CAAA"}