feat: img atom

This commit is contained in:
2025-09-23 00:26:48 -03:00
parent e13ce7b13c
commit 5e9afe0ea8
4 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1 @@
<img [ngSrc]="src()" [width]="width()" [height]="height()" [alt]="alt()" [priority]="hasPriority()">

View File

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ImgComponent } from './img.component';
describe('ImgComponent', () => {
let component: ImgComponent;
let fixture: ComponentFixture<ImgComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ImgComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ImgComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -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);
}

View File

@@ -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<ImgComponent> = {
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: `
<mw-img
[alt]='alt'
[hasPriority]='hasPriority'
[height]='height'
[src]='src'
[width]='width'
/>
`
});
export const Img = Template.bind({});