Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 0dce9d7

Browse files
tychenjiajunmatsp
authored andcommitted
feat(tabs): Use instances initialized from the parent tab bar (#443)
* feat(tab): update * feat(tab): update * fix(tabs): fixes #441 #442 #440 #304 #303 update readme * fix(tabs): minor bug in demo
1 parent 2f671d9 commit 0dce9d7

File tree

6 files changed

+465
-108
lines changed

6 files changed

+465
-108
lines changed

components/tabs/README.md

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
1-
## TabBar
1+
## Tab Bar
2+
3+
Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy. The Tab Bar contains the Tab Scroller and Tab components.
24

35
### Markup
46

57
```html
6-
<m-tab-bar scrollable>
7-
<m-tab href="#home">
8+
<m-tab-bar>
9+
<m-tab-scroller>
10+
<m-tab>
11+
<m-icon slot="icon" icon="home"/>
12+
Home
13+
</m-tab>
14+
<m-tab>
15+
<m-icon slot="icon" icon="favorite"/>
16+
Like me
17+
</m-tab>
18+
<m-tab>
19+
<m-icon slot="icon" icon="person"/>
20+
About me
21+
</m-tab>
22+
</m-tab-scroller>
23+
</m-tab-bar>
24+
```
25+
26+
or the `0.x.y` versions compatible way (not suggested)
27+
28+
```html
29+
<m-tab-bar>
30+
<m-tab>
831
<m-icon slot="icon" icon="home"/>
932
Home
1033
</m-tab>
11-
<m-tab active href="#social">
34+
<m-tab>
1235
<m-icon slot="icon" icon="favorite"/>
1336
Like me
1437
</m-tab>
15-
<m-tab href="#about">
38+
<m-tab>
1639
<m-icon slot="icon" icon="person"/>
1740
About me
1841
</m-tab>
@@ -23,33 +46,79 @@
2346

2447
| Prop | Type | Default | Description |
2548
|------|------|---------|-------------|
26-
| scrollable | Boolean | false | whether the tab bar should be scrollable |
27-
| iconTabBar | Boolean | false | should be set when there will be icons in the tab label |
28-
| withIconAndText | Boolean | false | should be set when there will be icons and text in the tab label |
49+
| focusOnActivate | Boolean | true | Sets whether tabs focus themselves when activated. |
50+
| useAutomaticActivation | Boolean | true | Sets how tabs activate in response to keyboard interaction. Automatic (true) activates as soon as a tab is focused with arrow keys; manual (false) activates only when the user presses space/enter. The default is automatic (true). |
51+
| activateTab | Number | 0 | Activates the tab at the given index. |
52+
| scrollIntoView | Number | 0 | Scrolls the tab at the given index into view. |
53+
| align | String | '' | __Only use when `<m-tab-scroller>` is not provided in the default slot.__ Sets the elements inside the scroll content element to be aligned to the `start`, `center`, or `end` of the scroll content element. |
54+
### Slots
55+
56+
| Slot | Description |
57+
|------|-------------|
58+
| default | tab bar content (tabs, or tabs within `<m-tab-scroller>`) |
59+
60+
### Events
61+
62+
| Event | Payload | Description |
63+
|-------|---------|-------------|
64+
| activated | {"index": number} | Emitted when a Tab is activated with the index of the activated Tab. Listen for this to update content when a Tab becomes active. |
65+
66+
## Tab Scroller
67+
68+
A Tab Scroller allows for smooth native and animated scrolling of tabs.
69+
70+
### Props
71+
72+
| Prop | Type | Default | Description |
73+
|------|------|---------|------------|
74+
| align | String | '' | Sets the elements inside the scroll content element to be aligned to the `start`, `center`, or `end` of the scroll content element. |
2975

3076
### Slots
3177

3278
| Slot | Description |
3379
|------|-------------|
34-
| default | tab bar content (tabs) |
80+
| default | tabs |
3581

3682
## Tab
3783

3884
### Props
3985

40-
| Prop | Type | Default |Description |
86+
| Prop | Type | Default | Description |
4187
|------|------|---------|------------|
4288
| active | Boolean | false | whether the tab should be marked as active |
43-
| label | Boolean | true | whether the label in the default slot should be visible |
89+
| spanningOnlyContent | Boolean | true | whether the label in the default slot should be visible |
90+
| focusOnActivate | Boolean | true | Sets whether the tab should focus itself when activated. |
91+
| stacked | Boolean | false | Indicates that the tab icon and label should flow vertically instead of horizontally. |
92+
| minWidth | Boolean | false | Indicates that the tab should shrink in size to be as narrow as possible without causing text to wrap. |
93+
| id | String | '' | Value of the root tab element's id attribute. |
94+
| fade | Boolean | false | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ Sets up the tab indicator to fade in on activation and fade out on deactivation. |
95+
| indicatorIcon | '' | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ The icon content of the tab indicator content.
96+
| indicatorIconClass | 'material-icons' | __Only use when `<m-tab-indicator>` is not provided in the `indicator` slot.__ The icon class of the tab indicator content.
97+
| href | '' | whether the tab should be a hyperlink and should use anchor tag instead of a button |
98+
> _NOTE_: The tab indicator is an underline indicator by default. You can change it to a icon indicator by setting `indicatorIcon` or `indicatorClass` to a different value or provide a `<m-tab-indicator>` in the `indicator` slot.
4499
45-
Non prop events are mapped to the inner button element.
100+
> _NOTE_: In case of using anchor tag for tab (`<m-tab href="some/url">`) it is required to switch off automatic activation in parent component (`<m-tab-bar :useAutomaticActivation="false">`).
46101
47102
### Slots
48103

49104
| Slot | Description |
50105
|------|-------------|
51106
| default | tab label |
52-
| icon | icon component |
107+
| icon | icon |
108+
| indicator | tab indicator |
109+
110+
## Tab Indicator
111+
112+
A Tab Indicator is a visual guide that shows which Tab is active.
113+
114+
### Props
115+
116+
| Prop | Type | Default | Description |
117+
|------|------|---------|------------|
118+
| fade | Boolean | false | Sets up the tab indicator to fade in on activation and fade out on deactivation. |
119+
| icon | String | '' | The icon to use when using as an icon indicator |
120+
| active | Boolean | false | Activates or deactivates the indicator. |
121+
| iconClass | String | 'material-icons' | The class applied to the icon when using as an icon indicator. |
53122

54123
### Reference
55124

0 commit comments

Comments
 (0)