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

Migrates topic-viewer-navbar-breadcrumb, subtopics-list, topic-viewer-page, practice-tab, topic-viewer-stories-list to angular components and introduces angular2+ material css. #9957

Merged
merged 57 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
fb57a9b
Migrated PracticeTabComponent
sainanee Jul 5, 2020
7a0c88c
Fixed references
sainanee Jul 5, 2020
316e7cb
Migrated TopicViewerNavbarBreadcrumb
sainanee Jul 5, 2020
91d7b6b
Added untracked files
sainanee Jul 5, 2020
410d43b
Migrates StoriesListComponent
sainanee Jul 5, 2020
122252c
Fixed frontend coverage
sainanee Jul 5, 2020
8706628
Styling changes + component addition
sainanee Jul 5, 2020
5488cba
Migrates subtopics list component
sainanee Jul 5, 2020
cc7c690
Fixed frontend coverage
sainanee Jul 5, 2020
5f0ac4c
Fixed ngfor
sainanee Jul 6, 2020
a46ca87
Fix html
sainanee Jul 6, 2020
9be7c24
Fix translates and return types for ngOnInit
sainanee Jul 7, 2020
fea29ec
Fixed coverage check
sainanee Jul 7, 2020
38d8c38
Resolve conflicts + fixed return types
sainanee Jul 8, 2020
f3ac675
Merge remote-tracking branch 'upstream/develop' into tv-migrate
sainanee Jul 8, 2020
b70638a
Removes translation services following PR #9842 + other minor fixes
sainanee Jul 9, 2020
4b962ca
Removed fully covered files
sainanee Jul 9, 2020
cb07fcd
Resolve conflicts
sainanee Jul 10, 2020
53e7a2d
Merge branch 'develop' into tv-migrate
sainanee Jul 10, 2020
38a934f
Merge branch 'develop' into tv-migrate
sainanee Jul 10, 2020
b4eb4d0
Review comments
sainanee Jul 10, 2020
884fb2d
Undo constants
sainanee Jul 10, 2020
f8ea6a3
Oppia-material
srijanreddy98 Jul 13, 2020
71c2e83
Merge remote-tracking branch 'upstream/develop' into angular-mat-css
srijanreddy98 Jul 16, 2020
971ab07
Don't lint oppia-mat css
srijanreddy98 Jul 16, 2020
71e30d7
Lint check fixes 😭
srijanreddy98 Jul 16, 2020
904fd86
Material
srijanreddy98 Jul 17, 2020
8236051
Merge with develop
srijanreddy98 Jul 17, 2020
0dfabd3
Merge branch 'angular-mat-css' into tv-migrate
srijanreddy98 Jul 19, 2020
aed63fc
Changes
srijanreddy98 Jul 19, 2020
47325f1
Changes
srijanreddy98 Jul 19, 2020
b673e28
Changes
srijanreddy98 Jul 19, 2020
e29e739
Merge branch 'develop' into tv-migrate
srijanreddy98 Jul 19, 2020
1fc880e
Changes to shared components
srijanreddy98 Jul 19, 2020
c227d7e
fix main component file
srijanreddy98 Jul 19, 2020
c6c49f3
Change subtopics component styling
srijanreddy98 Jul 19, 2020
9b70652
Linter 😑
srijanreddy98 Jul 19, 2020
8a5fe9e
Fully covered files 😩
srijanreddy98 Jul 19, 2020
6a83dec
Merge remote-tracking branch 'upstream/develop' into tv-migrate
srijanreddy98 Jul 26, 2020
54a4154
Update story summary
srijanreddy98 Jul 26, 2020
5e98faa
Fix layout issues
srijanreddy98 Jul 26, 2020
d4410ce
Files seem to fully cover themselves 😂
srijanreddy98 Jul 26, 2020
43d124e
Merge remote-tracking branch 'upstream/develop' into tv-migrate
srijanreddy98 Jul 27, 2020
583a804
Review
srijanreddy98 Jul 27, 2020
68d76d0
Review
srijanreddy98 Jul 27, 2020
8269897
Review
srijanreddy98 Jul 28, 2020
6eb8da1
Review
srijanreddy98 Jul 28, 2020
fcd8d18
Change button and checkbox styles
srijanreddy98 Jul 29, 2020
f56dc11
Update readme.ms
srijanreddy98 Jul 29, 2020
e8d7590
Review
srijanreddy98 Jul 29, 2020
1bbc5b2
Style changes
srijanreddy98 Jul 30, 2020
40a7012
Style changes
srijanreddy98 Jul 30, 2020
bdf0591
Style changes
srijanreddy98 Jul 30, 2020
8deaedf
Merge remote-tracking branch 'upstream/develop' into tv-migrate
srijanreddy98 Aug 5, 2020
d87ed9a
Style changes
srijanreddy98 Aug 5, 2020
b911f33
Changes
srijanreddy98 Aug 6, 2020
b04a548
Review
srijanreddy98 Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@

# Global stylesheet.
/core/templates/css/oppia.css @ankita240796
/core/templates/css/oppia-material.css @srijanreddy98 @bansalnitish


# Interaction project.
Expand Down Expand Up @@ -352,6 +353,7 @@

# Readme
/core/README.md @ankita240796
/core/templates/css/README.md @srijanreddy98 @bansalnitish
/extensions/README.md @ankita240796
/scripts/README.md @ankita240796

Expand Down
16 changes: 13 additions & 3 deletions core/templates/components/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
imports: [CommonModule, BrowserAnimationsModule,
MatButtonModule, MatCardModule
imports: [
BrowserAnimationsModule,
CommonModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule
],
exports: [BrowserAnimationsModule, MatButtonModule, MatCardModule]
exports: [
BrowserAnimationsModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule
]
})
export class MaterialModule {}
56 changes: 44 additions & 12 deletions core/templates/components/shared-component.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'zone.js';

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { BackgroundBannerComponent } from
'./common-layout-directives/common-elements/background-banner.component';
Expand All @@ -34,10 +35,14 @@ import { TranslatePipe } from 'filters/translate.pipe';
import { SafePipe } from 'filters/safe-pipe';
import { SkillMasteryViewerComponent } from
'./skill-mastery/skill-mastery.component';
import { SharingLinksComponent } from
'./common-layout-directives/common-elements/sharing-links.component';
import { ExplorationEmbedButtonModalComponent } from
'./button-directives/exploration-embed-button-modal.component';
import { SharingLinksComponent } from
'./common-layout-directives/common-elements/sharing-links.component';
srijanreddy98 marked this conversation as resolved.
Show resolved Hide resolved
import { StorySummaryTileDirective } from
'./summary-tile/story-summary-tile.directive';
import { SubtopicSummaryTileDirective } from
'./summary-tile/subtopic-summary-tile.directive';
import { SocialButtonsComponent } from
'components/button-directives/social-buttons.component';
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
Expand All @@ -50,23 +55,50 @@ import { ProfileLinkTextComponent } from


@NgModule({
imports: [CommonModule, MaterialModule, NgbModalModule],
declarations: [BackgroundBannerComponent, TranslatePipe,
SafePipe, SharingLinksComponent, ExplorationEmbedButtonModalComponent,
SkillMasteryViewerComponent, AttributionGuideComponent,
LazyLoadingComponent, LoadingDotsComponent, SocialButtonsComponent,
ProfileLinkImageComponent, ProfileLinkTextComponent,
ExplorationSummaryTileDirective],
entryComponents: [BackgroundBannerComponent, SharingLinksComponent,
imports: [CommonModule, MaterialModule, NgbModalModule, FormsModule],

declarations: [
AttributionGuideComponent,
BackgroundBannerComponent,
ExplorationEmbedButtonModalComponent,
ExplorationSummaryTileDirective,
LazyLoadingComponent,
LoadingDotsComponent,
ProfileLinkImageComponent,
ProfileLinkTextComponent,
SafePipe,
SharingLinksComponent,
SkillMasteryViewerComponent,
StorySummaryTileDirective,
SocialButtonsComponent,
SubtopicSummaryTileDirective,
TranslatePipe
],

entryComponents: [
BackgroundBannerComponent,
SharingLinksComponent,
SkillMasteryViewerComponent, AttributionGuideComponent,
LazyLoadingComponent, LoadingDotsComponent, SocialButtonsComponent,
ProfileLinkImageComponent, ProfileLinkTextComponent,
// These elements will remain here even after migration.
ExplorationEmbedButtonModalComponent,
SkillMasteryViewerComponent,
SocialButtonsComponent
],

exports: [
BackgroundBannerComponent, TranslatePipe, SafePipe,
SharingLinksComponent, MaterialModule, ExplorationSummaryTileDirective
// Modules.
FormsModule,
MaterialModule,
// Components, directives, and pipes.
BackgroundBannerComponent,
ExplorationSummaryTileDirective,
SafePipe,
SharingLinksComponent,
StorySummaryTileDirective,
SubtopicSummaryTileDirective,
TranslatePipe
],
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<div class="story-summary-tile">
<div class="oppia-story-title">
<strong class="title-text">
<a ng-href="<[$ctrl.getStoryLink()]>"><[$ctrl.getStorySummary().getTitle()]> </a>
<a ng-href="<[$ctrl.getStoryLink()]>"><[$ctrl.storySummary.getTitle()]> </a>
</strong>
<span style="padding-left: 10px; font-size: 0.75em; color: #404040;">
<[$ctrl.nodeCount]> <span translate="I18N_TOPIC_VIEWER_CHAPTER"></span><[($ctrl.nodeCount > 1) ? 's' : '']>
</span>
</div>
<div class="story-details">
<div class="story-thumbnail"
ng-style="{background: $ctrl.getStorySummary().getThumbnailBgColor()}">
ng-style="{background: $ctrl.storySummary.getThumbnailBgColor()}">
<img ng-src="<[$ctrl.thumbnailUrl]>"
alt=""
class="img-thumbnail"
ng-style="{background: $ctrl.getStorySummary().getThumbnailBgColor()}">
ng-style="{background: $ctrl.storySummary.getThumbnailBgColor()}">
</div>
<div class="chapter-details">
<div ng-class="{'border-bottom': $index < $ctrl.chaptersDisplayed, 'unavailable-chapter': !$ctrl.isPreviousChapterCompleted($index)}" class="chapter-title" ng-repeat="title in $ctrl.getStorySummary().getNodeTitles()">
<div ng-class="{'border-bottom': $index < $ctrl.chaptersDisplayed, 'unavailable-chapter': !$ctrl.isPreviousChapterCompleted($index)}" class="chapter-title" ng-repeat="title in $ctrl.storySummary.getNodeTitles()">
<span ng-if="$index < $ctrl.chaptersDisplayed">
<span ng-if="$ctrl.getStorySummary().isNodeCompleted(title)" class="material-icons completed-icon">
<span ng-if="$ctrl.storySummary.isNodeCompleted(title)" class="material-icons completed-icon">
done
</span>
<span ng-class="{'incomplete-chapter': !$ctrl.isChapterCompleted(title)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ angular.module('oppia').directive('storySummaryTile', [
restrict: 'E',
scope: {},
bindToController: {
getStorySummary: '&storySummary'
storySummary: '<'
},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/components/summary-tile/story-summary-tile.directive.html'),
template: require('./story-summary-tile.directive.html'),
controllerAs: '$ctrl',
controller: [
'AssetsBackendApiService', 'WindowDimensionsService',
Expand All @@ -42,21 +41,21 @@ angular.module('oppia').directive('storySummaryTile', [
ctrl.getStoryLink = function() {
return UrlInterpolationService.interpolateUrl(
STORY_VIEWER_URL_TEMPLATE, {
story_id: ctrl.getStorySummary().getId()
story_id: ctrl.storySummary.getId()
});
};

ctrl.isChapterCompleted = function(title) {
return ctrl.getStorySummary().isNodeCompleted(title);
return ctrl.storySummary.isNodeCompleted(title);
};

ctrl.isPreviousChapterCompleted = function(index) {
if (index === 0) {
return true;
}
var previousNodeTitle = (
ctrl.getStorySummary().getNodeTitles()[index - 1]);
return ctrl.getStorySummary().isNodeCompleted(previousNodeTitle);
ctrl.storySummary.getNodeTitles()[index - 1]);
return ctrl.storySummary.isNodeCompleted(previousNodeTitle);
};

ctrl.showAllChapters = function() {
Expand All @@ -69,7 +68,7 @@ angular.module('oppia').directive('storySummaryTile', [
};

ctrl.$onInit = function() {
ctrl.nodeCount = ctrl.getStorySummary().getNodeTitles().length;
ctrl.nodeCount = ctrl.storySummary.getNodeTitles().length;
ctrl.chaptersDisplayed = 3;
if (WindowDimensionsService.getWidth() <= 800) {
ctrl.chaptersDisplayed = 2;
Expand All @@ -79,11 +78,11 @@ angular.module('oppia').directive('storySummaryTile', [
ctrl.showButton = true;
}

if (ctrl.getStorySummary().getThumbnailFilename()) {
if (ctrl.storySummary.getThumbnailFilename()) {
ctrl.thumbnailUrl = (
AssetsBackendApiService.getThumbnailUrlForPreview(
ENTITY_TYPE.STORY, ctrl.getStorySummary().getId(),
ctrl.getStorySummary().getThumbnailFilename()));
ENTITY_TYPE.STORY, ctrl.storySummary.getId(),
ctrl.storySummary.getThumbnailFilename()));
} else {
ctrl.thumbnailUrl = null;
}
Expand All @@ -92,3 +91,16 @@ angular.module('oppia').directive('storySummaryTile', [
]
};
}]);

import { Directive, ElementRef, Injector, Input } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';

@Directive({
selector: 'story-summary-tile'
})
export class StorySummaryTileDirective extends UpgradeComponent {
@Input() storySummary;
constructor(elementRef: ElementRef, injector: Injector) {
super('storySummaryTile', elementRef, injector);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="subtopic-card" ng-click="$ctrl.openSubtopicPage()">
<div class="subtopic-thumbnail"
ng-style="{background: $ctrl.getSubtopic().getThumbnailBgColor()}">
ng-style="{background: $ctrl.subtopic.getThumbnailBgColor()}">
<img ng-src="<[$ctrl.thumbnailUrl]>"
class="img-thumbnail"
alt=""
ng-style="{background: $ctrl.getSubtopic().getThumbnailBgColor()}">
ng-style="{background: $ctrl.subtopic.getThumbnailBgColor()}">
</div>
<div class="subtopic-title">
<[$ctrl.getSubtopic().getTitle()]>
<[$ctrl.subtopic.getTitle()]>
</div>
</div>
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ angular.module('oppia').directive('subtopicSummaryTile', [
restrict: 'E',
scope: {},
bindToController: {
getSubtopic: '&subtopic',
getTopicId: '&topicId',
getTopicName: '&topicName'
subtopic: '<',
topicId: '<',
topicName: '<'
},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/components/summary-tile/subtopic-summary-tile.directive.html'),
template: require('./subtopic-summary-tile.directive.html'),
controllerAs: '$ctrl',
controller: [
'$window', 'AssetsBackendApiService', 'ENTITY_TYPE',
Expand All @@ -44,19 +43,19 @@ angular.module('oppia').directive('subtopicSummaryTile', [
$window.open(
UrlInterpolationService.interpolateUrl(
SUBTOPIC_VIEWER_URL_TEMPLATE, {
topic_name: ctrl.getTopicName(),
subtopic_id: ctrl.getSubtopic().getId().toString()
topic_name: ctrl.topicName,
subtopic_id: ctrl.subtopic.getId().toString()
}
), '_self'
);
};

ctrl.$onInit = function() {
if (ctrl.getSubtopic().getThumbnailFilename()) {
if (ctrl.subtopic.getThumbnailFilename()) {
ctrl.thumbnailUrl = (
AssetsBackendApiService.getThumbnailUrlForPreview(
ENTITY_TYPE.TOPIC, ctrl.getTopicId(),
ctrl.getSubtopic().getThumbnailFilename()));
ctrl.subtopic.getThumbnailFilename()));
} else {
ctrl.thumbnailUrl = null;
}
Expand All @@ -65,3 +64,18 @@ angular.module('oppia').directive('subtopicSummaryTile', [
]
};
}]);

import { Directive, ElementRef, Injector, Input } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';

@Directive({
selector: 'subtopic-summary-tile'
})
export class SubtopicSummaryTileDirective extends UpgradeComponent {
@Input() subtopic;
Showtim3 marked this conversation as resolved.
Show resolved Hide resolved
@Input() topicId;
@Input() topicName;
constructor(elementRef: ElementRef, injector: Injector) {
super('subtopicSummaryTile', elementRef, injector);
}
}
37 changes: 37 additions & 0 deletions core/templates/css/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# CSS
## Overview
This folder contains all the global style sheets for the oppia frontend.

## Files:
1. oppia.css — Custom css styles written by the oppia-devs for the frontend.
2. oppia-material.css — Material CSS for the oppia-codebase. This css file is generated and shouldn't be modified at all.

## Modification procedure:
1. oppia.css can be modified with proper reasoning in the pr that modifies the file.
2. oppia-material.css shouldn't be changed at any cost. No changes are accepted in this file.
If, at any time, the oppia-material.css is overriding the styles in oppia.css, create a style tag in the directive and make the selectors more specific.

## Oppia Material
**If at any time the css file is regenerated please update the pr number here**

- Introduced in: #9577
- Updated in: N/A (Comma seperated pr numbers).

### Info
More info regarding the oppia-material.css can be found in this doc:
Material CSS doc: https://docs.google.com/document/d/1UoCOC7XNhCZrWIMPAoR5Xex28OYWzteqXrqCU9gRUHQ/edit?usp=sharing

### Steps to generate oppia-material.css file:

Video: https://drive.google.com/file/d/1bRA0824CV6cDNYANcX2KT4skNilKdynh/view?usp=sharing

1. Clone angular components: `git clone https://github.com/angular/components.git`
2. `cd components`
3. `cd src/material/core/theming/prebuilt/`
4. `code .` (if you use vscode or open this folder in the code editor of your choice).
5. open any of the four files present in the folder.
6. Generate and copy a palette from http://mcg.mbitson.com/#!?oppia=%23009688 and paste it in the scss file.
7. Change `md` - `mat` and change $primary varibale value to be mat-palette($mat-oppia) in scss file.
8. Change $accent varibale value to be mat-pallete($mat-blue)
9. Install node-sass (`npm i -g node-sass`)
10. Run `node-sass ./deeppurple-amber.scss oppia-material.css`