Tweak file and folder styles

This commit is contained in:
Kevin Sawicki
2013-06-10 10:53:51 -07:00
parent 0f16b54d8e
commit 3102ac403b
4 changed files with 37 additions and 25 deletions

View File

@@ -37,7 +37,6 @@ class ArchiveView extends ScrollView
else
@tree.append(new FileView(@path, entry))
@tree.find('.entry.file:first').addClass('selected')
@tree.show()
setModel: (editSession) ->

View File

@@ -4,7 +4,8 @@ FileView = require './file-view'
module.exports =
class DirectoryView extends View
@content: (archivePath, entry) ->
@div entry.getName(), class: 'entry directory'
@div class: 'entry', =>
@span entry.getName(), class: 'directory'
initialize: (archivePath, entry) ->
for child in entry.children

View File

@@ -1,5 +1,5 @@
{View} = require 'space-pen'
fs = require 'fs'
fsUtils = require 'fs-utils'
path = require 'path'
temp = require 'temp'
archive = require 'ls-archive'
@@ -7,24 +7,26 @@ archive = require 'ls-archive'
module.exports =
class FileView extends View
@content: (archivePath, entry) ->
@div =>
@span entry.getName(), class: 'entry file'
@div class: 'entry', =>
@span entry.getName(), class: 'file', outlet: 'name'
initialize: (archivePath, entry) ->
@name.addClass('symlink') if entry.isSymbolicLink()
@on 'click', =>
@closest('.archive-view').find('.entry').removeClass('selected')
@addClass('selected')
@closest('.archive-view').find('.selected').removeClass('selected')
@name.addClass('selected')
archive.readFile archivePath, entry.getPath(), (error, contents) ->
if error?
console.error("Error reading: #{entry.getPath()} from #{archivePath}", error.stack ? error)
else
temp.mkdir path.basename(archivePath), (error, tempDirPath) ->
temp.mkdir 'atom-', (error, tempDirPath) ->
if error?
console.error("Error creating temp directory: #{tempDirPath}")
else
tempFilePath = path.join(tempDirPath, entry.getName())
fs.writeFile tempFilePath, contents, (error) ->
if error?
console.error("Error writing to #{tempFilePath}")
else
rootView.open(tempFilePath)
tempFilePath = path.join(tempDirPath, path.basename(archivePath), entry.getName())
fsUtils.writeAsync tempFilePath, contents, (error) ->
if error?
console.error("Error writing to #{tempFilePath}")
else
rootView.open(tempFilePath)

View File

@@ -26,27 +26,37 @@
}
.entry {
padding: 5px;
margin: 5px;
> .entry {
margin-left: 5px;
padding-left: 15px;
}
&:before {
margin-right: @icon-margin;
}
span.file {
display: inline-block;
padding: 5px;
&:before {
padding-right: @icon-margin;
}
&.file {
.mini-icon(text-file);
&.symlink {
.mini-icon(symlink);
}
}
&.directory {
span.directory {
display: inline-block;
padding-left: 5px;
&:before {
margin-right: @icon-margin;
}
.mini-icon(directory);
}
&.symlink {
.mini-icon(symlink);
}
}
}
}