-
Notifications
You must be signed in to change notification settings - Fork 0
feat: update icon size options and stroke width #26
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
610212f
feat: update icon size options and stroke width handling in SVGR temp…
YounixM b3c0d4e
refactor: replace icon size options list with a styled table for bett…
YounixM d3f5efa
fix: update stroke width handling in SVGR template to default to 'xs'…
YounixM 43c6e48
feat: introduce icon size and stroke width configuration in a new ico…
YounixM 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| node_modules | ||
| dist | ||
| src | ||
| storybook-static |
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
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,19 +1,22 @@ | ||
| const path = require('node:path'); | ||
|
|
||
| /** | ||
| * SVGR index template: generates src/index.ts with named exports. | ||
| * Component names starting with a number get an "Icon" prefix (e.g. 42.svg -> Icon42). | ||
| */ | ||
| function indexTemplate(filePaths) { | ||
| const exportEntries = filePaths | ||
| .filter((entry) => entry && (entry.path != null || entry.originalPath != null)) | ||
| .map((entry) => { | ||
| const filePath = entry.path ?? entry.originalPath; | ||
| const basename = path.basename(filePath, path.extname(filePath)); | ||
| const exportName = /^\d/.test(basename) ? `Icon${basename}` : basename; | ||
| return `export { default as ${exportName} } from './${basename}'`; | ||
| }); | ||
| return exportEntries.join('\n'); | ||
| function indexTemplate(fileEntries) { | ||
| const entries = Array.isArray(fileEntries) ? fileEntries : []; | ||
| const filePaths = entries | ||
| .map((entry) => (typeof entry === 'string' ? entry : (entry?.path ?? entry?.originalPath))) | ||
| .filter(Boolean); | ||
|
|
||
| filePaths.sort((a, b) => | ||
| path.basename(a, path.extname(a)).localeCompare(path.basename(b, path.extname(b))), | ||
| ); | ||
|
|
||
| const exportLines = filePaths.map((filePath) => { | ||
| const basename = path.basename(filePath, path.extname(filePath)); | ||
| const exportName = /^\d/.test(basename) ? `Icon${basename}` : basename; | ||
| return `export { default as ${exportName} } from './${basename}'`; | ||
| }); | ||
|
|
||
| return `export type { IconSize, IconStrokeWidth } from '../lib/icon-config';\n${exportLines.join('\n')}`; | ||
| } | ||
|
|
||
| module.exports = indexTemplate; |
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,27 @@ | ||
| export type IconSize = '5xl' | '4xl' | '3xl' | '2xl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs'; | ||
|
|
||
| export const ICON_SIZE_MAP: Record<IconSize, number> = { | ||
| xs: 10, | ||
| sm: 12, | ||
| md: 14, | ||
| lg: 16, | ||
| xl: 18, | ||
| '2xl': 20, | ||
| '3xl': 24, | ||
| '4xl': 28, | ||
| '5xl': 32, | ||
| }; | ||
|
|
||
| export const STROKE_WIDTH_MAP: Record<IconSize, number> = { | ||
| xs: 0.83, | ||
| sm: 1, | ||
| md: 1.17, | ||
| lg: 1.33, | ||
| xl: 1.5, | ||
| '2xl': 1.67, | ||
| '3xl': 2, | ||
| '4xl': 2.33, | ||
| '5xl': 2.67, | ||
| }; | ||
|
|
||
| export type IconStrokeWidth = (typeof STROKE_WIDTH_MAP)[IconSize]; |
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,96 @@ | ||
| import { Meta } from '@storybook/addon-docs/blocks'; | ||
|
|
||
| <Meta title="Docs" /> | ||
|
|
||
| # @signozhq/icons | ||
|
|
||
| SVG-based React icon components with fixed size presets and custom sizing. | ||
|
|
||
| --- | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # pnpm | ||
| pnpm add @signozhq/icons | ||
|
|
||
| # npm | ||
| npm install @signozhq/icons | ||
|
|
||
| # yarn | ||
| yarn add @signozhq/icons | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| Import the icon component you need and render it. Icons accept `size`, `color`, and `strokeWidth` (and standard SVG props). | ||
|
|
||
| ```tsx | ||
| import { ArrowRight } from '@signozhq/icons'; | ||
|
|
||
| <ArrowRight size="lg" color="#2A2E37" /> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Fixed sizes (presets) | ||
|
|
||
| Use a **preset** when you want icons to match the design system: each preset defines both the icon size (in pixels) and a stroke width so icons stay sharp and consistent across the UI. Pass the preset name to the `size` prop. | ||
|
|
||
| ### Quick reference | ||
|
|
||
| <table style={{ width: '100%', maxWidth: 360, borderCollapse: 'collapse', marginTop: 8, marginBottom: 16, fontSize: 14 }}> | ||
| <thead> | ||
| <tr style={{ borderBottom: '2px solid var(--docs-border-color, #e5e7eb)' }}> | ||
| <th style={{ textAlign: 'left', padding: '10px 12px', fontWeight: 600 }}>Preset</th> | ||
| <th style={{ textAlign: 'right', padding: '10px 12px', fontWeight: 600 }}>Size</th> | ||
| <th style={{ textAlign: 'right', padding: '10px 12px', fontWeight: 600 }}>Stroke width</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>xs</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>10px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>0.83</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>sm</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>12px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>1</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>md</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>14px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>1.17</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>lg</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>16px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>1.33</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>xl</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>18px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>1.5</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>2xl</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>20px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>1.67</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>3xl</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>24px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>2</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>4xl</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>28px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>2.33</td></tr> | ||
| <tr style={{ borderBottom: '1px solid var(--docs-border-color, #e5e7eb)' }}><td style={{ padding: '10px 12px' }}><code>5xl</code></td><td style={{ textAlign: 'right', padding: '10px 12px' }}>32px</td><td style={{ textAlign: 'right', padding: '10px 12px' }}>2.67</td></tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ### Example | ||
|
|
||
| ```tsx | ||
| <ArrowRight size="sm" /> {/* 12px, stroke 1 */} | ||
| <ArrowRight size="lg" /> {/* 16px, stroke 1.33 */} | ||
| <ArrowRight size="2xl" /> {/* 20px, stroke 1.67 */} | ||
| ``` | ||
|
|
||
| You can override the stroke for a preset with the `strokeWidth` prop if needed. | ||
|
|
||
| --- | ||
|
|
||
| ## Custom size | ||
|
|
||
| Pass a number to `size` for any pixel dimension. Stroke width defaults to `2` when using a custom size; override with `strokeWidth` if needed. | ||
|
|
||
| ```tsx | ||
| <ArrowRight size={32} /> | ||
| <ArrowRight size={48} strokeWidth={1.5} color="currentColor" /> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Other props | ||
|
|
||
| - **`color`** — Stroke/fill color (default: `"currentColor"`). | ||
| - **`strokeWidth`** — Override stroke width when using a preset or custom size. | ||
| - **`className`** — Applied alongside the default `signoz-icon` class. | ||
|
|
||
| --- | ||
|
|
||
| Browse the **Icons / Gallery** in the sidebar to search and preview all icons and copy snippets. | ||
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.