Skip to content

Commit

Permalink
feat(core/tabs): add oval tab headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Goncalo Alves Ferreira authored and nuke-ellington committed Sep 23, 2022
1 parent 811be9b commit 0e32dca
Show file tree
Hide file tree
Showing 16 changed files with 547 additions and 289 deletions.
8 changes: 4 additions & 4 deletions packages/angular/src/components.ts
Expand Up @@ -1331,13 +1331,13 @@ export declare interface IxTabItem extends Components.IxTabItem {}

@ProxyCmp({
defineCustomElementFn: undefined,
inputs: ['disabled', 'icon', 'layout', 'placement', 'selected', 'small']
inputs: ['counter', 'disabled', 'icon', 'layout', 'placement', 'rounded', 'selected', 'small']
})
@Component({
selector: 'ix-tab-item',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
inputs: ['disabled', 'icon', 'layout', 'placement', 'selected', 'small']
inputs: ['counter', 'disabled', 'icon', 'layout', 'placement', 'rounded', 'selected', 'small']
})
export class IxTabItem {
protected el: HTMLElement;
Expand All @@ -1352,13 +1352,13 @@ export declare interface IxTabs extends Components.IxTabs {}

@ProxyCmp({
defineCustomElementFn: undefined,
inputs: ['layout', 'placement', 'selected', 'small']
inputs: ['layout', 'placement', 'rounded', 'selected', 'small']
})
@Component({
selector: 'ix-tabs',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
inputs: ['layout', 'placement', 'selected', 'small']
inputs: ['layout', 'placement', 'rounded', 'selected', 'small']
})
export class IxTabs {
protected el: HTMLElement;
Expand Down
569 changes: 309 additions & 260 deletions packages/core/component-doc.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions packages/core/src/components.d.ts
Expand Up @@ -1069,6 +1069,10 @@ export namespace Components {
"label": string;
}
interface IxTabItem {
/**
* Set counter value
*/
"counter": number;
/**
* Set disabled tab
*/
Expand All @@ -1085,6 +1089,10 @@ export namespace Components {
* Set selected placement
*/
"placement": 'bottom' | 'top';
/**
* Set rounded tab
*/
"rounded": boolean;
/**
* Set selected tab
*/
Expand All @@ -1103,6 +1111,10 @@ export namespace Components {
* Set placement style
*/
"placement": 'bottom' | 'top';
/**
* Set rounded tabs
*/
"rounded": boolean;
/**
* Set default selected tab by index
*/
Expand Down Expand Up @@ -2966,6 +2978,10 @@ declare namespace LocalJSX {
"onItemClick"?: (event: CustomEvent<MouseEvent>) => void;
}
interface IxTabItem {
/**
* Set counter value
*/
"counter"?: number;
/**
* Set disabled tab
*/
Expand All @@ -2982,6 +2998,10 @@ declare namespace LocalJSX {
* Set selected placement
*/
"placement"?: 'bottom' | 'top';
/**
* Set rounded tab
*/
"rounded"?: boolean;
/**
* Set selected tab
*/
Expand All @@ -3000,6 +3020,10 @@ declare namespace LocalJSX {
* Set placement style
*/
"placement"?: 'bottom' | 'top';
/**
* Set rounded tabs
*/
"rounded"?: boolean;
/**
* Set default selected tab by index
*/
Expand Down
18 changes: 10 additions & 8 deletions packages/core/src/components/tab-item/readme.md
Expand Up @@ -11,14 +11,16 @@ SPDX-License-Identifier: MIT

## Properties

| Property | Attribute | Description | Type | Default |
| ----------- | ----------- | ---------------------- | ----------------------- | ---------- |
| `disabled` | `disabled` | Set disabled tab | `boolean` | `false` |
| `icon` | `icon` | Set icon only tab | `boolean` | `false` |
| `layout` | `layout` | Set layout width style | `"auto" \| "stretched"` | `'auto'` |
| `placement` | `placement` | Set selected placement | `"bottom" \| "top"` | `'bottom'` |
| `selected` | `selected` | Set selected tab | `boolean` | `false` |
| `small` | `small` | Set small size tab | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ----------- | ----------- | ---------------------- | ----------------------- | ----------- |
| `counter` | `counter` | Set counter value | `number` | `undefined` |
| `disabled` | `disabled` | Set disabled tab | `boolean` | `false` |
| `icon` | `icon` | Set icon only tab | `boolean` | `false` |
| `layout` | `layout` | Set layout width style | `"auto" \| "stretched"` | `'auto'` |
| `placement` | `placement` | Set selected placement | `"bottom" \| "top"` | `'bottom'` |
| `rounded` | `rounded` | Set rounded tab | `boolean` | `false` |
| `selected` | `selected` | Set selected tab | `boolean` | `false` |
| `small` | `small` | Set small size tab | `boolean` | `false` |


----------------------------------------------
Expand Down
97 changes: 93 additions & 4 deletions packages/core/src/components/tab-item/tab-item.scss
Expand Up @@ -24,6 +24,10 @@ ix-tab-item {
background-color: var(--theme-tab--background);
color: var(--theme-tab--color);

&.circle {
height: 72px;
}

&.top {
&::after {
top: 0;
Expand Down Expand Up @@ -63,16 +67,17 @@ ix-tab-item {
vertical-align: middle;
}

&:hover {
&:hover:not(.circle) {
background-color: var(--theme-tab--background--hover);
color: var(--theme-tab-color-hover);
cursor: pointer;

&::after {
background-color: var(--theme-tab-indicator--background--hover);
}
}

&:active {
&:active:not(.circle) {
background-color: var(--theme-tab--background--active);
color: var(--theme-tab-color--active);

Expand All @@ -82,9 +87,18 @@ ix-tab-item {
}

&:focus-visible {
outline: 1px solid var(--theme-focus--border-color);
outline: 0px solid var(--focus--border-color);

.circle {
outline: 1px solid var(--focus--border-color);
}
}

&:focus-visible:not(.circle) {
outline: 1px solid var(--focus--border-color);
}


&.disabled {
color: var(--theme-tab--color--disabled);
background-color: var(--theme-tab--background--disabled);
Expand All @@ -94,7 +108,7 @@ ix-tab-item {
}
}

&.selected {
&.selected:not(.disabled) {
background-color: var(--theme-tab--background--selected);
color: var(--theme-tab--color--selected);

Expand All @@ -115,4 +129,79 @@ ix-tab-item {
padding: $default-space $tiny-space;
}
}


.circle {
display: flex;
justify-content: center;
align-items: center;
height: 48px;
width: 48px;
background-color: var(--theme-animated-tab-indicator--background);
border-radius: 50%;
border: 2px solid var(--theme-animated-tab-circle--border-color);
color: var(--theme-an…icon--color);
cursor: pointer;

&.selected:not(.disabled) {
background-color: var(--theme-animated-tab-circle--background--selected);
color: var(--theme-animated-tab-icon--color--selected);
border-color: var(--theme-animated-tab-circle--border-color--selected);

&:hover {
background-color: var(--theme-animated-tab-circle--background--selected);
}
}

&:hover {
background-color: var(--theme-animated-tab-circle--background--hover);
}

&:active {
background-color: var(--theme-animated-tab-circle--background--active);
}

&:active {
background-color: var(--theme-animated-tab-circle--background--active);
}

&.disabled {
background-color: var(--theme-animated-tab-circle--background--disabled);
border-color: var(--theme-animated-tab-circle--border-color--disabled);
}

}

.counter {
position: absolute;
z-index: 1;
height: 16px;
width: auto;
background-color: var(--theme-pill-outline--background);
border: 1px solid var(--theme-tab-pill--border-color);
border-radius: 100px;
bottom: 6px;
display: flex;
justify-content: center;
align-items: center;
padding-left: $tiny-space;
padding-right: $tiny-space;
font-size: 12px;
line-height: 16px;
color: var(--theme-pill-outline--color);
cursor: pointer;

&.selected {
border-color: var(--theme-tab-pill--border-color--selected);
}

&.disabled {
border-color: var(--theme-tab-pill--border-color--disabled);
}
}

.hidden {
display: none;
}

}
22 changes: 19 additions & 3 deletions packages/core/src/components/tab-item/tab-item.tsx
Expand Up @@ -35,6 +35,16 @@ export class TabItem {
*/
@Prop() icon = false;

/**
* Set rounded tab
*/
@Prop() rounded = false;

/**
* Set counter value
*/
@Prop() counter: number;

/**
* Set layout width style
*/
Expand All @@ -50,6 +60,7 @@ export class TabItem {
disabled: boolean;
small: boolean;
icon: boolean;
circle: boolean;
layout: 'auto' | 'stretched';
placement: 'bottom' | 'top';
}) {
Expand All @@ -61,6 +72,7 @@ export class TabItem {
stretched: props.layout === 'stretched',
bottom: props.placement === 'bottom',
top: props.placement === 'top',
circle: props.circle
};
}

Expand All @@ -74,11 +86,15 @@ export class TabItem {
icon: this.icon,
layout: this.layout,
placement: this.placement,
circle: this.rounded,
})}
tabindex="0"
tabIndex={0}
>
<div class="text">
<slot></slot>
<div class={{ circle: this.rounded, text: !this.rounded, selected: this.selected, disabled: this.disabled }}>
<slot></slot>
</div>
<div class={{ counter: true, selected: this.selected, hidden: !(this.rounded && this.counter !== undefined), disabled: this.disabled }}>
{this.counter}
</div>
</Host>
);
Expand Down
Expand Up @@ -23,6 +23,7 @@ describe('tab-item', () => {
<div class="text">
Some text
</div>
<div class="counter hidden"></div>
</ix-tab-item>`);
});
});
13 changes: 7 additions & 6 deletions packages/core/src/components/tabs/readme.md
Expand Up @@ -11,12 +11,13 @@ SPDX-License-Identifier: MIT

## Properties

| Property | Attribute | Description | Type | Default |
| ----------- | ----------- | --------------------------------- | ----------------------- | ---------- |
| `layout` | `layout` | Set layout width style | `"auto" \| "stretched"` | `'auto'` |
| `placement` | `placement` | Set placement style | `"bottom" \| "top"` | `'bottom'` |
| `selected` | `selected` | Set default selected tab by index | `number` | `0` |
| `small` | `small` | Set tab items to small size | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ----------- | ----------- | --------------------------------- | ----------------------- | ----------- |
| `layout` | `layout` | Set layout width style | `"auto" \| "stretched"` | `'auto'` |
| `placement` | `placement` | Set placement style | `"bottom" \| "top"` | `'bottom'` |
| `rounded` | `rounded` | Set rounded tabs | `any` | `undefined` |
| `selected` | `selected` | Set default selected tab by index | `number` | `0` |
| `small` | `small` | Set tab items to small size | `boolean` | `false` |


----------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/components/tabs/tabs.tsx
Expand Up @@ -32,6 +32,11 @@ export class Tabs {
*/
@Prop() small = false;

/**
* Set rounded tabs
*/
@Prop() rounded = false;

/**
* Set default selected tab by index
*/
Expand Down Expand Up @@ -207,6 +212,8 @@ export class Tabs {
tabs.forEach((element, index) => {
if (this.small) element.setAttribute('small', 'true');

if(this.rounded) element.setAttribute('rounded', 'true');

element.setAttribute('layout', this.layout);
element.setAttribute(
'selected',
Expand Down

0 comments on commit 0e32dca

Please sign in to comment.