npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@apollo/chakra-helpers

v2.1.0

Published

Helps configure a Chakra UI theme for use with Apollo projects

Downloads

212

Readme

Apollo Chakra UI helpers

This package contains Chakra UI theme options that are shared between DX properties. This makes it easy to set up a theme with consistent color palettes, fonts, and component styles.

Installation

This package has peer dependencies on @apollo/space-kit and @chakra-ui/react. Make sure those packages are already installed in your project, and then install this package.

yarn add @apollo/chakra-helpers

Usage

The easiest way to set up Chakra UI in a Gatsby website is by using the @chakra-ui/gatsby-plugin package.

// gatsby-config.js
module.exports = {
  plugins: ["@chakra-ui/gatsby-plugin"],
};

Next, use Gatsby component shadowing to shadow the default theme.js file in the plugin. Use the extendTheme function to override default Chakra theme values and export your new theme.

// src/@chakra-ui/gatsby-plugin/theme.js
import { fonts, components } from "@apollo/chakra-helpers";
import { extendTheme } from "@chakra-ui/react";

const theme = extendTheme({
  fonts,
  components,
});

export default theme;

Color palettes

This package also provides two functions for creating Chakra UI color palettes from Space Kit ones.

Space Kit's color palettes use names ranging from lightest to darkest and contain five colors for monochrome palettes and seven colors for all other colors. Chakra UI, on the other hand, features palettes with 10 numerical variants ranging from 50 to 900.

To account for these differences, we need to mix Space Kit colors to fill in the gaps between different numerical keys in their corresponding Chakra palettes.

import { colors } from "@apollo/space-kit/colors";
import { createGrayPalette, createColorPalette } from "@apollo/chakra-helpers";

const { silver, grey, midnight, indigo } = colors;

const theme = extendTheme({
  colors: {
    gray: createGrayPalette(silver, grey, midnight),
    indigo: createColorPalette(indigo),
  },
});

Footer configuration

This package exports an object that helps configure footers on all Apollo properties. Each category contains a title field and an array of link objects with their own titles and URLs.

// Footer.js
import {footerConfig} from '@apollo/chakra-helpers';

export default function Footer() {
  return (
    <nav>
      {footerConfig.map(({links, title}, index) => (
        <ul key={index}>
          {links.map((link, index) => (
            <li key={index}>
              <a href={link.href}>{link.text}</a>
            </li>
          )}
        </ul>
      )}
    </nav>
  )
}

This package also exports the individual parts that make up the default footerConfig. These can be composed together to create your own custom footers.

import {
  communityCategory,
  companyCategory,
  helpCategory,
  productCategory,
  whyApolloCategory,
} from "@apollo/chakra-helpers/lib/footer";

const customFooterConfig = [communityCategory, helpCategory, whyApolloCategory];

For your convenince, there are also exported Category and Link interfaces for type safety and intellisense in TypeScript projects.

import { Category, Link } from "@apollo/chakra-helpers/lib/footer";

const customLink: Link = {
  title: "A Custom Link",
  href: "https://www.acustomlink.com",
};

const customCategory: Category = {
  title: "My Custom Category",
  links: [customLink],
};

EmbeddableExplorer

You can embed Apollo Studio Explorer in your Chakra sites using this component. It respects the selected color mode in your app.

import { EmbeddableExplorer } from "@apollo/chakra-helpers";

<EmbeddableExplorer />;

The component can be configured using the following props. No props are required to use this component, and it default to serving up the Apollo fullstack demo API with an example query.

| Name | Type | Description | Default value | | ----------- | ------ | ------------------------------------------------------------------------------------- | --------------------------------------------------- | | graphRef | string | The graph ref for the public variant you want to use the embedded Explorer with | Apollo-Fullstack-Demo-o3tsz8@current | | endpointUrl | string | The endpoint URL of the public variant you want to use the embedded Explorer with | https://apollo-fullstack-tutorial.herokuapp.com/ | | document | string | A URI-encoded operation to populate in the Explorer's editor on load. | See the source code |

Publishing changes

We use Changesets to automate the publishing of new versions of this package to the NPM registry.

To publish a new version, first add a changeset to your PR using npx changeset add. Follow the prompts in your terminal to select the version bump for this release, and add a message describing what is being changed.

After this PR gets merged to main, a new PR will be opened automatically that increments the package version. When this PR is merged, a GitHub action will be run that publishes the package to NPM.

Working on Chakra Helpers & the Docs at the same time

  1. Run npm workspace @apollo/chakra-helpers start
  2. Run npm run start:local in another terminal

Now your local docs will use your local chakra changes