Giter Club home page Giter Club logo

Comments (3)

alzalabany avatar alzalabany commented on May 24, 2024 1

@acstll thank you for response,

actually for footerNavigation i was able to work around this using onClick prop

example link to playground i was able to intercept click event and trigger custom navigation function.

{
						name: "Terms and conditions",
						id: "Terms and conditions",
						href: "/user",
						icon: "user-file-user",
						onClick: (e) => {
							e.preventDefault();
							history.push(e.currentTarget.pathname);
						},
					},

will try mainNavigation solution you provided -although its a bit verbose but i will try to look in source code for full example- and let you know

thank you again

from scale.

acstll avatar acstll commented on May 24, 2024 1

You're very welcome.

I'm glad the onClick prop works for you. onClick is also available in the for mainNavigation attribute in the header, so maybe you'd want to use it too. I would recommend exploring the slots/custom markup option anyways :)

from scale.

acstll avatar acstll commented on May 24, 2024

Thank you @alzalabany for opening this issue.

Currently it's not possible to add custom elements in neither mainNavigation for the header nor footerNavigation for the footer.

The header however allows you to add custom markup via slots. The 3 slots you could use for this would be:

  • menu-main for the main menu on the left hand side
  • menu-mobile for the mobile version of the main menu
  • menu-icon for the right hand side

When you use these slots, you are free to structure your menu in any way you like, including other React components like the router Link you mention.

Here's an example:

<scale-app-shell>
  <scale-app-header slot="header">
    <div slot="menu-main">
      <scale-menu-flyout>
        <button slot="trigger">Menu</button>
        <scale-menu-flyout-list>
          <scale-menu-flyout-item>
            <!-- replace with your own React component -->
            <a href="#1">Link 1</a>
          </scale-menu-flyout-item>
          <scale-menu-flyout-item>
            <a href="#2">Link 2</a>
          </scale-menu-flyout-item>
        </scale-menu-flyout-list>
      </scale-menu-flyout>
    </div>
    <div slot="menu-mobile">
      <!-- "left side" content for mobile -->
    </div>
    <div slot="menu-icon">
      <!-- right side, your code here -->
    </div>
  </scale-app-header>
</scale-app-shell>

If you need more info regarding slots (they work a bit different than in JS frameworks), I suggest you check these pages:


The "as prop" pattern idea is indeed interesting but not feasible, since you'll be passing a React component into a web component, and the web component wouldn't know how to deal with a virtual DOM node.

The ScaleLink component is a light wrapper around an a tag. So I believe it's better in this case for you to create a React component that wraps the router's Link and add some Scale styles using the Scale's CSS variables.

Let me know what you think.

from scale.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.