-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/UI chart kit release 0.1.0 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Omaima33
wants to merge
6
commits into
develop
Choose a base branch
from
chore/ui-chart-kit-release-0.1.0
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
65a0013
feat: add typed chart contracts and buildChartConfig utility with bar…
Omaima33 d56e280
feat: add BarChart component with typed props, stacking/horizontal su…
Omaima33 6fc8277
feat: add LineChart and AreaChart with smooth option, area fill, stac…
Omaima33 17d076a
test: add full test suite with mocked react-chartjs-2, config validat…
Omaima33 e3111b0
chore: add README and changeset
Omaima33 eed8fcb
Merge branch 'develop' into chore/ui-chart-kit-release-0.1.0
Omaima33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@ciscode/ui-chart-kit': minor | ||
| --- | ||
|
|
||
| Initial release of @ciscode/ui-chart-kit v0.1.0. | ||
|
|
||
| - ChartDataPoint, ChartDataset, and ChartTheme type contracts | ||
| - buildChartConfig utility mapping typed data to Chart.js config | ||
| - BarChart component with stacked and horizontal support | ||
| - LineChart component with smooth curve support | ||
| - AreaChart component with fill at 20% opacity and stacked support | ||
| - All components responsive with configurable height | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,170 @@ | ||
| # React TypeScript DeveloperKit (Template) | ||
| # @ciscode/ui-chart-kit | ||
|
|
||
| Template repository for building reusable React TypeScript **npm libraries** | ||
| (components + hooks + utilities). | ||
| Typed React chart components (Bar, Line, Area) built on Chart.js. | ||
| Pass data and a theme — get a fully configured, responsive chart. No raw Chart.js options required. | ||
|
|
||
| ## What you get | ||
| ## Installation | ||
|
|
||
| - ESM + CJS + Types build (tsup) | ||
| - Vitest testing | ||
| - ESLint + Prettier (flat config) | ||
| - Changesets (manual release flow, no automation PR) | ||
| - Husky (pre-commit + pre-push) | ||
| - Enforced public API via `src/index.ts` | ||
| - Dependency-free styling (Tailwind-compatible by convention only) | ||
| - `react` and `react-dom` as peerDependencies | ||
| ```bash | ||
| npm install @ciscode/ui-chart-kit | ||
| ``` | ||
|
|
||
| ## Package structure | ||
| ### Peer dependencies | ||
|
|
||
| - `src/components` – reusable UI components | ||
| - `src/hooks` – reusable React hooks | ||
| - `src/utils` – framework-agnostic utilities | ||
| - `src/index.ts` – **only public API** (no deep imports allowed) | ||
| | Package | Version | | ||
| | ----------- | ------- | | ||
| | `react` | ≥ 18 | | ||
| | `react-dom` | ≥ 18 | | ||
|
|
||
| Anything not exported from `src/index.ts` is considered private. | ||
| `chart.js` and `react-chartjs-2` are bundled — you do **not** need to install them separately. | ||
|
|
||
| ## Scripts | ||
| --- | ||
|
|
||
| - `npm run build` – build to `dist/` (tsup) | ||
| - `npm test` – run tests (vitest) | ||
| - `npm run typecheck` – TypeScript typecheck | ||
| - `npm run lint` – ESLint | ||
| - `npm run format` / `npm run format:write` – Prettier | ||
| - `npx changeset` – create a changeset | ||
| ## Data types | ||
|
|
||
| ## Release flow (summary) | ||
| ### `ChartDataPoint` | ||
|
|
||
| - Work on a `feature` branch from `develop` | ||
| - Merge to `develop` | ||
| - Add a changeset for user-facing changes: `npx changeset` | ||
| - Promote `develop` → `master` | ||
| - Tag `vX.Y.Z` to publish (npm OIDC) | ||
| ```ts | ||
| interface ChartDataPoint { | ||
| label: string; | ||
| value: number; | ||
| } | ||
| ``` | ||
|
|
||
| This repository is a **template**. Teams should clone it and focus only on | ||
| library logic, not tooling or release mechanics. | ||
| ### `ChartDataset` | ||
|
|
||
| ```ts | ||
| interface ChartDataset { | ||
| id: string; | ||
| label: string; | ||
| data: ChartDataPoint[]; | ||
| color?: string; // hex color — falls back to theme.colors when omitted | ||
| } | ||
| ``` | ||
|
|
||
| ### `ChartTheme` | ||
|
|
||
| ```ts | ||
| interface ChartTheme { | ||
| colors: string[]; // palette shared across datasets | ||
| fontFamily?: string; | ||
| fontSize?: number; | ||
| grid?: { | ||
| color?: string; | ||
| display?: boolean; | ||
| }; | ||
| tooltip?: { | ||
| enabled?: boolean; | ||
| backgroundColor?: string; | ||
| titleColor?: string; | ||
| bodyColor?: string; | ||
| }; | ||
| legend?: { | ||
| display?: boolean; | ||
| position?: 'top' | 'bottom' | 'left' | 'right'; | ||
| }; | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Components | ||
|
|
||
| ### BarChart | ||
|
|
||
| | Prop | Type | Default | Description | | ||
| | ------------ | ---------------- | ------- | --------------------------------- | | ||
| | `data` | `ChartDataset[]` | — | Datasets to render | | ||
| | `theme` | `ChartTheme` | — | Theme (colors, fonts, grid, etc.) | | ||
| | `height` | `number` | `300` | Chart height in pixels | | ||
| | `stacked` | `boolean` | `false` | Stack bars on top of each other | | ||
| | `horizontal` | `boolean` | `false` | Render horizontal bars | | ||
|
|
||
| ```tsx | ||
| import { BarChart } from '@ciscode/ui-chart-kit'; | ||
| import type { ChartDataset, ChartTheme } from '@ciscode/ui-chart-kit'; | ||
|
|
||
| const theme: ChartTheme = { | ||
| colors: ['#4F46E5', '#10B981', '#F59E0B'], | ||
| fontFamily: 'Inter, sans-serif', | ||
| fontSize: 12, | ||
| grid: { color: '#E5E7EB', display: true }, | ||
| tooltip: { enabled: true, backgroundColor: '#1F2937' }, | ||
| legend: { display: true, position: 'top' }, | ||
| }; | ||
|
|
||
| const datasets: ChartDataset[] = [ | ||
| { | ||
| id: 'revenue', | ||
| label: 'Revenue', | ||
| data: [ | ||
| { label: 'Q1', value: 120 }, | ||
| { label: 'Q2', value: 180 }, | ||
| { label: 'Q3', value: 150 }, | ||
| { label: 'Q4', value: 210 }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| function App() { | ||
| return <BarChart data={datasets} theme={theme} height={400} stacked />; | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### LineChart | ||
|
|
||
| | Prop | Type | Default | Description | | ||
| | -------- | ---------------- | ------- | --------------------------------------- | | ||
| | `data` | `ChartDataset[]` | — | Datasets to render | | ||
| | `theme` | `ChartTheme` | — | Theme (colors, fonts, grid, etc.) | | ||
| | `height` | `number` | `300` | Chart height in pixels | | ||
| | `smooth` | `boolean` | `false` | Curved line interpolation (0.4 tension) | | ||
|
|
||
| ```tsx | ||
| import { LineChart } from '@ciscode/ui-chart-kit'; | ||
|
|
||
| function App() { | ||
| return <LineChart data={datasets} theme={theme} smooth />; | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### AreaChart | ||
|
|
||
| | Prop | Type | Default | Description | | ||
| | --------- | ---------------- | ------- | --------------------------------------- | | ||
| | `data` | `ChartDataset[]` | — | Datasets to render | | ||
| | `theme` | `ChartTheme` | — | Theme (colors, fonts, grid, etc.) | | ||
| | `height` | `number` | `300` | Chart height in pixels | | ||
| | `smooth` | `boolean` | `false` | Curved line interpolation (0.4 tension) | | ||
| | `stacked` | `boolean` | `false` | Stack areas on top of each other | | ||
|
|
||
| Area fill uses the dataset color at 20 % opacity automatically. | ||
|
|
||
| ```tsx | ||
| import { AreaChart } from '@ciscode/ui-chart-kit'; | ||
|
|
||
| function App() { | ||
| return <AreaChart data={datasets} theme={theme} stacked smooth />; | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Design decisions | ||
|
|
||
| - **No Chart.js passthrough.** Components expose a curated props API only. | ||
| Chart.js configuration is built internally via `buildChartConfig`. | ||
| This keeps the public surface small and prevents breaking changes | ||
| when Chart.js internals evolve. | ||
| - **Colors cycle.** When there are more datasets than `theme.colors` entries, | ||
| colors wrap around automatically. | ||
| - **Responsive by default.** Every chart renders inside a `div` with | ||
| `width: 100%` and the specified `height`. | ||
|
|
||
| ## License | ||
|
|
||
| MIT |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changeset is marked as a
minorbump but the PR already setspackage.jsonto0.1.0and the text hard-codes "v0.1.0". If you runchangeset version, aminorchangeset will bump0.1.0 → 0.2.0, which conflicts with the stated initial release version. Consider adjusting the bump type and/or removing the hard-coded version from the changeset body so the release version is driven by Changesets.