@filip.mazev/blocks 1.0.2 → 1.0.3

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 CHANGED
@@ -1,3 +1,61 @@
1
- # Blocks Umbrella Package
1
+ # @filip.mazev/blocks
2
2
 
3
3
  This package is used to provide the Angular Schematic for adding the blocks libraries.
4
+
5
+ The **Blocks** umbrella package is the official entry point and Angular Schematic for the Blocks UI ecosystem. It provides a seamless, zero-config installation experience, allowing you to integrate our core tools, modals, and toast notifications into your Angular workspace with a single command.
6
+
7
+ ## Installation
8
+
9
+ To install the complete Blocks ecosystem and automatically configure your workspace, run:
10
+
11
+ ```bash
12
+ ng add @filip.mazev/blocks
13
+ ```
14
+
15
+ ## What does ng add do?
16
+
17
+ When you run the command above, the Angular CLI will execute our custom schematic to handle the boilerplate for you:
18
+
19
+ * Interactive Theme Selection: You will be prompted to choose your preferred global theme (Default or Orange Company).
20
+ * Dependency Management: Automatically adds the latest versions of the Blocks ecosystem to your package.json and runs npm install.
21
+ * SCSS Injection: Intelligently locates your project's global stylesheet (styles.scss or styles.sass) and injects the required @use statements, mixins, and both light/dark mode CSS variables based on your theme selection.
22
+
23
+ ## Included Packages
24
+
25
+ Running the schematic will automatically install the following libraries:
26
+
27
+ * @filip.mazev/blocks-core: The foundational package containing the styling engine, SCSS variables, scroll-lock services, and window dimension utilities.
28
+
29
+ * @filip.mazev/modal: A highly customizable, service-driven modal system with swipe-to-close gestures, custom guards, and responsive layouts.
30
+
31
+ * @filip.mazev/toastr: A component-driven toast notification system featuring smart queue management, auto-dismissal, and built-in status views.
32
+
33
+ ## Manual Setup (Without Angular CLI)
34
+
35
+ If you prefer not to use `ng add` or are in an environment that doesn't support Angular Schematics, you can install the packages manually:
36
+
37
+ ```bash
38
+ npm install @filip.mazev/blocks-core @filip.mazev/modal @filip.mazev/toastr
39
+ ```
40
+
41
+ Then, manually configure your styles.scss:
42
+
43
+ ```scss
44
+ @use '@filip.mazev/blocks-core/src/lib/styles/index' as *;
45
+ @use '@filip.mazev/modal/lib/styles/index' as modal;
46
+ @use '@filip.mazev/toastr/lib/styles/index' as toastr;
47
+
48
+ @layer base {
49
+ :root {
50
+ @include core-theme($default-light-theme-config);
51
+ @include modal.modal-theme();
52
+ @include toastr.toastr-theme(());
53
+ }
54
+
55
+ [data-theme='dark'] {
56
+ @include core-theme($default-dark-theme-config);
57
+ }
58
+ }
59
+ ```
60
+
61
+ _For detailed usage instructions, API references, and component configurations, please refer to the READMEs of the individual packages._
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filip.mazev/blocks",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "schematics": "./schematics/collection.json",
5
5
  "peerDependencies": {
6
6
  "@angular/core": "^21.1.1",
@@ -3,7 +3,8 @@
3
3
  "schematics": {
4
4
  "ng-add": {
5
5
  "description": "Installs blocks-core, modal, and toastr, and configures the SCSS theme.",
6
- "factory": "./ng-add/index#ngAdd"
6
+ "factory": "./ng-add/index#ngAdd",
7
+ "schema": "./ng-add/schema.json"
7
8
  }
8
9
  }
9
10
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngAdd = ngAdd;
4
4
  const tasks_1 = require("@angular-devkit/schematics/tasks");
5
- function ngAdd() {
5
+ function ngAdd(options) {
6
6
  return (tree, context) => {
7
7
  addDependencies(tree, context);
8
- injectStyles(tree, context);
8
+ injectStyles(tree, context, options);
9
9
  context.addTask(new tasks_1.NodePackageInstallTask());
10
10
  return tree;
11
11
  };
@@ -20,9 +20,8 @@ function addDependencies(tree, context) {
20
20
  if (!packageJsonBuffer)
21
21
  return;
22
22
  const packageJson = JSON.parse(packageJsonBuffer.toString('utf-8'));
23
- if (!packageJson.dependencies) {
23
+ if (!packageJson.dependencies)
24
24
  packageJson.dependencies = {};
25
- }
26
25
  const packages = [
27
26
  '@filip.mazev/blocks-core',
28
27
  '@filip.mazev/modal',
@@ -40,7 +39,7 @@ function addDependencies(tree, context) {
40
39
  tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
41
40
  }
42
41
  }
43
- function injectStyles(tree, context) {
42
+ function injectStyles(tree, context, options) {
44
43
  const workspaceConfigPath = '/angular.json';
45
44
  if (!tree.exists(workspaceConfigPath)) {
46
45
  context.logger.warn('Could not find angular.json. Please configure the Blocks theme manually.');
@@ -78,6 +77,8 @@ function injectStyles(tree, context) {
78
77
  context.logger.info('Blocks SCSS configuration already exists. Skipping style injection.');
79
78
  return;
80
79
  }
80
+ const lightThemeVar = options.theme === 'orange-company' ? '$orange-company-light-theme-config' : '$default-light-theme-config';
81
+ const darkThemeVar = options.theme === 'orange-company' ? '$orange-company-dark-theme-config' : '$default-dark-theme-config';
81
82
  const blocksThemeSnippet = `
82
83
  @use '@filip.mazev/blocks-core/src/lib/styles/index' as *;
83
84
  @use '@filip.mazev/modal/lib/styles/index' as modal;
@@ -85,12 +86,16 @@ function injectStyles(tree, context) {
85
86
 
86
87
  @layer base {
87
88
  :root {
88
- @include core-theme($default-light-theme-config);
89
+ @include core-theme(${lightThemeVar});
89
90
  @include modal.modal-theme();
90
91
  @include toastr.toastr-theme(());
91
92
  }
93
+
94
+ [data-theme='dark'] {
95
+ @include core-theme(${darkThemeVar});
96
+ }
92
97
  }
93
98
  `;
94
99
  tree.overwrite(targetStylePath, blocksThemeSnippet + '\n' + content);
95
- context.logger.info(`Successfully injected Blocks theme configuration into ${targetStylePath}.`);
100
+ context.logger.info(`Successfully injected the ${options.theme} Blocks theme configuration into ${targetStylePath}.`);
96
101
  }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "id": "BlocksNgAddSchema",
4
+ "title": "Blocks Initialization Options",
5
+ "type": "object",
6
+ "properties": {
7
+ "theme": {
8
+ "type": "string",
9
+ "description": "Select the default theme for your UI blocks.",
10
+ "enum": [
11
+ "default",
12
+ "orange-company"
13
+ ],
14
+ "x-prompt": {
15
+ "message": "Which theme would you like to use?",
16
+ "type": "list",
17
+ "items": [
18
+ {
19
+ "value": "default",
20
+ "label": "Default Theme"
21
+ },
22
+ {
23
+ "value": "orange-company",
24
+ "label": "Orange Company Theme"
25
+ }
26
+ ]
27
+ },
28
+ "default": "default"
29
+ }
30
+ },
31
+ "required": [
32
+ "theme"
33
+ ]
34
+ }