1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { FavoriteIcon } from "~/components/icon/icon";
7 import { connect } from "react-redux";
8 import { RootState } from "~/store/store";
9 import { withStyles, StyleRulesCallback, WithStyles } from "@material-ui/core";
11 type CssRules = "icon";
13 const styles: StyleRulesCallback<CssRules> = theme => ({
19 const mapStateToProps = (state: RootState, props: { resourceUuid: string; className?: string; }) => ({
21 visible: state.favorites[props.resourceUuid],
24 export const FavoriteStar = connect(mapStateToProps)(
25 withStyles(styles)((props: { visible: boolean; className?: string; } & WithStyles<CssRules>) =>
26 props.visible ? <FavoriteIcon className={props.className || props.classes.icon} /> : null