Skip to content

Commit

Permalink
Merge pull request atom#130 from atom/sm-left-close-button
Browse files Browse the repository at this point in the history
Add option for left tab close buttons
  • Loading branch information
simurai authored Mar 29, 2018
2 parents d7a5d98 + 06ac532 commit 15d224e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
16 changes: 16 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports =
atom.config.observe "#{themeName}.tabSizing", (value) ->
setTabSizing(value)

atom.config.observe "#{themeName}.tabCloseButton", (value) ->
setTabCloseButton(value)

atom.config.observe "#{themeName}.hideDockButtons", (value) ->
setHideDockButtons(value)

Expand All @@ -24,6 +27,7 @@ module.exports =
deactivate: ->
unsetFontSize()
unsetTabSizing()
unsetTabCloseButton()
unsetHideDockButtons()
unsetStickyHeaders()

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


# Tab Close Button -----------------------

setTabCloseButton = (tabCloseButton) ->
if tabCloseButton is 'Left'
root.setAttribute("theme-#{themeName}-tab-close-button", 'left')
else
unsetTabCloseButton()

unsetTabCloseButton = ->
root.removeAttribute("theme-#{themeName}-tab-close-button")


# Dock Buttons -----------------------

setHideDockButtons = (hideDockButtons) ->
Expand Down
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,29 @@
],
"order": 2
},
"tabCloseButton": {
"title": "Tab Close Button",
"description": "Choose the position of the close button shown in tabs.",
"type": "string",
"default": "Right",
"enum": [
"Left",
"Right"
],
"order": 3
},
"hideDockButtons": {
"title": "Hide dock toggle buttons",
"description": "Note: When hiding the toggle buttons, opening a dock needs to be done by using the keyboard or other alternatives.",
"type": "boolean",
"default": "false",
"order": 3
"order": 4
},
"stickyHeaders": {
"title": "Make tree-view project headers sticky",
"type": "boolean",
"default": "true",
"order": 4
"order": 5
}
}
}
4 changes: 4 additions & 0 deletions spec/theme-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ describe "#{themeName} theme", ->
atom.config.set("#{themeName}.tabSizing", 'Minimum')
expect(document.documentElement.getAttribute("theme-#{themeName}-tabsizing")).toBe 'minimum'

it "allows the tab close button to be shown on the left via config", ->
atom.config.set("#{themeName}.tabCloseButton", 'Left')
expect(document.documentElement.getAttribute("theme-#{themeName}-tab-close-button")).toBe 'left'

it "allows the dock toggle buttons to be hidden via config", ->
atom.config.set("#{themeName}.hideDockButtons", true)
expect(document.documentElement.getAttribute("theme-#{themeName}-dock-buttons")).toBe 'hidden'
Expand Down
27 changes: 22 additions & 5 deletions styles/config.less
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@

// Tabs ----------------------------------------------
// Theme config
// This gets changed from the theme settings

@theme-tabsizing: ~'theme-@{ui-theme-name}-tabsizing';
@theme-dockButtons: ~'theme-@{ui-theme-name}-dock-buttons';
@theme-stickyHeaders: ~'theme-@{ui-theme-name}-sticky-headers';
@theme-closeButton: ~'theme-@{ui-theme-name}-tab-close-button';

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

// Tabs ----------------------------------------------

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

// Even (default) ---------------
// Even (default)

.tab-bar {
.tab,
Expand All @@ -32,7 +36,7 @@
}


// Maximum (full width) ---------------
// Maximum (full width)

[@{theme-tabsizing}="maximum"] .tab-bar {
.tab,
Expand All @@ -42,7 +46,7 @@
}


// Minimum (show long paths) ---------------
// Minimum (show long paths)

[@{theme-tabsizing}="minimum"] .tab-bar {
.tab,
Expand All @@ -60,6 +64,19 @@
}


// Tabs: close button position ------------------------------

[@{theme-closeButton}="left"] {

.tab-bar .tab {
.close-icon {
right: auto;
left: @icon-padding-right;
}
}

}


// Hide docks toggle buttons ------------------------------

Expand Down

0 comments on commit 15d224e

Please sign in to comment.