@filip.mazev/blocks-core 0.0.2 → 0.0.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 CHANGED
@@ -1,63 +1,140 @@
1
- # UiServices
1
+ # @filip.mazev/blocks-core
2
2
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
3
+ ## Blocks - Core Library
4
4
 
5
- ## Code scaffolding
5
+ **Blocks Core** is the foundational library for the Blocks ecosystem. It provides the essential infrastructure for building responsive, theme-aware Angular applications. It bridges the gap between TypeScript logic and SCSS styling, offering a unified system for breakpoints, device detection, scroll management and theming.
6
6
 
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
7
+ ## Styles & Theming
8
8
 
9
- ```bash
10
- ng generate component component-name
9
+ Blocks Core utilizes a robust SCSS architecture to manage design tokens and responsiveness.
10
+
11
+ ### 1. Theme Provider
12
+
13
+ The library uses a CSS Variable system generated via SCSS maps. To initialize the core theme, use the `core-theme` mixin in your global styles.
14
+
15
+ ```scss
16
+ @use '@filip.mazev/blocks-core/src/lib/styles/index' as blocks;
17
+
18
+ :root {
19
+ // Initialize default light theme
20
+ @include blocks.core-theme(blocks.$default-light-theme-config);
21
+ }
22
+
23
+ // Example: Switch to dark theme based on a class
24
+ body.dark-theme {
25
+ @include blocks.core-theme(blocks.$default-dark-theme-config);
26
+ }
11
27
  ```
12
28
 
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
29
+ This generates CSS variables with the `--fm-` prefix (e.g.,`--fm-primary`, `--fm-bg-surface`, `--fm-text-main`).
30
+
31
+ ### 2. Responsive Mixins
32
+
33
+ The library provides mixins that strictly align with the WindowDimensionsService breakpoints in TypeScript.
34
+
35
+ Available Breakpoints:
36
+
37
+ * `xs`: 360px
38
+ * `sm`: 640px
39
+ * `md`: 768px
40
+ * `lg`: 1024px
41
+ * `xl`: 1280px
42
+ * `2xl`: 1536px
43
+ * `3xl`: 1920px
44
+ * `4xl`: 2560px
45
+
46
+ Usage:
47
+
48
+ ```scss
49
+ @use '@filip.mazev/blocks-core/src/lib/styles/mixins' as *;
50
+
51
+ .my-element {
52
+ width: 100%;
14
53
 
15
- ```bash
16
- ng generate --help
54
+ // Applies when width >= 768px
55
+ @include respond-up(md) {
56
+ width: 50%;
57
+ }
58
+
59
+ // Applies when width <= 640px
60
+ @include respond-down(sm) {
61
+ display: none;
62
+ }
17
63
  ```
18
64
 
19
- ## Building
65
+ ## Core Services
66
+
67
+ ### `WindowDimensionsService`
20
68
 
21
- To build the library, run:
69
+ Bridges the gap between CSS media queries and TypeScript logic. It provides reactive access to window size and standard breakpoint thresholds.
22
70
 
23
- ```bash
24
- ng build blocks-core
71
+ ```typescript
72
+ export class MyComponent {
73
+ constructor(private windowService: WindowDimensionsService) {
74
+ // Reactive stream
75
+ this.windowService.getWindowDimensions$().subscribe(dims => {
76
+ if (dims.width < dims.threshold_sm) {
77
+ console.log('Mobile View');
78
+ }
79
+ });
80
+ }
81
+ }
25
82
  ```
26
83
 
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
84
+ ### `ThemingService`
28
85
 
29
- ### Publishing the Library
86
+ Handles the detection of system preferences (Dark/Light mode) and manages the application-level theme state.
30
87
 
31
- Once the project is built, you can publish your library by following these steps:
88
+ * `getSystemTheme$()`: Observes the OS/Browser prefers-color-scheme.
89
+ * `getApplicationTheme$()`: Observes the manually set application theme.
90
+ * `setApplicationTheme(theme: DeviceTheme)`: Manually overrides the current theme ('light' | 'dark').
32
91
 
33
- 1. Navigate to the `dist` directory:
34
- ```bash
35
- cd dist/blocks-core
36
- ```
92
+ ### `DeviceTypeService`
37
93
 
38
- 2. Run the `npm publish` command to publish your library to the npm registry:
39
- ```bash
40
- npm publish
41
- ```
94
+ Provides detailed information about the user's device, OS, and orientation. Useful for logic that depends on specific hardware capabilities (e.g., touch handling on Windows tablets vs Android).
42
95
 
43
- ## Running unit tests
96
+ `getDeviceState()` returns:
44
97
 
45
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
98
+ * isMobile / isTablet / isDesktop
99
+ * desktopOS (Windows, Mac, Linux, Unix)
100
+ * mobileOS (iOS, Android)
101
+ * isAppleDevice (checks both iOS and MacOS)
102
+ * isLandscapeOrientation / isPortraitOrientation
46
103
 
47
- ```bash
48
- ng test
49
- ```
104
+ ### `ScrollLockService`
105
+
106
+ A utility to prevent background scrolling when overlays (like Modals) are active. This service handles complex edge cases, including:
107
+
108
+ * **Scrollbar Compensation**: Adds padding to the body to prevent layout shifts when the scrollbar disappears.
109
+
110
+ * **Mobile Touch**: Prevents "scroll chaining" on mobile devices.
50
111
 
51
- ## Running end-to-end tests
112
+ * **Extreme Overflow**: Optionally disables wheel and touch events entirely for strict locking.
52
113
 
53
- For end-to-end (e2e) testing, run:
114
+ ```typescript
115
+ // Lock scroll
116
+ this.scrollLockService.disableScroll({
117
+ handleTouchInput: true,
118
+ handleExtremeOverflow: false
119
+ });
54
120
 
55
- ```bash
56
- ng e2e
121
+ // Unlock
122
+ this.scrollLockService.enableScroll();
57
123
  ```
58
124
 
59
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
125
+ ### `UiActionsService`
126
+
127
+ Common UI utility methods.
128
+
129
+ ### `TextFormattingService`
130
+
131
+ Helper methods for string manipulation, such as:
132
+
133
+ * `generateNameCopy`: Generates unique names for duplicated items (e.g., "Item (Copy)", "Item (Copy 2)").
134
+ * `formattedDateString`: Converts Date objects or strings into a standardized locale date string.
135
+
136
+ ## Installation
60
137
 
61
- ## Additional Resources
138
+ To use Blocks Core, install the package and ensure the SCSS partials are accessible to your build pipeline.
62
139
 
63
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
140
+ _(Installation instructions depend on your specific build/publish setup)._
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filip.mazev/blocks-core",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "exports": {
5
5
  "./mixins": "./lib/styles/_mixins.scss",
6
6
  "./variables": "./lib/styles/_variables.scss",
@@ -29,7 +29,7 @@ $default-light-theme-config: (
29
29
  'info': #3b82f6,
30
30
 
31
31
  // Buttons
32
- 'button-primary': map-get($gray-palette, 200),
32
+ 'button-primary': map-get($gray-palette, 50),
33
33
  'button-confirm': #40ca73,
34
34
  'button-warn': map-get($warning-palette, 500),
35
35
  'button-grayscale': map-get($gray-palette, 200),
@@ -29,7 +29,7 @@ $orange-company-light-theme-config: (
29
29
  'info': #4da6ff,
30
30
 
31
31
  // Buttons
32
- 'button-primary': #FF690099,
32
+ 'button-primary': #FFA56699,
33
33
  'button-confirm': #00C95070,
34
34
  'button-warn': #FB2C3660,
35
35
  'button-grayscale': #d0d0d0b3,