artkonekt / menu

Laravel Menu Component
MIT License
26 stars 150 forks source link

Merging Attr to links #7

Open YnievesDotNet opened 2 years ago

YnievesDotNet commented 2 years ago

I trying to merge some attr to links when is active, but don't work. How is possible make that.

        $backendSideBarMenu = Menu::create('backendSideBarMenu', [
            'auto_activate' => true,
            'active_class' => 'shadow-soft-xl rounded-lg bg-white font-semibold text-slate-700',
            'active_element' => 'link',
        ]);
        $backendSideBarMenu->attr('class', 'flex flex-col pl-0 mb-0');
        $backendSideBarMenu->addItem('dashboard', __('Dashboard'), '/dashboard')->activateOnUrls('dashboard');
        $backendSideBarMenu->addItem('management', __('Management'), '/management')->activateOnUrls('management/*');
        $backendSideBarMenu->items->roots()->attr('class', 'mt-0.5 w-full');
        foreach ($backendSideBarMenu->items->roots() as $item) {
            $item->link->attr('class', 'py-2.7 text-size-sm ease-nav-brand my-0 mx-4 flex items-center whitespace-nowrap px-4 transition-colors');
        }

The active link only have the normal class py-2.7 ... when have to by shadow-soft-... py-2.7 ...

Best Regards.

Yoinier.

YnievesDotNet commented 2 years ago

Other thing I are using the ServiceProvider method, but not work the auto activate procedure.

Thanks

fulopattila122 commented 2 years ago

How do you render the menu in the blade template?

YnievesDotNet commented 2 years ago

How do you render the menu in the blade template?

{!! Menu::get('backendSideBarMenu')->render('ul') !!}