Sha256: 3d8cf935735fbc9f1a90f3a97d30c6cf09e7c3cb36dce616c67e7b4ea16dceae

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

import * as React from "react";
import Icon from "../application/icon.component";

interface VoteButtonProps {
  buttonClassName: string;
  iconName: string;
  text: string;
  votes: number;
  voteAction?: () => void;
  disabled?: boolean;
  selectedClass?: string;
  userLoggedIn: boolean;
}

const preventDefault = (event: any) => {
  event.preventDefault();
};

const VoteButton: React.SFC<VoteButtonProps> = ({
  buttonClassName,
  iconName,
  text,
  votes,
  voteAction,
  disabled,
  selectedClass,
  userLoggedIn
}) => (
  <button
    className={`${buttonClassName} ${selectedClass}`}
    onClick={userLoggedIn ? voteAction : preventDefault}
    disabled={disabled}
    title={text}
    data-open={userLoggedIn ? null : "loginModal"}
  >
    <span className="show-for-sr">{text}</span>
    <Icon name={iconName} iconExtraClassName="icon--small" />
    {` ${votes}`}
  </button>
);

VoteButton.defaultProps = {
  buttonClassName: "",
  iconName: "",
  votes: 0,
  selectedClass: "selected",
  disabled: false
};

export default VoteButton;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-comments-0.23.6 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.5 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.4 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.3 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.2 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.1 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.1.rc1 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.23.0 app/frontend/comments/vote_button.component.tsx
decidim-comments-0.22.0 app/frontend/comments/vote_button.component.tsx