Skip to content

Commit

Permalink
feat: implement Angular specific package
Browse files Browse the repository at this point in the history
  • Loading branch information
Soc Sieng authored and socsieng committed Nov 9, 2020
1 parent 1f4bba3 commit 12d021a
Show file tree
Hide file tree
Showing 34 changed files with 7,209 additions and 579 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Expand Up @@ -16,7 +16,13 @@ jobs:
node-version: '12.x'
registry-url: https://npm.pkg.github.com/
scope: '@google-pay'
- name: prebuild
run: scripts/prebuild.sh
- run: npm install
- name: npm install (button-angular)
run: |
cd src/button-angular
npm install
- run: npm run build
- name: publish all to github package repository
run: npm run publish:all
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/push.yml
Expand Up @@ -23,6 +23,12 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: prebuild
run: scripts/prebuild.sh
- run: npm install
- name: npm install (button-angular)
run: |
cd src/button-angular
npm install
- run: npm run build:all
- run: npm test
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -4,6 +4,7 @@ build/

CHANGELOG.md

src/button-angular/package.json
src/button-element/package.json
src/button-react/package.json

Expand Down
7 changes: 1 addition & 6 deletions .vscode/settings.json
@@ -1,12 +1,7 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -39,6 +39,20 @@ npm install @google-pay/button-react

Find out more about the [Google Pay React button][button-react].

## Angular

[![npm version](https://badge.fury.io/js/%40google-pay%2Fbutton-angular.svg)][npm-angular]

An Angular version of the [Google Pay button][button-angular] as been created to make it just as easier to integrate
Google Pay into your Angular website. The advantage of using the Angular version of the Google Pay button over the web
component is that it eliminates the need to register `CUSTOM_ELEMENTS_SCHEMA`.

```sh
npm install @google-pay/button-angular
```

Find out more about the [Google Pay Angular button][button-angular].

## Other frameworks

The intention is for the web component to support other web frameworks. Support for additional framework specific
Expand All @@ -47,7 +61,9 @@ libraries will be considered based on demand.
[google-pay]: https://developers.google.com/pay/api/web/overview
[button-element]: src/button-element
[button-react]: src/button-react
[button-angular]: src/button-angular
[live-demo]: https://developers.google.com/pay/api/web/guides/resources/demos
[custom-elements-compatible]: https://custom-elements-everywhere.com/
[npm-element]: https://www.npmjs.com/package/@google-pay/button-element
[npm-react]: https://www.npmjs.com/package/@google-pay/button-react
[npm-angular]: https://www.npmjs.com/package/@google-pay/button-angular
28 changes: 28 additions & 0 deletions angular.json
@@ -0,0 +1,28 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "src",
"projects": {
"google-pay-button": {
"projectType": "library",
"root": "src/button-angular",
"sourceRoot": "src/button-angular",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "src/button-angular/tsconfig.lib.json",
"project": "src/button-angular/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "src/button-angular/tsconfig.lib.prod.json"
}
}
}
}
}
},
"defaultProject": "google-pay-button"
}
91 changes: 48 additions & 43 deletions examples/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions examples/angular/package.json
Expand Up @@ -11,26 +11,27 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^10.2.0",
"@angular/common": "^10.2.0",
"@angular/compiler": "^10.2.0",
"@angular/core": "^10.2.0",
"@angular/forms": "^10.2.0",
"@angular/platform-browser": "^10.2.0",
"@angular/platform-browser-dynamic": "^10.2.0",
"@angular/router": "^10.2.0",
"@google-pay/button-element": "file:../../src/button-element",
"@angular/animations": "^10.2.2",
"@angular/common": "^10.2.2",
"@angular/compiler": "^10.2.2",
"@angular/core": "^10.2.2",
"@angular/forms": "^10.2.2",
"@angular/platform-browser": "^10.2.2",
"@angular/platform-browser-dynamic": "^10.2.2",
"@angular/router": "^10.2.2",
"@google-pay/button-angular": "file:../../src/button-angular/dist",
"@types/googlepay": "^0.5.0",
"rxjs": "~6.6.3",
"tslib": "^2.0.0",
"zone.js": "~0.11.2"
"zone.js": "^0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1002.0",
"@angular/cli": "^10.2.0",
"@angular/compiler-cli": "^10.2.0",
"@types/jasmine": "^3.6.0",
"@angular/compiler-cli": "^10.2.2",
"@types/jasmine": "^3.6.1",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^14.14.5",
"@types/node": "^14.14.6",
"codelyzer": "^6.0.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
Expand Down
3 changes: 2 additions & 1 deletion examples/angular/src/app/app.component.html
Expand Up @@ -174,7 +174,8 @@
(error)="onError($event)"
(readytopaychange)="onReadyToPayChange($event)"
[paymentAuthorizedCallback]="onPaymentDataAuthorized"
></google-pay-button>
>
</google-pay-button>
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions examples/angular/src/app/app.component.ts
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/

import '@google-pay/button-element';

import { ReadyToPayChangeResponse } from '@google-pay/button-element';
import { Component } from '@angular/core';
import { ReadyToPayChangeResponse } from '@google-pay/button-angular';

@Component({
selector: 'app-root',
Expand Down
6 changes: 3 additions & 3 deletions examples/angular/src/app/app.module.ts
Expand Up @@ -15,16 +15,16 @@
*/

import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';
import { GooglePayButtonModule } from '@google-pay/button-angular';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, FormsModule],
imports: [BrowserModule, FormsModule, GooglePayButtonModule],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
5 changes: 3 additions & 2 deletions examples/angular/tsconfig.app.json
Expand Up @@ -2,8 +2,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["googlepay"]
"types": ["googlepay", "node"]
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"]
"include": ["src/**/*.d.ts", "../../src/lib"],
"exclude": ["../../src/**/*.test.ts", "../../src/**/__*__"]
}
1 change: 1 addition & 0 deletions examples/angular/tsconfig.json
Expand Up @@ -14,6 +14,7 @@
"lib": ["es2018", "dom"]
},
"angularCompilerOptions": {
"enableIvy": false,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
Expand Down

0 comments on commit 12d021a

Please sign in to comment.