Skip to content

Commit 7bbee0a

Browse files
committed
fix code-demos todos, fix about page
1 parent ada2176 commit 7bbee0a

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

apps/codelab/src/app/codelabs/about/about.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ <h2>We don't. We use highlight instead</h2>
138138

139139
<div *slide>
140140
<h2>Find position by regex or string</h2>
141-
<!-- TODO(sancheez): check-->
142-
<!-- <code-demo-editor [(ngModel)]="code.highlights.find"></code-demo-editor>-->
141+
<code-demo-editor [(ngModel)]="code.highlights.find"></code-demo-editor>
143142
</div>
144143

145144
<div *slide>

apps/codelab/src/app/codelabs/about/about.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ export class AboutComponent implements OnInit {
3232
},
3333
},
3434
highlights: {
35-
// find: require('!!raw-loader!@codelab/code-demos/src/lib/code-demo-editor/utils/utils')
36-
// .default,
35+
find: require('!!raw-loader!./samples/find-position.ts.file')
36+
.default,
3737
},
3838
};
3939

40-
constructor() {}
40+
constructor() {
41+
}
4142

4243
ngOnInit() {}
4344
}

apps/codelab/src/app/codelabs/about/about.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { FormsModule } from '@angular/forms';
55
import { CodeDemoModule } from '@codelab/code-demos';
66
import { SlidesModule, SlidesRoutes } from '@codelab/slides';
77
import { AboutComponent } from './about.component';
8+
import { TrackingModule } from '@codelab/utils';
89

910
const routes = RouterModule.forChild(SlidesRoutes.get(AboutComponent));
1011

1112
@NgModule({
1213
declarations: [AboutComponent],
13-
imports: [CommonModule, SlidesModule, routes, CodeDemoModule, FormsModule],
14+
imports: [CommonModule, SlidesModule, routes, CodeDemoModule, FormsModule, TrackingModule]
1415
})
1516
export class AboutModule {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export function findPosition(code: string, match: string | RegExp) {
2+
if (match instanceof RegExp) {
3+
try {
4+
match = code.match(match)[0];
5+
} catch (e) {
6+
7+
debugger;
8+
match = '';
9+
}
10+
}
11+
12+
const textBeforeMatch = code.split(match as any)[0];
13+
const lineStart = textBeforeMatch.split('\n').length;
14+
const lineStartPosition =
15+
textBeforeMatch.lastIndexOf('\n') + /*compensate for \n */ 1;
16+
const indexStart = textBeforeMatch.length - lineStartPosition + 1;
17+
const lastMatchNewLinePosition = match.lastIndexOf('\n') + 1;
18+
const lineEnd = lineStart + match.split('\n').length - 1;
19+
const indexEnd = match.includes('\n')
20+
? match.length - lastMatchNewLinePosition
21+
: indexStart + match.length;
22+
return { lineStart, indexStart, indexEnd, lineEnd };
23+
}

libs/sync/src/lib/components/sync-code-game/sync-code-game-viewer/sync-code-game-viewer.component.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<!--TODO(sancheez): circle deps-->
2-
<!--<code-demo-editor-->
3-
<!-- fontSize="20"-->
4-
<!-- [(ngModel)]="questions[0].code"-->
5-
<!--&gt;</code-demo-editor>-->
1+
<code-demo-editor
2+
fontSize="20"
3+
[(ngModel)]="questions[0].code"
4+
></code-demo-editor>
65
<!-- <slides-typescript-checker-runner-->
76
<!-- [code]="q.code"-->
87
<!-- ></slides-typescript-checker-runner>-->

libs/utils/src/lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export { TrackingDirective } from './tracking/tracking.directive';
2+
export { TrackingModule } from './tracking/tracking.module';
13
export { SimpleTestsProgressComponent } from './test-results/simple-tests-progress/simple-tests-progress.component';
24
export { SimpleTestsProgressModule } from './test-results/simple-tests-progress/simple-tests-progress.module';
35
export { getMockAngularFireProviders } from './testing/mocks/angular-fire';

libs/utils/src/lib/tracking/tracking.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class TrackingDirective {
1919
private router: Router,
2020
private presentation: SlidesDeckComponent
2121
) {
22-
afAuth.auth.signInAnonymously();
22+
afAuth.signInAnonymously();
2323
afAuth.authState.subscribe((authData) => {
2424
this.auth = authData;
2525
});

0 commit comments

Comments
 (0)