Skip to content

Commit 6547ccd

Browse files
committed
feat: implement pipe preview
1 parent de9a853 commit 6547ccd

File tree

11 files changed

+190
-209
lines changed

11 files changed

+190
-209
lines changed

apps/docs/project.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"input": "apps/docs/public"
2020
}
2121
],
22-
"styles": ["apps/docs/src/styles.css"]
22+
"styles": ["apps/docs/src/styles.css"],
23+
"allowedCommonJsDependencies": ["prismjs"]
24+
2325
},
2426
"configurations": {
2527
"production": {

apps/docs/src/app/app.routes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Route } from '@angular/router';
22
import { Landing } from './pages/landing';
33
import { Introduction } from './pages/introduction';
4-
import { PipesPageComponent } from './pages/pipes';
5-
import { Count } from './pages/count';
6-
import { PipesList } from './pages/pipes-list';
4+
import { PipesPageComponent } from './pages/pipes/pipes';
5+
import { Count } from './pages/pipes/count';
6+
import { PipesList } from './pages/pipes/pipes-list';
77

88
export const appRoutes: Route[] = [
99
{

apps/docs/src/app/pages/count.ts

Lines changed: 0 additions & 122 deletions
This file was deleted.

apps/docs/src/app/pages/introduction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {Component} from '@angular/core';
2+
import {Footer} from '../reusables/footer';
23

34
@Component({
45
selector: 'app-introduction-page',
56
standalone: true,
7+
imports: [Footer],
68
template: `
79
<div class="container mx-auto py-10 px-4 md:px-8 max-w-4xl">
810
<h1 class="scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl mb-6">Introduction</h1>
@@ -29,6 +31,7 @@ import {Component} from '@angular/core';
2931
<div class="relative rounded-md bg-muted p-4 font-mono text-sm mt-4">
3032
npm install &#64;ngx-transforms/core
3133
</div>
34+
<app-footer />
3235
</div>
3336
`
3437
})
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import {Component, signal} from '@angular/core';
2+
import {CountPipe} from '@ngx-transforms';
3+
import {NgIconComponent, provideIcons} from '@ng-icons/core';
4+
import {lucideChevronRight} from '@ng-icons/lucide';
5+
import {CodePreview} from "../../reusables/code-preview/code-preview";
6+
import {CommandPreview} from "../../reusables/command-preview/command-preview";
7+
import {NextPrevNavigationComponent} from "../../reusables/next-prev-navigation/next-prev-navigation";
8+
9+
@Component({
10+
selector: 'app-count-pipe-page',
11+
standalone: true,
12+
imports: [CountPipe, NgIconComponent, CodePreview, CommandPreview, NextPrevNavigationComponent],
13+
providers: [provideIcons({lucideChevronRight})],
14+
template: `
15+
<div class="container mx-auto py-10 px-4 md:px-8 max-w-4xl">
16+
<!-- Breadcrumb -->
17+
<nav class="flex items-center text-sm text-muted-foreground mb-6">
18+
<a href="/docs/pipes" class="hover:text-foreground transition-colors">Pipes</a>
19+
<ng-icon name="lucideChevronRight" class="h-4 w-4 mx-2"></ng-icon>
20+
<span class="text-foreground font-medium">Count</span>
21+
</nav>
22+
23+
<h1 class="scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl mb-2">Count Pipe</h1>
24+
<p class="text-lg text-muted-foreground mb-8">Returns the length of an array or string.</p>
25+
26+
<h2 class="text-2xl font-bold my-8">Installation</h2>
27+
<app-command-preview command="npm install @ngx-transforms/core"></app-command-preview>
28+
29+
<h2 class="text-2xl font-bold my-8">Usage</h2>
30+
31+
<app-code-preview [code]="code" [language]="'typescript'">
32+
<div class="space-y-8">
33+
<div>
34+
<h3 class="text-xl font-semibold mb-4">Array Length</h3>
35+
<div class="rounded-md bg-muted p-6 border border-border">
36+
<div class="mb-4">
37+
<code class="text-sm font-mono bg-background/50 px-2 py-1 rounded">items = [1, 2, 3, 4, 5]</code>
38+
</div>
39+
<div class="flex items-center gap-4">
40+
<div class="text-sm font-mono text-muted-foreground">{{ '{' }}{{ '{' }} items |
41+
count {{ '}' }}{{ '}' }}
42+
</div>
43+
<div class="h-px flex-1 bg-border"></div>
44+
<div class="font-bold text-primary">{{ items | count }}</div>
45+
</div>
46+
</div>
47+
</div>
48+
49+
<div>
50+
<h3 class="text-xl font-semibold mb-4">String Length</h3>
51+
<div class="rounded-md bg-muted p-6 border border-border">
52+
<div class="mb-4">
53+
<code class="text-sm font-mono bg-background/50 px-2 py-1 rounded">text = 'Hello World'</code>
54+
</div>
55+
<div class="flex items-center gap-4">
56+
<div class="text-sm font-mono text-muted-foreground">{{ '{' }}{{ '{' }} text |
57+
count {{ '}' }}{{ '}' }}
58+
</div>
59+
<div class="h-px flex-1 bg-border"></div>
60+
<div class="font-bold text-primary">{{ text | count }}</div>
61+
</div>
62+
</div>
63+
</div>
64+
</div>
65+
</app-code-preview>
66+
67+
<div class="mt-16 pt-8 border-t border-border flex justify-between items-center text-sm text-muted-foreground">
68+
<div>
69+
Built by <a href="https://github.com/mofirojean" target="_blank"
70+
class="font-medium underline underline-offset-4 hover:text-foreground">Mofiro Jean</a>
71+
</div>
72+
<div class="flex gap-4">
73+
<app-next-prev-navigation [previous]="{label: 'Pipes', link: '/docs/pipes'}" [next]="{label: 'Debounce', link: '/docs/pipes/debounce'}" />
74+
</div>
75+
</div>
76+
</div>
77+
`,
78+
})
79+
export class Count {
80+
items = [1, 2, 3, 4, 5];
81+
text = 'Hello World';
82+
83+
code = `
84+
import { Component } from '@angular/core';
85+
import { CountPipe } from '@ngx-transforms/core';
86+
87+
@Component({
88+
selector: 'app-example',
89+
standalone: true,
90+
imports: [CountPipe],
91+
template: \`
92+
<p>Array Count: {{ items | count }}</p>
93+
<p>String Count: {{ text | count }}</p>
94+
\`
95+
})
96+
export class ExampleComponent {
97+
items = [1, 2, 3, 4, 5];
98+
text = 'Hello World';
99+
}
100+
`;
101+
}
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ import {lucideMenu, lucideX} from '@ng-icons/lucide';
4040
routerLink="/docs/introduction"
4141
routerLinkActive="font-medium text-primary bg-primary/10"
4242
(click)="isSidebarOpen.set(false)"
43-
class="group flex w-full items-center rounded-md border border-transparent px-2 py-1.5 hover:underline text-muted-foreground hover:text-foreground transition-colors"
43+
class="group flex w-full items-center rounded-md border border-transparent px-2 py-1.5 hover:bg-primary/10 text-muted-foreground hover:text-foreground transition-colors"
4444
>
4545
Introduction
4646
</a>
4747
</div>
4848
49-
<h4 class="mb-4 text-sm font-semibold leading-none tracking-tight">Pipes</h4>
49+
<h4 routerLink="/docs/pipes" class="mb-4 text-sm font-semibold cursor-pointer leading-none tracking-tight">Pipes</h4>
5050
<div class="grid grid-flow-row auto-rows-max text-sm">
5151
<a
5252
routerLink="/docs/pipes/count"
5353
routerLinkActive="font-medium text-primary bg-primary/10"
5454
(click)="isSidebarOpen.set(false)"
55-
class="group flex w-full items-center rounded-md border border-transparent px-2 py-1.5 hover:underline text-muted-foreground hover:text-foreground transition-colors"
55+
class="group flex w-full items-center rounded-md border border-transparent px-2 py-1.5 hover:bg-primary/10 text-muted-foreground hover:text-foreground transition-colors"
5656
>
5757
Count
5858
</a>

apps/docs/src/app/reusables/footer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Component } from '@angular/core';
88
<footer class="border-t border-border/40 bg-background py-6 md:py-0">
99
<div class="container mx-auto flex flex-col items-center justify-center gap-4 md:h-24 md:flex-row px-4 md:px-8">
1010
<p class="text-center text-sm leading-loose text-muted-foreground">
11-
Built by <a href="#" class="font-medium underline underline-offset-4">Mofiro Jean</a>.
11+
Built by <a href="https://github.com/mofirojean" class="font-medium underline underline-offset-4">Mofiro Jean</a>.
1212
The source code is available on <a href="https://github.com/mofirojean/ngx-transforms" class="font-medium underline underline-offset-4">GitHub</a>.
1313
</p>
1414
</div>

apps/docs/src/styles.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,20 @@
3838
--sidebar-accent-foreground: oklch(0.216 0.006 56.043);
3939
--sidebar-border: oklch(0.923 0.003 48.717);
4040
--sidebar-ring: oklch(0.709 0.01 56.259);
41+
42+
--token-comment: #999;
43+
--token-punctuation: #ccc;
44+
--token-tag: #e2777a;
45+
--token-function-name: #6196cc;
46+
--token-boolean: #f08d49;
47+
--token-property: #f8c555;
48+
--token-keyword: #cc99cd;
49+
--token-string: #7ec699;
50+
--token-operator: #67cdcc;
4151
}
4252

4353
:root.dark {
4454
color-scheme: dark;
45-
4655
--background: oklch(0.147 0.004 49.25);
4756
--foreground: oklch(0.985 0.001 106.423);
4857
--card: oklch(0.216 0.006 56.043);
@@ -75,6 +84,16 @@
7584
--sidebar-accent-foreground: oklch(0.985 0.001 106.423);
7685
--sidebar-border: oklch(1 0 0 / 10%);
7786
--sidebar-ring: oklch(0.553 0.013 58.071);
87+
88+
--token-comment: #6a737d;
89+
--token-punctuation: #d1d5da;
90+
--token-tag: #ff7b72;
91+
--token-function-name: #79b8ff;
92+
--token-boolean: #ffab70;
93+
--token-property: #ffea7f;
94+
--token-keyword: #f97583;
95+
--token-string: #9e FFB3;
96+
--token-operator: #79b8ff;
7897
}
7998

8099
@theme {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
"@ng-icons/lucide": ">=32.0.0 <34.0.0",
3939
"@spartan-ng/brain": "^0.0.1-alpha.586",
4040
"@spartan-ng/cli": "^0.0.1-alpha.586",
41+
"@types/prismjs": "^1.26.5",
4142
"class-variance-authority": "^0.7.0",
4243
"clsx": "^2.1.1",
4344
"express": "^5.1.0",
45+
"prismjs": "^1.30.0",
4446
"rxjs": "~7.8.0",
4547
"tailwind-merge": "^3.3.1",
4648
"tslib": "^2.3.0"

0 commit comments

Comments
 (0)