Skip to content

Commit 51ebda0

Browse files
Merge pull request #2 from sanjeetkumaritoutlook/stencil-web-app
Stencil web app
2 parents 5108bbb + 617d8d0 commit 51ebda0

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed
44.6 KB
Loading

src/components.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ export namespace Components {
99
interface AppHomePage {
1010
}
1111
interface AppProfilePage {
12+
/**
13+
* Alternate text for the image
14+
*/
15+
"alt": string;
16+
/**
17+
* Image height (e.g., "100px" or "auto")
18+
*/
19+
"height": string;
1220
"name": string;
21+
/**
22+
* Image width (e.g., "200px" or "100%")
23+
*/
24+
"width": string;
1325
}
1426
interface AppRoot {
1527
}
@@ -70,7 +82,19 @@ declare namespace LocalJSX {
7082
interface AppHomePage {
7183
}
7284
interface AppProfilePage {
85+
/**
86+
* Alternate text for the image
87+
*/
88+
"alt"?: string;
89+
/**
90+
* Image height (e.g., "100px" or "auto")
91+
*/
92+
"height"?: string;
7393
"name"?: string;
94+
/**
95+
* Image width (e.g., "200px" or "100%")
96+
*/
97+
"width"?: string;
7498
}
7599
interface AppRoot {
76100
}

src/components/app-home-page/app-home-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class AppHome {
2020
<a href="/posts-dashboard">Posts dashboard</a>
2121
</div>
2222
<button
23-
onClick={() => Router.push('/profile/stencil')}
23+
onClick={() => Router.push('/profile/sanjeet')}
2424
>
2525
Profile Page
2626
</button>

src/components/app-profile-page/app-profile-page.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import { Component, Prop, h } from '@stencil/core';
88
export class AppProfile {
99
@Prop() name: string;
1010

11+
/**
12+
* Alternate text for the image
13+
*/
14+
@Prop() alt: string = 'Sanjeet Kumar';
15+
/**
16+
* Image width (e.g., "200px" or "100%")
17+
*/
18+
@Prop() width: string = '100px';
19+
20+
/**
21+
* Image height (e.g., "100px" or "auto")
22+
*/
23+
@Prop() height: string = '100px';
24+
25+
1126
normalize(name: string): string {
1227
if (name) {
1328
return name.substr(0, 1).toUpperCase() + name.substr(1).toLowerCase();
@@ -16,10 +31,23 @@ export class AppProfile {
1631
}
1732

1833
render() {
19-
debugger;
34+
// debugger;
35+
// Use the import.meta.url feature to dynamically resolve the image path during runtime:
36+
// Dynamically resolve the path to the image file
37+
const imagePath = new URL('../../assets/images/Sanjeet-Kumar-profile.jpeg', import.meta.url).href;
38+
2039
if (this.name) {
2140
return (
2241
<div class="app-profile-page">
42+
<img
43+
src={imagePath}
44+
alt={this.alt}
45+
style={{
46+
width: this.width,
47+
height: this.height,
48+
}}
49+
loading="lazy"
50+
/>
2351
<p>Hello! My name is {this.normalize(this.name)}. My name was passed in through a route param!</p>
2452
</div>
2553
);

src/components/header-navigation/header-navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class HeaderNavigation {
1010
return (
1111
<header>
1212
<nav>
13-
<a href="/profile/stencil" class="nav-link" >Profile</a>
13+
<a href="/profile/sanjeet" class="nav-link" >Profile</a>
1414
<a href="/web-components" class="nav-link" >StencilJS components</a>
1515
<a href="/posts-dashboard" class="nav-link">Posts Dashboard</a>
1616
</nav>

0 commit comments

Comments
 (0)