forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement color picking from predefined set for category badges + opt…
…ion to change foreground color
- Loading branch information
1 parent
a8c44d9
commit 8784c55
Showing
17 changed files
with
142 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/templates/excerpt/category.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/templates/search/category_result.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{{#with view.content}} | ||
<a href='{{unbound url}}'> | ||
<span class='badge-category' style="background-color: #{{unbound color}}">{{unbound title}}</span> | ||
<span class='badge-category' style="background-color: #{{unbound color}}; color: #{{unbound text_color}};">{{unbound title}}</span> | ||
</a> | ||
{{/with}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/assets/javascripts/discourse/views/modal/colors_view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
This view shows an array of buttons for selection of a color from a predefined set. | ||
@class ColorsView | ||
@extends Ember.ContainerView | ||
@namespace Discourse | ||
@module Discourse | ||
**/ | ||
Discourse.ColorsView = Ember.ContainerView.extend({ | ||
classNames: 'colors-container', | ||
|
||
init: function() { | ||
this._super(); | ||
return this.createButtons(); | ||
}, | ||
|
||
createButtons: function() { | ||
var colors = this.get('colors'); | ||
var _this = this; | ||
|
||
colors.each(function(color) { | ||
_this.addObject(Discourse.View.create({ | ||
tagName: 'button', | ||
attributeBindings: ['style'], | ||
classNames: ['colorpicker'], | ||
style: 'background-color: #' + color + ';', | ||
click: function() { | ||
_this.set("value", color); | ||
return false; | ||
} | ||
})); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// styles for the category badge color picker | ||
|
||
@import "foundation/variables"; | ||
@import "foundation/mixins"; | ||
|
||
.category-color-editor { | ||
input { | ||
width: 70px; | ||
} | ||
|
||
.color-title { | ||
display: inline-block; | ||
width: 130px; | ||
} | ||
|
||
.colors-container { | ||
display: inline-block; | ||
vertical-align: bottom; | ||
padding-bottom: 2px; | ||
padding-left: 15px; | ||
|
||
.colorpicker { | ||
border: 1px solid $darkish_gray; | ||
width: 15px; | ||
height: 15px; | ||
margin-right: 2px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20130314093434_add_foreground_color_to_categories.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddForegroundColorToCategories < ActiveRecord::Migration | ||
def change | ||
add_column :categories, :text_color, :string, limit: 6, null: false, default: 'FFFFFF' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters