codogo-react-widgets
Version:
Provides a unified way to access the styling of commonly used widgets across different apps
48 lines (39 loc) • 1.63 kB
JavaScript
import _taggedTemplateLiteral from "babel-runtime/helpers/taggedTemplateLiteral";
var _templateObject = _taggedTemplateLiteral(["\n\tquery getUserForSidebar {\n\t\tuser {\n\t\t\tid\n\t\t\tusername\n\t\t\timage\n\t\t\tpersonal {\n\t\t\t\tid\n\t\t\t}\n\t\t}\n\t}\n"], ["\n\tquery getUserForSidebar {\n\t\tuser {\n\t\t\tid\n\t\t\tusername\n\t\t\timage\n\t\t\tpersonal {\n\t\t\t\tid\n\t\t\t}\n\t\t}\n\t}\n"]);
import React from "react";
import * as R from "ramda";
import { Link } from "react-router-dom";
import { withTheme } from "styled-components";
import gql from "graphql-tag";
import { graphql } from "react-apollo";
import CloudinaryImage from "../../cloudinaryImage";
import { SideBarButtonImage } from "../styles";
//------------------------------
var getUser = gql(_templateObject);
var getLinkTo = function getLinkTo(props) {
return "/app/" + R.pathOr("", ["getUser", "user", "personal", "id"], props);
};
var getImageID = R.path(["getUser", "user", "image", "cloudinaryID"]);
//------------------------------
export default R.compose(graphql(getUser, {
name: "getUser",
skip: function skip(ownProps) {
return ownProps.placeholder || ownProps.addNew;
}
}), withTheme)(function (props) {
return React.createElement(
Link,
{ to: getLinkTo(props) },
React.createElement(
SideBarButtonImage,
{ active: props.active },
React.createElement(CloudinaryImage, {
isButton: true,
height: props.theme.sizes.sidebarButtonSize,
width: props.theme.sizes.sidebarButtonSize,
transformation: CloudinaryImage.commonTransforms.smartSquare,
cloudinaryID: getImageID(props)
})
)
);
});