datocms-plugin-lucide-icon-selector 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Seppe Alaerts
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.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # DatoCMS Icon Selector Plugin
2
+
3
+ A custom field extension for DatoCMS that provides a searchable icon selector using [Lucide Icons](https://lucide.dev/).
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Visual Icon Selection**: Browse and select from hundreds of Lucide icons with visual previews
8
+ - 🔍 **Search Functionality**: Quickly find icons by typing their name
9
+ - 💾 **Simple Storage**: Icons are stored as string values (icon names) that you can use with the Lucide React library
10
+ - 🎯 **Easy Integration**: Can be manually assigned to any string field in the DatoCMS schema editor
11
+ - ✨ **Modern UI**: Clean, intuitive interface that adapts to DatoCMS light and dark mode
12
+ - 🎛️ **Per-field Icon Filtering**: Restrict which icons are available per field via the field configuration screen
13
+ - 🔧 **Manual Assignment**: Can be manually assigned to any string field in the DatoCMS schema editor
14
+
15
+ ## Installation
16
+
17
+ 1. Install the plugin in your DatoCMS project:
18
+
19
+ - Go to your DatoCMS project settings
20
+ - Navigate to Plugins
21
+ - Click "Add plugin" and select this plugin
22
+
23
+ 2. Or install via npm (for development):
24
+ ```bash
25
+ npm install
26
+ ```
27
+
28
+ ## Setting up a field
29
+
30
+ Assign the **Lucide Icon Selector** editor to any string field via the DatoCMS schema editor:
31
+
32
+ 1. Create a **String** field in your DatoCMS model
33
+ 2. In the field's **Presentation** settings, look for the **Editor** dropdown
34
+ 3. Select **Lucide Icon Selector** from the list of available editors
35
+ 4. Optionally click the gear icon ⚙ to configure which icons are pickable
36
+
37
+ ### Per-field Icon Filtering
38
+
39
+ When you manually assign the Lucide Icon Selector to a string field, you can configure exactly which icons are available for selection:
40
+
41
+ 1. In the field's **Presentation** settings, select **Lucide Icon Selector** as the editor
42
+ 2. Click the gear icon ⚙ next to the editor name
43
+ 3. The configuration screen opens showing all available Lucide icons
44
+ 4. **Search** for specific icons by name
45
+ 5. **Toggle** individual icons to whitelist them
46
+ 6. Use **Select all filtered** to bulk-select visible icons, or **Clear all** to reset the selection
47
+ 7. Save your changes
48
+
49
+ When icons are whitelisted, content editors can only pick from the configured set. If no icons are whitelisted, all Lucide icons are available.
50
+
51
+ To reset the whitelist back to "all icons", clear the configuration settings for that field.
52
+
53
+ ### Using the selected icon in your application
54
+
55
+ The plugin stores the icon name as a string. Use it with the Lucide React library:
56
+
57
+ ```tsx
58
+ import { Heart, Star, User } from "lucide-react";
59
+
60
+ // Get the icon name from DatoCMS
61
+ const iconName = record.icon; // e.g., "Heart"
62
+
63
+ // Use it in your component
64
+ const IconComponent = { Heart, Star, User }[iconName];
65
+ return <IconComponent size={24} />;
66
+ ```
67
+
68
+ Or dynamically:
69
+
70
+ ```tsx
71
+ import * as LucideIcons from "lucide-react";
72
+
73
+ const iconName = record.icon;
74
+ const IconComponent = LucideIcons[iconName as keyof typeof LucideIcons];
75
+ return IconComponent ? <IconComponent size={24} /> : null;
76
+ ```
77
+
78
+ ## How It Works
79
+
80
+ The plugin works by:
81
+
82
+ 1. **Custom Editor**: Replaces the default text input with a custom icon selector when manually assigned to a string field
83
+ 2. **Icon Loading**: Dynamically loads and displays all available Lucide icons
84
+ 3. **Search & Filter**: Provides real-time search to filter through hundreds of icons
85
+ 4. **Per-field Configuration**: The field-level configuration screen lets you whitelist specific icons per field
86
+ 5. **Theme Adaptation**: The plugin automatically adapts to DatoCMS light and dark mode via the built-in `Canvas` component and native CSS custom properties
87
+ 6. **Value Storage**: Stores the selected icon name as a string value in DatoCMS
88
+
89
+ ## Development
90
+
91
+ ### Prerequisites
92
+
93
+ - Node.js 18+
94
+ - npm or yarn
95
+
96
+ ### Setup
97
+
98
+ ```bash
99
+ # Install dependencies
100
+ npm install
101
+
102
+ # Start development server
103
+ npm run dev
104
+
105
+ # Build for production
106
+ npm run build
107
+
108
+ # Preview production build
109
+ npm run preview
110
+ ```
111
+
112
+ ### Project Structure
113
+
114
+ ```
115
+ src/
116
+ ├── entrypoints/
117
+ │ ├── ConfigScreen.tsx # Plugin configuration screen
118
+ │ ├── FieldExtensionConfigScreen.tsx # Per-field icon filtering config screen
119
+ │ ├── IconSelectField.tsx # Main icon selector field component
120
+ │ └── styles.module.css # Component styles
121
+ ├── utils/
122
+ │ ├── lucideIcons.ts # Lucide icon names utility
123
+ │ └── render.tsx # React rendering utility
124
+ └── main.tsx # Plugin entry point
125
+ ```
126
+
127
+ ## License
128
+
129
+ MIT License - see [LICENSE](LICENSE) file for details.
130
+
131
+ ## Contributing
132
+
133
+ Contributions are welcome! Please feel free to submit a Pull Request.
134
+
135
+ ## Support
136
+
137
+ For issues, questions, or feature requests, please open an issue on the GitHub repository.