mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(doc): move anchor scrolling
This commit is contained in:
10
apps/angular/anchor-scrolling/src/app/app.component.ts
Normal file
10
apps/angular/anchor-scrolling/src/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [RouterOutlet],
|
||||
selector: 'app-root',
|
||||
template: ` <router-outlet></router-outlet> `,
|
||||
})
|
||||
export class AppComponent {}
|
||||
6
apps/angular/anchor-scrolling/src/app/app.config.ts
Normal file
6
apps/angular/anchor-scrolling/src/app/app.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { appRoutes } from './app.routes';
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideRouter(appRoutes)],
|
||||
};
|
||||
9
apps/angular/anchor-scrolling/src/app/app.routes.ts
Normal file
9
apps/angular/anchor-scrolling/src/app/app.routes.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Route } from '@angular/router';
|
||||
import { FooComponent } from './foo.component';
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
export const appRoutes: Route[] = [
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'foo', component: FooComponent },
|
||||
{ path: '**', redirectTo: 'home' },
|
||||
];
|
||||
15
apps/angular/anchor-scrolling/src/app/foo.component.ts
Normal file
15
apps/angular/anchor-scrolling/src/app/foo.component.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavButtonComponent } from './nav-button.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [NavButtonComponent],
|
||||
selector: 'app-foo',
|
||||
template: `
|
||||
Welcome to foo page
|
||||
<nav-button href="home" class="fixed top-3 left-1/2">Home Page</nav-button>
|
||||
<div class="h-screen bg-blue-200">section 1</div>
|
||||
<div class="h-screen bg-red-200">section 2</div>
|
||||
`,
|
||||
})
|
||||
export class FooComponent {}
|
||||
20
apps/angular/anchor-scrolling/src/app/home.component.ts
Normal file
20
apps/angular/anchor-scrolling/src/app/home.component.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavButtonComponent } from './nav-button.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [NavButtonComponent],
|
||||
selector: 'app-home',
|
||||
template: `
|
||||
<nav-button href="/foo" class="fixed top-3 left-1/2">Foo Page</nav-button>
|
||||
<div id="top" class="h-screen bg-gray-500">
|
||||
Empty
|
||||
<nav-button href="#bottom">Scroll Bottom</nav-button>
|
||||
</div>
|
||||
<div id="bottom" class="h-screen bg-blue-300">
|
||||
I want to scroll each
|
||||
<nav-button href="#top">Scroll Top</nav-button>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class HomeComponent {}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable @angular-eslint/component-selector */
|
||||
import { Component, Input } from '@angular/core';
|
||||
@Component({
|
||||
selector: 'nav-button',
|
||||
standalone: true,
|
||||
template: `
|
||||
<a [href]="href">
|
||||
<ng-content></ng-content>
|
||||
</a>
|
||||
`,
|
||||
host: {
|
||||
class: 'block w-fit border border-red-500 rounded-md p-4 m-2',
|
||||
},
|
||||
})
|
||||
export class NavButtonComponent {
|
||||
@Input() href = '';
|
||||
}
|
||||
0
apps/angular/anchor-scrolling/src/assets/.gitkeep
Normal file
0
apps/angular/anchor-scrolling/src/assets/.gitkeep
Normal file
BIN
apps/angular/anchor-scrolling/src/favicon.ico
Normal file
BIN
apps/angular/anchor-scrolling/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
apps/angular/anchor-scrolling/src/index.html
Normal file
13
apps/angular/anchor-scrolling/src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>AnchorScrolling</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
8
apps/angular/anchor-scrolling/src/main.ts
Normal file
8
apps/angular/anchor-scrolling/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { appConfig } from './app/app.config';
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
||||
console.error(err)
|
||||
);
|
||||
5
apps/angular/anchor-scrolling/src/styles.scss
Normal file
5
apps/angular/anchor-scrolling/src/styles.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
1
apps/angular/anchor-scrolling/src/test-setup.ts
Normal file
1
apps/angular/anchor-scrolling/src/test-setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
Reference in New Issue
Block a user