Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 43 additions & 78 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"changeDetection": "OnPush",
"standalone": true,
Comment thread
artembelik marked this conversation as resolved.
"inlineTemplate": true,
"inlineStyle": true,
"skipTests": true
Comment thread
NikGurev marked this conversation as resolved.
},
"@schematics/angular:application": {
"strict": true,
"standalone": true,
Comment thread
artembelik marked this conversation as resolved.
"inlineTemplate": true,
"inlineStyle": true,
"skipTests": true,
"minimal": true
}
},
"projects": {
"koobiq-docs": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"changeDetection": "OnPush",
"standalone": true,
"inlineTemplate": true,
"inlineStyle": true,
"skipTests": true
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "apps/docs",
"sourceRoot": "apps/docs",
"prefix": "app",
"prefix": "docs",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"sourceMap": true,
"outputPath": "./dist/releases/koobiq-docs",
"outputPath": {
"base": "dist/releases/koobiq-docs"
},
"index": "apps/docs/src/index.html",
"main": "apps/docs/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/docs/tsconfig.app.json",
"assets": [
Expand Down Expand Up @@ -76,86 +81,46 @@
"stylePreprocessorOptions": {
"includePaths": ["dist", "apps/docs/src"]
},
"styles": [
"apps/docs/src/main.scss"
],
"styles": ["apps/docs/src/main.scss"],
"scripts": [],
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"optimization": false,
"namedChunks": true,
"allowedCommonJsDependencies": [
"highlight.js",
"@messageformat/core",
"path-normalize"
]
"browser": "apps/docs/src/main.ts",
"server": "apps/docs/src/main.server.ts",
"prerender": true,
Comment thread
artembelik marked this conversation as resolved.
"ssr": {
"entry": "apps/docs/src/server.ts"
}
Comment thread
NikGurev marked this conversation as resolved.
},
"configurations": {
"development": {
"tsConfig": "apps/docs/tsconfig.app.json",
"fileReplacements": [
{
"replace": "apps/docs/src/environments/environment.ts",
"with": "apps/docs/src/environments/environment.prod.ts"
}
],
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"production": {
"outputHashing": "all",
"tsConfig": "apps/docs/tsconfig.build.json",
"fileReplacements": [
{
"replace": "apps/docs/src/environments/environment.ts",
"with": "apps/docs/src/environments/environment.prod.ts"
}
],
"optimization": {
"scripts": true,
"styles": true,
"fonts": false
},
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"aot": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"buildTarget": "koobiq-docs:build"
},
"configurations": {
"development": {
"buildTarget": "koobiq-docs:build:development"
},
"production": {
"buildTarget": "koobiq-docs:build:production"
},
"development": {
"buildTarget": "koobiq-docs:build:development"
}
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-builders/jest:run",
Expand Down
60 changes: 25 additions & 35 deletions apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,41 @@
## [Production Build](../../.github/workflows/actions/build-docs/action.yml)
# Documentation application

Before building the documentation, you must first [build packages](#build-packages) and [generate sitemap](#generate-sitemapxml)
This is the [Koobiq design system](https://koobiq.io/en) website application.

```bash
yarn run build:docs-examples-module &&
yarn run build:docs-examples &&
yarn run build:docs-content &&
yarn run build:package-docs-content &&
yarn run docs:build
```
## Development

## Generate `sitemap.xml`
Make sure you have the [correct version](.nvmrc) of Node.js installed (we recommend using [nvm](https://github.com/nvm-sh/nvm)).

```bash
yarn run docs:generate-sitemap
```
# Setup Node.js
nvm use

## Build packages
# Install dependencies
yarn install

```bash
yarn run build:cdk &&
yarn run build:components &&
yarn run build:angular-luxon-adapter &&
yarn run build:angular-moment-adapter &&
# Build packages
yarn run build:cdk
yarn run build:angular-luxon-adapter
yarn run build:angular-moment-adapter
yarn run styles:build-all
```

## Generate `docs-content` folder (dgeni)

```bash
yarn run build:docs-content && yarn run build:package-docs-content
```
yarn run build:components
yarn run build:components-experimental
Comment thread
artembelik marked this conversation as resolved.

## Generate basic module
# Generate content
yarn run build:docs-content
yarn run build:package-docs-content

```bash
# Generate examples
yarn run build:docs-examples-module
```

## Generate examples

```bash
yarn run build:docs-examples
```

## Debugging
# Generate sitemap
yarn run docs:generate-sitemap

```bash
# Run application
yarn run docs:start:dev
# Then open http://localhost:4200

# Build application
yarn run docs:build
```
26 changes: 18 additions & 8 deletions apps/docs/src/app/components/anchors/anchors.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class DocsAnchorsComponent implements OnDestroy, OnInit {
return this.anchors.find((anchor) => anchor.href === href) || this.firstAnchor;
}

setScrollPosition() {
setScrollPosition(): void {
this.anchors = this.createAnchors();

this.updateActiveAnchor();
Expand All @@ -143,14 +143,18 @@ export class DocsAnchorsComponent implements OnDestroy, OnInit {
// scroll after docs-sidepanel scrolled
setTimeout(() => target.scrollIntoView());
} else {
this.scrollContainer.scroll(0, 0);
// For SSR compatibility
if (typeof this.scrollContainer.scroll === 'function') this.scrollContainer.scroll(0, 0);
Comment thread
artembelik marked this conversation as resolved.
}

this.scrollSubscription?.unsubscribe();

this.scrollSubscription = fromEvent(this.scrollContainer, 'scroll')
.pipe(debounceTime(this.debounceTime), takeUntilDestroyed(this.destroyRef))
.subscribe(this.onScroll);
// For SSR compatibility
if (typeof this.scrollContainer.scroll === 'function') {
Comment thread
artembelik marked this conversation as resolved.
this.scrollSubscription = fromEvent(this.scrollContainer, 'scroll')
.pipe(debounceTime(this.debounceTime), takeUntilDestroyed(this.destroyRef))
.subscribe(this.onScroll);
}

this.ref.detectChanges();
}
Expand Down Expand Up @@ -209,10 +213,16 @@ export class DocsAnchorsComponent implements OnDestroy, OnInit {
);
}

private getHeaderTopOffset(header: HTMLElement) {
const bodyTop = this.document.body.getBoundingClientRect().top;
private getHeaderTopOffset(header: HTMLElement): number {
// For SSR compatibility
if (typeof this.document.body.getBoundingClientRect !== 'function') return 0;

return this.scrollContainer.scrollTop + header.getBoundingClientRect().top - bodyTop + this.headerHeight;
return (
this.scrollContainer.scrollTop +
header.getBoundingClientRect().top -
this.document.body.getBoundingClientRect().top +
this.headerHeight
);
}

private getLevel(classList): number {
Expand Down
54 changes: 54 additions & 0 deletions apps/docs/src/config.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { mergeApplicationConfig, Provider } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { KBQ_WINDOW } from '@koobiq/components/core';
import config from './config';

const provideServerWindow = (): Provider => {
Comment thread
artembelik marked this conversation as resolved.
return {
provide: KBQ_WINDOW,
useFactory: () => {
return {
matchMedia: () => ({
addEventListener: () => {},
dispatchEvent: () => false,
removeEventListener: () => {},
matches: false,
media: '',
onchange: null,
addListener: () => {},
removeListener: () => {}
}),
Comment thread
artembelik marked this conversation as resolved.
localStorage: {
length: 0,
getItem: () => null,
setItem: () => {},
removeItem: () => {},
clear: () => {},
key: () => null
},
location: {
host: '',
protocol: '',
ancestorOrigins: {} as DOMStringList,
hash: '',
hostname: '',
href: '',
origin: '',
pathname: '/',
port: '',
search: '',
assign: () => {},
reload: () => {},
replace: () => {}
}
} satisfies Partial<Window>;
}
};
};

export default mergeApplicationConfig(config, {
providers: [
provideServerRendering(),
provideServerWindow()
]
});
16 changes: 16 additions & 0 deletions apps/docs/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { provideHttpClient, withFetch } from '@angular/common/http';
import { ApplicationConfig } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { KBQ_LOCALE_SERVICE, KbqLocaleService, kbqLocaleServiceLangAttrNameProvider } from '@koobiq/components/core';
import { DOCS_ROUTES } from './app/routes';

export default {
providers: [
{ provide: KBQ_LOCALE_SERVICE, useClass: KbqLocaleService },
kbqLocaleServiceLangAttrNameProvider('examples-lang'),
provideRouter(DOCS_ROUTES),
provideHttpClient(withFetch()),
provideAnimations()
]
} satisfies ApplicationConfig;
Comment thread
artembelik marked this conversation as resolved.
5 changes: 5 additions & 0 deletions apps/docs/src/main.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { bootstrapApplication, BootstrapContext } from '@angular/platform-browser';
Comment thread
artembelik marked this conversation as resolved.
import { DocsAppComponent } from './app/app.component';
import config from './config.server';

export default (context: BootstrapContext) => bootstrapApplication(DocsAppComponent, config, context);
21 changes: 2 additions & 19 deletions apps/docs/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import { provideHttpClient } from '@angular/common/http';
import { enableProdMode } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { KBQ_LOCALE_SERVICE, KbqLocaleService, kbqLocaleServiceLangAttrNameProvider } from '@koobiq/components/core';
import { DocsAppComponent } from './app/app.component';
import { DOCS_ROUTES } from './app/routes';
import { environment } from './environments/environment';
import config from './config';

if (environment.production) {
enableProdMode();
}

bootstrapApplication(DocsAppComponent, {
providers: [
provideAnimations(),
provideHttpClient(),
provideRouter(DOCS_ROUTES),
kbqLocaleServiceLangAttrNameProvider('examples-lang'),
{ provide: KBQ_LOCALE_SERVICE, useClass: KbqLocaleService }]
}).catch((error) => console.error(error));
bootstrapApplication(DocsAppComponent, config).catch((err) => console.error(err));
Loading
Loading