Skip to content

Commit 133700e

Browse files
committed
Update package to @nsmr/pixelart-react and improve gallery
1 parent 40d8614 commit 133700e

File tree

8 files changed

+161
-59
lines changed

8 files changed

+161
-59
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@ React components for [pixelarticons](https://github.com/halfmage/pixelarticons).
1414

1515
## 🚨 Version 2.0.0 Migration Guide 🚨
1616

17-
The package has been renamed from `@nicholuassommer/pixelarticons-react` to `@nsommer/pixelart-react` for simplicity.
17+
The package includes several improvements in version 2.0.0:
1818

19-
This is a fork of the original (and amazing) package from halfmage.
20-
-Please visit https://github.com/halfmage/pixelarticons for the original repo.
21-
-Also consider purchasing the extended Icon pack @ https://pixelarticons.com/
22-
23-
Actively monitored and maintained by [nicholuassommer](https://github.com/nicholuassommer).
19+
- Interactive gallery with all 486 icons
20+
- Improved documentation
21+
- Better React component support
22+
- Enhanced build process
2423

2524
### Migration Steps:
2625

2726
1. Update your package.json dependency:
2827

2928
```diff
3029
- "@nicholuassommer/pixelarticons-react": "^1.0.1"
31-
+ "@nsommer/pixelart-react": "^2.0.0"
30+
+ "@nsmr/pixelart-react": "^2.0.0"
3231
```
3332

3433
2. Update your imports:
@@ -43,7 +42,7 @@ import { User, Heart } from "@nicholuassommer/pixelarticons-react";
4342

4443
```jsx
4544
// Option 1: Direct from package (similar to before)
46-
import { User, Heart } from "@nsommer/pixelart-react";
45+
import { User, Heart } from "@nsmr/pixelart-react";
4746

4847
// Option 2: New shorter path
4948
import { User, Heart } from "pixelart/react";
@@ -52,7 +51,7 @@ import { User, Heart } from "pixelart/react";
5251
## Installation
5352

5453
```bash
55-
npm install @nsommer/pixelart-react
54+
npm install @nsmr/pixelart-react
5655
```
5756

5857
## Usage

cover.png

108 Bytes
Loading

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@nsommer/pixelart-react",
2+
"name": "@nsmr/pixelart-react",
33
"version": "2.0.0",
4-
"description": "Pixelarticons as React Components - Finest handmade pixelart icons, now for React.",
4+
"description": "Pixelarticons as React Components - Finest handmade pixelart icons, now for React. Includes interactive gallery with all 486 icons.",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",
77
"types": "dist/index.d.ts",
@@ -20,7 +20,8 @@
2020
},
2121
"files": [
2222
"dist",
23-
"svg"
23+
"svg",
24+
"examples/gallery-generator.html"
2425
],
2526
"sideEffects": false,
2627
"scripts": {
@@ -29,16 +30,16 @@
2930
"build:esm": "tsc --module esnext --outDir dist/esm",
3031
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
3132
"build:webpack": "webpack --config webpack.config.js",
32-
"build:gallery": "echo \"Gallery image placeholder created\" && exit 0",
33+
"build:gallery": "node scripts/generate-gallery.js",
3334
"dev": "tsc --watch",
3435
"typecheck": "tsc --noEmit",
3536
"lint": "eslint src --ext .ts,.tsx",
3637
"prepublishOnly": "npm run build",
37-
"demo": "npx http-server . -o examples/icon-catalog.html"
38+
"demo": "npx http-server . -o examples/gallery-generator.html"
3839
},
3940
"repository": {
4041
"type": "git",
41-
"url": "git+https://github.com/gitntg/pixelarticons.git"
42+
"url": "git+https://github.com/nicholuassommer/pixelarticons-react.git"
4243
},
4344
"keywords": [
4445
"pixel",
@@ -54,9 +55,9 @@
5455
"author": "Gerrit Halfmann",
5556
"license": "MIT",
5657
"bugs": {
57-
"url": "https://github.com/nicholuassommer/pixelarticons/issues"
58+
"url": "https://github.com/nicholuassommer/pixelarticons-react/issues"
5859
},
59-
"homepage": "https://github.com/nicholuassommer/pixelarticons#readme",
60+
"homepage": "https://github.com/nicholuassommer/pixelarticons-react#readme",
6061
"peerDependencies": {
6162
"react": ">=16.8.0",
6263
"react-dom": ">=16.8.0"

scripts/generate-gallery.js

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,99 @@
1-
// Script to generate an icon gallery image for the README
2-
// Run with: node scripts/generate-gallery.js
1+
// Script to generate icon gallery image for README
2+
const puppeteer = require('puppeteer');
3+
const path = require('path');
4+
const fs = require('fs');
35

4-
import puppeteer from 'puppeteer';
5-
import path from 'path';
6-
import fs from 'fs';
7-
import { fileURLToPath } from 'url';
8-
9-
// Get the directory name in ESM
10-
const __filename = fileURLToPath(import.meta.url);
11-
const __dirname = path.dirname(__filename);
6+
(async () => {
7+
console.log('Generating gallery image...');
8+
9+
// Make sure the gallery HTML file exists
10+
const galleryPath = path.resolve(__dirname, '../examples/gallery-generator.html');
11+
if (!fs.existsSync(galleryPath)) {
12+
console.error('Gallery HTML file not found:', galleryPath);
13+
process.exit(1);
14+
}
1215

13-
async function generateGalleryImage() {
14-
console.log('Launching browser...');
16+
// Launch browser
1517
const browser = await puppeteer.launch({
16-
headless: 'new', // Use new headless mode
18+
headless: 'new',
1719
args: ['--no-sandbox', '--disable-setuid-sandbox']
1820
});
19-
21+
2022
try {
2123
const page = await browser.newPage();
2224

23-
// Set viewport to a reasonable size
24-
await page.setViewport({
25-
width: 1200,
26-
height: 800,
27-
deviceScaleFactor: 2, // Higher resolution image
28-
});
29-
30-
const htmlPath = path.resolve(__dirname, '../examples/gallery-generator.html');
31-
const fileUrl = `file://${htmlPath}`;
32-
33-
console.log(`Opening gallery page: ${fileUrl}`);
25+
// Go to gallery page
26+
const fileUrl = `file://${galleryPath}`;
3427
await page.goto(fileUrl, { waitUntil: 'networkidle0' });
3528

36-
// Make sure the DOM is fully loaded
37-
await page.waitForSelector('.gallery');
38-
39-
// Give additional time for all visual elements to render
29+
// Allow time for all SVGs to load
4030
await page.waitForTimeout(1000);
4131

42-
// Find the gallery element and get its dimensions
43-
const galleryElement = await page.$('.gallery');
44-
const boundingBox = await galleryElement.boundingBox();
32+
// Take screenshot of gallery area
33+
const gallery = await page.$('#gallery');
34+
if (!gallery) {
35+
throw new Error('Gallery element not found on page');
36+
}
4537

4638
const outputPath = path.resolve(__dirname, '../examples/icon-gallery.png');
47-
console.log(`Taking screenshot and saving to: ${outputPath}`);
4839

49-
// Take screenshot of just the gallery area
40+
// Get the first 6 rows of icons
41+
await page.evaluate(() => {
42+
// Calculate row height based on first icon
43+
const iconItem = document.querySelector('.icon-item');
44+
if (!iconItem) return;
45+
46+
const itemHeight = iconItem.offsetHeight;
47+
const containerWidth = document.getElementById('gallery').offsetWidth;
48+
const rowSize = Math.floor(containerWidth / (iconItem.offsetWidth + 20)); // 20px is the gap
49+
50+
// Show limited number of rows for the image
51+
const showItems = rowSize * 6; // Show 6 rows
52+
53+
// Update subtitle
54+
const subtitle = document.querySelector('.subtitle');
55+
if (subtitle) {
56+
subtitle.textContent = 'A collection of 486 pixel-perfect icons for React';
57+
}
58+
59+
// Hide icons beyond the first 6 rows
60+
const items = document.querySelectorAll('.icon-item');
61+
if (items.length > showItems) {
62+
for (let i = showItems; i < items.length; i++) {
63+
items[i].style.display = 'none';
64+
}
65+
}
66+
});
67+
68+
// Take a screenshot with appropriate padding
69+
await page.evaluate(() => {
70+
const gallery = document.getElementById('gallery');
71+
const header = document.querySelector('.header');
72+
if (gallery && header) {
73+
// Add padding and margin for better appearance
74+
document.body.style.padding = '40px';
75+
gallery.style.marginBottom = '40px';
76+
}
77+
});
78+
79+
// Take full page screenshot
5080
await page.screenshot({
5181
path: outputPath,
82+
fullPage: false,
5283
clip: {
53-
x: boundingBox.x,
54-
y: boundingBox.y - 100, // Include the header
55-
width: boundingBox.width,
56-
height: boundingBox.height + 150 // Add some padding
84+
x: 0,
85+
y: 0,
86+
width: 1000,
87+
height: 550
5788
}
5889
});
90+
91+
console.log(`Gallery image generated: ${outputPath}`);
5992

60-
console.log('Gallery image created successfully!');
6193
} catch (error) {
6294
console.error('Error generating gallery image:', error);
6395
process.exit(1);
6496
} finally {
6597
await browser.close();
6698
}
67-
}
68-
69-
generateGalleryImage();
99+
})();

temp-old-package/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# DEPRECATED
2+
3+
This package has been renamed to [`@nsmr/pixelart-react`](https://www.npmjs.com/package/@nsmr/pixelart-react).
4+
5+
## Migration
6+
7+
Update your package.json:
8+
9+
```diff
10+
- "@nicholuassommer/pixelarticons-react": "^1.0.1"
11+
+ "@nsmr/pixelart-react": "^2.0.0"
12+
```
13+
14+
Update your imports:
15+
16+
```diff
17+
- import { PixelArtIcon } from '@nicholuassommer/pixelarticons-react'
18+
+ import { PixelArtIcon } from '@nsmr/pixelart-react'
19+
```
20+
21+
## Why the change?
22+
23+
The new package name is shorter, more concise, and easier to remember. It also better reflects the focus on pixel art icons for React.

temp-old-package/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This package has been renamed to @nsmr/pixelart-react
2+
// Re-export everything from the new package
3+
export * from '@nsmr/pixelart-react';

temp-old-package/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This package has been renamed to @nsmr/pixelart-react
2+
console.warn(
3+
'\n⚠️ [DEPRECATED] @nicholuassommer/pixelarticons-react has been renamed to @nsmr/pixelart-react.\n' +
4+
'Please update your imports to use the new package name.\n' +
5+
'e.g., `import { Icon } from "@nsmr/pixelart-react"`\n'
6+
);
7+
8+
module.exports = require('@nsmr/pixelart-react');

temp-old-package/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@nicholuassommer/pixelarticons-react",
3+
"version": "2.0.0",
4+
"description": "DEPRECATED: This package has been renamed to @nsmr/pixelart-react",
5+
"main": "index.js",
6+
"types": "index.d.ts",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/gitntg/pixelarticons-react.git"
13+
},
14+
"keywords": [
15+
"pixel",
16+
"pixelart",
17+
"icon",
18+
"icons",
19+
"iconset",
20+
"vector",
21+
"react",
22+
"react-component",
23+
"typescript"
24+
],
25+
"author": "Gerrit Halfmann",
26+
"license": "MIT",
27+
"bugs": {
28+
"url": "https://github.com/gitntg/pixelarticons-react/issues"
29+
},
30+
"homepage": "https://github.com/gitntg/pixelarticons-react#readme",
31+
"dependencies": {
32+
"@nsmr/pixelart-react": "^2.0.0"
33+
},
34+
"peerDependencies": {
35+
"react": ">=16.8.0",
36+
"react-dom": ">=16.8.0"
37+
}
38+
}

0 commit comments

Comments
 (0)