mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add directory and ImportPaths paths to themes
This commit is contained in:
@@ -24,6 +24,12 @@ describe "ThemeManager", ->
|
||||
config.set('core.themes', [])
|
||||
expect($('style.userTheme').length).toBe 0
|
||||
|
||||
# atom-dark-ui has an directory path, the syntax ones dont.
|
||||
config.set('core.themes', ['atom-light-syntax', 'atom-dark-ui', 'atom-dark-syntax'])
|
||||
importPaths = themeManager.getImportPaths()
|
||||
expect(importPaths.length).toBe 1
|
||||
expect(importPaths[0]).toContain 'atom-dark-ui'
|
||||
|
||||
describe "when a theme fails to load", ->
|
||||
it "logs a warning", ->
|
||||
themeManager = new ThemeManager()
|
||||
|
||||
@@ -18,6 +18,7 @@ describe "Theme", ->
|
||||
themePath = project.resolve('themes/theme-stylesheet.css')
|
||||
theme = new Theme(themePath)
|
||||
expect($(".editor").css("padding-top")).toBe "1234px"
|
||||
expect(theme.directoryPath).not.toBeDefined()
|
||||
|
||||
it "parses, loads and applies less", ->
|
||||
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
|
||||
@@ -33,6 +34,7 @@ describe "Theme", ->
|
||||
|
||||
themePath = project.resolve('themes/theme-with-package-file')
|
||||
theme = new Theme(themePath)
|
||||
expect(theme.directoryPath).toBe themePath
|
||||
expect($(".editor").css("padding-top")).toBe("101px")
|
||||
expect($(".editor").css("padding-right")).toBe("102px")
|
||||
expect($(".editor").css("padding-bottom")).toBe("103px")
|
||||
@@ -45,6 +47,7 @@ describe "Theme", ->
|
||||
|
||||
themePath = project.resolve('themes/theme-without-package-file')
|
||||
theme = new Theme(themePath)
|
||||
expect(theme.directoryPath).toBe themePath
|
||||
expect($(".editor").css("padding-top")).toBe "10px"
|
||||
expect($(".editor").css("padding-right")).toBe "20px"
|
||||
expect($(".editor").css("padding-bottom")).toBe "30px"
|
||||
|
||||
@@ -40,6 +40,9 @@ class ThemeManager
|
||||
else
|
||||
null
|
||||
|
||||
getImportPaths: ->
|
||||
(theme.directoryPath for theme in @loadedThemes when theme.directoryPath)
|
||||
|
||||
loadUserStylesheet: ->
|
||||
if userStylesheetPath = @getUserStylesheetPath()
|
||||
@userStylesheetPath = userStylesheetPath
|
||||
|
||||
@@ -24,11 +24,12 @@ class Theme
|
||||
if path.extname(@stylesheetPath) in ['.css', '.less']
|
||||
@loadStylesheet(@stylesheetPath)
|
||||
else
|
||||
@directoryPath = @stylesheetPath
|
||||
metadataPath = fsUtils.resolveExtension(path.join(@stylesheetPath, 'package'), ['cson', 'json'])
|
||||
if fsUtils.isFileSync(metadataPath)
|
||||
stylesheetNames = fsUtils.readObjectSync(metadataPath)?.stylesheets
|
||||
if stylesheetNames
|
||||
for name in stylesheetNames
|
||||
@metadata = fsUtils.readObjectSync(metadataPath)
|
||||
if @metadata?.stylesheets
|
||||
for name in @metadata.stylesheets
|
||||
filename = fsUtils.resolveExtension(path.join(@stylesheetPath, name), ['.css', '.less', ''])
|
||||
@loadStylesheet(filename)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user