Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit edb9733

Browse files
Splaktarmmalerba
authored andcommitted
docs(tabs): clean up the dynamic tabs demo (#11439)
remove inline styles that make the example harder to read improve SCSS and remove unused rules fix adjustOffset() JSDoc to mark param as optional
1 parent dc3b028 commit edb9733

File tree

4 files changed

+65
-40
lines changed

4 files changed

+65
-40
lines changed

src/components/tabs/demoDynamicTabs/index.html

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
<md-tab ng-repeat="tab in tabs"
55
ng-disabled="tab.disabled"
66
label="{{tab.title}}">
7-
<div class="demo-tab tab{{$index%4}}" style="padding: 25px; text-align: center;">
7+
<div class="demo-tab tab{{$index%4}}">
88
<div ng-bind="tab.content"></div>
99
<br/>
10-
<md-button class="md-primary md-raised" ng-click="removeTab( tab )" ng-disabled="tabs.length <= 1">Remove Tab</md-button>
10+
<md-button class="md-primary md-raised" ng-click="removeTab( tab )"
11+
ng-disabled="tabs.length <= 1">
12+
Remove Tab
13+
</md-button>
1114
</div>
1215
</md-tab>
1316
</md-tabs>
1417
</md-content>
1518

16-
<form ng-submit="addTab(tTitle,tContent)" layout="column" class="md-padding" style="padding-top: 0;">
17-
<div layout="row" layout-sm="column">
18-
<div flex style="position: relative;">
19-
<h2 class="md-subhead" style="position: absolute; bottom: 0; left: 0; margin: 0; font-weight: 500; text-transform: uppercase; line-height: 35px; white-space: nowrap;">Add a new Tab:</h2>
19+
<form ng-submit="addTab(tTitle,tContent)" layout="column" class="md-padding">
20+
<div layout="row" layout-xs="column">
21+
<div flex>
22+
<h2 class="md-subhead">Add a new Tab:</h2>
2023
</div>
2124
<md-input-container>
2225
<label for="label">Label</label>
@@ -26,8 +29,10 @@ <h2 class="md-subhead" style="position: absolute; bottom: 0; left: 0; margin: 0;
2629
<label for="content">Content</label>
2730
<input type="text" id="content" ng-model="tContent">
2831
</md-input-container>
29-
<md-button class="add-tab md-primary md-raised" ng-disabled="!tTitle || !tContent" type="submit" style="margin-right: 0;">Add Tab</md-button>
32+
<md-button class="add-tab md-primary md-raised" ng-disabled="!tTitle || !tContent"
33+
type="submit">
34+
Add Tab
35+
</md-button>
3036
</div>
3137
</form>
32-
3338
</div>

src/components/tabs/demoDynamicTabs/script.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@
3232
previous = null;
3333
$scope.tabs = tabs;
3434
$scope.selectedIndex = 0;
35-
$scope.$watch('selectedIndex', function(current, old){
35+
$scope.$watch('selectedIndex', function(current, old) {
3636
previous = selected;
3737
selected = tabs[current];
38-
if ( old + 1 && (old != current)) $log.debug('Goodbye ' + previous.title + '!');
39-
if ( current + 1 ) $log.debug('Hello ' + selected.title + '!');
38+
if (old + 1 && (old != current)) {
39+
$log.debug('Goodbye ' + previous.title + '!');
40+
}
41+
if (current + 1) {
42+
$log.debug('Hello ' + selected.title + '!');
43+
}
4044
});
41-
$scope.addTab = function (title, view) {
45+
$scope.addTab = function(title, view) {
4246
view = view || title + " Content View";
43-
tabs.push({ title: title, content: view, disabled: false});
47+
tabs.push({title: title, content: view, disabled: false});
4448
};
45-
$scope.removeTab = function (tab) {
49+
$scope.removeTab = function(tab) {
4650
var index = tabs.indexOf(tab);
4751
tabs.splice(index, 1);
4852
};

src/components/tabs/demoDynamicTabs/style.scss

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,45 @@ md-content {
22
h1:first-child {
33
margin-top: 0;
44
}
5-
}
6-
md-input-container {
7-
padding-bottom: 0;
8-
}
9-
.remove-tab {
10-
margin-bottom: 40px;
11-
}
12-
.demo-tab > div > div {
13-
padding: 25px;
14-
box-sizing: border-box;
15-
}
16-
.edit-form input {
17-
width: 100%;
18-
}
19-
md-tab[disabled] {
20-
opacity: 0.5;
21-
}
22-
label {
23-
text-align: left;
24-
}
25-
.long > input {
26-
width: 264px;
27-
}
28-
.md-button.add-tab {
29-
transform: translateY(5px);
5+
md-tabs {
6+
.demo-tab {
7+
padding: 25px;
8+
text-align: center;
9+
10+
&> div > div {
11+
padding: 25px;
12+
box-sizing: border-box;
13+
}
14+
}
15+
md-tab {
16+
&[disabled] {
17+
opacity: 0.5;
18+
}
19+
}
20+
}
21+
form {
22+
padding-top: 0;
23+
24+
div[flex] {
25+
position: relative;
26+
27+
h2.md-subhead {
28+
position: absolute;
29+
bottom: 0;
30+
left: 0;
31+
margin: 0;
32+
font-weight: 500;
33+
text-transform: uppercase;
34+
line-height: 35px;
35+
white-space: nowrap;
36+
}
37+
}
38+
md-button.add-tab {
39+
margin-right: 0;
40+
transform: translateY(5px);
41+
}
42+
md-input-container {
43+
padding-bottom: 0;
44+
}
45+
}
3046
}

src/components/tabs/js/tabsController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
726726

727727
/**
728728
* Forces the pagination to move the focused tab into view.
729-
* @param {number} index of tab to have its offset adjusted
729+
* @param {number=} index of tab to have its offset adjusted
730730
*/
731731
function adjustOffset (index) {
732732
var elements = getElements();

0 commit comments

Comments
 (0)