FEATURE: optionally show category logo, change text alignment (#44)
This commit is contained in:
parent
264dde939a
commit
daec18921f
|
@ -1,2 +1,3 @@
|
||||||
node_modules
|
node_modules
|
||||||
.discourse-site
|
.discourse-site
|
||||||
|
.vscode
|
|
@ -5,11 +5,44 @@ body:not(.category-header) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.category-title-contents {
|
||||||
|
display: grid;
|
||||||
|
grid-template-areas: "logo title" "logo description";
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
|
||||||
|
@include breakpoint(tablet) {
|
||||||
|
grid-template-areas: "logo" "title" "description";
|
||||||
|
grid-template-columns: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.category-logo {
|
||||||
|
grid-area: logo;
|
||||||
|
align-self: center;
|
||||||
|
margin: 0 1em 0 0;
|
||||||
|
--max-height: 8em;
|
||||||
|
@include breakpoint(tablet) {
|
||||||
|
margin: 0 0 0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.category-title {
|
||||||
|
grid-area: title;
|
||||||
|
align-self: end;
|
||||||
|
}
|
||||||
|
.category-title-description {
|
||||||
|
grid-area: description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
div[class^="category-title-header"] {
|
div[class^="category-title-header"] {
|
||||||
display: flex;
|
display: flex;
|
||||||
text-align: center;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@if $align_text == "center" {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
@if $align_text == "right" {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.category-title-contents {
|
.category-title-contents {
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
>
|
>
|
||||||
{{#if this.category}}
|
{{#if this.category}}
|
||||||
<div class="category-title-contents">
|
<div class="category-title-contents">
|
||||||
|
{{#if (theme-setting "show_category_logo")}}
|
||||||
|
<CategoryLogo @category={{this.category}} />
|
||||||
|
{{/if}}
|
||||||
<h1 class="category-title">
|
<h1 class="category-title">
|
||||||
{{#if (and (theme-setting "show_category_icon") this.category)}}
|
{{#if (and (theme-setting "show_category_icon") this.category)}}
|
||||||
{{#if this.hasIconComponent}}
|
{{#if this.hasIconComponent}}
|
||||||
|
|
11
settings.yml
11
settings.yml
|
@ -14,6 +14,17 @@ hide_if_no_description:
|
||||||
default: true
|
default: true
|
||||||
description: "Hide banners if category description is not set"
|
description: "Hide banners if category description is not set"
|
||||||
|
|
||||||
|
show_category_logo:
|
||||||
|
default: false
|
||||||
|
description: "Displays the category logo as set in the category's settings"
|
||||||
|
|
||||||
|
align_text:
|
||||||
|
default: center
|
||||||
|
choices:
|
||||||
|
- center
|
||||||
|
- left
|
||||||
|
- right
|
||||||
|
|
||||||
exceptions:
|
exceptions:
|
||||||
default: ""
|
default: ""
|
||||||
type: list
|
type: list
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe "Category Banners", type: :system do
|
||||||
let!(:theme) { upload_theme_component }
|
let!(:theme) { upload_theme_component }
|
||||||
fab!(:category) { Fabricate(:category, description: "<p>this is some description</p>") }
|
fab!(:category) { Fabricate(:category, description: "<p>this is some description</p>") }
|
||||||
fab!(:category_subcategory) do
|
fab!(:category_subcategory) do
|
||||||
Fabricate(:category, parent_category: category, description: "some description")
|
Fabricate(:category, parent_category: category, description: "some description", uploaded_logo: Fabricate(:upload))
|
||||||
end
|
end
|
||||||
let(:category_banner) { PageObjects::Components::CategoryBanner.new(category) }
|
let(:category_banner) { PageObjects::Components::CategoryBanner.new(category) }
|
||||||
let(:subcategory_banner) { PageObjects::Components::CategoryBanner.new(category_subcategory) }
|
let(:subcategory_banner) { PageObjects::Components::CategoryBanner.new(category_subcategory) }
|
||||||
|
@ -69,4 +69,22 @@ RSpec.describe "Category Banners", type: :system do
|
||||||
|
|
||||||
visit(category_subcategory.url)
|
visit(category_subcategory.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "displays a category logo when show_category_logo is true" do
|
||||||
|
theme.update_setting(:show_category_logo, true)
|
||||||
|
theme.save!
|
||||||
|
|
||||||
|
visit(category_subcategory.url)
|
||||||
|
|
||||||
|
expect(subcategory_banner).to have_logo
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not display a category logo when show_category_logo is false" do
|
||||||
|
theme.update_setting(:show_category_logo, false)
|
||||||
|
theme.save!
|
||||||
|
|
||||||
|
visit(category_subcategory.url)
|
||||||
|
|
||||||
|
expect(subcategory_banner).to have_no_logo
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,6 +30,14 @@ module PageObjects
|
||||||
has_no_css?("#{category_banner_selector} .category-title-description")
|
has_no_css?("#{category_banner_selector} .category-title-description")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_logo?
|
||||||
|
has_css?("#{category_banner_selector} .category-logo img[src]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_no_logo?
|
||||||
|
has_no_css?("#{category_banner_selector} .category-logo img[src]")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def category_banner_selector
|
def category_banner_selector
|
||||||
|
|
Loading…
Reference in New Issue