mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:57:25 +08:00
UX: Remove button styles on polls.
This commit is contained in:
@ -1,15 +1,19 @@
|
|||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||||
|
|
||||||
export default Em.Component.extend({
|
export default Em.Component.extend({
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
attributeBindings: ["data-poll-option-id", "data-poll-selected"],
|
attributeBindings: ["data-poll-option-id"],
|
||||||
|
|
||||||
"data-poll-option-id": Em.computed.alias("option.id"),
|
"data-poll-option-id": Em.computed.alias("option.id"),
|
||||||
|
|
||||||
"data-poll-selected": function() {
|
@computed("option.selected", "isMultiple")
|
||||||
return this.get("option.selected") ? "selected" : false;
|
optionIcon(selected, isMultiple) {
|
||||||
}.property("option.selected"),
|
if (isMultiple) {
|
||||||
|
return iconHTML(selected ? 'check-square-o' : 'square-o');
|
||||||
render(buffer) {
|
} else {
|
||||||
buffer.push(this.get("option.html"));
|
return iconHTML(selected ? 'dot-circle-o' : 'circle-o');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
click(e) {
|
click(e) {
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
{{{optionIcon}}}
|
||||||
|
{{option.html}}
|
@ -9,7 +9,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<ul>
|
<ul>
|
||||||
{{#each poll.options as |option|}}
|
{{#each poll.options as |option|}}
|
||||||
{{poll-option option=option toggle="toggleOption"}}
|
{{poll-option option=option toggle="toggleOption" isMultiple=isMultiple}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -28,24 +28,7 @@ div.poll {
|
|||||||
|
|
||||||
li[data-poll-option-id] {
|
li[data-poll-option-id] {
|
||||||
color: $option-foreground;
|
color: $option-foreground;
|
||||||
background: $option-background;
|
|
||||||
box-shadow: inset 0 -6px rgba(0,0,0,.25), inset 0 0 0 100px rgba(0,0,0,0);
|
|
||||||
padding: .5em .7em .7em .5em;
|
padding: .5em .7em .7em .5em;
|
||||||
border-radius: 4px;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: inset 0 -6px rgba(0,0,0,.35), inset 0 0 0 100px rgba(0,0,0,.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
-webkit-transform: translate(0,2px);
|
|
||||||
transform: translate(0,2px);
|
|
||||||
box-shadow: inset 0 -4px rgba(0,0,0,.35), inset 0 0 0 100px rgba(0,0,0,.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-poll-selected="selected"] {
|
|
||||||
background: $option-background-selected !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
@ -136,8 +119,7 @@ div.poll {
|
|||||||
|
|
||||||
li[data-poll-option-id] {
|
li[data-poll-option-id] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-align: center;
|
width: 45px;
|
||||||
width: 25px;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
import componentTest from 'helpers/component-test';
|
||||||
|
moduleForComponent('poll-option', { integration: true });
|
||||||
|
|
||||||
|
componentTest('test poll option', {
|
||||||
|
template: '{{poll-option option=option isMultiple=isMultiple}}',
|
||||||
|
|
||||||
|
setup(store) {
|
||||||
|
this.set('option', Em.Object.create({ id: 1, selected: false }));
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.ok(this.$('li .fa-circle-o:eq(0)').length === 1);
|
||||||
|
|
||||||
|
this.set('option.selected', true);
|
||||||
|
|
||||||
|
assert.ok(this.$('li .fa-dot-circle-o:eq(0)').length === 1);
|
||||||
|
|
||||||
|
this.set('isMultiple', true);
|
||||||
|
|
||||||
|
assert.ok(this.$('li .fa-check-square-o:eq(0)').length === 1);
|
||||||
|
|
||||||
|
this.set('option.selected', false);
|
||||||
|
|
||||||
|
assert.ok(this.$('li .fa-square-o:eq(0)').length === 1);
|
||||||
|
}
|
||||||
|
});
|
Reference in New Issue
Block a user