Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

draft on how to show want/undo

goenninge780802e7fa5
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2af9bc52b..7e05d5fcf 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -17,7 +17,7 @@
"dist": true,
"coverage.txt": true,
"debug": true,
- "debug.test": true
+ "**/debug.test": true
},
"vsicons.presets.angular": true
}
\ No newline at end of file
diff --git a/public/components/SupportCounter.tsx b/public/components/SupportCounter.tsx
new file mode 100644
index 000000000..3b5f9d39f
--- /dev/null
+++ b/public/components/SupportCounter.tsx
@@ -0,0 +1,50 @@
+import * as React from "react";
+import { Idea } from "../models";
+
+interface SupportCounterProps {
+ idea: Idea;
+}
+
+interface SupportCounterState {
+ supported: boolean;
+}
+
+export class SupportCounter extends React.Component<SupportCounterProps, SupportCounterState> {
+ constructor(props: SupportCounterProps) {
+ super(props);
+ this.state = {
+ supported: props.idea.totalSupporters >= 1 && props.idea.totalSupporters <= 10,
+ };
+ }
+
+ public undoButton() {
+ return <div className="support-button ui mini violet animated button">
+ <div className="visible content"><i className="heart icon"></i></div>
+ <div className="hidden content">
+ Undo
+ </div>
+ </div>;
+ }
+
+ public supportButton() {
+ return <div className="support-button ui mini violet inverted animated button">
+ <div className="visible content">Want</div>
+ <div className="hidden content">
+ <i className="heart icon"></i>
+ </div>
+ </div>;
+ }
+
+ public render() {
+ const button = this.state.supported ? this.undoButton() : this.supportButton();
+
+ return <div className="ui small statistics">
+ <div className="statistic">
+ <div className="value">
+ { this.props.idea.totalSupporters }
+ </div>
+ { button }
+ </div>
+ </div>;
+ }
+}
diff --git a/public/components/idea_input.tsx b/public/components/idea_input.tsx
index cdac35f5d..a6692c16f 100644
--- a/public/components/idea_input.tsx
+++ b/public/components/idea_input.tsx
@@ -44,7 +44,7 @@ export class IdeaInput extends React.Component<{}, IdeaInputState> {
public render() {
const user = getCurrentUser();
- const buttonClasses = `ui positive button ${this.state.clicked && "loading disabled"}`;
+ const buttonClasses = `ui primary button ${this.state.clicked && "loading disabled"}`;
const details = user ?
<div>
<div className="field">
diff --git a/public/components/root.tsx b/public/components/root.tsx
index ce0ac00e5..dfc56342d 100644
--- a/public/components/root.tsx
+++ b/public/components/root.tsx
@@ -3,6 +3,7 @@ import * as React from "react";
import { Idea } from "../models";
import * as storage from "../storage";
import { Gravatar, MultiLineText } from "./common";
+import { SupportCounter } from "./SupportCounter";
import { Footer } from "./footer";
import { Header } from "./header";
@@ -14,19 +15,7 @@ export class Root extends React.Component<{}, {}> {
const ideasList = ideas.map((x) =>
<div className="item" key={x.id}>
- <div className="ui small statistics">
- <div className="statistic">
- <div className="value">
- { x.totalSupporters }
- </div>
- <div className="ui mini primary animated button">
- <div className="visible content">Want</div>
- <div className="hidden content">
- <i className="heart icon"></i>
- </div>
- </div>
- </div>
- </div>
+ <SupportCounter idea={x} />
<div className="content">
<a href={`/ideas/${x.number}`} className="header">
<i className="idea icon"></i> { x.totalSupporters } { x.title }
diff --git a/public/components/show_idea_root.tsx b/public/components/show_idea_root.tsx
index fd2d6075f..f70cd573a 100644
--- a/public/components/show_idea_root.tsx
+++ b/public/components/show_idea_root.tsx
@@ -6,6 +6,7 @@ import { Comment, Idea } from "../models";
import { CommentInput } from "./comment_input";
import { Gravatar, MultiLineText } from "./common";
import { SocialSignInButton } from "./social_signin_button";
+import { SupportCounter } from "./SupportCounter";
import { Footer } from "./footer";
import { Header } from "./header";
@@ -40,19 +41,7 @@ export class ShowIdeaRoot extends React.Component<{}, {}> {
<div className="ui items unstackable">
<div className="item">
- <div className="ui small statistics">
- <div className="statistic">
- <div className="value">
- { idea.totalSupporters }
- </div>
- <div className="ui mini primary animated button">
- <div className="visible content">Want</div>
- <div className="hidden content">
- <i className="heart icon"></i>
- </div>
- </div>
- </div>
- </div>
+ <SupportCounter idea={idea} />
<div className="idea-header">
<h1 className="ui header">{ idea.title }</h1>
diff --git a/public/css/main.css b/public/css/main.css
index d8733126f..605599e21 100644
--- a/public/css/main.css
+++ b/public/css/main.css
@@ -20,4 +20,12 @@
.idea-header {
margin-left: 20px;
+}
+
+.support-button {
+ width: 60px;
+}
+
+.support-button i.icon {
+ margin: 0px;
}
\ No newline at end of file