Skip to content

Commit e17239e

Browse files
Merge pull request #5 from code4rena-dev/develop
Preparing library for npm
2 parents a9fb577 + c03d1b6 commit e17239e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6348
-2917
lines changed

._.DS_Store

-4 KB
Binary file not shown.

.babelrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/release-package.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
name: NPM Package Release
3+
on:
4+
release:
5+
types: [created]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: "18"
14+
- run: npm ci
15+
- run: npm test
16+
publish-pkg:
17+
needs: build
18+
runs-on: ubuntu-latest
19+
permissions:
20+
packages: write
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-node@v3
25+
with:
26+
node-version: "18"
27+
registry-url: https://npm.pkg.github.com/
28+
- run: npm ci
29+
- run: npm run build
30+
- run: npm publish --access public

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
dist
22
node_modules
3+
*DS_Store
34

45
# Jest test results directory
56
coverage
67
# Storybook build directory
78
storybook-static
89
# Prefer npm to yarn
910
yarn.lock
10-
yarn-error.log
11+
yarn-error.log

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
src
2+
.babelrc.json
3+
.gitignore
4+
vercel.jsontsconfig.json
5+
jest.config.ts
6+
.storybook
7+
.github
8+
*DS_Store

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@code4rena:registry=https://npm.pkg.github.com

.storybook/manager-header.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="shortcut icon" href="/favicon.ico">
2+
<link rel="icon" type="image/png" href="/logos/apple-touch-icon.png" sizes="192x192">

.storybook/preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import type { Preview } from "@storybook/react";
3-
import "../src/styles/_global.scss";
3+
import "../src/styles/base/typography.scss";
44

55
const wrapperStyle = {
66
display: "flex",

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
# Code4rena Components Library
44

5+
## Using Components in your project
6+
7+
Start by installing the components library in your project:
8+
9+
```
10+
npm install @code4rena/components-library
11+
```
12+
13+
Next, to ensure that all the components have the appropriate styling, import the library's css file in your application's wrapping Layout or in any page/component wrapping your application where you would normally import global styling.
14+
```
15+
import "@code4rena/components-library/dist/style.css";
16+
```
17+
18+
All the components in this package can be accessed through named imports. For a full list of available components, take a look at our [Storybook](components-library-wine.vercel.app)
19+
20+
```
21+
import { Alert } from "@code4rena/components-library";
22+
23+
<Alert {...args} />
24+
```
25+
526
## Run Storybook
627
Storybook will run on [http://localhost:6006](http://localhost:6006)
728

@@ -21,5 +42,12 @@ For testing, we are using [Jest](https://jestjs.io/docs/getting-started) and [Re
2142

2243
To maintain the standards, test files should be named `componentName.test.tsx` and be placed inside the component folder for which the test relates to.
2344

24-
2545
## Publishing to NPM
46+
47+
A GitHub Action has been developed to help automate package releases. All that you will need to do is:
48+
49+
1. Make sure to increase the `version` field in the **package.json**
50+
2. On the GitHub repo's home page, navigate to the righthand side and click on **Create a new release**
51+
3. Give the release a `title` and `description` outlining the changes made in the release
52+
4. Choose/Create a **tag** corresponding to the new version that was added in the package.json in **step 1**
53+
5. Once the details are filled out, submit the release. You will get taken to a confirmation page. This process will automatically trigger the GitHub action that will publish the package to npm.

globals.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.svg" {
2+
const content: string;
3+
export default content;
4+
}

0 commit comments

Comments
 (0)