Skip to content

Commit

Permalink
fix(tabs): add missing target prop. Closes #700
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Oct 10, 2022
1 parent dda1799 commit 808d52e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,10 @@ export namespace Components {
* Sets the tab active.
*/
"setActive": (active: boolean) => Promise<void>;
/**
* Specifies where to display the linked URL. Only applies when an `href` is provided.
*/
"target": Props.BalButtonTarget;
/**
* This is the key of the tab.
*/
Expand Down Expand Up @@ -5845,6 +5849,10 @@ declare namespace LocalJSX {
* Tell's if the linking is done by a router.
*/
"prevent"?: boolean;
/**
* Specifies where to display the linked URL. Only applies when an `href` is provided.
*/
"target"?: Props.BalButtonTarget;
/**
* This is the key of the tab.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Host, h, Prop, Method, State, Element, EventEmitter, Event } from '@stencil/core'
import { Props } from '../../../types'
import { BalTabOption } from '../bal-tab.type'

@Component({
Expand Down Expand Up @@ -29,6 +30,12 @@ export class TabItem {
*/
@Prop({ reflect: true }) href = ''

/**
* Specifies where to display the linked URL.
* Only applies when an `href` is provided.
*/
@Prop() target: Props.BalButtonTarget = '_self'

/**
* If `true` a small red bubble is added to the tab.
*/
Expand Down Expand Up @@ -91,6 +98,7 @@ export class TabItem {
icon: this.icon,
label: this.label,
href: this.href,
target: this.target,
active: this.active,
disabled: this.disabled,
done: this.done,
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/components/bal-tabs/bal-tab.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface BalTabOption {
label: string
icon?: string
href: string
target: Props.BalButtonTarget
active: boolean
disabled: boolean
done: boolean
Expand Down Expand Up @@ -60,6 +61,7 @@ export interface TabItemProps {
disabled: boolean
bubble: boolean | string
href: string | undefined
target: Props.BalButtonTarget
label: string | undefined
context: Props.BalTabsInterface
iconPosition: Props.BalTabsIconPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const TabItem: FunctionalComponent<TabItemProps> = ({
expanded,
disabled,
href,
target,
label,
vertical,
iconPosition,
Expand Down Expand Up @@ -38,7 +39,8 @@ export const TabItem: FunctionalComponent<TabItemProps> = ({
if (href) {
hrefAttribute = {
href,
}
target,
} as any
}

const bubbleString = bubble === true || bubble === false ? '' : bubble
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const TabList: FunctionalComponent<TabProps> = ({
iconPosition={iconPosition}
disabled={tab.disabled}
href={tab.href}
target={tab.target}
label={tab.label}
bubble={tab.bubble}
onSelectTab={e => onSelectTab(e, tab)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const Basic = args => ({
<bal-tab-item bubble value="tab-c" label="Tab C">Content of Tab C</bal-tab-item>
<bal-tab-item value="tab-d" label="Tab D" hidden>Hidden Content of Tab D</bal-tab-item>
<bal-tab-item value="tab-e" label="Tab E" disabled>Content of Tab E</bal-tab-item>
<bal-tab-item value="tab-link" label="Tab link" href="https://github.com/baloise-incubator/design-system" target="_blank">Content of Tab link</bal-tab-item>
</bal-tabs>`,
})
Basic.args = {
Expand Down

0 comments on commit 808d52e

Please sign in to comment.