mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(anchorscrolling): new challenge
This commit is contained in:
36
apps/anchor-scrolling/.eslintrc.json
Normal file
36
apps/anchor-scrolling/.eslintrc.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@nrwl/nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
]
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@nrwl/nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
22
apps/anchor-scrolling/jest.config.ts
Normal file
22
apps/anchor-scrolling/jest.config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'anchor-scrolling',
|
||||
preset: '../../jest.preset.js',
|
||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||
coverageDirectory: '../../coverage/apps/anchor-scrolling',
|
||||
transform: {
|
||||
'^.+\\.(ts|mjs|js|html)$': [
|
||||
'jest-preset-angular',
|
||||
{
|
||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
||||
snapshotSerializers: [
|
||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||
'jest-preset-angular/build/serializers/html-comment',
|
||||
],
|
||||
};
|
||||
96
apps/anchor-scrolling/project.json
Normal file
96
apps/anchor-scrolling/project.json
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "anchor-scrolling",
|
||||
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"sourceRoot": "apps/anchor-scrolling/src",
|
||||
"prefix": "app",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/apps/anchor-scrolling",
|
||||
"index": "apps/anchor-scrolling/src/index.html",
|
||||
"main": "apps/anchor-scrolling/src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "apps/anchor-scrolling/tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"apps/anchor-scrolling/src/favicon.ico",
|
||||
"apps/anchor-scrolling/src/assets"
|
||||
],
|
||||
"styles": ["apps/anchor-scrolling/src/styles.scss"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"optimization": false,
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "anchor-scrolling:build:production"
|
||||
},
|
||||
"development": {
|
||||
"browserTarget": "anchor-scrolling:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "anchor-scrolling:build"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/anchor-scrolling/**/*.ts",
|
||||
"apps/anchor-scrolling/**/*.html"
|
||||
]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/anchor-scrolling/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
},
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
19
apps/anchor-scrolling/src/app/anchor-button.component.ts
Normal file
19
apps/anchor-scrolling/src/app/anchor-button.component.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/* eslint-disable @angular-eslint/component-selector */
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { RouterLinkWithHref } from '@angular/router';
|
||||
@Component({
|
||||
selector: 'anchor-button',
|
||||
standalone: true,
|
||||
imports: [RouterLinkWithHref],
|
||||
template: `
|
||||
<a [routerLink]="href">
|
||||
<ng-content></ng-content>
|
||||
</a>
|
||||
`,
|
||||
host: {
|
||||
class: 'block w-fit border border-red-500 rounded-md p-4 m-2',
|
||||
},
|
||||
})
|
||||
export class AnchorButtonComponent {
|
||||
@Input() href = '#top';
|
||||
}
|
||||
19
apps/anchor-scrolling/src/app/app.component.ts
Normal file
19
apps/anchor-scrolling/src/app/app.component.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AnchorButtonComponent } from './anchor-button.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [AnchorButtonComponent],
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<div id="top" class="h-screen bg-gray-500">
|
||||
Empty
|
||||
<anchor-button href="#bottom">Scroll Bottom</anchor-button>
|
||||
</div>
|
||||
<div id="bottom" class="h-screen bg-blue-300">
|
||||
I want to scroll each
|
||||
<anchor-button href="#top">Scroll Top</anchor-button>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class AppComponent {}
|
||||
3
apps/anchor-scrolling/src/app/app.routes.ts
Normal file
3
apps/anchor-scrolling/src/app/app.routes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Route } from '@angular/router';
|
||||
|
||||
export const appRoutes: Route[] = [];
|
||||
0
apps/anchor-scrolling/src/assets/.gitkeep
Normal file
0
apps/anchor-scrolling/src/assets/.gitkeep
Normal file
BIN
apps/anchor-scrolling/src/favicon.ico
Normal file
BIN
apps/anchor-scrolling/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
apps/anchor-scrolling/src/index.html
Normal file
13
apps/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>
|
||||
11
apps/anchor-scrolling/src/main.ts
Normal file
11
apps/anchor-scrolling/src/main.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import {
|
||||
provideRouter,
|
||||
withEnabledBlockingInitialNavigation,
|
||||
} from '@angular/router';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { appRoutes } from './app/app.routes';
|
||||
|
||||
bootstrapApplication(AppComponent, {
|
||||
providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation())],
|
||||
}).catch((err) => console.error(err));
|
||||
5
apps/anchor-scrolling/src/styles.scss
Normal file
5
apps/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/anchor-scrolling/src/test-setup.ts
Normal file
1
apps/anchor-scrolling/src/test-setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
14
apps/anchor-scrolling/tailwind.config.js
Normal file
14
apps/anchor-scrolling/tailwind.config.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { createGlobPatternsForDependencies } = require('@nrwl/angular/tailwind');
|
||||
const { join } = require('path');
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,html}'),
|
||||
...createGlobPatternsForDependencies(__dirname),
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
10
apps/anchor-scrolling/tsconfig.app.json
Normal file
10
apps/anchor-scrolling/tsconfig.app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"],
|
||||
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
7
apps/anchor-scrolling/tsconfig.editor.json
Normal file
7
apps/anchor-scrolling/tsconfig.editor.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src/**/*.ts"],
|
||||
"compilerOptions": {
|
||||
"types": ["jest", "node"]
|
||||
}
|
||||
}
|
||||
32
apps/anchor-scrolling/tsconfig.json
Normal file
32
apps/anchor-scrolling/tsconfig.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.editor.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
15
apps/anchor-scrolling/tsconfig.spec.json
Normal file
15
apps/anchor-scrolling/tsconfig.spec.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"files": ["src/test-setup.ts"],
|
||||
"include": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user