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 slotted anchor styling for the tab #81

Closed
web-padawan opened this issue Feb 9, 2018 · 8 comments
Closed

Add slotted anchor styling for the tab #81

web-padawan opened this issue Feb 9, 2018 · 8 comments
Assignees

Comments

@web-padawan
Copy link
Member

The problem

As a user I want to place the anchor inside of the tab and make it to occupy the full height and width. This is now impossible because of the padding

Solution

Add theme="link" similar to what paper-tab does with the attribute.

@web-padawan
Copy link
Member Author

BTW, another possible feature here would be also to also forward click events which paper-tab does here, so the links would be accessible from the keyboard.

@abdonrd
Copy link
Contributor

abdonrd commented Feb 9, 2018

@web-padawan
Copy link
Member Author

@abdonrd I remember that use case as well, IMO it would make sense to maintain both.

@heruan
Copy link
Member

heruan commented Feb 14, 2018

I agree with @abdonrd, what is the advantage of having to explicitly place the anchor inside the tab? What if I place two anchors inside a tab then, one to activate the tab and one for another action?

Plus, what does happen when I click the tab and/or the anchor inside it? Is the tab select event triggered or the browser navigation? What if I control-click the link to open on a new (browser) tab/window (in which case tab should not be selected on the current window, but on the new one)?

Another solution could be using a new vaadin-link-tab element, which would wrap an anchor in its shadow root so that all the tab content would already be inside it and the new element can delegate click events to the anchor itself and avoid mixing tab/anchor behaviors.

Tested the PR, the only confirmed glitch from my considerations above is the selection of the tab on control/meta-click of the link, which should not happen (added a comment in the PR too).

@heruan
Copy link
Member

heruan commented Feb 14, 2018

I'm not a Polymer expert, but could this possibly work: <a href="tab1" is="vaadin-tab">?

Update Okay, I've just read about Polymer 2.0 not supporting the is attribute. Pity!

@heruan
Copy link
Member

heruan commented May 7, 2018

I'm currently using anchors in tabs without issues with this custom theme:

<dom-module id="vaadin-tab-link-theme" theme-for="vaadin-tab">
  <template>
    <style>
      :host ::slotted(a) {
        display: flex;
        flex: 1 1 auto;
        justify-content: center;
        align-items: center;
        align-self: stretch;
        margin: -.25em -1em;
        padding: .25em 1em;
        color: inherit !important;
      }

      :host ::slotted(a:hover) {
        text-decoration: none !important;
      }

      :host ::slotted(a) > iron-icon {
        margin: 0 4px;
      }

      :host ::slotted(a) > iron-icon:first-child {
        margin-left: 0;
      }

      :host ::slotted(a) > iron-icon:last-child {
        margin-right: 0;
      }

      :host([theme~="icon-on-top"]) ::slotted(a) {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
      }

      :host([theme~="icon-on-top"]) ::slotted(a) > iron-icon {
        margin: 0;
      }
    </style>
  </template>
</dom-module>

I can submit a PR with this added to the core tab theme, but IIRC @jouni had raised a warning about the ::slotted(a) > iron-icon selector.

@pleku
Copy link

pleku commented May 29, 2018

This is also something that Flow users need when they are using vaadin-tabs as a navigation menu, as there should be anchors inside the tabs that trigger the navigation.

@heruan
Copy link
Member

heruan commented May 31, 2018

I've just updated my previous comment using Flexbox to fit the anchor into the tab.

@web-padawan web-padawan self-assigned this Feb 21, 2019
@web-padawan web-padawan added in progress and removed needs design Design is needed in progress labels Feb 21, 2019
@web-padawan web-padawan changed the title Add theme to place anchor inside of the tab Add slotted anchor styling for the tab Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants