UNPKG

codogo-react-widgets

Version:

Provides a unified way to access the styling of commonly used widgets across different apps

55 lines (46 loc) 1.66 kB
import _taggedTemplateLiteral from "babel-runtime/helpers/taggedTemplateLiteral"; var _templateObject = _taggedTemplateLiteral(["\n\tquery GetOrgForSidebar($id: ID!) {\n\t\tOrg(id: $id) {\n\t\t\tid\n\t\t\tname\n\t\t\timage\n\t\t}\n\t}\n"], ["\n\tquery GetOrgForSidebar($id: ID!) {\n\t\tOrg(id: $id) {\n\t\t\tid\n\t\t\tname\n\t\t\timage\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 getOrg = gql(_templateObject); var getLinkTo = function getLinkTo(props) { return "/app/" + R.pathOr("", ["getOrg", "Org", "id"], props); }; var getImageID = R.path(["getOrg", "Org", "image", "cloudinaryID"]); //------------------------------ export default R.compose(graphql(getOrg, { name: "getOrg", skip: function skip(ownProps) { return ownProps.placeholder || ownProps.addNew; }, options: function options(ownProps) { return { variables: { id: ownProps.id } }; } }), 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) }) ) ); });