Skip to content

Commit

Permalink
comp(social-login-buttons) Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacklone committed Jul 15, 2020
1 parent bffcddf commit aaa08b2
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Cool inline edit field for angular

Cool button with loading indicator for angular

## [@angular-cool/loading-button](/projects/social-login-buttons/README.md)
[![NPM version][social-login-buttons-npm-image]][social-login-buttons-npm-url] [![Downloads][social-login-buttons-downloads-image]][social-login-buttons-npm-url] [![Total Downloads][social-login-buttons-total-downloads-image]][social-login-buttons-npm-url]

Cool social login buttons for angular

## [@angular-cool/virtual-grid](/projects/virtual-grid/README.md)
[![NPM version][virtual-grid-npm-image]][virtual-grid-npm-url] [![Downloads][virtual-grid-downloads-image]][virtual-grid-npm-url] [![Total Downloads][virtual-grid-total-downloads-image]][virtual-grid-npm-url]

Expand Down
40 changes: 40 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,46 @@
}
}
},
"social-login-buttons": {
"projectType": "library",
"root": "projects/social-login-buttons",
"sourceRoot": "projects/social-login-buttons/src",
"prefix": "cool",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/social-login-buttons/tsconfig.lib.json",
"project": "projects/social-login-buttons/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/social-login-buttons/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/social-login-buttons/src/test.ts",
"tsConfig": "projects/social-login-buttons/tsconfig.spec.json",
"karmaConfig": "projects/social-login-buttons/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/social-login-buttons/tsconfig.lib.json",
"projects/social-login-buttons/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"loading-indicator": {
"projectType": "library",
"root": "projects/loading-indicator",
Expand Down
21 changes: 21 additions & 0 deletions projects/social-login-buttons/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Hacklone <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions projects/social-login-buttons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[npm-url]: https://npmjs.org/package/@angular-cool/social-login-buttons
[npm-image]: https://img.shields.io/npm/v/@angular-cool/social-login-buttons.svg
[downloads-image]: https://img.shields.io/npm/dm/@angular-cool/social-login-buttons.svg
[total-downloads-image]: https://img.shields.io/npm/dt/@angular-cool/social-login-buttons.svg

# @angular-cool/social-login-buttons [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Total Downloads][total-downloads-image]][npm-url]
Cool social login buttons for angular

## Install
> npm install --save @angular-cool/social-login-buttons
## Setup
```javascript
import { NgModule } from '@angular/core';
import { CoolLoadingButtonModule } from '@angular-cool/social-login-buttons';

@NgModule({
imports: [CoolSocialLoginButtonsModule]
})
export class MyAppModule {}
```

## Google button

### Usage

```html
<cool-google-button style="dark" (click)="onGoogleLoginClicked()">
Login with Google
</cool-google-button>
```

### API
#### Inputs
* \[style]
- Type: 'dark' | 'light'
- Style of the button

* \[disabled]
- Type: boolean
- Whether the button is disabled

#### Outputs
* \(click)
- Type: MouseEvent
- Called when the button has been clicked

## License
> The MIT License (MIT)
> Copyright (c) 2020 Hacklone
> https://github.com/Hacklone
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
32 changes: 32 additions & 0 deletions projects/social-login-buttons/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/social-login-buttons'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
7 changes: 7 additions & 0 deletions projects/social-login-buttons/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/social-login-buttons",
"lib": {
"entryFile": "src/public-api.ts"
}
}
35 changes: 35 additions & 0 deletions projects/social-login-buttons/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@angular-cool/social-login-buttons",
"version": "2.0.0",
"description": "Cool social login buttons for angular",
"peerDependencies": {
"@angular/common": "^9.0.0",
"@angular/core": "^9.0.0",
"tslib": "^1.10.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Hacklone/angular-cool.git"
},
"keywords": [
"angular2",
"angular",
"social",
"login",
"sign-in",
"google",
"button"
],
"author": "Hacklone <[email protected]>",
"license": "MIT",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/Hacklone/angular-cool/raw/master/LICENSE"
}
],
"bugs": {
"url": "https://github.com/Hacklone/angular-cool/issues"
},
"homepage": "https://github.com/Hacklone/angular-cool/blob/master/projects/social-login-buttons/README.md"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';

import { CommonModule } from '@angular/common';
import { CoolGoogleButtonComponent } from './google-button/cool-google-button.component';

@NgModule({
imports: [
CommonModule,
],
providers: [],
declarations: [
CoolGoogleButtonComponent,
],
exports: [
CoolGoogleButtonComponent,
],
})
export class CoolSocialLoginButtonsModule {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<button type="button" class="google-button"
[class.disabled]="disabled"
[class.light]="style === 'light'"
[class.dark]="style === 'dark'"
(click)="onClick($event)">
<span class="icon">
<svg viewBox="0 0 366 372" xmlns="http://www.w3.org/2000/svg"><path
d="M125.9 10.2c40.2-13.9 85.3-13.6 125.3 1.1 22.2 8.2 42.5 21 59.9 37.1-5.8 6.3-12.1 12.2-18.1 18.3l-34.2 34.2c-11.3-10.8-25.1-19-40.1-23.6-17.6-5.3-36.6-6.1-54.6-2.2-21 4.5-40.5 15.5-55.6 30.9-12.2 12.3-21.4 27.5-27 43.9-20.3-15.8-40.6-31.5-61-47.3 21.5-43 60.1-76.9 105.4-92.4z"
id="Shape" fill="#EA4335"/><path
d="M20.6 102.4c20.3 15.8 40.6 31.5 61 47.3-8 23.3-8 49.2 0 72.4-20.3 15.8-40.6 31.6-60.9 47.3C1.9 232.7-3.8 189.6 4.4 149.2c3.3-16.2 8.7-32 16.2-46.8z"
id="Shape" fill="#FBBC05"/><path
d="M361.7 151.1c5.8 32.7 4.5 66.8-4.7 98.8-8.5 29.3-24.6 56.5-47.1 77.2l-59.1-45.9c19.5-13.1 33.3-34.3 37.2-57.5H186.6c.1-24.2.1-48.4.1-72.6h175z"
id="Shape" fill="#4285F4"/><path
d="M81.4 222.2c7.8 22.9 22.8 43.2 42.6 57.1 12.4 8.7 26.6 14.9 41.4 17.9 14.6 3 29.7 2.6 44.4.1 14.6-2.6 28.7-7.9 41-16.2l59.1 45.9c-21.3 19.7-48 33.1-76.2 39.6-31.2 7.1-64.2 7.3-95.2-1-24.6-6.5-47.7-18.2-67.6-34.1-20.9-16.6-38.3-38-50.4-62 20.3-15.7 40.6-31.5 60.9-47.3z"
fill="#34A853"/></svg>
</span>
<span class="text"><ng-content></ng-content></span>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.google-button {
height: 36px;
background-color: #4285f4;
border: 1px solid #4285f4;
color: #fff;
border-radius: 5px;
white-space: nowrap;
box-shadow: 1px 1px 0 1px rgba(0, 0, 0, 0.05);
transition-property: background-color, box-shadow;
transition-duration: 150ms;
transition-timing-function: ease-in-out;
padding: 0;

cursor: pointer;

&.dark {
background-color: #4285f4;
border: 1px solid #4285f4;

color: #fff;
}

&.light {
background-color: #fff;
border: 1px solid #fff;

color: #757575;
}

&:focus,
&:active,
&:hover {
outline: 0;
}

&:not(.disabled) {
&:focus,
&:active,
&:hover {
box-shadow: 1px 4px 5px 1px rgba(0, 0, 0, 0.1);
}
}

&.disabled {
cursor: default;

background-color: rgba(0, 0, 0, 0.12);
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);
border-color: #eee;
color: rgba(0, 0, 0, 0.26);

.icon {
background-color: #eee;
}
}

.icon {
display: inline-block;
vertical-align: middle;
width: 40px;
height: 100%;
padding: 4px 12px;
box-sizing: border-box;

border-top-left-radius: 5px;
border-bottom-left-radius: 5px;

background-color: #fff;
}

.text {
display: inline-block;
vertical-align: middle;
padding: 0 10px 0 10px;
font-size: 14px;
font-weight: 500;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';

@Component({
selector: 'cool-google-button',
templateUrl: './cool-google-button.component.html',
styleUrls: ['./cool-google-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CoolGoogleButtonComponent implements OnInit {

constructor() { }

@Input()
public disabled: boolean;

@Input()
public style: 'dark' | 'light' = 'dark';

@Output()
public click: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

ngOnInit() {
}

public onClick(event: MouseEvent) {
if (this.disabled) {
return;
}

this.click.emit(event);

event.stopPropagation();
event.preventDefault();
}
}
6 changes: 6 additions & 0 deletions projects/social-login-buttons/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Public API Surface of social-login-buttons
*/

export * from './lib/google-button/cool-google-button.component';
export * from './lib/cool-social-login-buttons.module';
Loading

0 comments on commit aaa08b2

Please sign in to comment.