caplin / FlexLayout

Docking Layout Manager for React
MIT License
920 stars 174 forks source link

How to conditional colour a tab button #339

Open mattspeller opened 1 year ago

mattspeller commented 1 year ago

Is it possible to apply a classname programmatically to the tabnode so that the tab button (header) updates based on the classname provided. We have cases where data could be in error after initial render and want to update the colouring. I am assuming it is something using updateModelAttributes but I can't find anything in discussions or documentation to perform something like the below:

node.getModel().doAction( Actions.updateModelAttributes({ className: 'someRedClass' }) );

eric-ho-github commented 1 year ago

onRenderTab and onRenderTabSet will do the job for you

mattspeller commented 1 year ago

Many thanks, I know they are the right callbacks but what do I set to override the tab colour so it changes when set in the callbacks? Nothing seems to apply.

On Thu, 22 Dec 2022 at 02:23, Eric Ho @.***> wrote:

onRenderTab and onRenderTabSet will do the job for you

— Reply to this email directly, view it on GitHub https://github.com/caplin/FlexLayout/issues/339#issuecomment-1362313080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNP4KR55JOEYLSY22FFBDLWOO3TFANCNFSM6AAAAAAQ436MR4 . You are receiving this because you authored the thread.Message ID: @.***>

eric-ho-github commented 1 year ago

@mattspeller you can use

import { Actions } from 'flexlayout-react';
...

            layoutModel.doAction(
              Actions.updateNodeAttributes(
                'node-id',
                {
                  className: 'new-css-class-name',
                }
              ),
            )
eric-ho-github commented 1 year ago

12-22-2022 (18-39-01)

mattspeller commented 1 year ago

Amazing thank you

On Thu, 22 Dec 2022 at 11:34, Eric Ho @.***> wrote:

@mattspeller https://github.com/mattspeller you can use

import { Actions } from 'flexlayout-react'; ...

        layoutModel.doAction(
          Actions.updateNodeAttributes(
            'node-id',
            {
              className: 'new-css-class-name',
            }
          ),
        )

— Reply to this email directly, view it on GitHub https://github.com/caplin/FlexLayout/issues/339#issuecomment-1362733134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNP4KXYW754EZVRZR64RDLWOQ4E3ANCNFSM6AAAAAAQ436MR4 . You are receiving this because you were mentioned.Message ID: @.***>