Skip to content

Commit 84089ad

Browse files
authored
fix: empty npm package, update readme, types error, build scripts
2 parents 536b318 + 676d0f3 commit 84089ad

File tree

6 files changed

+71
-42
lines changed

6 files changed

+71
-42
lines changed

.github/workflows/npm_publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
registry-url: 'https://registry.npmjs.org/'
3232
- run: npm install
3333
- run: npm test
34+
- run: npm run build
3435
- run: npm publish
3536
env:
3637
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

README.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,90 @@
11
# React Proportion Slider
22

3-
> **Note:** This package is currently in beta
3+
> **Note:** This package is currently in beta.
44
55
A React component that allows users to adjust the proportion of two elements using a slider.
66

77
## Installation
88

9-
(Not yet published to npm)
10-
119
```bash
1210
npm install react-proportion-slider
1311
```
1412

13+
```bash
14+
yarn add react-proportion-slider
15+
```
16+
1517
## Usage
1618

1719
```tsx
18-
import React from "react";
19-
import { ProportionSlider } from "react-proportion-slider";
20-
2120
function App() {
2221
const [proportions, setProportions] = React.useState<[number, number]>([
2322
50, 50,
2423
]);
2524
return (
26-
<div
27-
style={{
28-
height: "100%",
29-
flex: 1,
30-
padding: "20px 200px",
31-
display: "flex",
32-
flexDirection: "column",
33-
justifyContent: "center",
34-
}}
35-
>
25+
<div>
3626
<ProportionSlider
3727
value={proportions}
28+
width={500}
3829
proportions={[
3930
{
40-
name: "Skill",
31+
label: "Skill",
4132
backgroundColor: "#31332E",
4233
},
4334
{
44-
name: "3.7 Sonnet",
35+
label: "3.7 Sonnet",
4536
backgroundColor: "#5f625C",
4637
},
4738
]}
4839
onChange={(change) => {
4940
setProportions(change);
5041
}}
51-
sliderOptions={{
42+
knobOptions={{
5243
width: 5,
5344
gap: 5,
5445
backgroundColor: "#EC1308",
5546
}}
56-
options={{
57-
height: 50,
58-
displayValueType: "percentage",
59-
}}
47+
height={50}
6048
/>
6149
</div>
6250
);
6351
}
6452
```
6553

54+
## Props
55+
56+
| Prop Name | Type | Required | Description |
57+
| ----------- | ------------------------------------ | -------- | --------------------------------------------------- |
58+
| value | [number, number] | Yes | Current values of the two proportions [left, right] |
59+
| proportions | [ProportionDetail, ProportionDetail] | Yes | Details for the two proportions [left, right] |
60+
| onChange | (values: [number, number]) => void | No | Callback when values change |
61+
| knobOptions | SliderKnobOptions | No | Appearance of the slider knob |
62+
| height | number | No | Height of the slider in pixels |
63+
| width | number | No | Width of the slider in pixels |
64+
| disabled | boolean | No | Whether the slider is disabled |
65+
| className | string | No | Custom class name for the slider container |
66+
| style | React.CSSProperties | No | Custom styles for the slider container |
67+
| ariaLabel | string | No | Accessibility label for the slider |
68+
69+
### ProportionDetail
70+
71+
| Property | Type | Required | Description |
72+
| --------------- | ------ | -------- | ----------------------------------------------- |
73+
| label | string | Yes | Custom label to display |
74+
| backgroundColor | string | No | Color of the proportion segment |
75+
| data | any | No | Optional data to associate with this proportion |
76+
| ariaLabel | string | No | Accessibility label for this proportion |
77+
78+
### SliderKnobOptions
79+
80+
| Property | Type | Required | Description |
81+
| --------------- | ------------------- | -------- | ------------------------------------ |
82+
| width | number | No | Width of the slider knob in pixels |
83+
| gap | number | No | Gap around the slider knob in pixels |
84+
| backgroundColor | string | No | Color of the slider knob |
85+
| className | string | No | Custom class name for the knob |
86+
| style | React.CSSProperties | No | Custom styles for the knob |
87+
6688
## Future Features
6789

6890
1. Make it possible to adjust the proportion of more than two elements

package-lock.json

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-proportion-slider",
33
"private": false,
4-
"version": "0.9.3",
4+
"version": "0.9.4",
55
"type": "module",
66
"files": [
77
"dist"
@@ -11,9 +11,9 @@
1111
"types": "./dist/index.d.ts",
1212
"exports": {
1313
".": {
14+
"types": "./dist/index.d.ts",
1415
"import": "./dist/react-proportion-slider.es.js",
15-
"require": "./dist/react-proportion-slider.umd.js",
16-
"types": "./dist/index.d.ts"
16+
"require": "./dist/react-proportion-slider.umd.js"
1717
}
1818
},
1919
"scripts": {
@@ -24,10 +24,6 @@
2424
"test": "vitest",
2525
"test:watch": "vitest --watch"
2626
},
27-
"dependencies": {
28-
"react": ">=16.8.0",
29-
"react-dom": ">=16.8.0"
30-
},
3127
"devDependencies": {
3228
"@eslint/js": "^9.21.0",
3329
"@testing-library/react": "^14.2.1",
@@ -39,6 +35,8 @@
3935
"eslint-plugin-react-refresh": "^0.4.19",
4036
"globals": "^15.15.0",
4137
"jsdom": "^24.0.0",
38+
"react": ">=16.8.0",
39+
"react-dom": ">=16.8.0",
4240
"typescript": "~5.7.2",
4341
"typescript-eslint": "^8.24.1",
4442
"vite": "^6.2.0",

src/ProportionSlider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { useCallback, useRef, CSSProperties, useEffect } from "react";
2-
import { DynamicChildPositioner, SliderKnob } from "./components";
3-
import { ProportionDetail, SliderKnobOptions } from "./components/types";
2+
import {
3+
DynamicChildPositioner,
4+
SliderKnob,
5+
ProportionDetail,
6+
SliderKnobOptions,
7+
} from "./components";
48
import { EventType, getClientX, clamp } from "./utilities";
59

610
export type ProportionSliderProps = {

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./DynamicChildPositioner";
22
export * from "./HiddenSpaceTaker";
33
export * from "./SliderKnob";
4+
export * from "./types";

0 commit comments

Comments
 (0)