Decaffeinate one-light-ui package

This commit is contained in:
Max Brunsfeld 2018-09-06 11:22:42 -07:00
parent 6db97d3fc9
commit 376c5ca57a
8 changed files with 136 additions and 161 deletions

View File

@ -14,6 +14,9 @@
"engines": {
"atom": ">0.40.0"
},
"devDependencies": {
"standard": "^11.0.0"
},
"configSchema": {
"fontSize": {
"title": "Font Size",

View File

@ -1 +0,0 @@
spec/fixtures

View File

@ -1,37 +0,0 @@
{
"max_line_length": {
"level": "ignore"
},
"no_empty_param_list": {
"level": "error"
},
"arrow_spacing": {
"level": "error"
},
"no_interpolation_in_single_quotes": {
"level": "error"
},
"no_debugger": {
"level": "error"
},
"prefer_english_operator": {
"level": "error"
},
"colon_assignment_spacing": {
"spacing": {
"left": 0,
"right": 1
},
"level": "error"
},
"braces_spacing": {
"spaces": 0,
"level": "error"
},
"spacing_after_comma": {
"level": "error"
},
"no_stand_alone_at": {
"level": "error"
}
}

View File

@ -1,86 +0,0 @@
root = document.documentElement
themeName = 'one-light-ui'
module.exports =
activate: (state) ->
atom.config.observe "#{themeName}.fontSize", (value) ->
setFontSize(value)
atom.config.observe "#{themeName}.tabSizing", (value) ->
setTabSizing(value)
atom.config.observe "#{themeName}.tabCloseButton", (value) ->
setTabCloseButton(value)
atom.config.observe "#{themeName}.hideDockButtons", (value) ->
setHideDockButtons(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("#{themeName}.layoutMode")
atom.config.unset("#{themeName}.layoutMode")
deactivate: ->
unsetFontSize()
unsetTabSizing()
unsetTabCloseButton()
unsetHideDockButtons()
unsetStickyHeaders()
# Font Size -----------------------
setFontSize = (currentFontSize) ->
root.style.fontSize = "#{currentFontSize}px"
unsetFontSize = ->
root.style.fontSize = ''
# Tab Sizing -----------------------
setTabSizing = (tabSizing) ->
root.setAttribute("theme-#{themeName}-tabsizing", tabSizing.toLowerCase())
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) ->
if hideDockButtons
root.setAttribute("theme-#{themeName}-dock-buttons", 'hidden')
else
unsetHideDockButtons()
unsetHideDockButtons = ->
root.removeAttribute("theme-#{themeName}-dock-buttons")
# Sticky Headers -----------------------
setStickyHeaders = (stickyHeaders) ->
if stickyHeaders
root.setAttribute("theme-#{themeName}-sticky-headers", 'sticky')
else
unsetStickyHeaders()
unsetStickyHeaders = ->
root.removeAttribute("theme-#{themeName}-sticky-headers")

View File

@ -0,0 +1,88 @@
const root = document.documentElement
const themeName = 'one-light-ui'
module.exports = {
activate (state) {
atom.config.observe(`${themeName}.fontSize`, setFontSize)
atom.config.observe(`${themeName}.tabSizing`, setTabSizing)
atom.config.observe(`${themeName}.tabCloseButton`, setTabCloseButton)
atom.config.observe(`${themeName}.hideDockButtons`, setHideDockButtons)
atom.config.observe(`${themeName}.stickyHeaders`, setStickyHeaders)
// DEPRECATED: This can be removed at some point (added in Atom 1.17/1.18ish)
// It removes `layoutMode`
if (atom.config.get(`${themeName}.layoutMode`)) {
atom.config.unset(`${themeName}.layoutMode`)
}
},
deactivate () {
unsetFontSize()
unsetTabSizing()
unsetTabCloseButton()
unsetHideDockButtons()
unsetStickyHeaders()
}
}
// Font Size -----------------------
function setFontSize (currentFontSize) {
root.style.fontSize = `${currentFontSize}px`
}
function unsetFontSize () {
root.style.fontSize = ''
}
// Tab Sizing -----------------------
function setTabSizing (tabSizing) {
root.setAttribute(`theme-${themeName}-tabsizing`, tabSizing.toLowerCase())
}
function unsetTabSizing () {
root.removeAttribute(`theme-${themeName}-tabsizing`)
}
// Tab Close Button -----------------------
function setTabCloseButton (tabCloseButton) {
if (tabCloseButton === 'Left') {
root.setAttribute(`theme-${themeName}-tab-close-button`, 'left')
} else {
unsetTabCloseButton()
}
}
function unsetTabCloseButton () {
root.removeAttribute(`theme-${themeName}-tab-close-button`)
}
// Dock Buttons -----------------------
function setHideDockButtons (hideDockButtons) {
if (hideDockButtons) {
root.setAttribute(`theme-${themeName}-dock-buttons`, 'hidden')
} else {
unsetHideDockButtons()
}
}
function unsetHideDockButtons () {
root.removeAttribute(`theme-${themeName}-dock-buttons`)
}
// Sticky Headers -----------------------
function setStickyHeaders (stickyHeaders) {
if (stickyHeaders) {
root.setAttribute(`theme-${themeName}-sticky-headers`, 'sticky')
} else {
unsetStickyHeaders()
}
}
function unsetStickyHeaders () {
root.removeAttribute(`theme-${themeName}-sticky-headers`)
}

View File

@ -15,7 +15,7 @@
"atom": ">0.40.0"
},
"devDependencies": {
"coffeelint": "^1.9.7"
"standard": "^11.0.0"
},
"configSchema": {
"fontSize": {

View File

@ -1,36 +0,0 @@
themeName = 'one-light-ui'
describe "#{themeName} theme", ->
beforeEach ->
waitsForPromise ->
atom.packages.activatePackage(themeName)
it "allows the font size to be set via config", ->
expect(document.documentElement.style.fontSize).toBe '12px'
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("#{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("#{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'
it "allows the tree-view headers to be sticky via config", ->
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("#{themeName}.stickyHeaders", false)
expect(document.documentElement.getAttribute("theme-#{themeName}-sticky-headers")).toBe null

View File

@ -0,0 +1,44 @@
const themeName = 'one-light-ui'
describe(`${themeName} theme`, () => {
beforeEach(() => {
waitsForPromise(() => atom.packages.activatePackage(themeName))
})
it('allows the font size to be set via config', () => {
expect(document.documentElement.style.fontSize).toBe('12px')
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(`${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(`${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')
})
it('allows the tree-view headers to be sticky via config', () => {
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(`${themeName}.stickyHeaders`, false)
expect(document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)).toBe(null)
})
})