@healthcatalyst/react-cashmere
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

npm version Master Build Status Develop Build Status Commitizen friendly

Getting Started with React Cashmere

Install

First you will need an existing react app or create a new project using create react app.

npx create-react-app my-app

Install the peer dependencies (You will need React 17.x.x|18.x.x and Material UI 5.8.x)

npm install --save @mui/lab @mui/material

Now you can install React Cashmere and fonts

npm install --save @healthcatalyst/react-cashmere

# optional install fonts and icons sets
npm install --save sass font-awesome notosans-fontface @healthcatalyst/cashmere

Adding Fonts

Create a sass file to import the desired fonts. These fonts are optional if your app does not need them.

/* src/fonts.scss */
$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome";

$notosans-fontface-path: "~notosans-fontface/fonts";
@import "~notosans-fontface/scss/notosans-fontface-allweight";

$hc-icons-font-path: "~@healthcatalyst/cashmere/hcicons";
@import "~@healthcatalyst/cashmere/hcicons/hcicons";

ThemeProvider

Now you are ready to wrap your app with the ThemeProvider higher order component. The ThemeProvider will take care of all the cashmere styling and apply it so most Material UI child components are properly themed. There are also custom HC components such as Icon, Navbar, etc available.

/* src/index.js */
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { ThemeProvider, themes } from "@healthcatalyst/react-cashmere";
import "./fonts.scss"; /* optional scss fonts import */
const [lightTheme, darkTheme] = themes;

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <ThemeProvider theme={lightTheme}>
      <App />
    </ThemeProvider>
  </React.StrictMode>
);
/* src/App.js */
import React from "react";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";

import { Icon, Navbar } from "@healthcatalyst/react-cashmere";

const App = (props) => {
  return (
    <Box mt={"53px"} p={2}>
      <Navbar
        position="fixed"
        appIcon="My App"
        brandIcon={<Icon size="large" icon={"hci-catalyst-logo"} />}
        linkContent={[]}
        rightContent={<Box p={2}>Welcome, User!</Box>}
      />
      <Typography variant="h1" pb={2}>
        Hello Cashmere!
      </Typography>
      <Typography variant="subheading1">
        This app is using React, Material UI and themed with Cashmere.
      </Typography>
      <Typography variant="h2" pt={3}>
        Butons
      </Typography>
      <Button color="primary">Button</Button>
      &nbsp;
      <Button color="secondary">Button</Button>
      <Typography variant="h2" pt={3}>
        Icons
      </Typography>
      Font Awesome: <Icon size="large" icon={"fa-cog"} />
      <br />
      Health Catalyst Icons: <Icon size="large" icon={"hci-catalyst-logo"} />
      <br />
    </Box>
  );
};

export default App;

Library Development & Contributing

More information about contributing to the repo can be found here:

Readme

Keywords

none

Package Sidebar

Install

npm i @healthcatalyst/react-cashmere

Weekly Downloads

83

Version

1.0.2

License

none

Unpacked Size

2.6 MB

Total Files

14

Last publish

Collaborators

  • hcvsadmin
  • health-catalyst
  • corykon
  • afrueh
  • bthuganator
  • jacerm
  • isaaclyman
  • phess123
  • aknowles