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

Commit a4a500f

Browse files
committed
Add option for left tab close buttons
1 parent ca63f70 commit a4a500f

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

lib/main.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module.exports =
1010
atom.config.observe "#{themeName}.tabSizing", (value) ->
1111
setTabSizing(value)
1212

13+
atom.config.observe "#{themeName}.tabCloseButton", (value) ->
14+
setTabCloseButton(value)
15+
1316
atom.config.observe "#{themeName}.hideDockButtons", (value) ->
1417
setHideDockButtons(value)
1518

@@ -24,6 +27,7 @@ module.exports =
2427
deactivate: ->
2528
unsetFontSize()
2629
unsetTabSizing()
30+
unsetTabCloseButton()
2731
unsetHideDockButtons()
2832
unsetStickyHeaders()
2933

@@ -46,6 +50,18 @@ unsetTabSizing = ->
4650
root.removeAttribute("theme-#{themeName}-tabsizing")
4751

4852

53+
# Tab Close Button -----------------------
54+
55+
setTabCloseButton = (tabCloseButton) ->
56+
if tabCloseButton is 'Left'
57+
root.setAttribute("theme-#{themeName}-tab-close-button", 'left')
58+
else
59+
unsetTabCloseButton()
60+
61+
unsetTabCloseButton = ->
62+
root.removeAttribute("theme-#{themeName}-tab-close-button")
63+
64+
4965
# Dock Buttons -----------------------
5066

5167
setHideDockButtons = (hideDockButtons) ->

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,29 @@
5050
],
5151
"order": 2
5252
},
53+
"tabCloseButton": {
54+
"title": "Tab Close Button",
55+
"description": "Choose the position of the close button shown in tabs.",
56+
"type": "string",
57+
"default": "Right",
58+
"enum": [
59+
"Left",
60+
"Right"
61+
],
62+
"order": 3
63+
},
5364
"hideDockButtons": {
5465
"title": "Hide dock toggle buttons",
5566
"description": "Note: When hiding the toggle buttons, opening a dock needs to be done by using the keyboard or other alternatives.",
5667
"type": "boolean",
5768
"default": "false",
58-
"order": 3
69+
"order": 4
5970
},
6071
"stickyHeaders": {
6172
"title": "Make tree-view project headers sticky",
6273
"type": "boolean",
6374
"default": "true",
64-
"order": 4
75+
"order": 5
6576
}
6677
}
6778
}

spec/theme-spec.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ describe "#{themeName} theme", ->
1919
atom.config.set("#{themeName}.tabSizing", 'Minimum')
2020
expect(document.documentElement.getAttribute("theme-#{themeName}-tabsizing")).toBe 'minimum'
2121

22+
it "allows the tab close button to be shown on the left via config", ->
23+
atom.config.set("#{themeName}.tabCloseButton", 'Left')
24+
expect(document.documentElement.getAttribute("theme-#{themeName}-tab-close-button")).toBe 'left'
25+
2226
it "allows the dock toggle buttons to be hidden via config", ->
2327
atom.config.set("#{themeName}.hideDockButtons", true)
2428
expect(document.documentElement.getAttribute("theme-#{themeName}-dock-buttons")).toBe 'hidden'

styles/config.less

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11

2-
// Tabs ----------------------------------------------
2+
// Theme config
3+
// This gets changed from the theme settings
34

45
@theme-tabsizing: ~'theme-@{ui-theme-name}-tabsizing';
56
@theme-dockButtons: ~'theme-@{ui-theme-name}-dock-buttons';
67
@theme-stickyHeaders: ~'theme-@{ui-theme-name}-sticky-headers';
8+
@theme-closeButton: ~'theme-@{ui-theme-name}-tab-close-button';
79

8-
@tab-min-width: 7em; // ~ icon + 6 characters
910

11+
// Tabs ----------------------------------------------
12+
13+
@tab-min-width: 7em; // ~ icon + 6 characters
1014

11-
// Even (default) ---------------
15+
// Even (default)
1216

1317
.tab-bar {
1418
.tab,
@@ -32,7 +36,7 @@
3236
}
3337

3438

35-
// Maximum (full width) ---------------
39+
// Maximum (full width)
3640

3741
[@{theme-tabsizing}="maximum"] .tab-bar {
3842
.tab,
@@ -42,7 +46,7 @@
4246
}
4347

4448

45-
// Minimum (show long paths) ---------------
49+
// Minimum (show long paths)
4650

4751
[@{theme-tabsizing}="minimum"] .tab-bar {
4852
.tab,
@@ -60,6 +64,19 @@
6064
}
6165

6266

67+
// Tabs: close button position ------------------------------
68+
69+
[@{theme-closeButton}="left"] {
70+
71+
.tab-bar .tab {
72+
.close-icon {
73+
right: auto;
74+
left: @icon-padding-right;
75+
}
76+
}
77+
78+
}
79+
6380

6481
// Hide docks toggle buttons ------------------------------
6582

0 commit comments

Comments
 (0)