Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.5.9 #594

Merged
merged 14 commits into from
Jun 19, 2020
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Goponents

###### Currently `v1.5.8`
###### Currently `v1.5.9`

This project houses a set of UI components for Angular 7+ and designed around the 'Go' design system.

Expand Down
2 changes: 1 addition & 1 deletion projects/go-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tangoe/goponents",
"version": "1.5.8",
"version": "1.5.9",
"repository": {
"type": "git",
"url": "git+https://github.com/mobi/goponents.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(click)="clicked()"
[disabled]="buttonDisabled || isProcessing"
[ngClass]="classObject"
[class.go-button--icon-only]="buttonContent.childNodes.length == 0"
[type]="buttonType">
<span class="go-button__loader"
*ngIf="isProcessing"
Expand All @@ -19,7 +20,7 @@
[disabled]="buttonDisabled || isProcessing"
*ngIf="buttonIcon">
</go-icon>
<span #buttonContent>
<span #buttonContent class="go-button__text">
<ng-content></ng-content>
</span>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@

.go-button__icon {
display: inline-flex;
padding-right: .5rem;
}

.go-button--icon-only {
padding: calc(.625rem - 1px) .625rem;
}

.go-button__icon {
padding: 0;
}
.go-button__icon ~ .go-button__text:not(:empty) {
padding-left: .5rem;
}

.go-button--loading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,37 +105,6 @@ describe('GoButtonComponent', () => {
expect(component.classObject['go-button--dark']).toBe(true);
expect(component.classObject['go-button--loading']).toBe(true);
});

it('returns an object that sets go-button--icon-only to false if buttonIcon is set and there is content in the button', () => {
component.buttonIcon = 'wizard';

component.ngOnChanges();

expect(component.classObject['go-button--icon-only']).toBeTruthy();

const goButtonTemplate: HTMLElement = fixture.nativeElement;
const buttonContentElement: HTMLButtonElement = goButtonTemplate.querySelector('button span:not(.go-button__loader)');
buttonContentElement.innerHTML = 'Harry Potter';
component.ngOnChanges();

expect(component.classObject['go-button--icon-only']).toBeFalsy();
});

it('returns an object that sets go-button--icon-only to true if buttonIcon is set and there is no content in the button', () => {
component.buttonIcon = 'wizard';
const goButtonTemplate: HTMLElement = fixture.nativeElement;
const buttonContentElement: HTMLButtonElement = goButtonTemplate.querySelector('button span:not(.go-button__loader)');
buttonContentElement.innerHTML = 'Harry Potter';

component.ngOnChanges();

expect(component.classObject['go-button--icon-only']).toBeFalsy();

buttonContentElement.innerHTML = null;
component.ngOnChanges();

expect(component.classObject['go-button--icon-only']).toBeTruthy();
});
});

describe('the template', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
ViewChild
} from '@angular/core';
import { fadeTemplateAnimation } from '../../animations/fade.animation';

Expand All @@ -30,8 +28,6 @@ export class GoButtonComponent implements OnChanges, OnInit {

@Output() handleClick: EventEmitter<boolean> = new EventEmitter<boolean>();

@ViewChild('buttonContent') buttonContent: ElementRef;

clicked(): void {
this.handleClick.emit(this.isProcessing);
}
Expand All @@ -53,7 +49,6 @@ export class GoButtonComponent implements OnChanges, OnInit {
this.classObject = {
'go-button--dark': this.useDarkTheme,
'go-button--loading': this.isProcessing,
'go-button--icon-only': this.buttonIcon && !this.buttonContent.nativeElement.innerHTML
};

this.classObject['go-button--' + this.buttonVariant] = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component, ElementRef } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { GoCopyDocLinkDirective } from './go-copy-doc-link.directive';
import { GoCopyComponent } from './go-copy.component';
import { GoCopyModule } from './go-copy.module';
import { GoIconModule } from '../go-icon/go-icon.module';

@Component({
template: `<go-copy cardId="testId" goCopyDocLink></go-copy>`
})
class TestParentComponent {}

describe('GoCopyDocLinkDirective', () => {
let fixture: ComponentFixture<TestParentComponent>;
let elementRef: ElementRef;
let goCopyComponent: GoCopyComponent;
let directive: GoCopyDocLinkDirective;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
TestParentComponent
],
imports: [
GoCopyModule,
GoIconModule
]
});

fixture = TestBed.createComponent(TestParentComponent);
elementRef = fixture.elementRef;
goCopyComponent = TestBed.createComponent(GoCopyComponent).componentInstance;
directive = new GoCopyDocLinkDirective(elementRef, goCopyComponent);
});

it('creates an instance', () => {
expect(directive).toBeTruthy();
});

describe('ngOnInit', () => {
it('adds a class of go-copy--card-header and sets the title of the element', () => {
directive.ngOnInit();
expect(elementRef.nativeElement.classList).toContain('go-copy--card-header');
expect(elementRef.nativeElement.title).toBe('Copy the URL to this card');
});


it('sets the text of the element with the current url and an id selector', () => {
directive.cardId = 'testId';
directive.ngOnInit();
expect(goCopyComponent.text).toBe('http://localhost:9876/context.html/#testId');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Directive, ElementRef, Host, Input, OnInit } from '@angular/core';
import { GoCopyComponent } from './go-copy.component';

@Directive({
selector: '[goCopyDocLink]'
})
export class GoCopyDocLinkDirective implements OnInit {

@Input() cardId: string;

constructor(
private elementRef: ElementRef,
@Host() private baseComponent: GoCopyComponent
) { }

ngOnInit(): void {
this.elementRef.nativeElement.classList.add('go-copy--card-header');
this.elementRef.nativeElement.title = 'Copy the URL to this card';
this.baseComponent.text = `${window.location.href}/#${this.cardId}`;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
position: relative;
}

:host.go-copy--card-header {
position: absolute;
margin-left: 0.75rem;
padding-top: 0.25rem;
}

.go-copy__textarea {
left: 99999px;
position: absolute;
Expand Down
7 changes: 5 additions & 2 deletions projects/go-lib/src/lib/components/go-copy/go-copy.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { CommonModule } from '@angular/common';

import { GoCopyComponent } from './go-copy.component';
import { GoIconModule } from '../go-icon/go-icon.module';
import { GoCopyDocLinkDirective } from './go-copy-doc-link.directive';

@NgModule({
declarations: [
GoCopyComponent
GoCopyComponent,
GoCopyDocLinkDirective
],
imports: [
CommonModule,
GoIconModule
],
exports: [
GoCopyComponent
GoCopyComponent,
GoCopyDocLinkDirective
]
})

Expand Down
4 changes: 4 additions & 0 deletions projects/go-lib/src/styles/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ strong {
@extend %element--no-margin;
}

.go-heading--inline {
display: inline;
}

.go-link {
@include transition(all);

Expand Down