From 8e1ba5a2af8c916fa77e83637e80a1f88621bd3d Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 6 May 2015 08:32:33 +0930 Subject: [PATCH] Dasherize post/notification type class names --- js/forum/src/components/notification.js | 3 ++- js/forum/src/components/post-activity.js | 3 ++- js/lib/utils/string.js | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 js/lib/utils/string.js diff --git a/js/forum/src/components/notification.js b/js/forum/src/components/notification.js index 34541ee8f..ac2cf0791 100644 --- a/js/forum/src/components/notification.js +++ b/js/forum/src/components/notification.js @@ -2,12 +2,13 @@ import Component from 'flarum/component'; import avatar from 'flarum/helpers/avatar'; import icon from 'flarum/helpers/icon'; import humanTime from 'flarum/helpers/human-time'; +import { dasherize } from 'flarum/utils/string'; export default class Notification extends Component { view(args) { var notification = this.props.notification; - return m('div.notification.notification-'+notification.contentType(), { + return m('div.notification.notification-'+dasherize(notification.contentType()), { classNames: !notification.isRead() ? 'unread' : '', onclick: this.read.bind(this) }, m('a', {href: args.href, config: args.config}, [ diff --git a/js/forum/src/components/post-activity.js b/js/forum/src/components/post-activity.js index 6c6b2a938..db71254af 100644 --- a/js/forum/src/components/post-activity.js +++ b/js/forum/src/components/post-activity.js @@ -2,13 +2,14 @@ import Post from 'flarum/components/post'; import username from 'flarum/helpers/username'; import icon from 'flarum/helpers/icon'; import humanTime from 'flarum/utils/human-time'; +import { dasherize } from 'flarum/utils/string'; export default class PostActivity extends Post { view(iconName, content, attrs) { var post = this.props.post; attrs = attrs || {}; - attrs.className = 'post-activity post-'+post.contentType()+' '+(attrs.className || ''); + attrs.className = 'post-activity post-'+dasherize(post.contentType())+' '+(attrs.className || ''); return super.view([ icon(iconName+' post-icon'), diff --git a/js/lib/utils/string.js b/js/lib/utils/string.js new file mode 100644 index 000000000..2fb5b2b65 --- /dev/null +++ b/js/lib/utils/string.js @@ -0,0 +1,5 @@ +export function dasherize(string) { + return string.replace(/([A-Z])/g, function ($1) { + return '-' + $1.toLowerCase(); + }); +}