From 7ae4c4dedcfb37ffe4295c64d5b6d89d0afa54e4 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 19 Jun 2014 17:11:21 -0400 Subject: [PATCH] COSMETIC: visual tweaks to the categories page --- .../discourse/helpers/application_helpers.js | 1 + app/assets/javascripts/discourse/lib/html.js | 9 ++++++--- .../discourse/routes/application_routes.js | 2 +- .../discourse/routes/discovery_route_builders.js | 1 + .../templates/discovery/categories.js.handlebars | 12 ++++-------- app/assets/stylesheets/desktop/topic-list.scss | 13 ++++++++++--- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/helpers/application_helpers.js b/app/assets/javascripts/discourse/helpers/application_helpers.js index d89bd512b..19be3d120 100644 --- a/app/assets/javascripts/discourse/helpers/application_helpers.js +++ b/app/assets/javascripts/discourse/helpers/application_helpers.js @@ -61,6 +61,7 @@ function categoryLinkHTML(category, options) { if (options.hash) { if (options.hash.allowUncategorized) { categoryOptions.allowUncategorized = true; } if (options.hash.showParent) { categoryOptions.showParent = true; } + if (options.hash.clearChildColor) { categoryOptions.clearChildColor = true; } if (options.hash.link !== undefined) { categoryOptions.link = options.hash.link; } if (options.hash.extraClasses) { categoryOptions.extraClasses = options.hash.extraClasses; } if (options.hash.categories) { diff --git a/app/assets/javascripts/discourse/lib/html.js b/app/assets/javascripts/discourse/lib/html.js index d3fbff5ea..19e9fa165 100644 --- a/app/assets/javascripts/discourse/lib/html.js +++ b/app/assets/javascripts/discourse/lib/html.js @@ -92,14 +92,17 @@ Discourse.HTML = { html = "<" + elem + " href=\"" + (opts.link === false ? '' : url) + "\" "; html += "data-drop-close=\"true\" class=\"badge-category" + (restricted ? ' restricted' : '' ) + + (opts.clearChildColor ? ' clear-badge' : '') + extraClasses + "\" "; name = Handlebars.Utils.escapeExpression(name); // Add description if we have it if (description) html += "title=\"" + Handlebars.Utils.escapeExpression(description) + "\" "; - var categoryStyle = Discourse.HTML.categoryStyle(category); - if (categoryStyle) { - html += "style=\"" + categoryStyle + "\" "; + if (!opts.clearChildColor) { + var categoryStyle = Discourse.HTML.categoryStyle(category); + if (categoryStyle) { + html += "style=\"" + categoryStyle + "\" "; + } } if (restricted) { diff --git a/app/assets/javascripts/discourse/routes/application_routes.js b/app/assets/javascripts/discourse/routes/application_routes.js index 461cd2a00..813528d26 100644 --- a/app/assets/javascripts/discourse/routes/application_routes.js +++ b/app/assets/javascripts/discourse/routes/application_routes.js @@ -48,7 +48,7 @@ Discourse.Route.buildRoutes(function() { this.route('categories'); // default filter for a category - this.route('category', { path: '/category/:slug' }); + this.route('parentCategory', { path: '/category/:slug' }); this.route('categoryNone', { path: '/category/:slug/none' }); this.route('category', { path: '/category/:parentSlug/:slug' }); diff --git a/app/assets/javascripts/discourse/routes/discovery_route_builders.js b/app/assets/javascripts/discourse/routes/discovery_route_builders.js index 14ec47169..8e03658de 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route_builders.js +++ b/app/assets/javascripts/discourse/routes/discovery_route_builders.js @@ -179,6 +179,7 @@ function buildCategoryRoute(filter, params) { // Finally, build all the routes with the helpers we created Discourse.addInitializer(function() { Discourse.DiscoveryCategoryRoute = buildCategoryRoute('latest'); + Discourse.DiscoveryParentCategoryRoute = buildCategoryRoute('latest'); Discourse.DiscoveryCategoryNoneRoute = buildCategoryRoute('latest', {no_subcategories: true}); Discourse.Site.currentProp('filters').forEach(function(filter) { diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars index db9277cc1..7e7b6f457 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars @@ -14,11 +14,12 @@ {{#each model.categories}} - +
{{#if controller.ordering}}{{/if}} - {{category-link this allowUncategorized=true extraClasses="bigger"}} + +

{{#link-to 'discovery.parentCategory' this}}{{unbound name}}{{/link-to}}

{{#if unreadTopics}} {{unbound unreadTopics}} {{/if}} @@ -26,11 +27,6 @@ {{i18n filters.new.lower_title_with_count count="newTopics"}} {{/if}}
-
{{#if description_excerpt}} @@ -41,7 +37,7 @@ {{#if subcategories}}
{{#each subcategories}} - {{category-link this showParent=true}} + {{category-link this showParent=true clearChildColor=true}} {{#if unreadTopics}} {{unbound unreadTopics}} {{/if}} diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scss index 2ed496b41..25b623cfc 100644 --- a/app/assets/stylesheets/desktop/topic-list.scss +++ b/app/assets/stylesheets/desktop/topic-list.scss @@ -63,9 +63,6 @@ .fa-thumb-tack {color: $primary;} .fa-thumb-tack.unpinned {color: $primary;} - a.title {color: $primary;} - a.title:visited:not(.badge-notification) {color: scale-color($primary, $lightness: 35%);} - > tbody > tr { &:nth-child(even) { background-color: darken($secondary, 3%); @@ -292,6 +289,13 @@ position: relative; width: 45%; + h3 { + display: inline-block; + font-size: 18px; + a[href] { + color: $primary; + } + } .subcategories { margin-top: 10px; } @@ -302,6 +306,9 @@ .category-description { margin-top: 10px; } + .clear-badge { + color: $primary; + } .badge-category.bigger { padding: 6px 10px; font-size: 14px;