1.2.9 • Published 3 months ago

cross-country v1.2.9

Weekly downloads
3
License
MIT
Repository
github
Last release
3 months ago

cross-country

an atomic react design system for personal metrics and creating courses

NPM JavaScript Style Guide

Core Tech

  • React (18.02), react-spring & react-hook-form
  • CSS modules & Tailwind CSS compatible
  • D3
  • Storybook 7
  • Typescript 5
  • Vite

Do you pour over your personal stats from Github, Strava or Spotify? Is your year always in review?! By experimenting with code, you can hone your developer skills while exploring subject matter that interests you.

storybook

Install

npm install cross-country

Use

import { Column, Row, Paragraph, Table, Chart } from "cross-country"

NextJS Support

For this third-party library to work within NextJS, you need to make one change when you consume cross-country to import it's single css bundle.

Edit the _app.js file to:

import "../styles/globals.css";
import "cross-country/dist/bundle.css";

function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}

export default MyApp;

Tailwind CSS Support

Each component provides a customClass propertity where you can supply your own tailwind css classes.

After upgrading to Vite, this library did not with NextJS due to the way it imports its CSS. I explored different approaches and landed on rollup-plugin-css-only which has minimal configuration.

Example Page

By wrapping html, each component is augmented for building accessible experiences across screens. A simple page may look like this:

<Wrapper>
  <Page>
    <Column>
      <Paragraph>
       Hello! I'm a developer with a mix of frontend and backend experience.
      </Paragraph>
      <Metrics keyValuePairs=[{label: "Frontend", value: 75, type: "percent"}, {label: "Backend", value: 25, type: "percent"}] />
    </Column>
  </Page>
  <Wallpaper />
</Wrapper>

Generating New Components

I've included a handy NodeJS util file under generate-component folder. Instead of copy pasting components to create a new component, you can instead run this command to generate all the files you need to plan & start building out a new component. To use it:

yarn new YourComponentName YourAtomicType

example

yarn new accordion molecules

This will generate the following files and your component name will also be captilized (ie import { Accordion } from "country-country"):

/src
  /YourComponentName
    /__stories__
      YourComponentName.stories.tsx
    /__tests__
      YourComponentName.test.tsx
    index.ts
    YourComponentName.tsx
    YourComponentName.types.ts
    YourComponentName.module.css
    index.d.ts
    typings.d.ts

When you ready, remember to expose the component in the index.ts file at the root.

SCSS to CSS modules

Originally, I started with SCSS Module but "downgraded" to CSS to upgrade Node from 12 to 18. I'm currently experimenting PostCSS variables and Tailwind, and have found that both are supported via the existing customClass prop.

n 14.20.1

Webpack 4 migration to 5

Storybook support for Webpack 5

Server Side Rendering

Part of my dogfooding process is to use my library on my own site, headwinds.

Initially, I ran into a build error where I had to account for every window and document ensuring that they are not referenced until the UI hits the client. After hunting through my webpack build file, I was ble to eliminate them all, and it now works 100% server side!

Unsplash Config

Before installing, create a cross-country-config-private.js file in your root directory by copying the cross-country-config.js and renaming it.

export const privateConfig = {
  UNSPLASH_API_KEY: 'YOUR-UNSPLASH-KEY',
};

Install

yarn add cross-country

or

npm install --save cross-country

While building, you can use Storybook

yarn storybook

When you are ready to publish, you can test the build by starting it

yarn start

Open your browser to http://localhost:6006/

Build the Static Site

After running npm run build-storybook, I had to make one change to the iframe.html file in the storybook-static folder.

The bundle.css isn't added so I had to add it manually.

  <link rel="stylesheet" href="./bundle.css" />

Publish to NPM

After you commit, make sure you have updated the version number before publishing usually npm version patch

npm login
your-username-not-your-email
your-password
now-your-email
npm publish

Since I had .npmrc setup in other projects, I had to one for this project using the default. At first, I thought I needed /headwinds and then /headwinds/cross-country but nope! Just use the default - see my .npmrc file.

Inspiration

Fullstack

TILE

MODELS & DATASETS

ALGORITHMS

Maps

Automation

Functional Programming

Graph

Learning Python

Data Visualization

Stats, NLP & Machine Learning

Gaming

Goal Setting

License

MIT © headwinds

1.2.8

3 months ago

1.2.9

3 months ago

1.2.7

4 months ago

1.2.6

4 months ago

1.2.5

4 months ago

1.2.4

4 months ago

1.2.3

4 months ago

1.2.1

4 months ago

1.2.0

5 months ago

1.1.80

10 months ago

1.1.85

9 months ago

1.1.84

9 months ago

1.1.82

9 months ago

1.1.79

1 year ago

1.1.78

1 year ago

1.1.77

1 year ago

1.1.76

1 year ago

1.1.75

1 year ago

1.1.70

1 year ago

1.1.74

1 year ago

1.1.73

1 year ago

1.1.72

1 year ago

1.1.71

1 year ago

1.1.63

1 year ago

1.1.62

1 year ago

1.1.61

1 year ago

1.1.67

1 year ago

1.1.66

1 year ago

1.1.65

1 year ago

1.1.64

1 year ago

1.1.69

1 year ago

1.1.68

1 year ago

1.1.49

1 year ago

1.1.48

1 year ago

1.1.47

1 year ago

1.1.46

1 year ago

1.1.52

1 year ago

1.1.51

1 year ago

1.1.50

1 year ago

1.1.56

1 year ago

1.1.54

1 year ago

1.1.53

1 year ago

1.1.58

1 year ago

1.1.57

1 year ago

1.1.60

1 year ago

1.1.45

2 years ago

1.1.39

3 years ago

1.1.41

3 years ago

1.1.40

3 years ago

1.1.43

3 years ago

1.1.42

3 years ago

1.1.30

3 years ago

1.1.34

3 years ago

1.1.32

3 years ago

1.1.31

3 years ago

1.1.35

3 years ago

1.1.27

3 years ago

1.1.26

3 years ago

1.1.25

3 years ago

1.1.24

3 years ago

1.1.21

3 years ago

1.1.20

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.12

3 years ago

1.1.10

3 years ago

1.1.9

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago