UX: Improving styles for narrow viewports, some general styling (#3)

This commit is contained in:
Kris 2019-11-07 14:47:15 -05:00 committed by Justin DiRose
parent f31b01ec91
commit 5389d58872
10 changed files with 184 additions and 125 deletions

View File

@ -1,12 +1,15 @@
import { default as computed } from "ember-addons/ember-computed-decorators"; import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({ export default Ember.Component.extend({
tagName: "",
@computed("category") @computed("category")
categoryName(category) { categoryName(category) {
return this.site.categories.findBy("id", category.id).name; return this.site.categories.findBy("id", category.id).name;
}, },
click() { actions: {
selectCategory() {
this.selectCategory(this.category); this.selectCategory(this.category);
return false; return false;
} }
}
}); });

View File

@ -1,6 +1,9 @@
export default Ember.Component.extend({ export default Ember.Component.extend({
click() { tagName: "",
actions: {
selectTag() {
this.selectTag(this.tag); this.selectTag(this.tag);
return false; return false;
} }
}
}); });

View File

@ -1,10 +1,10 @@
<div class="knowledge-explorer-category {{if category.active 'selected'}}"> <a {{action "selectCategory"}} class="knowledge-explorer-item knowledge-explorer-category {{if category.active 'selected'}}">
{{#unless category.active}} {{#unless category.active}}
{{d-icon "plus"}} {{d-icon "plus"}}
{{/unless}} {{/unless}}
<span class="category-id">{{categoryName}}</span>
<span class="category-count">({{category.count}})</span>
{{#if category.active}} {{#if category.active}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
{{/if}} {{/if}}
</div> <span class="knowledge-explorer-item-id category-id">{{categoryName}}</span>
<span class="knowledge-explorer-item-count category-count">{{category.count}}</span>
</a>

View File

@ -1,8 +1,12 @@
<span class="knowledge-base-search-wrapper">
{{input {{input
type="text" type="text"
value=(readonly searchTerm) value=(readonly searchTerm)
input=(action "onSearchTermChange" value="target.value") input=(action "onSearchTermChange" value="target.value")
class="knowledge-explorer-search-bar" class="knowledge-explorer-search-bar"
autocorrect="off" autocorrect="off"
placeholder=(i18n "knowledge_explorer.search.placeholder")
autocapitalize="off" autocapitalize="off"
}} }}
{{d-icon "search"}}
</span>

View File

@ -1,10 +1,10 @@
<div class="knowledge-explorer-tag {{if tag.active 'selected'}} {{if subtag 'subtag'}}"> <a {{action "selectTag"}} class="knowledge-explorer-item knowledge-explorer-tag {{if tag.active 'selected'}} {{if subtag 'subtag'}}">
{{#unless tag.active}} {{#unless tag.active}}
{{d-icon "plus"}} {{d-icon "plus"}}
{{/unless}} {{/unless}}
<span class="tag-id">{{tag.id}}</span>
<span class="tag-count">({{tag.count}})</span>
{{#if tag.active}} {{#if tag.active}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
{{/if}} {{/if}}
</div> <span class="knowledge-explorer-item-id tag-id">{{tag.id}}</span>
<span class="knowledge-explorer-item-count tag-count">{{tag.count}}</span>
</a>

View File

@ -8,5 +8,5 @@
</div> </div>
<a class="knowledge-explorer-nav-link more" href="/t/{{topic.id}}"> <a class="knowledge-explorer-nav-link more" href="/t/{{topic.id}}">
{{i18n 'knowledge_explorer.topic.navigate_to_topic'}} {{d-icon "far-comment"}} {{i18n 'knowledge_explorer.topic.navigate_to_topic'}}
</a> </a>

View File

@ -6,16 +6,20 @@
{{#conditional-loading-spinner condition=isLoading}} {{#conditional-loading-spinner condition=isLoading}}
<div class="knowledge-explorer-browse"> <div class="knowledge-explorer-browse">
<div class="knowledge-explorer-filters"> <div class="knowledge-explorer-filters">
<div class="knowledge-explorer-categories"> {{#if categories}}
<div class="knowledge-explorer-items knowledge-explorer-categories">
<h3>{{i18n 'knowledge_explorer.categories'}}</h3> <h3>{{i18n 'knowledge_explorer.categories'}}</h3>
{{#each categories as |category|}} {{#each categories as |category|}}
{{knowledge-explorer-category {{knowledge-explorer-category
category=category category=category
selectCategory=(action "updateSelectedCategories") selectCategory=(action "updateSelectedCategories"
tagName="")
}} }}
{{/each}} {{/each}}
</div> </div>
<div class="knowledge-explorer-tags"> {{/if}}
{{#if tags}}
<div class="knowledge-explorer-items knowledge-explorer-tags">
<h3>{{i18n 'knowledge_explorer.tags'}}</h3> <h3>{{i18n 'knowledge_explorer.tags'}}</h3>
{{#each tags as |tag|}} {{#each tags as |tag|}}
{{knowledge-explorer-tag {{knowledge-explorer-tag
@ -24,6 +28,7 @@
}} }}
{{/each}} {{/each}}
</div> </div>
{{/if}}
</div> </div>
{{#if selectedTopic}} {{#if selectedTopic}}
{{#conditional-loading-spinner condition=isTopicLoading}} {{#conditional-loading-spinner condition=isTopicLoading}}

View File

@ -1,15 +1,34 @@
.knowledge-explorer { .knowledge-base-search-wrapper {
position: relative;
width: 500px;
.d-icon {
position: absolute;
right: 0.75em;
top: 25%;
font-size: 1.5em;
color: $primary-low-mid;
pointer-events: none;
@media screen and (max-width: 400px) {
// Just decoration, remove on small screens
display: none;
} }
}
}
.knowledge-explorer-search { .knowledge-explorer-search {
align-items: center; align-items: center;
background-color: $primary-very-low; background-color: $primary-very-low;
display: flex; display: flex;
justify-content: center; justify-content: center;
padding: 1.5em 1em; padding: 1.5em 1em;
@include breakpoint(mobile-extra-large, min-width) {
// More breathing room on larger screens
margin-bottom: 2em;
}
.knowledge-explorer-search-bar { .knowledge-explorer-search-bar {
height: 50px; height: 50px;
margin-bottom: 0px; margin-bottom: 0px;
width: 500px; width: 100%;
} }
} }
.knowledge-explorer-browse { .knowledge-explorer-browse {
@ -17,7 +36,7 @@
.loading-container { .loading-container {
display: flex; display: flex;
flex-basis: 100%; flex-basis: 100%;
padding: 10px 0 10px 10px; padding: 0.625em 0 0.625em 0.625em;
} }
.knowledge-explorer-results { .knowledge-explorer-results {
display: flex; display: flex;
@ -25,57 +44,84 @@
flex-basis: 100%; flex-basis: 100%;
.result-count { .result-count {
padding-top: 15px; padding-top: 15px;
padding-left: 10px; padding-left: 0.625em;
} }
} }
.knowledge-explorer-filters { .knowledge-explorer-filters {
flex-basis: 25%; margin-top: 0.15em;
flex: 0 1 20%;
@include breakpoint(tablet, min-width) {
padding-right: 2em;
} }
.knowledge-explorer-tags, .knowledge-explorer-categories { // min-width on flex allows container to
padding: 10px 10px 10px 0; // be more narrow than content if needed
min-width: 175px;
}
.knowledge-explorer-items {
padding: 0.57em 1em 1em 0;
a { a {
color: $primary; color: $primary;
white-space: nowrap;
} }
.knowledge-explorer-tag, .knowledge-explorer-category {
h3 {
padding-left: 0.35em;
font-size: $font-up-1;
}
.knowledge-explorer-item-count {
margin-left: auto;
color: $primary-high;
font-size: $font-down-1;
}
.knowledge-explorer-item {
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
height: 30px; padding: 0.25em 0.5em;
padding-left: 10px;
.d-icon { .d-icon {
height: 1em; height: 1em;
padding-bottom: 0.15em;
margin-right: 0.25em;
color: $primary-high;
&.d-icon-plus { &.d-icon-plus {
height: 0.75em; height: 0.75em;
margin-right: 0.25em; margin-right: 0.25em;
} }
&.d-icon-times-circle {
margin-left: 0.25em;
}
} }
&:hover { &:hover {
background: $highlight-medium; background: $highlight-medium;
} }
&.selected:hover { &.selected:hover {
background: $danger-low; background: $danger-low;
.d-icon { .d-icon {
color: $danger; color: $danger;
} }
} }
.tag-id, .category-id { .tag-id,
.category-id {
margin-right: 3px; margin-right: 3px;
overflow: hidden;
text-overflow: ellipsis;
} }
} }
.selected { .selected {
font-weight: bold; font-weight: bold;
} }
} }
.knowledge-explorer-topic-list { .knowledge-explorer-topic-list {
flex-basis: 100%; flex-basis: 100%;
.badge-wrapper .badge-category .category-name {
// extra protection for ultra-long category names
max-width: 30vw;
}
.knowledge-explorer-topic-link { .knowledge-explorer-topic-link {
color: $tertiary; color: $tertiary;
cursor: pointer;
} }
.discourse-tag { .discourse-tag {
padding-right: 5px; padding-right: 5px;
@ -94,16 +140,14 @@
} }
} }
&.more { &.more {
margin-left: auto;
font-size: $font-up-1; font-size: $font-up-1;
padding: 10px 0; padding: 10px 0;
&::after {
content: "»";
margin-left: 5px;
}
} }
} }
.topic-content { .topic-content {
h1 {
line-height: $line-height-medium;
}
padding-top: 10px; padding-top: 10px;
} }
} }

View File

@ -1,25 +1,24 @@
.mobile-view { .mobile-view {
.knowledge-explorer { .knowledge-explorer {
.knowledge-explorer-topic { .knowledge-explorer-topic {
width: calc(100vw - .75em); width: calc(100vw - 0.75em);
margin: 10px 0; margin: 0.625em 0;
} }
.knowledge-explorer-search { .knowledge-explorer-search {
font-size: $font-up-2; font-size: $font-up-2;
padding: .5em 0; padding: 0.5em 0;
.knowledge-explorer-search-bar { .knowledge-explorer-search-bar {
width: calc(100vw - 2em); width: calc(100vw - 2em);
} }
} }
.knowledge-explorer-browse { .knowledge-explorer-browse {
.knowledge-explorer-items {
padding-right: 0;
}
flex-direction: column; flex-direction: column;
.knowledge-explorer-results .result-count { .knowledge-explorer-results .result-count {
padding-left: 0px; padding-left: 0;
}
.knowledge-explorer-tags {
flex-basis: 100%;
padding: 1em 0;
} }
.knowledge-explorer-topic-list { .knowledge-explorer-topic-list {
flex-basis: 100%; flex-basis: 100%;

View File

@ -8,6 +8,7 @@ en:
results: results:
one: "%{count} result found" one: "%{count} result found"
other: "%{count} results found" other: "%{count} results found"
placeholder: "Search for topics"
topic: topic:
back: "Go back" back: "Go back"
navigate_to_topic: "View the discussion on this topic" navigate_to_topic: "View the discussion on this topic"