Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add item constructor name as data attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki committed Feb 9, 2015
1 parent 7c1316d commit 61d66a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/tab-view.coffee
Expand Up @@ -5,8 +5,6 @@ module.exports =
class TabView extends HTMLElement
initialize: (@item) ->
@classList.add('tab', 'sortable')
if itemPath = @item.getPath?()
@classList.add('has-path')

@itemTitle = document.createElement('div')
@itemTitle.classList.add('title')
Expand Down Expand Up @@ -110,6 +108,14 @@ class TabView extends HTMLElement
if itemPath = @item.getPath?()
@itemTitle.dataset.name = path.basename(itemPath)
@itemTitle.dataset.path = itemPath
else
delete @itemTitle.dataset.name
delete @itemTitle.dataset.path

if itemClass = @item.constructor.name
@dataset.type = itemClass
else
delete @dataset.type

updateTitle: ({updateSiblings, useLongTitle}={}) ->
return if @updatingTitle
Expand Down

1 comment on commit 61d66a7

@jessegrosjean
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to create another type of editor view, I'd like to to be a peer to TextEditor as much as possible. So for example I'm using colors for my content area out of the syntax-variables.less file, etc.

In this commit you've added @dataset.type = itemClass and now some themes are targeting that value directly to apply special styling to TextEditor tabs. For example the One theme does:

.tab.active[data-type="TextEditor"] {
  color: @tab-text-color-editor;
  background-color: @tab-background-color-editor;
  &:after {
    border-bottom-color: @tab-background-color-editor;
  }
}

And that makes the active tab match the text editors background color, but only for TextEditor panes.

Is there some way to update this so that my editor type can get the same styling? Here's one change that would allow me to hack a solution:

if itemClass = @item.tabsDataTypeOverride or @item.constructor?.name

Though probably better is to have some way for items to tell the rest of the UI (tabs for example) that their content is styled using values from "Syntax Theme" and then tabs, etc can adjust default styles appropriately?

Jesse

Please sign in to comment.