ng-glass 0.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/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # ng-glass
2
+
3
+ `ng-glass` is a lightweight Angular library for creating beautiful glassmorphism effects in your applications. It provides a directive and a component to easily apply the glass effect to any element.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install ng-glass
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### `ngGlass` Directive
14
+
15
+ The `ngGlass` directive can be applied to any element to give it the glassmorphism effect. It provides several inputs to customize the effect:
16
+
17
+ - `blur`: The amount of blur to apply to the background. (default: 10)
18
+ - `opacity`: The opacity of the glass effect. (default: 0.15)
19
+ - `borderRadius`: The border radius of the element. (default: 10)
20
+ - `shadow`: The box shadow of the element. (default: '0 4px 30px rgba(0, 0, 0, 0.1)')
21
+ - `gradient`: The background gradient of the element. (default: 'linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0))')
22
+
23
+ **Example:**
24
+
25
+ ```html
26
+ <div ngGlass [blur]="20" [borderRadius]="15"></div>
27
+ ```
28
+
29
+ ### `ng-glass-card` Component
30
+
31
+ The `ng-glass-card` component is a ready-to-use card with the glassmorphism effect. It uses the `ngGlass` directive internally and provides a simple way to create consistent and beautiful UIs. It supports content projection for the header, body, and footer of the card.
32
+
33
+ **Example:**
34
+
35
+ ```html
36
+ <ng-glass-card [borderRadius]="20">
37
+ <div card-header>...</div>
38
+ <div card-body>...</div>
39
+ <div card-footer>...</div>
40
+ </ng-glass-card>
41
+ ```
42
+
43
+ ## Benefits
44
+
45
+ - Easy to use
46
+ - Highly customizable
47
+ - Lightweight
48
+ - Modern and beautiful design
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ng-glass",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "ng-glass",
3
+ "version": "0.0.2",
4
+ "peerDependencies": {
5
+ "@angular/common": "^21.2.0",
6
+ "@angular/core": "^21.2.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false
12
+ }
@@ -0,0 +1,13 @@
1
+ .card-header {
2
+ padding-bottom: 10px;
3
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
4
+ }
5
+
6
+ .card-body {
7
+ padding: 20px 0;
8
+ }
9
+
10
+ .card-footer {
11
+ padding-top: 10px;
12
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
13
+ }
@@ -0,0 +1,11 @@
1
+ <div ngGlass [blur]="blur()" [opacity]="opacity()" [borderRadius]="borderRadius()" [shadow]="shadow()" [gradient]="gradient()">
2
+ <div class="card-header">
3
+ <ng-content select="[card-header]"></ng-content>
4
+ </div>
5
+ <div class="card-body">
6
+ <ng-content select="[card-body]"></ng-content>
7
+ </div>
8
+ <div class="card-footer">
9
+ <ng-content select="[card-footer]"></ng-content>
10
+ </div>
11
+ </div>
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { GlassCard } from './glass-card';
4
+
5
+ describe('GlassCard', () => {
6
+ let component: GlassCard;
7
+ let fixture: ComponentFixture<GlassCard>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [GlassCard],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(GlassCard);
15
+ component = fixture.componentInstance;
16
+ await fixture.whenStable();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,18 @@
1
+ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
2
+ import { GlassDirective } from '../glass.directive';
3
+
4
+ @Component({
5
+ selector: 'ng-glass-card',
6
+ templateUrl: './glass-card.html',
7
+ styleUrls: ['./glass-card.css'],
8
+ standalone: true,
9
+ imports: [GlassDirective],
10
+ changeDetection: ChangeDetectionStrategy.OnPush
11
+ })
12
+ export class GlassCardComponent {
13
+ blur = input<number>(10);
14
+ opacity = input<number>(0.15);
15
+ borderRadius = input.required<number>();
16
+ shadow = input<string>('0 4px 30px rgba(0, 0, 0, 0.1)');
17
+ gradient = input<string>('linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0))');
18
+ }
@@ -0,0 +1,28 @@
1
+ import { Directive, ElementRef, Renderer2, input, effect } from '@angular/core';
2
+
3
+ @Directive({
4
+ selector: '[ngGlass]',
5
+ standalone: true
6
+ })
7
+ export class GlassDirective {
8
+ private el: HTMLElement;
9
+
10
+ blur = input(10);
11
+ opacity = input(0.15);
12
+ borderRadius = input(10);
13
+ shadow = input('0 4px 30px rgba(0, 0, 0, 0.1)');
14
+ gradient = input('linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0))');
15
+
16
+ constructor(private elementRef: ElementRef, private renderer: Renderer2) {
17
+ this.el = this.elementRef.nativeElement;
18
+
19
+ effect(() => {
20
+ this.renderer.setStyle(this.el, 'backdrop-filter', `blur(${this.blur()}px)`);
21
+ this.renderer.setStyle(this.el, '-webkit-backdrop-filter', `blur(${this.blur()}px)`);
22
+ this.renderer.setStyle(this.el, 'background', this.gradient());
23
+ this.renderer.setStyle(this.el, 'border-radius', `${this.borderRadius()}px`);
24
+ this.renderer.setStyle(this.el, 'box-shadow', this.shadow());
25
+ this.renderer.setStyle(this.el, 'border', '1px solid rgba(255, 255, 255, 0.18)');
26
+ });
27
+ }
28
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { NgGlass } from './ng-glass';
4
+
5
+ describe('NgGlass', () => {
6
+ let component: NgGlass;
7
+ let fixture: ComponentFixture<NgGlass>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [NgGlass],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(NgGlass);
15
+ component = fixture.componentInstance;
16
+ await fixture.whenStable();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,9 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'lib-ng-glass',
5
+ imports: [],
6
+ template: ` <p>ng-glass works!</p> `,
7
+ styles: ``,
8
+ })
9
+ export class NgGlass {}
@@ -0,0 +1,3 @@
1
+
2
+ export * from './lib/glass.directive';
3
+ export * from './lib/glass-card/glass-card';
@@ -0,0 +1,13 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "types": []
10
+ },
11
+ "include": ["src/**/*.ts"],
12
+ "exclude": ["**/*.spec.ts"]
13
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,10 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "types": ["vitest/globals"]
8
+ },
9
+ "include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
10
+ }