Skip to content

Commit

Permalink
feat(agora): migration About and related components (AG-1545) (#2837)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagely1 authored Sep 23, 2024
1 parent 5632759 commit bd41e69
Show file tree
Hide file tree
Showing 67 changed files with 1,590 additions and 160 deletions.
4 changes: 4 additions & 0 deletions apps/agora/app/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Route } from '@angular/router';

export const routes: Route[] = [
{
path: 'about',
loadChildren: () => import('@sagebionetworks/agora/about').then((routes) => routes.routes),
},
{
path: 'not-found',
loadChildren: () => import('@sagebionetworks/agora/not-found').then((routes) => routes.routes),
Expand Down
3 changes: 2 additions & 1 deletion apps/agora/app/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
import 'jest-preset-angular/setup-jest';
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};

import 'jest-preset-angular/setup-jest';
8 changes: 4 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getJestProjects } = require('@nx/jest');
import { getJestProjectsAsync } from '@nx/jest';

export default {
projects: getJestProjects(),
};
export default async () => ({
projects: await getJestProjectsAsync(),
});
40 changes: 40 additions & 0 deletions libs/agora/about/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"env": {
"jest": true
},
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:jest/recommended"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "agora",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "agora",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
3 changes: 3 additions & 0 deletions libs/agora/about/.hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["../../../.hintrc"]
}
7 changes: 7 additions & 0 deletions libs/agora/about/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# agora-about

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test agora-about` to execute the unit tests.
23 changes: 23 additions & 0 deletions libs/agora/about/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
export default {
displayName: 'agora-about',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageDirectory: '../../../coverage/libs/agora/about',
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',
],
};
35 changes: 35 additions & 0 deletions libs/agora/about/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "agora-about",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/agora/about/src",
"prefix": "agora",
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/agora/about"],
"options": {
"jestConfig": "libs/agora/about/jest.config.ts"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"lint-fix": {
"executor": "@nx/eslint:lint",
"options": {
"fix": true
}
},
"lint-html": {
"executor": "nx:run-commands",
"options": {
"commands": ["hint src/**/*.html"],
"cwd": "libs/agora/about",
"parallel": false
}
}
},
"tags": ["type:feature", "scope:agora", "language:typescript"],
"implicitDependencies": []
}
1 change: 1 addition & 0 deletions libs/agora/about/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/about.routes';
15 changes: 15 additions & 0 deletions libs/agora/about/src/lib/about.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="section section-hero">
<div class="section-inner">
<div class="container-sm">
<h1 class="h2">About</h1>
</div>
</div>
</div>

<div class="section">
<div class="section-inner">
<div class="container-sm">
<agora-wiki [wikiId]="wikiId" [className]="className"></agora-wiki>
</div>
</div>
</div>
Empty file.
13 changes: 13 additions & 0 deletions libs/agora/about/src/lib/about.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AboutComponent } from './about.component';

describe('AboutComponent', () => {
let component: AboutComponent;

beforeEach(() => {
component = new AboutComponent();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions libs/agora/about/src/lib/about.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { WikiComponent } from 'libs/agora/wiki/src/lib/wiki.component';

@Component({
selector: 'agora-about',
standalone: true,
imports: [CommonModule, WikiComponent],
templateUrl: './about.component.html',
styleUrls: ['./about.component.scss'],
})
export class AboutComponent {
wikiId = '612058';
className = 'about-page-content';
}
4 changes: 4 additions & 0 deletions libs/agora/about/src/lib/about.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Routes } from '@angular/router';
import { AboutComponent } from './about.component';

export const routes: Routes = [{ path: '', component: AboutComponent }];
1 change: 1 addition & 0 deletions libs/agora/about/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';
28 changes: 28 additions & 0 deletions libs/agora/about/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"target": "es2020",
"esModuleInterop": true
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
12 changes: 12 additions & 0 deletions libs/agora/about/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}
10 changes: 10 additions & 0 deletions libs/agora/about/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts", "jest.config.ts"]
}
1 change: 1 addition & 0 deletions libs/agora/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"target": "es2020",
"esModuleInterop": true
},
"angularCompilerOptions": {
Expand Down
1 change: 1 addition & 0 deletions libs/agora/styles/src/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

@use './lib/constants';
@use './lib/general';
@use './lib/variables';
103 changes: 103 additions & 0 deletions libs/agora/styles/src/lib/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
@use 'sass:map';
@use 'sass:meta';

@import 'variables';

@mixin reset-button() {
border: none;
margin: 0;
padding: 0;
width: auto;
overflow: visible;
background: transparent;
color: inherit;
font: inherit;
line-height: normal;
appearance: none;

&::-moz-focus-inner {
border: 0;
padding: 0;
}
}

@mixin reset-ul() {
list-style: none;
padding: 0;
margin: 0;
}

@mixin container($width: 'md') {
max-width: var(--container-max-width-#{$width});
padding-left: 0;
padding-right: 0;
margin-left: auto;
margin-right: auto;
}

/**
* Responsive breakpoint manager
* S. https://sass-guidelin.es/#architecture
*/
@mixin respond-to($breakpoint) {
$raw-query: map.get($breakpoints, $breakpoint);

@if $raw-query {
$query: if(
meta.type-of($raw-query) == 'string',
string.unquote($raw-query),
meta.inspect($raw-query)
);

@media #{$query} {
@content;
}
} @else {
@error 'No value found for `#{$breakpoint}`. '
+ 'Please make sure it is defined in `$breakpoints` map.';
}
}

@mixin link-hover {
color: var(--color-link);
text-decoration: underline;
}

@mixin link {
color: var(--color-link);
cursor: pointer;
text-decoration: none;

&:hover {
@include link-hover;
}
}

@mixin two-tone-icon-hover {
.svg-icon-bg {
fill: rgb(var(--color-action-primary-rgb) / 30%);
}

circle,
rect,
path {
&:not(.svg-icon-bg) {
fill: var(--color-action-primary);
}
}
}

@mixin two-tone-icon {
color: var(--color-gray-600);
transition: $transition-duration;

circle,
rect,
path {
transition: $transition-duration;
}

&:hover {
@include two-tone-icon-hover;
}
}
Loading

0 comments on commit bd41e69

Please sign in to comment.