Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customSelectedOptionRenderer to style ContextSwitcher dropdown button #1151

Conversation

ndricimrr
Copy link
Contributor

@ndricimrr ndricimrr commented Mar 11, 2020

Description

Changes proposed in this pull request:
Added function to customise context switcher button label

In order to test it append the following entry to contextSwitcher.options at test/e2e-test-application/src/luigi-config/extended/navigation.js:233 after label and pathValue
customRendererCategory: n !== 1 ? n % 2 == 0 ? "production" : "stage" : “”

Next add another entry to the contextSwitcher{...}

...
customSelectedOptionRenderer: (option) => {
    if (option.customRendererCategory === 'production') {
      // render a green bubble
      return `<label style="color: #8F0; font-weight:bold">
      ${option.label}
      <img src="https://i.ibb.co/sJZ4TwX/favicon-16x16.png" height="10" />
      </label>`;
    } else if (option.customRendererCategory === 'stage') {
      // render a blue bubble
      return `<label style="color: #08F; font-weight:bold">
      ${option.label}
      <img src="https://i.ibb.co/4p6jtzw/favicon-16x16.png" height="10"  />
      </label>`;
    } else {
    return `${option.label}`;
    }
},
..

Result:
cswitcher

Add this flag to lerna when bootstrapping if your dependencies are not linked:
lerna bootstrap --force-local

Related issue(s)

@alexandra-simeonova alexandra-simeonova self-assigned this Mar 12, 2020
@ndricimrr ndricimrr added this to the Sprint 9 milestone Mar 12, 2020
@JohannesDoberer JohannesDoberer self-assigned this Mar 12, 2020
Copy link
Contributor

@alexandra-simeonova alexandra-simeonova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job 👍

docs/navigation-advanced.md Outdated Show resolved Hide resolved
docs/navigation-advanced.md Outdated Show resolved Hide resolved
core/src/navigation/ContextSwitcher.html Show resolved Hide resolved
@maxmarkus maxmarkus self-assigned this Mar 12, 2020
@maxmarkus maxmarkus changed the title added documentation and custom function Add customSelectedOptionRenderer to style ContextSwitcher dropdown button Mar 12, 2020
@maxmarkus maxmarkus added the enhancement New feature or request label Mar 12, 2020
Copy link
Contributor

@JohannesDoberer JohannesDoberer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@maxmarkus maxmarkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JohannesDoberer JohannesDoberer merged commit 31718f6 into SAP:release-v1 Mar 26, 2020
@ndricimrr ndricimrr deleted the 1134-custom-rendering-selected-context-switcher branch September 8, 2020 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants