@web-portfolio/icons-sanity 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/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @web-portfolio/icons-sanity
2
+
3
+ A [Sanity Studio](https://www.sanity.io) plugin that adds an **icon picker
4
+ field** backed by a bundled library of **622 SVG icons** — so content editors
5
+ can pick an icon by searching a name, tag, or category instead of pasting raw
6
+ SVG markup into every field. Built for portfolio sites, agency/marketing
7
+ sites, and any Sanity project where editors need to attach icons to skills,
8
+ tech stacks, services, or social/contact links — without needing design or
9
+ dev help for every change.
10
+
11
+ [![npm version](https://img.shields.io/npm/v/@web-portfolio/icons-sanity.svg)](https://www.npmjs.com/package/@web-portfolio/icons-sanity)
12
+ [![license](https://img.shields.io/npm/l/@web-portfolio/icons-sanity.svg)](https://github.com/jatinrao/icons/blob/main/LICENSE)
13
+
14
+ ## Why this plugin
15
+
16
+ If you're a **developer** shipping a portfolio or personal-site CMS setup,
17
+ you've probably built a "paste an SVG" field before — it works, but it means
18
+ every content edit needs someone who knows what valid SVG markup looks like.
19
+ This plugin replaces that with a proper picker:
20
+
21
+ - **622 icons out of the box** — tech/tool logos, social platform icons, and
22
+ common communication/navigation icons (see [Icon set](#whats-in-the-icon-set)).
23
+ Editors search by name, tag, or category; no SVG knowledge required.
24
+ - **No API calls from Studio** — the entire icon registry is bundled into the
25
+ plugin at build time, so the picker works offline and loads instantly.
26
+ Nothing is fetched from a database or CDN while editing.
27
+ - **Stores just a name** — the field value is a plain string (`"react"`,
28
+ `"github"`, ...), which pairs directly with
29
+ [`@web-portfolio/icons`](https://www.npmjs.com/package/@web-portfolio/icons)'s
30
+ `<Icon name="..." />` on your frontend — no ID lookups, no asset references.
31
+ - **Live preview** — the currently selected icon renders inline in the form,
32
+ not just its name.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ npm install @web-portfolio/icons-sanity
38
+ ```
39
+
40
+ ```bash
41
+ pnpm add @web-portfolio/icons-sanity
42
+ ```
43
+
44
+ Peer dependencies (already present in any standard Sanity Studio v3 project):
45
+ `sanity >=3`, `@sanity/ui >=2`, `react >=18`, `styled-components >=6`.
46
+
47
+ ## Setup
48
+
49
+ Add the plugin to your Studio config:
50
+
51
+ ```ts
52
+ // sanity.config.ts
53
+ import { defineConfig } from 'sanity'
54
+ import { sanityIconPicker } from '@web-portfolio/icons-sanity'
55
+
56
+ export default defineConfig({
57
+ // ...your existing config
58
+ plugins: [
59
+ // ...your existing plugins
60
+ sanityIconPicker(),
61
+ ],
62
+ })
63
+ ```
64
+
65
+ This registers an `iconRef` schema type you can use on any document or
66
+ object.
67
+
68
+ ## Usage
69
+
70
+ Use `type: 'iconRef'` on any field that should store an icon:
71
+
72
+ ```ts
73
+ // schemaTypes/documents/skill.ts
74
+ import { defineField, defineType } from 'sanity'
75
+
76
+ export default defineType({
77
+ name: 'skill',
78
+ title: 'Skill',
79
+ type: 'document',
80
+ fields: [
81
+ defineField({ name: 'name', type: 'string' }),
82
+ defineField({ name: 'icon', title: 'Icon', type: 'iconRef' }),
83
+ ],
84
+ })
85
+ ```
86
+
87
+ Editors click the field, search ("react", "docker", "mail"...), and select an
88
+ icon from a live-previewed grid. The field stores the icon's name as a plain
89
+ string — e.g. `"react"`.
90
+
91
+ ### Social/contact links example
92
+
93
+ ```ts
94
+ defineField({
95
+ name: 'socialLinks',
96
+ title: 'Social links',
97
+ type: 'array',
98
+ of: [
99
+ defineType({
100
+ type: 'object',
101
+ name: 'socialLink',
102
+ fields: [
103
+ defineField({ name: 'icon', type: 'iconRef' }),
104
+ defineField({ name: 'url', type: 'url' }),
105
+ ],
106
+ }),
107
+ ],
108
+ })
109
+ ```
110
+
111
+ ### Rendering the picked icon on your frontend
112
+
113
+ Pair with [`@web-portfolio/icons`](https://www.npmjs.com/package/@web-portfolio/icons)
114
+ — pass the stored string straight through as `name`:
115
+
116
+ ```tsx
117
+ import { Icon } from '@web-portfolio/icons'
118
+
119
+ function SkillBadge({ skill }: { skill: { name: string; icon: string } }) {
120
+ return (
121
+ <span>
122
+ <Icon name={skill.icon} size={20} />
123
+ {skill.name}
124
+ </span>
125
+ )
126
+ }
127
+ ```
128
+
129
+ ## What's in the icon set
130
+
131
+ 622 icons from three sources, shared with `@web-portfolio/icons`:
132
+
133
+ - **[devicon](https://github.com/devicons/devicon)** (578 icons, MIT) —
134
+ programming languages, frameworks, databases, cloud platforms, dev tools.
135
+ - **[Material Symbols](https://github.com/marella/material-symbols)** (32
136
+ icons, Apache-2.0) — communication and navigation icons (mail, call,
137
+ arrows, menu, close, ...).
138
+ - **[Simple Icons](https://simpleicons.org)** (12 icons, CC0-1.0) — social
139
+ platform logos devicon doesn't cover (Instagram, YouTube, WhatsApp,
140
+ Telegram, TikTok, Discord, ...).
141
+
142
+ ## License
143
+
144
+ MIT — see [LICENSE](https://github.com/jatinrao/icons/blob/main/LICENSE).
145
+ Bundled icon sets keep their original licenses (devicon: MIT, Material
146
+ Symbols: Apache-2.0, Simple Icons: CC0-1.0) — see the
147
+ [repo README](https://github.com/jatinrao/icons#attribution) for full
148
+ attribution.