├── .changeset
├── README.md
└── config.json
├── .eslintrc.js
├── .github
├── CODEOWNERS
├── FUNDING.yml
├── pull_request_template.md
└── workflows
│ └── release.yaml
├── .gitignore
├── .npmrc
├── LICENSE
├── README.md
├── apps
└── website
│ ├── .prettierrc.js
│ ├── components.json
│ ├── next-env.d.ts
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── public
│ └── og-image.png
│ ├── src
│ ├── app
│ │ ├── api
│ │ │ └── page.tsx
│ │ ├── icon.tsx
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── components
│ │ ├── api-hero.tsx
│ │ ├── code-block.tsx
│ │ ├── hero.tsx
│ │ ├── scroll-area.tsx
│ │ ├── section.tsx
│ │ ├── sections
│ │ │ ├── api
│ │ │ │ ├── api-introduction.tsx
│ │ │ │ ├── api-table.tsx
│ │ │ │ └── react-server-component.tsx
│ │ │ └── home
│ │ │ │ ├── animation.tsx
│ │ │ │ ├── arc-priority.tsx
│ │ │ │ ├── custom-color-scale.tsx
│ │ │ │ ├── custom-secondary-color.tsx
│ │ │ │ ├── default-color-scale.tsx
│ │ │ │ ├── default.tsx
│ │ │ │ ├── installation.tsx
│ │ │ │ ├── introduction.tsx
│ │ │ │ ├── label.tsx
│ │ │ │ ├── playground.tsx
│ │ │ │ └── variant.tsx
│ │ ├── snippet.tsx
│ │ ├── sparkle-svg.tsx
│ │ ├── tailwind-indicator.tsx
│ │ └── ui
│ │ │ ├── button.tsx
│ │ │ ├── card.tsx
│ │ │ ├── color-picker.tsx
│ │ │ ├── input.tsx
│ │ │ ├── label.tsx
│ │ │ ├── popover.tsx
│ │ │ ├── select.tsx
│ │ │ ├── sonner.tsx
│ │ │ ├── switch.tsx
│ │ │ └── table.tsx
│ ├── globals.css
│ ├── hooks
│ │ └── use-replay-animation.ts
│ └── lib
│ │ ├── constants.ts
│ │ └── utils.ts
│ ├── tailwind.config.ts
│ └── tsconfig.json
├── package.json
├── packages
└── gauge
│ ├── .prettierrc.js
│ ├── package.json
│ ├── src
│ ├── index.tsx
│ ├── index.types.ts
│ └── lib
│ │ └── utils.ts
│ └── tsconfig.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── renovate.json
└── turbo.json
/.changeset/README.md:
--------------------------------------------------------------------------------
1 | # Changesets
2 |
3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4 | with multi-package repos, or single-package repos to help you version and publish your code. You can
5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6 |
7 | We have a quick list of common questions to get you started engaging with this project in
8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": false,
5 | "linked": [],
6 | "access": "public",
7 | "baseBranch": "main",
8 | "updateInternalDependencies": "patch",
9 | "ignore": ["website"]
10 | }
11 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | // This tells ESLint to load the config from the package `eslint-config-custom`
4 | extends: ['custom'],
5 | settings: {
6 | next: {
7 | rootDir: ['apps/*/']
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Learn how to add code owners here:
2 | # https://help.github.com/en/articles/about-code-owners
3 |
4 | * @suyalcinkaya
5 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: suyalcinkaya
2 | ko_fi: suyalcinkaya
3 | buy_me_a_coffee: suyalcinkaya
4 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ### Description
2 |
3 | Please provide a brief description of what this PR accomplishes.
4 |
5 | If applicable, you should then provide a more detailed description including screenshots (if appropriate) to benefit
6 | everyone.
7 |
8 | #### Type of project(s)
9 |
10 | - [ ] :package: `packages/gauge`
11 | - [ ] :sparkles: `apps/website`
12 |
13 | #### Type of change
14 |
15 | - [ ] :bug: Bug fix
16 | - [ ] :rocket: New feature
17 | - [ ] :boom: Breaking change
18 |
19 | ### How do I test this?
20 |
21 | - Provide clear step-by-step instructions for easy reproduction.
22 | - Highlight the current issue and explain how the change resolves it.
23 | - Preferably provide links from the relevant Vercel Preview URL.
24 |
25 | ### Checklist
26 |
27 | Did you remember to take care of the following?
28 |
29 | - [ ] `pnpm install` – for the new dependencies
30 | - [ ] Verify `pnpm-lock.yaml` file when there is a package addition, deletion, or update
31 | - [ ] Perform a self-review
32 | - [ ] Provide comments, particularly in hard-to-understand areas
33 |
--------------------------------------------------------------------------------
/.github/workflows/release.yaml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | concurrency: ${{ github.workflow }}-${{ github.ref }}
7 |
8 | jobs:
9 | release:
10 | name: Release
11 | runs-on: ubuntu-latest
12 | if: github.actor == github.repository_owner
13 |
14 | steps:
15 | - name: Checkout Repo
16 | uses: actions/checkout@v4
17 |
18 | - name: Setup pnpm
19 | uses: pnpm/action-setup@v4
20 | with:
21 | version: 9
22 |
23 | - name: Setup Node.js
24 | uses: actions/setup-node@v4
25 | with:
26 | node-version: 20.x
27 |
28 | - name: Install Dependencies
29 | run: pnpm i
30 |
31 | - name: Publish to NPM
32 | id: changesets
33 | uses: changesets/action@v1
34 | with:
35 | publish: pnpm publish-packages
36 | env:
37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .env
3 |
4 | # next.js
5 | .next
6 | /out/
7 | .vercel
8 |
9 | # dependencies
10 | node_modules
11 | /.pnp
12 | .pnp.js
13 |
14 | # production
15 | /build
16 | sw.js
17 | workbox-*.js
18 | dist
19 |
20 | # misc
21 | .DS_Store
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # ts
29 | tsconfig.tsbuildinfo
30 |
31 | # turbo
32 | .turbo
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://registry.npmjs.org/
2 | engine-strict=true
3 | auto-install-peers=true
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Onur Şuyalçınkaya
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Gauge [](https://www.npmjs.com/package/@suyalcinkaya/gauge?activeTab=code) [](https://www.npmjs.com/package/@suyalcinkaya/gauge)  
4 |
5 | [Gauge](https://gauge.onur.dev/) is an aesthetic and customizable circular visual component for React.
6 |
7 | Examples and playground: [https://gauge.onur.dev](https://gauge.onur.dev)
8 |
9 | ## Documentation
10 |
11 | Find the full API reference in the [documentation](https://gauge.onur.dev/api).
12 |
13 | ## Install
14 |
15 | ```bash
16 | pnpm install @suyalcinkaya/gauge
17 | ```
18 |
19 | ## Use
20 |
21 | ```tsx
22 | import { Gauge } from '@suyalcinkaya/gauge'
23 |
24 | export function Component(): JSX.Element {
25 | return
53 | :nth-child(1)]:bg-blue-100 [&>:nth-child(1)]:after:absolute [&>:nth-child(1)]:after:inset-y-0 [&>:nth-child(1)]:after:left-0 [&>:nth-child(1)]:after:w-[2px] [&>:nth-child(1)]:after:bg-blue-500 [&>:nth-child(1)]:after:content-[""]',
57 | highlightedLinesNumbers?.includes(6) &&
58 | '[&>:nth-child(6)]:bg-blue-100 [&>:nth-child(6)]:after:absolute [&>:nth-child(6)]:after:inset-y-0 [&>:nth-child(6)]:after:left-0 [&>:nth-child(6)]:after:w-[2px] [&>:nth-child(6)]:after:bg-blue-500 [&>:nth-child(6)]:after:content-[""]',
59 | highlightedLinesNumbers?.includes(7) &&
60 | '[&>:nth-child(7)]:bg-blue-100 [&>:nth-child(7)]:after:absolute [&>:nth-child(7)]:after:inset-y-0 [&>:nth-child(7)]:after:left-0 [&>:nth-child(7)]:after:w-[2px] [&>:nth-child(7)]:after:bg-blue-500 [&>:nth-child(7)]:after:content-[""]',
61 | highlightedLinesNumbers?.includes(8) &&
62 | '[&>:nth-child(8)]:bg-blue-100 [&>:nth-child(8)]:after:absolute [&>:nth-child(8)]:after:inset-y-0 [&>:nth-child(8)]:after:left-0 [&>:nth-child(8)]:after:w-[2px] [&>:nth-child(8)]:after:bg-blue-500 [&>:nth-child(8)]:after:content-[""]'
63 | )}
64 | dangerouslySetInnerHTML={{ __html: codeHTML }}
65 | />
66 |
67 |
}
107 |
}>
112 | )}
113 | API documention for Gauge.
11 |xs
,
14 | sm
, md
,{' '}
15 | lg
, xl
,{' '}
16 | 2xl
, or a numeric value as number
or{' '}
17 | string
.
18 | >
19 | ),
20 | defaultValue: md
21 | },
22 | {
23 | property: 'gapPercent',
24 | description: 'Percentage of the total circumference that represents a gap between primary and secondary arcs.',
25 | defaultValue: 5
26 | },
27 | {
28 | property: 'strokeWidth',
29 | description: 'Stroke width of the Gauge.',
30 | defaultValue: 10
31 | },
32 | {
33 | property: 'variant',
34 | description: "Direction of the Gauge's animation.",
35 | defaultValue: ascending
36 | },
37 | {
38 | property: 'showValue',
39 | description: 'Option to display the numeric value inside the Gauge.',
40 | defaultValue: false
41 | },
42 | {
43 | property: 'showAnimation',
44 | description: "Option to animate the Gauge's progress.",
45 | defaultValue: false
46 | },
47 | {
48 | property: 'primary',
49 | description: (
50 | 51 | Primary color or set of colors for the Gauge, with optional threshold values to determine color changes. Default 52 | primary color scale goes as red (0-25) {` ->`} amber (26-50) {` ->`} blue (51-75) {` ->`} green (76-100). 53 |
54 | ), 55 | defaultValue: ( 56 |
68 | Secondary color or set of colors for the Gauge, similar to primary
. Default
69 | secondary color is gray.
70 |
89 | The Gauge component only requires the value
prop and supports many props to
90 | customize it according to your needs.
91 |
11 | Not yet. Gauge depends on state and effects (for now). So, if you are using server components, you need to add
12 | the 'use client'
{' '}
13 | {' '}
18 | at the top of a file, above your imports.
19 |
24 | On initial render, the showAnimation
prop animates the Gauge from 0 to the{' '}
25 | value
for the ascending
variant, and
26 | from 100 to the value
for the{' '}
27 | descending
variant.
28 |
16 | When displaying half ratio (51 > value
> 49), the Gauge will make
17 | both arcs are equally sized.
18 |
63 | In the following example, the Gauge will loop through the values 42, 50, and 58 every 1.5 seconds to make it 64 | easier to visualize. 65 |
66 |An aesthetic and customizable circular visual component for React.
12 |
12 | Display the value inside the Gauge with the showValue
prop.
13 |
Play with the configuration of the Gauge.
60 |
12 | The ascending
variant (default) is useful for cases like tracking the
13 | percentage of a goal *achieved*. The descending
variant is useful for cases
14 | like tracking the percentage of a goal *remaining*.
15 |
{code}38 |