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

@heroku/react-hk-components

v2.12.0

Published

React components for Heroku

Downloads

433

Maintainers

brittany.jonesbrittany.jonesviniljainviniljainjoshwlewis-sfdcjoshwlewis-sfdcmarcusblankenshipmarcusblankenshipmengxiao.zhaomengxiao.zhaodlira-sfdlira-sfjulianduque-sfdcjulianduque-sfdcnilamuthunilamuthusmrutisamantasmrutisamantajdowningjdowningdpark.herokudpark.herokunnaidu9nnaidu9cgfuhcgfuhyann_ckyann_ckjeffrey.estradajeffrey.estradacwallsfcwallsfaklimaiteaklimaiterishabh.wasonrishabh.wasondzuelke-sfdcdzuelke-sfdcdgallegossfdcdgallegossfdcsmukusmukukmichalskiskmichalskiscory.steelecory.steeleykatzykatzkerry-bennettkerry-bennettangelayoungangelayoungdreichenbergdreichenbergmble-sfdc-2mble-sfdc-2taylor.jonestaylor.jonessfjonnpmsfjonnpmsimonebonettisfitasimonebonettisfitakamakshinagarkamakshinagarafraidknotafraidknotvish_herokuvish_herokusarahoh2468sarahoh2468sghaffarsghaffardkabanov1dkabanov1sbosio_sfsbosio_sfangelcampbellangelcampbell7ftz7ftzsfalansfalanhillzbot2000hillzbot2000kdreyerorenkdreyerorenrcrossrcrosslsorstokkelsorstokkesudarshanhiraysudarshanhirayalex_herokualex_herokurajashri-gurusamyrajashri-gurusamymandeepsfmandeepsfmingzhi-liu1258mingzhi-liu1258beanieboibeanieboidougmcinnes-sfdcdougmcinnes-sfdcbeckychenbeckychendasofieidasofieixx-sfdc-npmxx-sfdc-npmkpremkumarkpremkumarstessema-sfcstessema-sfcchap-herokuchap-herokudhammer25dhammer25ndavidson-sfndavidson-sfumarsfdcumarsfdccdwort-sfdccdwort-sfdcapoorvasrivapoorvasrivmichellejhlimmichellejhlimjhili!16jhili!16apadalaapadalacmcclung-npm-salesforce.comcmcclung-npm-salesforce.comrstiltonsfrstiltonsftlowrimoretlowrimorerchandarchandaabhinavkoulabhinavkouldaniel.brightdaniel.brightjonnymacjonnymacjustinwilaby-sfjustinwilaby-sfcv88cv88aaronromeosfdcaaronromeosfdctenharmsel_sftenharmsel_sfekozilforceekozilforcecoreypurcell_salesforcecoreypurcell_salesforcejmonrealjmonrealsconklinsconklinsuppadasuppadagnettergnettertkoh-sfdctkoh-sfdcjasoncummings-herokujasoncummings-herokudiana.doherty.sfdcdiana.doherty.sfdcjoeybrown90sfjoeybrown90sfrsoerensenrsoerensenademusoyoademusoyolsangalang2023lsangalang2023ccaseyccaseyryanbrainardryanbrainardmarcelsfdcmarcelsfdcnrisaronrisarochetankd10chetankd10kscareykscareybemory-herokubemory-herokurevativelagadarevativelagadabrock-salesforcebrock-salesforcebencdentonbencdentonrafaydinrafaydindhagberg-sfdhagberg-sfelzoonaelzoonacmarcojoscmarcojosadirasanamadirasanamkbaird-sfkbaird-sfbhawnaherokubhawnaherokujondaniel-sfdcjondaniel-sfdcgkomminenigkomminenip.shreyap.shreyasai_harshitha_neelasai_harshitha_neelaktsforcektsforcehkiihkiiheroku-front-endheroku-front-endvammundravammundrathe7okathe7okavlazukavlazukagrismar17grismar17lucaszhoulucaszhoumarsmarsnlanattanlanattapranamsharmapranamsharmanrenkenrenkerichatiwaririchatiwaripsalimpsalimwchrisjohnsonwchrisjohnsonagatpareekagatpareekswapnilghoseswapnilghosemgates-salesforcemgates-salesforceryoneyamaryoneyamasripad.kulkarnisripad.kulkarnianujpandey001anujpandey001dboston528dboston528adirksmeieradirksmeierchristopher.josechristopher.josecbaxtersfcbaxtersfmttrmttrtetsuya_tetsuya_daebumleedaebumleemsaminenimsaminenisrishtigautamsrishtigautampbommapbommalalitreddylalitreddyzli-sfzli-sfsbaner18sbaner18joanneyeungjoanneyeungpaguilarpaguilarbleongbleongmontes_herokumontes_herokupfuentepfuentesaikrishna0202saikrishna0202jwadsworthsfjwadsworthsfjheikesjheikesmimenmimendaigo-herokudaigo-herokujmccartiejmccartiejordaneekeyjordaneekeylmckenzielmckenziev.anandv.anandarajaarajasarassassinsarassassinreidmixreidmixmbuschherokumbuschherokuk.plentyk.plentyeblackeblacksheax0rsheax0rk80bowmank80bowmanrdagg-herordagg-herogrundy.ggrundy.grobinson.mrobinson.mtcareysmith-sfdctcareysmith-sfdcptemporiniptemporinipaulaprado18paulaprado18harish.457harish.457jsullivandigsjsullivandigsntonollierntonollierelearyelearysalesforce-releasessalesforce-releases

Keywords

Readme

React HK Components

Reusable React components. A sister library of ember-hk-components.

Assumptions

Usage of these components assumes you are using the Purple3 CSS framework and Malibu.

Usage

Installation

yarn add @heroku/react-hk-components

If you want to use HKFlagIcon, you will need to tell Webpack to copy the flag images into a directory that is served up by your app:

  // somewhere in your webpack config...
  plugins: [
    new CopyWebpackPlugin([
      {
        from: 'node_modules/@heroku/react-hk-components/dist/flags',
        to: 'flags', // this is relative to your the outputPath you configured in webpack
      }
    ]),
  ],

<HKFlagIcon> defaults to loading the flag images from /static/dist/flags, but if you have a different base path to the flag images, you'll need to pass it as a prop like <HKFlagIcon basePath='/foo/bar/flags' region='europe' />.

Components

See react-hk-components.herokuapp.com for a complete list of components that are available.

HKModal

The HKModal component displays modal dialogs of two kinds: normal, which appear in the middle of the browser viewport, and flyout, which slides in from the right. It takes the following props:

  • isFlyout: boolean?. Defaults to false.
  • show: boolean. Set it to true in order to trigger display of the modal, or false to trigger hiding.
  • type: string?. Set to destructive if you want the title of the modal to be rendered in red.
  • onDismiss: (value?: string) => any. A handler that is invoked with the close value when the modal is dismissed. Closing the modal by clicking outside the modal or by clicking on the X at the top-right of the modal will result in the handler being invoked with a value of cancel.
  • header: JSX element. What is rendered in the header of the modal.
  • buttons: IButtonDefinition[]?: an optional array of button definitions. These will be rendered left-to-right as buttons in the footer of the modal.

The contents of the modal are the children passed in the body of the react element, e.g. <HKModal> stuff to render in body of modal </HKModal>

Buttons are defined as follows:

  • text: string. The text on the button
  • type: Button.Type. Primary, secondary, danger, etc.
  • disabled: boolean. Set to true if you want the button disabled.
  • value: string. The value associated with the button. This is what will be remitted to the onDismiss handler when the user closes the modal by clicking on this button.

So here's a working example:

public class MyModalWrapper extends React.Component {
  handleDismiss = (value?: string): any => {
    switch(value) {
      case 'ok':
        // handle the OK case
        break
      case cancel:
      default:
        // handle the cancel case, which is also the default
    }
  }
  public render() {
    return (<HKModal
      isFlyout={false}
      show={true}
      onDismiss={this.handleDismiss}
      header={<div>My Modal</div>}
      buttons={[
        {text: 'cancel', value: 'cancel', type: 'tertiary'},
        {text: 'OK', value: 'ok', type: 'primary'},
      ]}
    >
      <div>Look at my shiny modal content!</div>
      <p>Such shiny. Much wow.</p>
    </HKModal>)    
  }
}


HKDropdown

The HKDropdown component consists of a HKButton that toggles the display of it's dropdown contents. It takes the following props:

  • align: Align?. Aligns dropdown menu anchoring left or right side of dropdown button. Options are left or right. Defaults to left.
  • className: string?. Styling for the dropdown button.
  • closeOnClick: boolean?. Specifies whether the dropdown menu should toggle to close after clicking inside the dropdown menu. Defaults to true
  • contentClassName: string?. Styling for the dropdown menu.
  • disabled: boolean?: disables the button from toggling the dropdown menu. Defaults to false
  • name: string?: name of the dropdown, used for testing for data-testid. Defaults to hkdropdown.
  • title: string?: The title of the dropdown button.

The contents of the dropdown menu are the children passed in the body of the react element, e.g. <HKDropdown> stuff to render inside dropdown menu </HKDropdown>

Best practices for content in dropdown menu:

  • Each dropdown menu item should have the class hk-dropdown-item
  • Thematic breaks between elements (i.e. separators) should be used with <li className='hk-dropdown-divider' />
  • Dangerous menu items should have the class hk-dropdown-item--danger

Refer to the stories for examples.

Development

Installation

  • git clone https://github.com/heroku/react-hk-components
  • cd react-hk-components
  • yarn

Running

Local Usage in Another Application

The demo app is useful for developing this addon, but it can often be helpful to consume your version of this addon in another application either to more easily develop your changes or to validate that your changes work as you expect. You can use your local version of react-hk-components in another application that consumes it via yarn's link command.

# in your react-hk-components directory
$ yarn link

# in your consuming app directory
$ yarn link @heroku/react-hk-components

# You will need to re-run yarn in your consuming app directory and restart your app
$ yarn

You can check the success of linking in your consuming app ls -l node_modules/@heroku/react-hk-components which should return a symlink to your development copy of rhkc

Now, when you make changes in your copy of react-hk-components those changes will be reflected in the consuming application.

Caveats when linking - you will need to rebuild each time you want to see changes in your consuming app directory. yarn build

To simplify, you can install watch or a similar tool and run watch 'yarn run build' src in react-hk-components. This will rebuild the bundled version that your consuming app directory pulls in whenever you make changes in rhkc.

Remember to unlink rhkc once finished.

Demo app

This repo can be deployed to Heroku as a demo app using Storybook.

heroku create
# ensure that heroku installs the dev dependency storybook
heroku config:set NPM_CONFIG_PRODUCTION=false
git push heroku master

Releasing

Setup (one time)

  1. Install np globally using npm: npm install -g np

Release

  1. rm -rf node_modules
  2. yarn
  3. yarn test. No errors? Lovely, proceed.
  4. When you're ready to publish, np.