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

Commit

Permalink
use themeName variable
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Mar 19, 2018
1 parent f3b6e8a commit 1f086d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
26 changes: 14 additions & 12 deletions lib/main.coffee
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
root = document.documentElement
themeName = 'one-dark-ui'


module.exports =
activate: (state) ->
atom.config.observe 'one-dark-ui.fontSize', (value) ->
atom.config.observe "#{themeName}.fontSize", (value) ->
setFontSize(value)

atom.config.observe 'one-dark-ui.tabSizing', (value) ->
atom.config.observe "#{themeName}.tabSizing", (value) ->
setTabSizing(value)

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

atom.config.observe 'one-dark-ui.stickyHeaders', (value) ->
atom.config.observe "#{themeName}.stickyHeaders", (value) ->
setStickyHeaders(value)

# DEPRECATED: This can be removed at some point (added in Atom 1.17/1.18ish)
# It removes `layoutMode`
if atom.config.get('one-dark-ui.layoutMode')
atom.config.unset('one-dark-ui.layoutMode')
if atom.config.get("#{themeName}.layoutMode")
atom.config.unset("#{themeName}.layoutMode")

deactivate: ->
unsetFontSize()
Expand All @@ -38,31 +40,31 @@ unsetFontSize = ->
# Tab Sizing -----------------------

setTabSizing = (tabSizing) ->
root.setAttribute('theme-one-dark-ui-tabsizing', tabSizing.toLowerCase())
root.setAttribute("theme-#{themeName}-tabsizing", tabSizing.toLowerCase())

unsetTabSizing = ->
root.removeAttribute('theme-one-dark-ui-tabsizing')
root.removeAttribute("theme-#{themeName}-tabsizing")


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

setHideDockButtons = (hideDockButtons) ->
if hideDockButtons
root.setAttribute('theme-one-dark-ui-dock-buttons', 'hidden')
root.setAttribute("theme-#{themeName}-dock-buttons", 'hidden')
else
unsetHideDockButtons()

unsetHideDockButtons = ->
root.removeAttribute('theme-one-dark-ui-dock-buttons')
root.removeAttribute("theme-#{themeName}-dock-buttons")


# Sticky Headers -----------------------

setStickyHeaders = (stickyHeaders) ->
if stickyHeaders
root.setAttribute('theme-one-dark-ui-sticky-headers', 'sticky')
root.setAttribute("theme-#{themeName}-sticky-headers", 'sticky')
else
unsetStickyHeaders()

unsetStickyHeaders = ->
root.removeAttribute('theme-one-dark-ui-sticky-headers')
root.removeAttribute("theme-#{themeName}-sticky-headers")
28 changes: 15 additions & 13 deletions spec/theme-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
describe "One Dark UI theme", ->
themeName = 'one-dark-ui'

describe "#{themeName} theme", ->
beforeEach ->
waitsForPromise ->
atom.packages.activatePackage('one-dark-ui')
atom.packages.activatePackage(themeName)

it "allows the font size to be set via config", ->
expect(document.documentElement.style.fontSize).toBe '12px'

atom.config.set('one-dark-ui.fontSize', '10')
atom.config.set("#{themeName}.fontSize", '10')
expect(document.documentElement.style.fontSize).toBe '10px'

it "allows the tab sizing to be set via config", ->
atom.config.set('one-dark-ui.tabSizing', 'Maximum')
expect(document.documentElement.getAttribute('theme-one-dark-ui-tabsizing')).toBe 'maximum'
atom.config.set("#{themeName}.tabSizing", 'Maximum')
expect(document.documentElement.getAttribute("theme-#{themeName}-tabsizing")).toBe 'maximum'

it "allows the tab sizing to be set via config", ->
atom.config.set('one-dark-ui.tabSizing', 'Minimum')
expect(document.documentElement.getAttribute('theme-one-dark-ui-tabsizing')).toBe 'minimum'
atom.config.set("#{themeName}.tabSizing", 'Minimum')
expect(document.documentElement.getAttribute("theme-#{themeName}-tabsizing")).toBe 'minimum'

it "allows the dock toggle buttons to be hidden via config", ->
atom.config.set('one-dark-ui.hideDockButtons', true)
expect(document.documentElement.getAttribute('theme-one-dark-ui-dock-buttons')).toBe 'hidden'
atom.config.set("#{themeName}.hideDockButtons", true)
expect(document.documentElement.getAttribute("theme-#{themeName}-dock-buttons")).toBe 'hidden'

it "allows the tree-view headers to be sticky via config", ->
atom.config.set('one-dark-ui.stickyHeaders', true)
expect(document.documentElement.getAttribute('theme-one-dark-ui-sticky-headers')).toBe 'sticky'
atom.config.set("#{themeName}.stickyHeaders", true)
expect(document.documentElement.getAttribute("theme-#{themeName}-sticky-headers")).toBe 'sticky'

it "allows the tree-view headers to not be sticky via config", ->
atom.config.set('one-dark-ui.stickyHeaders', false)
expect(document.documentElement.getAttribute('theme-one-dark-ui-sticky-headers')).toBe null
atom.config.set("#{themeName}.stickyHeaders", false)
expect(document.documentElement.getAttribute("theme-#{themeName}-sticky-headers")).toBe null

0 comments on commit 1f086d6

Please sign in to comment.