Skip to content

Commit 0caeaca

Browse files
Merge pull request #11 from code4rena-dev/develop
Minor version - Bundling Changes
2 parents 7bd02b4 + aa9d2cf commit 0caeaca

File tree

9 files changed

+83
-14
lines changed

9 files changed

+83
-14
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
[![Jest](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml/badge.svg)](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml)
22

33
# Code4rena Components Library
4+
---
45

56
## Using Components in your project
67

8+
### 1. Installing the library
79
Start by installing the components library in your project:
810

911
```
1012
npm install @code4rena/components-library
1113
```
1214

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.
15+
### 2. Component Styling
16+
Next, to ensure that all the components have the appropriate styling, **import the library's styles** into your application. This can be done in one of two ways:
17+
18+
1. If you have a global CSS/SCSS file, you can import the custom styles using the CSS import rule into that global file.
19+
```
20+
@import "@code4rena/components-library/styles"
21+
```
22+
2. Another option is to import it in any layout/page/component which wraps your entire web application; in doing so, you make sure the styling bubbles down to all pages of the application using the library's components.
1423
```
15-
import "@code4rena/components-library/dist/style.css";
24+
import "@code4rena/components-library/styles";
1625
```
1726

27+
### 3. Importing Components
1828
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](https://components-library-wine.vercel.app)
1929

2030
```
@@ -23,6 +33,19 @@ import { Alert } from "@code4rena/components-library";
2333
<Alert {...args} />
2434
```
2535

36+
### 4. Typescript Support
37+
All components in this library have TypeScript support. Types for all complex component props are also named exports available through the `/types` subdirectory (see example below):
38+
```
39+
import { ButtonSize, ButtonType, ButtonVariant } from "@code4rena/componenets-library/types";
40+
41+
<Button
42+
label="Sample Button"
43+
type={ButtonType.BUTTON}
44+
variant={ButtonVariant.SECONDARY}
45+
size={ButtonSize.NARROW}
46+
/>
47+
```
48+
2649
## Run Storybook
2750
Storybook will run on [http://localhost:6006](http://localhost:6006)
2851

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
[![Jest](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml/badge.svg)](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml)
22

33
# Code4rena Components Library
4+
---
45

56
## Using Components in your project
67

8+
### 1. Installing the library
79
Start by installing the components library in your project:
810

911
```
1012
npm install @code4rena/components-library
1113
```
1214

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.
15+
### 2. Component Styling
16+
Next, to ensure that all the components have the appropriate styling, **import the library's styles** into your application. This can be done in one of two ways:
17+
18+
1. If you have a global CSS/SCSS file, you can import the custom styles using the CSS import rule into that global file.
19+
```
20+
@import "@code4rena/components-library/styles"
21+
```
22+
2. Another option is to import it in any layout/page/component which wraps your entire web application; in doing so, you make sure the styling bubbles down to all pages of the application using the library's components.
1423
```
15-
import "@code4rena/components-library/dist/style.css";
24+
import "@code4rena/components-library/styles";
1625
```
1726

27+
### 3. Importing Components
1828
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](https://components-library-wine.vercel.app)
1929

2030
```
2131
import { Alert } from "@code4rena/components-library";
2232
2333
<Alert {...args} />
2434
```
35+
36+
### 4. Typescript Support
37+
All components in this library have TypeScript support. Types for all complex component props are also named exports available through the `/types` subdirectory (see example below):
38+
```
39+
import { ButtonSize, ButtonType, ButtonVariant } from "@code4rena/componenets-library/types";
40+
41+
<Button
42+
label="Sample Button"
43+
type={ButtonType.BUTTON}
44+
variant={ButtonVariant.SECONDARY}
45+
size={ButtonSize.NARROW}
46+
/>
47+
```

package.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
{
22
"name": "@code4rena/components-library",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Code4rena's official components library ",
5-
"main": "dist/components-library.umd.js",
6-
"module": "dist/components-library.mjs",
7-
"types": "dist/index.d.ts",
5+
"types": "./dist/lib.d.ts",
6+
"exports": {
7+
".": "./dist/lib.mjs",
8+
"./types": "./dist/types.mjs",
9+
"./styles": "./dist/style.css"
10+
},
11+
"typesVersions": {
12+
"*": {
13+
"types": [
14+
"./dist/types.d.ts"
15+
]
16+
}
17+
},
818
"files": [
9-
"dist"
19+
"/dist"
1020
],
1121
"scripts": {
1222
"build": "vite build && tsc",
@@ -74,4 +84,4 @@
7484
"@babel/preset-react"
7585
]
7686
}
77-
}
87+
}

src/index.ts renamed to src/lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import "./styles/base/typography.scss";
22

3-
export * from "./lib";
3+
export * from "./lib/index";

src/lib/Card/Card.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
display: flex;
105105
flex-direction: column;
106106
margin: 0 $spacing__m;
107+
flex-grow: 1;
107108
order: 2;
108109
}
109110

src/lib/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export * from "./Alert/Alert.types";
2+
export * from "./Button/Button.types";
3+
export * from "./Card/Card.types";
4+
export * from "./ContestStatus/ContestStatus.types";
5+
export * from "./ContestTile/ContestTile.types";
6+
export * from "./Dropdown/Dropdown.types";
7+
export * from "./EyebrowBar/EyebrowBar.types";
8+
export * from "./Input/Input.types";
9+
export * from "./NavBar/NavBar.types";
10+
export * from "./Tag/Tag.types";

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./lib/types";

vite.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ export default defineConfig ({
66
build: {
77
// Tells Vite we're building library code as opposed to application code
88
lib: {
9-
entry: resolve(__dirname, "src/index.ts"),
9+
entry: {
10+
lib: resolve(__dirname, "src/lib.ts"),
11+
types: resolve(__dirname, "src/types.ts")
12+
},
1013
// Component library name
1114
name: "components-library",
1215
formats: ["es"],
13-
// Output file name
14-
filename: "index",
1516
},
1617
plugins: [dts({ rollupTypes: true })],
1718
rollupOptions: {

0 commit comments

Comments
 (0)