forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: oppia#16119 Added a copy tooltip + corrected the save progress c…
…ard indentation and padding (oppia#15989) * save progress button behaviour * added copy tooltip + card indentation * added copy tooltip + card indentation * improved copy-tooltip * improved copy-tooltip * improved copy-tooltip * Update core/templates/pages/exploration-player-page/templates/lesson-information-card-modal.component.html Co-authored-by: Rijuta Singh <[email protected]> * Update core/templates/pages/exploration-player-page/templates/lesson-information-card-modal.component.css Co-authored-by: Rijuta Singh <[email protected]> * copy-tooltip * front-end tests passed * front-end tests passed * used I18N translation and ngIf * tooltip modification * I18N translation * new component * declaration for component * component changes * component using ngbModal * component * component * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * retrigger checks * retrigger checks * tests * typescript tests * generalizing copy-url component * generalizing copy-url component * generalizing copy-url component * generalizing copy-url component * generalizing copy-url component * fixed typescript tests * fixed typescript tests * fixed typescript tests * minor nits * minor nits * minor nits Co-authored-by: Rijuta Singh <[email protected]>
- Loading branch information
1 parent
73f47c4
commit cf30a8d
Showing
17 changed files
with
251 additions
and
146 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
core/templates/components/copy-url/copy-url.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<div class="uid-copy"> | ||
<span class="unique-progress-id">{{ urlToCopy }}</span> | ||
<span class="uid-btn-container" [ngClass]="{ 'copy-tooltip-margin' : showTooltip }"> | ||
<span class="uid-btn-message-box" *ngIf="showTooltip">{{ 'I18N_SAVE_PROGRESS_COPY_TOOLTIP' | translate }}</span> | ||
<div class="uid-btn-message-arrow" *ngIf="showTooltip"></div> | ||
<button type="button" class="btn btn-secondary uid-copy-btn" (click)="copyUrlButton()">{{ 'I18N_SAVE_PROGRESS_BUTTON_TEXT' | translate }}</button> | ||
</span> | ||
</div> | ||
|
||
|
||
<style> | ||
.uid-copy { | ||
align-items: flex-end; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
margin-bottom: 30px; | ||
width: 100%; | ||
} | ||
|
||
.unique-progress-id { | ||
align-items: center; | ||
border: 1px solid black; | ||
border-radius: 5px; | ||
display: flex; | ||
flex-direction: row; | ||
height: 100%; | ||
padding: 5px; | ||
word-break: break-word; | ||
} | ||
|
||
.uid-btn-container { | ||
margin-left: 2%; | ||
position: relative; | ||
width: 20%; | ||
} | ||
|
||
.copy-tooltip-margin { | ||
margin-top: -33px; | ||
} | ||
|
||
.uid-btn-message-box { | ||
background-color: #00645c; | ||
border-radius: 4px; | ||
color: #fff; | ||
cursor: default; | ||
font-size: 14px; | ||
font-style: Roboto, Arial, sans-serif; | ||
padding: 8px 10px; | ||
position: relative; | ||
top: -5px; | ||
} | ||
|
||
.uid-btn-message-arrow { | ||
background-color: #00645c; | ||
color: #fff; | ||
cursor: default; | ||
height: 10px; | ||
position: relative; | ||
right: -45px; | ||
top: -7px; | ||
transform: rotate(45deg); | ||
width: 10px; | ||
} | ||
|
||
.uid-copy-btn { | ||
box-shadow: 1px 1px 2px 0 rgba(0, 100, 92, 0.8); | ||
color: #00645c; | ||
font-family: Roboto, sans-serif; | ||
font-size: 14px; | ||
font-weight: 700; | ||
margin: 0 auto; | ||
width: 100px; | ||
} | ||
</style> |
75 changes: 75 additions & 0 deletions
75
core/templates/components/copy-url/copy-url.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2022 The Oppia Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS-IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
/** | ||
* @fileoverview Unit tests for Copy Exploration URL component | ||
*/ | ||
|
||
import { Clipboard } from '@angular/cdk/clipboard'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { ComponentOverviewComponent } from './copy-url.component'; | ||
import { I18nLanguageCodeService } from 'services/i18n-language-code.service'; | ||
import { MockTranslatePipe } from 'tests/unit-test-utils'; | ||
|
||
class MockI18nLanguageCodeService { | ||
isCurrentLanguageRTL() { | ||
return true; | ||
} | ||
} | ||
|
||
describe('Copy Exploration URL component', function() { | ||
let clipboard: Clipboard; | ||
let component: ComponentOverviewComponent; | ||
let fixture: ComponentFixture<ComponentOverviewComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
HttpClientTestingModule, | ||
], | ||
declarations: [ | ||
ComponentOverviewComponent, | ||
MockTranslatePipe | ||
], | ||
providers: [ | ||
{ | ||
provide: I18nLanguageCodeService, | ||
useClass: MockI18nLanguageCodeService | ||
} | ||
], | ||
schemas: [NO_ERRORS_SCHEMA] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ComponentOverviewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
clipboard = TestBed.inject(Clipboard); | ||
}); | ||
|
||
it('should correctly copy progress URL', () => { | ||
spyOn(clipboard, 'copy').and.callThrough(); | ||
let explorationURL = 'https://oppia.org/progress/abcdef'; | ||
component.urlToCopy = explorationURL; | ||
|
||
component.copyUrlButton(); | ||
|
||
expect(clipboard.copy).toHaveBeenCalledWith( | ||
explorationURL); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2022 The Oppia Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS-IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @fileoverview Component for the copy message tooltip. | ||
*/ | ||
|
||
import { Component, Input } from '@angular/core'; | ||
import { Clipboard } from '@angular/cdk/clipboard'; | ||
import { I18nLanguageCodeService } from 'services/i18n-language-code.service'; | ||
|
||
@Component({ | ||
selector: 'copy-url', | ||
templateUrl: './copy-url.component.html' | ||
}) | ||
|
||
export class ComponentOverviewComponent { | ||
@Input() urlToCopy !: string; | ||
showTooltip: boolean = false; | ||
|
||
constructor( | ||
private clipboard: Clipboard, | ||
private i18nLanguageCodeService: I18nLanguageCodeService) {} | ||
|
||
copyUrlButton(): void { | ||
this.clipboard.copy(this.urlToCopy); | ||
this.showTooltip = true; | ||
setTimeout(() => { | ||
this.showTooltip = false; | ||
}, 1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.