Skip to content

Commit

Permalink
Fix #6, add option to specify font color
Browse files Browse the repository at this point in the history
  • Loading branch information
petetnt committed Jun 19, 2015
1 parent 54bf694 commit 7429ab2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
11 changes: 9 additions & 2 deletions htmlContent/project-name-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ <h1 class="dialog-title petetnt-name-a-project-dialog-title">{{title}} <small>{{
<div class="field-container">
<label>
<span>{{Strings.PROJECT_BACKGROUND_COLOR}}:</span>
<input name="colorValue" type="text" placeholder="{{Strings.PROJECT_BACKGROUND_COLOR}}" value="{{bgColor}}" class="url">
<div class="petetnt-name-a-project-color-hint" style="background-color: {{bgColor}}">
<input name="bgColorValue" type="text" placeholder="{{Strings.PROJECT_BACKGROUND_COLOR}}" value="{{bgColor}}" class="url">
<div class="petetnt-name-a-project-bgcolor-hint" style="background-color: {{bgColor}}">
<span class="color-swatch" style="background-color: {{bgColor}}"></span>
</div>
</label>
<label>
<span>{{Strings.PROJECT_TEXT_COLOR}}:</span>
<input name="textColorValue" type="text" placeholder="{{Strings.PROJECT_TEXT_COLOR}}" value="{{textColor}}" class="url">
<div class="petetnt-name-a-project-textcolor-hint" style="color-color: {{textColor}}">
<span class="color-swatch" style="background-color: {{textColor}}"></span>
</div>
</label>
</div>
<div class="field-container">
<label for="petetnt-scope-selection">
Expand Down
26 changes: 20 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,44 @@ define(function (require, exports, module) {
projectNameConfig = _getProjectNameConfig(projectRoot._path),
projectName = projectNameConfig ? projectNameConfig.name : projectRoot._name,
bgColor = projectNameConfig ? projectNameConfig.bgColor : "transparent",
textColor = projectNameConfig ? projectNameConfig.textColor : "#0000",
title = StringUtils.format(Strings.PROJECT_DIALOG_TITLE, projectRoot._name),
templateVars = {
title: title,
path: projectRoot._path,
Strings: Strings,
BracketsStrings: BracketsStrings,
projectName: projectName,
bgColor: bgColor
bgColor: bgColor,
textColor: textColor
},
bgColorInput,
bgColorHint;
bgColorHint,
textColorInput,
textColorHint;

dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(ProjectNameDialogTemplate, templateVars));

bgColorInput = dialog.getElement().find("input[name='colorValue']");
bgColorHint = dialog.getElement().find(".petetnt-name-a-project-color-hint");
bgColorInput = dialog.getElement().find("input[name='bgColorValue']");
textColorInput = dialog.getElement().find("input[name='textColorValue']");
bgColorHint = dialog.getElement().find(".petetnt-name-a-project-bgcolor-hint");
textColorHint = dialog.getElement().find(".petetnt-name-a-project-textcolor-hint");

dialog.done(function (id) {
if (id === Dialogs.DIALOG_BTN_OK) {
var config = {},
value = dialog.getElement().find("input[name='projectName']").val(),
name = value.length ? value : projectRoot._name,
bgColor = bgColorInput.val(),
textColor = textColorInput.val(),
scope = dialog.getElement().find("#petetnt-scope-selection").val();

config = {
_parentPath: projectRoot._path,
_name: projectRoot._name,
name: name,
bgColor: bgColor
bgColor: bgColor,
textColor: textColor
};

_setProjectNameConfig(config, projectRoot._path, scope);
Expand All @@ -84,6 +92,12 @@ define(function (require, exports, module) {
bgColorHint.html("");
ColorUtils.formatColorHint(bgColorHint, val);
});

textColorInput.on("keyup", function() {
var val = $(this).val();
textColorHint.html("");
ColorUtils.formatColorHint(textColorHint, val);
});
}

/*
Expand All @@ -104,7 +118,7 @@ define(function (require, exports, module) {
var recentFolder = $elem.find("span").eq(0);
recentFolder.html(projectNameConfig.name);
recentFolder.addClass("petetnt-name-a-project-is-named");
recentFolder.attr("style", "background-color:" + projectNameConfig.bgColor);
recentFolder.attr("style", "background-color:" + projectNameConfig.bgColor + "; color:" + projectNameConfig.textColor);
}
});
}
Expand Down
1 change: 1 addition & 0 deletions nls/en-gb/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"PROJECT_NAME": "Project Name",
"PROJECT_DIALOG_TITLE": "Project Name for {0}",
"PROJECT_BACKGROUND_COLOR": "Background colour (Hex, hsla, rgb or name)",
"PROJECT_TEXT_COLOR": "Text colour (Hex, hsla, rgb or name)",
"PROJECT_SETTINGS_SCOPES": {
"TITLE": "Scope:",
"DEFAULT": "Default",
Expand Down
1 change: 1 addition & 0 deletions nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"PROJECT_NAME": "Project Name",
"PROJECT_DIALOG_TITLE": "Project Name for {0}",
"PROJECT_BACKGROUND_COLOR": "Background color (hex, hsla, rgba or name)",
"PROJECT_TEXT_COLOR": "Text color (hex, hsla, rgba or name)",
"PROJECT_SETTINGS_SCOPES": {
"TITLE": "Scope:",
"DEFAULT": "Default",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Name-a-project",
"description": "Extension to enable personalized, per-project nicknames for projects.",
"homepage": "https://github.com/petetnt/brackets-name-a-project",
"version": "0.0.4",
"version": "0.0.3",
"author": "Pete Nykänen <[email protected]> (http://github.com/petetnt)",
"license": "MIT",
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion style/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
border: 4px solid transparent;
}

&-color-hint {
&-bgcolor-hint,
&-textcolor-hint {
margin-left: 10px;
height: 20px;
width: 20px;
Expand Down

0 comments on commit 7429ab2

Please sign in to comment.