Browse Source

feat(angular): add references, image

fix/testnet-redirects
kyranjamie 4 years ago
committed by kyranjamie
parent
commit
b9b8300654
  1. 15
      public/images/pages/angular-app-sm.svg
  2. 4
      src/pages/authentication/building-todo-app.md
  3. 30
      src/pages/authentication/building-with-angular.md
  4. 5
      src/pages/build-apps.md

15
public/images/pages/angular-app-sm.svg

@ -0,0 +1,15 @@
<svg width="65" height="65" viewBox="0 0 65 65" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="65" height="65">
<path d="M64.5764 0.0744896H0.576416V64.0745H64.5764V0.0744896Z" fill="#F0F0F5"/>
</mask>
<g mask="url(#mask0)">
<path d="M64.5764 0.0744896H0.576416V64.0745H64.5764V0.0744896Z" fill="#9985FF"/>
<path d="M12.5764 16.0745C12.5764 13.8654 14.3673 12.0745 16.5764 12.0745H104.576C106.786 12.0745 108.576 13.8654 108.576 16.0745V68.0745H12.5764V16.0745Z" fill="white"/>
<path opacity="0.32" d="M24.5764 26.5745C24.5764 26.0222 25.0241 25.5745 25.5764 25.5745H67.5764C68.1287 25.5745 68.5764 26.0222 68.5764 26.5745V30.0745C68.5764 30.6268 68.1287 31.0745 67.5764 31.0745H25.5764C25.0241 31.0745 24.5764 30.6268 24.5764 30.0745V26.5745Z" fill="#08018A"/>
<path opacity="0.2" d="M31.5764 40.5745C31.5764 40.0222 32.0241 39.5745 32.5764 39.5745H66.5764C67.1287 39.5745 67.5764 40.0222 67.5764 40.5745V44.0745C67.5764 44.6268 67.1287 45.0745 66.5764 45.0745H32.5764C32.0241 45.0745 31.5764 44.6268 31.5764 44.0745V40.5745Z" fill="#08018A"/>
<path opacity="0.12" d="M27.5764 54.5745C27.5764 54.0222 28.0241 53.5745 28.5764 53.5745H82.5764C83.1287 53.5745 83.5764 54.0222 83.5764 54.5745V58.0745C83.5764 58.6268 83.1287 59.0745 82.5764 59.0745H28.5764C28.0241 59.0745 27.5764 58.6268 27.5764 58.0745V54.5745Z" fill="#08018A"/>
<path d="M28.0165 7L8 14.138L11.053 40.6045L28.0165 50L44.98 40.6045L48.033 14.138L28.0165 7Z" fill="#DD0031"/>
<path d="M28.0165 7V11.773V11.7515V33.531V50L44.98 40.6045L48.033 14.138L28.0165 7Z" fill="#C3002F"/>
<path d="M28.0165 11.7515L15.5035 39.809H20.169L22.6845 33.531H33.3055L35.821 39.809H40.4865L28.0165 11.7515ZM31.6715 29.661H24.3615L28.0165 20.8675L31.6715 29.661Z" fill="white"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

4
src/pages/authentication/building-todo-app.md

@ -1,6 +1,6 @@
---
title: Review Todos app
description: Learn about Stacks authentication and storage by reviewing simple app
title: Building a Todo app
description: Learn how to integrate authentication and data storage with React.
experience: beginners
duration: 30 minutes
tags:

30
src/pages/authentication/building-with-angular.md

@ -1,19 +1,16 @@
---
title: Building an app with Angular
description: Learn how to integrate authentication within an Angular application
title: Stacks Auth with Angular
description: How to integrate authentication within an Angular application
experience: beginners
duration: 30 minutes
tags:
- tutorial
# images:
# large: /images/pages/todo-app.svg
# sm: /images/pages/todo-app-sm.svg
images:
sm: /images/pages/angular-app-sm.svg
---
# Building an with Angular
<!-- ![What you'll be creating in this tutorial](/images/todo-list-app.png) -->
## Getting started with Angular
In this tutorial, you'll learn how to work with Stacks Connect when using [Angular](https://angular.io/) as your framework of choice. It builds on what you've learnt in the [Authentication Overview](/authentication/overview).
@ -36,9 +33,12 @@ Use the `ng new` command to scaffold a new project. We've named ours `ng-stacks-
ng new --minimal --inline-style --inline-template
```
Inside the newly created `ng-stacks-connect` directory, we can boot up the development server on [localhost:4200](http://localhost:4200).
You'll be asked to enter some preferences: whether your app with use routing, and whether you want to use a CSS preprocessor like SASS. For sake of this tutorial, we're keeping things simple. No routing. No preprocessing.
Inside the newly created `ng-stacks-connect` directory, let's boot up the development server which defaults to [localhost:4200](http://localhost:4200).
```sh
cd ng-stacks-connect
ng serve
```
@ -85,9 +85,9 @@ We can use the CLI's generator to scaffold components.
ng generate component
```
Enter the name: `stacks-sign-in-button`. You'll find the newly generated component in `src/app/stacks-sign-in-button`.
Enter the name: `stacks-sign-in-button`. You'll find the newly generated component in `src/app/stacks-sign-in-button/stacks-sign-in-button.component.ts`.
Here's our Sign In button component
Here's our Sign In button component. Let's replace this example with the following code.
```typescript
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
@ -103,7 +103,7 @@ export class StacksSignInButtonComponent {
### 4.2 Connecting Stacks Connect
Let's add this button to our `app-root` component (`app.component.ts`) and wire up the `(onSignIn)` event.
Let's add this button to our `app-root` component (`app.component.ts`) and wire up the `(onSignIn)` event. Make sure to import `Subject` from `rxjs`.
```typescript
@Component({
@ -121,7 +121,7 @@ Here we're using an Rxjs `Subject` to represent a stream of sign in events. `sta
### 4.3 Authentication
First, describe the auth options we need to pass to Connect. [Learn more about `AuthOptions` here](https://docs.blockstack.org/authentication/overview).
First, describe the auth options we need to pass to Connect. [Learn more about `AuthOptions` here](https://docs.blockstack.org/authentication/overview). Let's modify the default component to look like this:
```typescript
import { Component } from '@angular/core';
@ -165,9 +165,10 @@ The output of `authResponse$` can be added to the template for debugging purpose
### 4.3 Loading text
One problem with the current implementation is that there's a network delay while waiting to load the Connect library. Let's keep track of the loading state and display some text in the sign in button component.
One problem with the current implementation is that there's a network delay while waiting to load the Connect library. Let's keep track of the loading state and display some text in the sign in button component. You'll need to `import { tap, switchMap } from 'rxjs/operators';`.
```typescript
// src/app/app.component.ts
isLoadingConnect$ = new BehaviorSubject(false);
ngOnInit() {
@ -201,6 +202,7 @@ export class StacksSignInButtonComponent {
Then, pass the `isLoadingConnect$` Observable into the component, and hide it when the user has already authenticated.
```html
// Edit src/app/app.component.ts
<app-stacks-sign-in-button
*ngIf="!(authResponse$ | async)"
(onSignIn)="stacksAuth$.next()"
@ -208,6 +210,6 @@ Then, pass the `isLoadingConnect$` Observable into the component, and hide it wh
></app-stacks-sign-in-button>
```
## Next steps
### Next steps
This tutorial has shown you how to integrate Stacks Connect with an Angular application. You may want to consider abstracting the Stacks Connect logic behind an [Angular service](https://angular.io/guide/architecture-services), or using [Material Design](https://material.angular.io/) to theme your application.

5
src/pages/build-apps.md

@ -8,11 +8,14 @@ images:
## Introduction
Prefer to jump right in? Get started with this tutorial where you’ll learn by reviewing the code for a todos app built with Stacks.
Prefer to jump right in? Get started with these tutorials such as creating a decentralized to-do list app
[@page-reference | inline]
| /authentication/building-todo-app
[@page-reference | inline]
| /authentication/building-with-angular
## What are decentralized apps?
Decentralized apps are apps that don’t depend on a centralized platform, server or database. Instead, they use a

Loading…
Cancel
Save