webzop / yii2-notifications

Yii2 module to provide a notification managing system
BSD 3-Clause "New" or "Revised" License
70 stars 42 forks source link

Possibility to override style class of badge #4

Closed vuylov closed 6 years ago

vuylov commented 6 years ago

Hi, thanks for your work. It's great.

Can you give possibility to override class of badge. Now it looks like: https://github.com/webzop/yii2-notifications/blob/master/widgets/Notifications.php#L50

May be extract in public attribute

class Notifications extends \yii\base\Widget
{
    /**
     * @var string $badgeStyles badge style
     */
    public $badgeStyles = 'badge badge-warning navbar-badge notifications-count label label-warning';

  /**
     * @inheritdoc
     */
    public function run()
    {
        $html  = Html::beginTag('li', $this->options);
        $html .= Html::beginTag('a', ['href' => '#', 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']);
        $html .= Html::tag('span', '', ['class' => 'glyphicon glyphicon-bell']);
        $count = self::getCountUnseen();
        $countOptions = ['class' => $this->badgeStyles,'data-count' => $count];
        if(!$count){
            $countOptions['style'] = 'display: none;';
        }
        $html .= Html::tag('span', $count, $countOptions);
        $html .= Html::endTag('a');
        $html .= Html::begintag('div', ['class' => 'dropdown-menu']);
        $header = Html::a(\Yii::t('modules/notifications', 'Mark all as read'), '#', ['class' => 'read-all pull-right']);
        $header .= \Yii::t('modules/notifications', 'Notifications');
        $html .= Html::tag('div', $header, ['class' => 'header']);

        $html .= Html::begintag('div', ['class' => 'notifications-list']);
        //$html .= Html::tag('div', '<span class="ajax-loader"></span>', ['class' => 'loading-row']);
        $html .= Html::tag('div', Html::tag('span', \Yii::t('modules/notifications', 'There are no notifications to show'), ['style' => 'display: none;']), ['class' => 'empty-row']);
        $html .= Html::endTag('div');

        $footer = Html::a(\Yii::t('modules/notifications', 'View all'), ['/notifications/default/index']);
        $html .= Html::tag('div', $footer, ['class' => 'footer']);
        $html .= Html::endTag('div');
        $html .= Html::endTag('li');

        echo $html;

        $this->registerAssets();
    }
goncaloe commented 6 years ago

fixed