From 5e9afe0ea8210c16fbb65dcc7cea087a50afb659 Mon Sep 17 00:00:00 2001 From: Gabriel De Los Rios Date: Tue, 23 Sep 2025 00:26:48 -0300 Subject: [PATCH] feat: img atom --- .../src/lib/atoms/img/img.component.html | 1 + .../src/lib/atoms/img/img.component.spec.ts | 23 ++++++ .../src/lib/atoms/img/img.component.ts | 32 +++++++++ .../src/stories/atoms/img.stories.ts | 71 +++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 projects/my-wallet-ds/src/lib/atoms/img/img.component.html create mode 100644 projects/my-wallet-ds/src/lib/atoms/img/img.component.spec.ts create mode 100644 projects/my-wallet-ds/src/lib/atoms/img/img.component.ts create mode 100644 projects/my-wallet-ds/src/stories/atoms/img.stories.ts diff --git a/projects/my-wallet-ds/src/lib/atoms/img/img.component.html b/projects/my-wallet-ds/src/lib/atoms/img/img.component.html new file mode 100644 index 0000000..254794f --- /dev/null +++ b/projects/my-wallet-ds/src/lib/atoms/img/img.component.html @@ -0,0 +1 @@ + diff --git a/projects/my-wallet-ds/src/lib/atoms/img/img.component.spec.ts b/projects/my-wallet-ds/src/lib/atoms/img/img.component.spec.ts new file mode 100644 index 0000000..0988365 --- /dev/null +++ b/projects/my-wallet-ds/src/lib/atoms/img/img.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ImgComponent } from './img.component'; + +describe('ImgComponent', () => { + let component: ImgComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ImgComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ImgComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/my-wallet-ds/src/lib/atoms/img/img.component.ts b/projects/my-wallet-ds/src/lib/atoms/img/img.component.ts new file mode 100644 index 0000000..b5e2b42 --- /dev/null +++ b/projects/my-wallet-ds/src/lib/atoms/img/img.component.ts @@ -0,0 +1,32 @@ +import { Component, input } from '@angular/core'; +import { NgOptimizedImage } from "@angular/common"; + +@Component({ + selector: 'mw-img', + standalone: true, + imports: [NgOptimizedImage], + templateUrl: './img.component.html', + styles: '' +}) +export class ImgComponent { + /** + * @description An alternative text description of the image. + */ + alt = input('img'); + /** + * @description Indicates whether this image should have a high priority. + */ + hasPriority = input(false); + /** + * @description The intrinsic height of the image in pixels. + */ + height = input(36); + /** + * @description The src path to the asset + */ + src = input('/assets/icons/blank.png'); + /** + * @description The intrinsic width of the image in pixels. + */ + width = input(36); +} diff --git a/projects/my-wallet-ds/src/stories/atoms/img.stories.ts b/projects/my-wallet-ds/src/stories/atoms/img.stories.ts new file mode 100644 index 0000000..791f408 --- /dev/null +++ b/projects/my-wallet-ds/src/stories/atoms/img.stories.ts @@ -0,0 +1,71 @@ +import type { Meta } from '@storybook/angular'; +import { ImgComponent } from '../../lib/atoms/img/img.component'; +import { pngIconsList } from '../png-icons-list'; + +const meta: Meta = { + title: 'Atoms/Img', + component: ImgComponent, + tags: ['autodocs'], + args: { + alt: 'Alt text', + hasPriority: false, + height: 36, + src: '/assets/icons/blank.png', + width: 36 + }, + argTypes: { + alt: { + description: 'An alternative text description of the image', + type: 'string', + table: {defaultValue: {detail: 'Defaults to \'img\'.', summary: 'img'}} + }, + hasPriority: { + description: 'Indicates whether this image should have a high priority.', + table: {defaultValue: {detail: 'Defaults to false.', summary: 'false'}}, + type: 'boolean', + }, + height: { + description: 'The intrinsic height of the image in pixels', + table: {defaultValue: {detail: 'Defaults to 36px.', summary: '36',}}, + type: 'number', + }, + src: { + control: 'select', + description: 'The path to the png asset', + options: pngIconsList, + table: {defaultValue: {detail:'Defaults to transparent png', summary:'/assets/icons/blank.png'}}, + type: 'string', + }, + width: { + description: 'The intrinsic width of the image in pixels.', + table: {defaultValue: {detail: 'Defaults to 36px.', summary: '36',}}, + type: 'number' + } + + } +}; + +export default meta; + +const Template = (args: { alt: string, hasPriority: boolean, height: number, src: string, width: number}) => ({ + props: args, + styles: ` + :host { + display:flex; + justify-content: center; + background-color:#000; + padding: 20px 0; + } + `, + template: ` + + ` +}); + +export const Img = Template.bind({}); \ No newline at end of file