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 tabs component #341

Merged
merged 72 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
9a304b9
feat(tabs): initial implementation
mtsvyatkova Apr 20, 2022
16dfafd
Merge branch 'master' into mtsvyatkova/tabs-component
mtsvyatkova Apr 20, 2022
42899b0
feat(tabs): update scrolling
mtsvyatkova Apr 21, 2022
263c920
Merge branch 'mtsvyatkova/tabs-component' of https://github.com/Ignit…
mtsvyatkova Apr 21, 2022
6f37677
feat(tabs): update indicator and panel styles
mtsvyatkova Apr 27, 2022
d37938c
chore: fix lint
mtsvyatkova Apr 27, 2022
1554c4c
feat(tabs): initial styling
SisIvanova May 3, 2022
3cbae96
fix lint error
SisIvanova May 3, 2022
9c5dba5
feat(tab): add themes
SisIvanova May 4, 2022
96cd2aa
feat(tabs):add keyboard events and activation prop
mtsvyatkova May 9, 2022
5a4b94f
feat(tabs): add igcChange event and select method
mtsvyatkova May 9, 2022
08da984
light & dark themes improvements
SisIvanova May 10, 2022
dae461c
add fluent theme
SisIvanova May 11, 2022
c1816b3
finish bootstrap focus styles
SisIvanova May 12, 2022
097b369
remove unnecessary changes
SisIvanova May 12, 2022
366e04a
remove panel div and update selected prop
mtsvyatkova May 12, 2022
85da81f
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 16, 2022
452e1d6
feat(tabs): add RTL support
mtsvyatkova May 16, 2022
72dc15c
Merge branch 'mtsvyatkova/tabs-component' of https://github.com/Ignit…
mtsvyatkova May 16, 2022
3d65d9c
add docs, fix imports and cache DOM elements
mtsvyatkova May 17, 2022
c1458ac
apply requested styling changes
SisIvanova May 18, 2022
40eeea6
add tests
mtsvyatkova May 18, 2022
47e7dde
Merge branch 'mtsvyatkova/tabs-component' of https://github.com/Ignit…
mtsvyatkova May 18, 2022
04c0b9f
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 19, 2022
42c12e8
update bootstrap & fluent themes
SisIvanova May 19, 2022
571cc2e
remove icon-button hover & focus styles
SisIvanova May 19, 2022
dd01331
update scroll logic
mtsvyatkova May 20, 2022
54b1aa7
Merge branch 'master' into mtsvyatkova/tabs-component
SisIvanova May 20, 2022
4572eae
add button renderer & get next tab on button click
mtsvyatkova May 23, 2022
194593d
Merge branch 'master' into mtsvyatkova/tabs-component
mtsvyatkova May 23, 2022
e7328a5
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 25, 2022
51d46df
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 26, 2022
1853be7
update scroll buttons colors
SisIvanova May 26, 2022
a94741d
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 26, 2022
6c0bbf9
update tabs typography
SisIvanova May 27, 2022
86bfca4
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 30, 2022
c6e24f3
update scroll logic and add alignment tests
mtsvyatkova May 30, 2022
7b6dd45
align selected indicator after scroll
mtsvyatkova May 30, 2022
74a8253
Merge branch 'master' into mtsvyatkova/tabs-component
simeonoff May 31, 2022
bdc0062
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov May 31, 2022
d37509e
Merge branch 'master' into mtsvyatkova/tabs-component
simeonoff May 31, 2022
3d22354
display both scroll buttons
mtsvyatkova Jun 2, 2022
83e9716
Merge branch 'master' into mtsvyatkova/tabs-component
simeonoff Jun 2, 2022
43ce217
fix(tabs): Various paper-cut fixes
rkaraivanov Jun 3, 2022
183b538
update disabled header button color
SisIvanova Jun 3, 2022
89f289a
fix bootstrap & material justify alignment
SisIvanova Jun 3, 2022
b3696b4
test(tabs): Wait for buttons update in scroll tests
rkaraivanov Jun 6, 2022
7162b51
test(tabs): Added RTL scrolling tests
rkaraivanov Jun 6, 2022
a2991b5
test(tabs): Add RTL indicator&key selection tests
mtsvyatkova Jun 6, 2022
ed2fb51
Merge branch 'master' into mtsvyatkova/tabs-component
mtsvyatkova Jun 6, 2022
4581887
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov Jun 6, 2022
a18196f
refactor(tabs): Slotchange behavior for tabs
rkaraivanov Jun 8, 2022
267208e
fix(tabs): Scrolling when tab is partially visible
mtsvyatkova Jun 8, 2022
cfc0763
fix(tabs): set default scroll to nearest
mtsvyatkova Jun 8, 2022
46bff71
fix(tabs): scroll buttons size
SisIvanova Jun 15, 2022
82e3928
fix(tabs): improve tab alignment
simeonoff Jun 15, 2022
65379e6
Merge branch 'master' into mtsvyatkova/tabs-component
simeonoff Jun 16, 2022
c1eb4ab
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov Jun 17, 2022
77fcefb
fix(tabs): set aria attrs and remove panel's props
mtsvyatkova Jun 17, 2022
7ffea4a
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov Jun 17, 2022
dcc14dd
fix(tabs): scroll doesn't work in safari
simeonoff Jun 23, 2022
b1c8517
Merge branch 'master' into mtsvyatkova/tabs-component
ChronosSF Jun 23, 2022
8ef0fc7
fix(tabs): Scroll behavior
rkaraivanov Jun 27, 2022
08f41b3
stories(tab): update icons
simeonoff Jun 27, 2022
a13ffa2
refactor(tab-panel): Implicit attributes
rkaraivanov Jun 29, 2022
097e1e9
refactor: Selection logic
rkaraivanov Jul 1, 2022
299b9cf
themes(tabs): fix prefix/suffix styling
simeonoff Jul 1, 2022
905e2f6
fix(tabs): scrollIntoView options
mtsvyatkova Jul 4, 2022
90c49d1
Merge branch 'master' into mtsvyatkova/tabs-component
rkaraivanov Jul 5, 2022
b40785d
refactor: Addressed PR comments
rkaraivanov Jul 6, 2022
115e738
refactor: Auto increment handling and mutaiton observer callback
rkaraivanov Jul 6, 2022
f9d7e9c
fix: Automatic attribute wire-up
rkaraivanov Jul 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/common/definitions/defineAllComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import IgcSliderComponent from '../../slider/slider.js';
import IgcSnackbarComponent from '../../snackbar/snackbar.js';
import IgcToastComponent from '../../toast/toast.js';
import IgcSliderLabelComponent from '../../slider/slider-label.js';
import IgcTabsComponent from '../../tabs/tabs';
import IgcTabComponent from '../../tabs/tab';
import IgcTabPanelComponent from '../../tabs/tab-panel';
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved
import { defineComponents } from './defineComponents.js';
import IgcCircularGradientComponent from '../../progress/circular-gradient.js';
import IgcMaskInputComponent from '../../mask-input/mask-input.js';
Expand Down Expand Up @@ -79,6 +82,9 @@ const allComponents: CustomElementConstructor[] = [
IgcToastComponent,
IgcSliderLabelComponent,
IgcRangeSliderComponent,
IgcTabsComponent,
IgcTabComponent,
IgcTabPanelComponent,
IgcCircularProgressComponent,
IgcLinearProgressComponent,
IgcCircularGradientComponent,
Expand Down
44 changes: 44 additions & 0 deletions src/components/tabs/tab-panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { html, LitElement } from 'lit';
import { property, state } from 'lit/decorators.js';
import { watch } from '../common/decorators';
import { styles } from './themes/light/tab-panel.base.css';
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved

export default class IgcTabPanelComponent extends LitElement {
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved
public static readonly tagName = 'igc-tab-panel';

public static override styles = styles;

@state()
public selected = false;
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved

@state()
public disabled = false;
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved

@property({ type: String })
public name = '';
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved

public override connectedCallback() {
super.connectedCallback();

this.setAttribute('role', 'tabpanel');
this.setAttribute('tabindex', '0');
}

@watch('selected')
protected selectedChange() {
const styles: Partial<CSSStyleDeclaration> = {
display: `${this.selected ? 'block' : 'none'}`,
};
Object.assign(this.style, styles);
}

protected override render() {
return html` <slot></slot> `;
}
}

declare global {
interface HTMLElementTagNameMap {
'igc-tab-panel': IgcTabPanelComponent;
}
}
56 changes: 56 additions & 0 deletions src/components/tabs/tab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { html, LitElement } from 'lit';
import { themes } from '../../theming/theming-decorator.js';
import { property, query } from 'lit/decorators.js';
import { styles } from './themes/light/tab.base.css';
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved
import { styles as bootstrap } from './themes/light/tab.bootstrap.css.js';
import { styles as fluent } from './themes/light/tab.fluent.css.js';
import { styles as indigo } from './themes/light/tab.indigo.css.js';

@themes({ bootstrap, fluent, indigo })
export default class IgcTabComponent extends LitElement {
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved
public static readonly tagName = 'igc-tab';

public static override styles = styles;

@query('[part="base"]')
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved
private tab!: HTMLElement;

@property({ type: String })
public panel = '';

@property({ type: Boolean, reflect: true })
public selected = false;

@property({ type: Boolean, reflect: true })
public disabled = false;

public override focus(options?: FocusOptions) {
this.tab.focus(options);
}

public override blur() {
this.tab.blur();
}
mtsvyatkova marked this conversation as resolved.
Show resolved Hide resolved

protected override render() {
return html`
<div
part="base"
role="tab"
aria-disabled=${this.disabled ? 'true' : 'false'}
aria-selected=${this.selected ? 'true' : 'false'}
Copy link
Member

Choose a reason for hiding this comment

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

I don't see aria-controls linking to the panel the tab controls, the specs say 'should' but I think it might be needed to properly reflect the active tab when the focus is in the panel or its children.
To that end - @rkaraivanov would it not make more sense to have id on the panel instead of name as the ARIA link is based on id-s anyway?

Copy link
Member

Choose a reason for hiding this comment

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

@damyanpetev
Fine by me. Feel free to update the specification.

Copy link
Member

@damyanpetev damyanpetev Jun 24, 2022

Choose a reason for hiding this comment

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

I did though aria-controls is described as should have.
Reading https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tab_role we might also consider aria-owns list on the tabs themselves it seems as it's described as must

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tablist role is set for the parent element of the tabs so I believe we don't need the aria-owns attribute.

tabindex=${this.disabled || !this.selected ? -1 : 0}
>
<slot name="prefix" part="prefix"></slot>
<slot></slot>
<slot name="suffix" part="suffix"></slot>
</div>
`;
}
}

declare global {
interface HTMLElementTagNameMap {
'igc-tab': IgcTabComponent;
}
}
Loading