mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
Dasherize post/notification type class names
This commit is contained in:
parent
e2ab767cb9
commit
496e11c003
|
@ -2,12 +2,13 @@ import Component from 'flarum/component';
|
||||||
import avatar from 'flarum/helpers/avatar';
|
import avatar from 'flarum/helpers/avatar';
|
||||||
import icon from 'flarum/helpers/icon';
|
import icon from 'flarum/helpers/icon';
|
||||||
import humanTime from 'flarum/helpers/human-time';
|
import humanTime from 'flarum/helpers/human-time';
|
||||||
|
import { dasherize } from 'flarum/utils/string';
|
||||||
|
|
||||||
export default class Notification extends Component {
|
export default class Notification extends Component {
|
||||||
view(args) {
|
view(args) {
|
||||||
var notification = this.props.notification;
|
var notification = this.props.notification;
|
||||||
|
|
||||||
return m('div.notification.notification-'+notification.contentType(), {
|
return m('div.notification.notification-'+dasherize(notification.contentType()), {
|
||||||
classNames: !notification.isRead() ? 'unread' : '',
|
classNames: !notification.isRead() ? 'unread' : '',
|
||||||
onclick: this.read.bind(this)
|
onclick: this.read.bind(this)
|
||||||
}, m('a', {href: args.href, config: args.config}, [
|
}, m('a', {href: args.href, config: args.config}, [
|
||||||
|
|
|
@ -2,13 +2,14 @@ import Post from 'flarum/components/post';
|
||||||
import username from 'flarum/helpers/username';
|
import username from 'flarum/helpers/username';
|
||||||
import icon from 'flarum/helpers/icon';
|
import icon from 'flarum/helpers/icon';
|
||||||
import humanTime from 'flarum/utils/human-time';
|
import humanTime from 'flarum/utils/human-time';
|
||||||
|
import { dasherize } from 'flarum/utils/string';
|
||||||
|
|
||||||
export default class PostActivity extends Post {
|
export default class PostActivity extends Post {
|
||||||
view(iconName, content, attrs) {
|
view(iconName, content, attrs) {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
|
|
||||||
attrs = attrs || {};
|
attrs = attrs || {};
|
||||||
attrs.className = 'post-activity post-'+post.contentType()+' '+(attrs.className || '');
|
attrs.className = 'post-activity post-'+dasherize(post.contentType())+' '+(attrs.className || '');
|
||||||
|
|
||||||
return super.view([
|
return super.view([
|
||||||
icon(iconName+' post-icon'),
|
icon(iconName+' post-icon'),
|
||||||
|
|
5
framework/core/js/lib/utils/string.js
Normal file
5
framework/core/js/lib/utils/string.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export function dasherize(string) {
|
||||||
|
return string.replace(/([A-Z])/g, function ($1) {
|
||||||
|
return '-' + $1.toLowerCase();
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user