0.0.114 • Published 23 days ago

@ndlib/component-library v0.0.114

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

Hesburgh Component Library

This is the repo for The Hesburgh Component Library, a set of React components that escapsulate the design patterns used by the Hesburgh Library IT department.

Using the library

Installation

To install the library in your project, run

yarn install @ndlib/component-library

Setup

UiProvider

In order for styles to be applied correctly, the UiProvider component must be included at the top of your project.

<UiProvider>
  <App>
</UiProvider>

For frameworks that split application code by pages, it is recommended to add this provider at the root level rather than at the page level. In Gatsby, this can be done using the wrapRootElement browser API.

exports.wrapRootElement = ({ element }) => {
  return (
    <UiProvider>
      {element}
    </UiProvider>
  )
}

Configuring Link

By default, the Link component in this library will use a native HTML <a> component in its implementation. This behavior can be overriden by setting the link.internalLink and/or link.externalLink property on the components prop of the UiProvider component. If a custom component is provided, the custom component will be rendered by when the component is used. It will receive the same props the receives, as well as an sx object with default link styles from the theme and any custom styles provided.

Note that the theme-ui jsx transform is needed in order to convert the sx prop into a stylesheet definition.

/** @jsxImportSource theme-ui */
import { Link } from 'gatsby'

const CustomInternalLink = ({ sx, ...rest}) => ()
  return <Link sx={sx} {...rest} />
)

const WrappedApp = () => {
  <UiProvider components={{
    link: {
      internalLink: CustomInternalLink
    }
  }}>
    <App />
  </UiProvider>
}

Running locally

Dependencies must be installed before storybook can be started. Dependencies can be installed with: yarn install.

To build and deploy your storybook locally for development, run yarn start

Deploying Storybook

Whenever a commit is added to the main branch, the contents of the /docs folder will be deployed to our Github pages site.

To build a new version of the storybook to be deployed, run yarn build-storybook. Our storybook build uses vite.

Running tests

Tests are run using vitest, a test-runner built for vite that is similar to jest. Test suite can be run with: yarn test

Linting

Changes should be linted before commits. Run our linter with yarn lint. Failed linting will block builds and deploys. Our lint process uses eslint and prettier. Running yarn lint:fix will fix any issues that can be automatically fixed.

Building for npm

The build process for the npm module for this library uses tsc. ESM exports are used to better support tree-shaking. When adding new code to this library, be careful to ensure than importing the module do not cause side-effects. In other words, don't execute any process or do any state management outside of exported properties or functions because this code might be removed by tree-shaker. See examples below:

Wrong

// This code may get removed by tree-shaker
setTimeout(() => {
  console.log('hello world')
})

Right

export const myFunction = () => {
  setTimeout(() => {
    console.log('hello world')
  })
}
0.0.114

23 days ago

0.0.113

23 days ago

0.0.112

29 days ago

0.0.111

1 month ago

0.0.110

1 month ago

0.0.109

1 month ago

0.0.108

1 month ago

0.0.106

2 months ago

0.0.105

2 months ago

0.0.104

2 months ago

0.0.103

2 months ago

0.0.102

2 months ago

0.0.101

2 months ago

0.0.100

2 months ago

0.0.99

2 months ago

0.0.98

2 months ago

0.0.97

3 months ago

0.0.96

3 months ago

0.0.95

3 months ago

0.0.94

3 months ago

0.0.93

3 months ago

0.0.92

4 months ago

0.0.90

4 months ago

0.0.91

4 months ago

0.0.89

4 months ago

0.0.87

4 months ago

0.0.88

4 months ago

0.0.86

4 months ago

0.0.85

5 months ago

0.0.84

5 months ago

0.0.83

5 months ago

0.0.79

5 months ago

0.0.7-9.1

5 months ago

0.0.7-9.2

5 months ago

0.0.73

5 months ago

0.0.74

5 months ago

0.0.77

5 months ago

0.0.78

5 months ago

0.0.72

5 months ago

0.0.71

5 months ago

0.0.70

5 months ago

0.0.40

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.0.43

8 months ago

0.0.44

8 months ago

0.0.45

8 months ago

0.0.46

7 months ago

0.0.47

7 months ago

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.0.30

9 months ago

0.0.31

8 months ago

0.0.32

8 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.0.26

9 months ago

0.0.27

9 months ago

0.0.28

9 months ago

0.0.29

9 months ago

0.0.62

6 months ago

0.0.63

6 months ago

0.0.20

9 months ago

0.0.65

6 months ago

0.0.21

9 months ago

0.0.66

6 months ago

0.0.22

9 months ago

0.0.67

6 months ago

0.0.23

9 months ago

0.0.68

5 months ago

0.0.24

9 months ago

0.0.69

5 months ago

0.0.25

9 months ago

0.0.60

6 months ago

0.0.61

6 months ago

0.0.15

10 months ago

0.0.17

9 months ago

0.0.18

9 months ago

0.0.19

9 months ago

0.0.52

7 months ago

0.0.53

7 months ago

0.0.54

7 months ago

0.0.55

6 months ago

0.0.56

6 months ago

0.0.58

6 months ago

0.0.14

10 months ago

0.0.50

7 months ago

0.0.48

7 months ago

0.0.10

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago