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

Add SVG icons #465

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dist/less/order-service.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
max-height: 60px;
max-width: 60px;
}
&[src$=".svg"] {
height: 52px;
@media (min-width: @order-service-title-sm-min) {
height: 60px;
}
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions dist/origin-web-catalogs.css

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

287 changes: 148 additions & 139 deletions dist/origin-web-catalogs.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="order-service-details">
<div class="order-service-details-top">
<div class="service-icon">
<span class="icon {{$ctrl.imageStream.iconClass}}" aria-hidden="true"></span>
<span ng-if="!$ctrl.imageStream.imageUrl" class="icon {{$ctrl.imageStreamiconClass}}" aria-hidden="true"></span>
<span ng-if="$ctrl.imageStream.imageUrl" class="image"><img ng-src="{{$ctrl.imageStream.imageUrl}}" alt=""></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-hidden="true"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For img elements, I don't think aria-hidden is needed if alt="" is set.

https://www.w3.org/WAI/tutorials/images/decorative/

</div>
<div class="service-title-area">
<div class="service-title">
Expand Down
8 changes: 5 additions & 3 deletions src/components/services-view/services-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ <h1>Browse Catalog</h1>
ng-class="{ active: $ctrl.currentSubFilter === subCategory.id }">
<a href="" id="{{'services-sub-category-'+subCategory.id}}"
class="services-sub-category-tab" ng-click="$ctrl.selectSubCategory(subCategory.id)">
<div class="services-sub-category-tab-image" ng-if="subCategory.imageUrl">
<img ng-src="{{subCategory.imageUrl}}" alt="">
<div class="services-sub-category-tab-image" ng-if="imageUrl = (subCategory.imageUrl || (subCategory.icon | imageForIconClass))">
<img ng-src="{{imageUrl}}" alt="">
</div>
<div class="services-sub-category-tab-icon {{subCategory.icon}}" ng-if="subCategory.icon && !subCategory.imageUrl"></div>
<div class="services-sub-category-tab-icon {{subCategory.icon}}"
ng-class="{ 'font-icon': !subCategory.icon.contains('fa ') }"
ng-if="subCategory.icon && !subCategory.imageUrl && !(subCategory.icon | imageForIconClass)"></div>
<div class="services-sub-category-tab-name">{{subCategory.label}}</div>
</a>
<a ng-click="$ctrl.mobileView = 'subcategories'" class="services-back-link" href="">Back</a>
Expand Down
26 changes: 13 additions & 13 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ var saasOfferings: any = [

var categories: any = [
{id: 'languages', label: 'Languages', subCategories: [
{id: 'java', label: 'Java', tags: ['java'], icon: 'font-icon icon-openjdk'},
{id: 'javascript', tags: ['javascript', 'nodejs', 'js'], label: 'JavaScript', icon: 'font-icon icon-js'},
{id: 'dotnet', label: '.NET', tags: ['dotnet'], icon: 'font-icon icon-dotnet'},
{id: 'perl', label: 'Perl', tags: ['perl'], icon: 'font-icon icon-perl'},
{id: 'ruby', label: 'Ruby', tags: ['ruby'], icon: 'font-icon icon-ruby'},
{id: 'php', label: 'PHP', tags: ['php'], icon: 'font-icon icon-php'},
{id: 'python', label: 'Python', tags: ['python'], icon: 'font-icon icon-python'},
{id: 'golang', label: 'Go', tags: ['golang', 'go'], icon: 'font-icon icon-go-gopher'}
{id: 'java', label: 'Java', tags: ['java'], icon: 'icon-openjdk'},
{id: 'javascript', tags: ['javascript', 'nodejs', 'js'], label: 'JavaScript', icon: 'icon-js'},
{id: 'dotnet', label: '.NET', tags: ['dotnet'], icon: 'icon-dotnet'},
{id: 'perl', label: 'Perl', tags: ['perl'], icon: 'icon-perl'},
{id: 'ruby', label: 'Ruby', tags: ['ruby'], icon: 'icon-ruby'},
{id: 'php', label: 'PHP', tags: ['php'], icon: 'icon-php'},
{id: 'python', label: 'Python', tags: ['python'], icon: 'icon-python'},
{id: 'golang', label: 'Go', tags: ['golang', 'go'], icon: 'icon-go-gopher'},
]},
{id: 'databases', label: 'Databases', subCategories: [
{id: 'mongodb', label: 'Mongo', tags: ['mongodb'], icon: 'font-icon icon-mongodb'},
{id: 'mysql', label: 'mySQL', tags: ['mysql'], icon: 'font-icon icon-mysql-database'},
{id: 'postgresql', label: 'Postgres', tags: ['postgresql'], icon: 'font-icon icon-postgresql'},
{id: 'mariadb', label: 'MariaDB', tags: ['mariadb'], icon: 'font-icon icon-mariadb'}
{id: 'mongodb', label: 'Mongo', tags: ['mongodb'], icon: 'icon-mongodb'},
{id: 'mysql', label: 'mySQL', tags: ['mysql'], icon: 'icon-mysql-database'},
{id: 'postgresql', label: 'Postgres', tags: ['postgresql'], icon: 'icon-postgresql'},
{id: 'mariadb', label: 'MariaDB', tags: ['mariadb'], icon: 'icon-mariadb'}
]},
{id: 'middleware', label: 'Middleware', subCategories: [
{id: 'integration', label: 'Integration', tags: ['amq', 'fuse', 'jboss-fuse', 'sso']},
Expand All @@ -42,7 +42,7 @@ var categories: any = [
{id: 'runtimes', label: 'Runtimes & Frameworks', tags: ['eap', 'httpd', 'tomcat']}
]},
{id: 'cicd', label: 'CI/CD', subCategories: [
{id: 'jenkins', label: 'Jenkins', tags: ['jenkins'], icon: 'font-icon icon-jenkins'},
{id: 'jenkins', label: 'Jenkins', tags: ['jenkins'], icon: 'icon-jenkins'},
{id: 'pipelines', label: 'Pipelines', tags: ['pipelines'], icon: 'fa fa-clone'}
]}
];
Expand Down
23 changes: 21 additions & 2 deletions src/services/catalog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export class CatalogService { static $inject = ['$filter', '$q', 'Constants', 'A
return _.get(this.constants, ['PUBLISHER_SYNONYMS', rawVendor]) as string || rawVendor;
}

public getImageForIconClass(iconClass: string): string {
return this.$filter('imageForIconClass')(iconClass) as string;
}

/**
* Creates an items array under each sub-category and categorizes each
* item accordingly. Dynamically creates 'all' and 'other' main and sub-
Expand Down Expand Up @@ -353,7 +357,14 @@ export class ServiceItem implements IServiceItem {
}

private getImage(): string {
return _.get(this.resource, 'spec.externalMetadata.imageUrl') as string || '';
let image: string = _.get(this.resource, 'spec.externalMetadata.imageUrl') as string;
if (image) {
return image;
}


let iconClass: string = _.get(this.resource, ['spec', 'externalMetadata', 'console.openshift.io/iconClass']) as string;
return this.catalogSrv.getImageForIconClass(iconClass);
}

private getIcon(): string {
Expand Down Expand Up @@ -404,6 +415,7 @@ export class ImageItem implements IServiceItem {
this.builderSpecTagName = this.getBuilderSpecTagName();
if (this.builderSpecTagName) {
this.tags = this.getTags();
this.imageUrl = this.getImage();
this.iconClass = this.getIcon();
this.name = this.getName();
this.description = this.getDescription();
Expand Down Expand Up @@ -442,6 +454,11 @@ export class ImageItem implements IServiceItem {
return this.catalogSrv.$filter('imageStreamTagTags')(this.resource, this.builderSpecTagName);
}

private getImage() {
let iconClass = this.catalogSrv.$filter('imageStreamTagIconClass')(this.resource, this.builderSpecTagName);
return this.catalogSrv.getImageForIconClass(iconClass);
}

private getIcon() {
let icon = this.catalogSrv.$filter('imageStreamTagIconClass')(this.resource, this.builderSpecTagName);
icon = (icon.indexOf('icon-') !== -1) ? 'font-icon ' + icon : icon;
Expand Down Expand Up @@ -495,7 +512,9 @@ export class TemplateItem implements IServiceItem {
}

private getImage() {
return '';
// Show images instead for some icon classes that we recognize.
let iconClass = _.get(this.resource, 'metadata.annotations.iconClass') as string;
return this.catalogSrv.getImageForIconClass(iconClass);
}

private getIcon() {
Expand Down
6 changes: 6 additions & 0 deletions src/styles/order-service.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
max-height: 60px;
max-width: 60px;
}
&[src$=".svg"] {
height: 52px;
@media (min-width: @order-service-title-sm-min) {
height: 60px;
}
}
}
}
}
Expand Down