Create FavoriteStar component
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 23 Jul 2018 20:16:44 +0000 (22:16 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 23 Jul 2018 20:16:44 +0000 (22:16 +0200)
Feature #13784

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/views-components/favorite-star/favorite-star.tsx [new file with mode: 0644]

diff --git a/src/views-components/favorite-star/favorite-star.tsx b/src/views-components/favorite-star/favorite-star.tsx
new file mode 100644 (file)
index 0000000..f896e30
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { FavoriteIcon } from "../../components/icon/icon";
+import { connect } from "react-redux";
+import { RootState } from "../../store/store";
+import { withStyles, StyleRulesCallback, WithStyles } from "@material-ui/core";
+
+type CssRules = "icon";
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+    icon: {
+        fontSize: "inherit"
+    }
+});
+
+const mapStateToProps = (state: RootState, props: { resourceUuid: string; className?: string; }) => ({
+    ...props,
+    visible: state.favorites[props.resourceUuid],
+});
+
+export const FavoriteStar = connect(mapStateToProps)(
+    withStyles(styles)((props: { visible: boolean; className?: string; } & WithStyles<CssRules>) =>
+        props.visible ? <FavoriteIcon className={props.className || props.classes.icon} /> : null
+    ));
\ No newline at end of file