Use more semantic names for various tracking icons

This way they can be replaced by plugins without conflicting with other
icons. For example `circle` is used in some places that doesn't
represent `tracking`.
This commit is contained in:
Robin Ward 2017-09-01 12:14:16 -04:00
parent 46ebd0ee40
commit c6ff387ce9
6 changed files with 27 additions and 15 deletions

View File

@ -1,6 +1,14 @@
import { h } from 'virtual-dom'; import { h } from 'virtual-dom';
let _renderers = []; let _renderers = [];
const REPLACEMENTS = {
'd-tracking': 'circle',
'd-muted': 'times-circle',
'd-regular': 'circle-o',
'd-watching': 'exclamation-circle',
'd-watching-first': 'dot-circle-o'
};
export function renderIcon(renderType, id, params) { export function renderIcon(renderType, id, params) {
for (let i=0; i<_renderers.length; i++) { for (let i=0; i<_renderers.length; i++) {
let renderer = _renderers[i]; let renderer = _renderers[i];
@ -44,6 +52,8 @@ registerIconRenderer({
name: 'font-awesome', name: 'font-awesome',
string(id, params) { string(id, params) {
id = REPLACEMENTS[id] || id;
let tagName = params.tagName || 'i'; let tagName = params.tagName || 'i';
let html = `<${tagName} class='${faClasses(id, params)}'`; let html = `<${tagName} class='${faClasses(id, params)}'`;
if (params.title) { html += ` title='${I18n.t(params.title)}'`; } if (params.title) { html += ` title='${I18n.t(params.title)}'`; }
@ -56,6 +66,8 @@ registerIconRenderer({
}, },
node(id, params) { node(id, params) {
id = REPLACEMENTS[id] || id;
let tagName = params.tagName || 'i'; let tagName = params.tagName || 'i';
const properties = { const properties = {

View File

@ -25,7 +25,7 @@ function addBulkButton(action, key, opts) {
addBulkButton('showChangeCategory', 'change_category', {icon: 'pencil'}); addBulkButton('showChangeCategory', 'change_category', {icon: 'pencil'});
addBulkButton('closeTopics', 'close_topics', {icon: 'lock'}); addBulkButton('closeTopics', 'close_topics', {icon: 'lock'});
addBulkButton('archiveTopics', 'archive_topics', {icon: 'folder'}); addBulkButton('archiveTopics', 'archive_topics', {icon: 'folder'});
addBulkButton('showNotificationLevel', 'notification_level', {icon: 'circle-o'}); addBulkButton('showNotificationLevel', 'notification_level', {icon: 'd-regular'});
addBulkButton('resetRead', 'reset_read', {icon: 'backward'}); addBulkButton('resetRead', 'reset_read', {icon: 'backward'});
addBulkButton('unlistTopics', 'unlist_topics', { addBulkButton('unlistTopics', 'unlist_topics', {
icon: 'eye-slash', icon: 'eye-slash',

View File

@ -9,15 +9,15 @@ export const NotificationLevels = { WATCHING_FIRST_POST, WATCHING, TRACKING, REG
export function buttonDetails(level) { export function buttonDetails(level) {
switch(level) { switch(level) {
case WATCHING_FIRST_POST: case WATCHING_FIRST_POST:
return { id: WATCHING_FIRST_POST, key: 'watching_first_post', icon: 'dot-circle-o' }; return { id: WATCHING_FIRST_POST, key: 'watching_first_post', icon: 'd-watching-first' };
case WATCHING: case WATCHING:
return { id: WATCHING, key: 'watching', icon: 'exclamation-circle' }; return { id: WATCHING, key: 'watching', icon: 'd-watching' };
case TRACKING: case TRACKING:
return { id: TRACKING, key: 'tracking', icon: 'circle' }; return { id: TRACKING, key: 'tracking', icon: 'd-tracking' };
case MUTED: case MUTED:
return { id: MUTED, key: 'muted', icon: 'times-circle' }; return { id: MUTED, key: 'muted', icon: 'd-muted' };
default: default:
return { id: REGULAR, key: 'regular', icon: 'circle-o' }; return { id: REGULAR, key: 'regular', icon: 'd-regular' };
} }
} }

View File

@ -3,7 +3,7 @@
<label class="control-label">{{i18n 'user.categories_settings'}}</label> <label class="control-label">{{i18n 'user.categories_settings'}}</label>
<div class="controls category-controls"> <div class="controls category-controls">
<label>{{d-icon "exclamation-circle" class="icon watching"}} {{i18n 'user.watched_categories'}}</label> <label>{{d-icon "d-watching" class="icon watching"}} {{i18n 'user.watched_categories'}}</label>
{{category-selector categories=model.watchedCategories blacklist=selectedCategories}} {{category-selector categories=model.watchedCategories blacklist=selectedCategories}}
</div> </div>
<div class="instructions">{{i18n 'user.watched_categories_instructions'}}</div> <div class="instructions">{{i18n 'user.watched_categories_instructions'}}</div>
@ -12,7 +12,7 @@
</div> </div>
<div class="controls category-controls"> <div class="controls category-controls">
<label>{{d-icon "circle" class="icon tracking"}} {{i18n 'user.tracked_categories'}}</label> <label>{{d-icon "d-tracking" class="icon tracking"}} {{i18n 'user.tracked_categories'}}</label>
{{category-selector categories=model.trackedCategories blacklist=selectedCategories}} {{category-selector categories=model.trackedCategories blacklist=selectedCategories}}
</div> </div>
<div class="instructions">{{i18n 'user.tracked_categories_instructions'}}</div> <div class="instructions">{{i18n 'user.tracked_categories_instructions'}}</div>
@ -21,13 +21,13 @@
</div> </div>
<div class="controls category-controls"> <div class="controls category-controls">
<label>{{d-icon "dot-circle-o" class="icon watching-first-post"}} {{i18n 'user.watched_first_post_categories'}}</label> <label>{{d-icon "d-watching-first" class="icon watching-first-post"}} {{i18n 'user.watched_first_post_categories'}}</label>
{{category-selector categories=model.watchedFirstPostCategories}} {{category-selector categories=model.watchedFirstPostCategories}}
</div> </div>
<div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div> <div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div>
<div class="controls category-controls"> <div class="controls category-controls">
<label>{{d-icon "times-circle" class="icon muted"}} {{i18n 'user.muted_categories'}}</label> <label>{{d-icon "d-muted" class="icon muted"}} {{i18n 'user.muted_categories'}}</label>
{{category-selector categories=model.mutedCategories blacklist=selectedCategories}} {{category-selector categories=model.mutedCategories blacklist=selectedCategories}}
</div> </div>
<div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div> <div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div>

View File

@ -29,7 +29,7 @@
<div class="control-group muting"> <div class="control-group muting">
<label class="control-label">{{i18n 'user.users'}}</label> <label class="control-label">{{i18n 'user.users'}}</label>
<div class="controls category-controls"> <div class="controls category-controls">
<label>{{d-icon "times-circle" class="muted icon"}} {{i18n 'user.muted_users'}}</label> <label>{{d-icon "d-muted" class="muted icon"}} {{i18n 'user.muted_users'}}</label>
{{user-selector excludeCurrentUser=true usernames=model.muted_usernames class="user-selector"}} {{user-selector excludeCurrentUser=true usernames=model.muted_usernames class="user-selector"}}
</div> </div>
<div class="instructions">{{i18n 'user.muted_users_instructions'}}</div> <div class="instructions">{{i18n 'user.muted_users_instructions'}}</div>

View File

@ -4,25 +4,25 @@
<label class="control-label">{{i18n 'user.tag_settings'}}</label> <label class="control-label">{{i18n 'user.tag_settings'}}</label>
<div class="controls tag-controls"> <div class="controls tag-controls">
<label>{{d-icon "exclamation-circle" class="icon watching"}} {{i18n 'user.watched_tags'}}</label> <label>{{d-icon "d-watching" class="icon watching"}} {{i18n 'user.watched_tags'}}</label>
{{tag-chooser tags=model.watched_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}} {{tag-chooser tags=model.watched_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
</div> </div>
<div class="instructions">{{i18n 'user.watched_tags_instructions'}}</div> <div class="instructions">{{i18n 'user.watched_tags_instructions'}}</div>
<div class="controls tag-controls"> <div class="controls tag-controls">
<label>{{d-icon "circle" class="icon tracking"}} {{i18n 'user.tracked_tags'}}</label> <label>{{d-icon "d-regular" class="icon tracking"}} {{i18n 'user.tracked_tags'}}</label>
{{tag-chooser tags=model.tracked_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}} {{tag-chooser tags=model.tracked_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
</div> </div>
<div class="instructions">{{i18n 'user.tracked_tags_instructions'}}</div> <div class="instructions">{{i18n 'user.tracked_tags_instructions'}}</div>
<div class="controls tag-controls"> <div class="controls tag-controls">
<label>{{d-icon "dot-circle-o" class="icon watching-first-post"}} {{i18n 'user.watched_first_post_tags'}}</label> <label>{{d-icon "d-watching-first" class="icon watching-first-post"}} {{i18n 'user.watched_first_post_tags'}}</label>
{{tag-chooser tags=model.watching_first_post_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}} {{tag-chooser tags=model.watching_first_post_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
</div> </div>
<div class="instructions">{{i18n 'user.watched_first_post_tags_instructions'}}</div> <div class="instructions">{{i18n 'user.watched_first_post_tags_instructions'}}</div>
<div class="controls tag-controls"> <div class="controls tag-controls">
<label>{{d-icon "times-circle" class="icon muted"}} {{i18n 'user.muted_tags'}}</label> <label>{{d-icon "d-muted" class="icon muted"}} {{i18n 'user.muted_tags'}}</label>
{{tag-chooser tags=model.muted_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}} {{tag-chooser tags=model.muted_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
</div> </div>
<div class="instructions">{{i18n 'user.muted_tags_instructions'}}</div> <div class="instructions">{{i18n 'user.muted_tags_instructions'}}</div>