@ingredient-icons/core 0.2.0 → 0.3.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 CHANGED
@@ -1,45 +1,107 @@
1
- # @ingredient-icons/core
1
+ <p align="center">
2
+ <a href="https://ingredient-icons.vercel.app">
3
+ <img alt="Ingredient Icons: an icon for every ingredient" src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/.github/assets/banner-light.webp" width="100%">
4
+ </a>
5
+ </p>
2
6
 
3
- Soft 3D icons for cooking ingredients, keyed by the [Open Food Facts ingredients taxonomy](https://wiki.openfoodfacts.org/Global_taxonomies). An ingredient without its own icon gets its closest ancestor's: cherry tomatoes get the tomato, lardons get bacon.
7
+ <p align="center">
8
+ <b>265 soft 3D icons for recipe apps, keyed by the Open Food Facts taxonomy.</b><br>
9
+ Shallots, crème fraîche, salt and pepper each get their own, and anything else borrows its closest parent's.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://ingredient-icons.vercel.app"><b>Website</b></a> ·
14
+ <a href="https://ingredient-icons.vercel.app/docs">Docs</a> ·
15
+ <a href="https://ingredient-icons.vercel.app/icons">Browse the icons</a> ·
16
+ <a href="https://github.com/EBf-Studio/ingredient-icons">GitHub</a> ·
17
+ <a href="https://github.com/EBf-Studio/ingredient-icons/issues/new">Request an icon</a>
18
+ </p>
19
+
20
+ ## Emojis run out at the onion
21
+
22
+ There is no emoji for a shallot, and 🧂 has to stand in for salt and pepper. A recipe shows each ingredient as what it is.
23
+
24
+ | Emoji | Ingredient Icons |
25
+ | :---: | --- |
26
+ | 🧅 | <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_onion.png" width="56" alt="Onion"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_red-onion.png" width="56" alt="Red onion"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_shallot.png" width="56" alt="Shallot"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_spring-onion.png" width="56" alt="Spring onion"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_leek.png" width="56" alt="Leek"> |
27
+ | 🧂 | <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_salt.png" width="56" alt="Salt"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_black-pepper.png" width="56" alt="Black pepper"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_white-pepper.png" width="56" alt="White pepper"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_pink-peppercorn.png" width="56" alt="Pink peppercorn"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_celery-salt.png" width="56" alt="Celery salt"> |
28
+ | 🧀 | <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_brie.png" width="56" alt="Brie"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_feta.png" width="56" alt="Feta"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_roquefort.png" width="56" alt="Roquefort"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_mozzarella.png" width="56" alt="Mozzarella"> <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_parmigiano-reggiano.png" width="56" alt="Parmigiano Reggiano"> |
29
+
30
+ ## Quick start
4
31
 
5
32
  ```sh
6
33
  npm install @ingredient-icons/core
7
34
  ```
8
35
 
36
+ Pass the Open Food Facts id your recipe already stores, get back an image URL:
37
+
38
+ ```tsx
39
+ import { iconUrl } from "@ingredient-icons/core"
40
+
41
+ export function Ingredient({ id, quantity, name }) {
42
+ return (
43
+ <li>
44
+ <img src={iconUrl(id)} alt="" width={40} height={40} />
45
+ {quantity} {name}
46
+ </li>
47
+ )
48
+ }
49
+
50
+ <Ingredient id="en:cherry-tomato" quantity="250 g" name="cherry tomatoes" />
51
+ ```
52
+
53
+ URLs point to the exact release you installed on jsDelivr, so icons never change under you. Pass `baseUrl` to serve them from your own CDN or app bundle. Works in React, React Native, Node, Bun, Deno and anything else that shows images, with TypeScript types included.
54
+
9
55
  ```ts
10
56
  import { findIcon, iconName, iconUrl } from "@ingredient-icons/core"
11
57
 
12
- iconUrl("en:shallot") // https://cdn.jsdelivr.net/npm/@ingredient-icons/core@<version>/icons/webp/128/en_shallot.webp
13
- iconUrl("en:cherry-tomato", { size: 64 }) // the tomato's icon
14
- findIcon("en:cherry-tomato") // { id: "en:tomato", file: "en_tomato", exact: false }
15
- iconName("en:shallot", "fr") // "échalote"
58
+ iconUrl("en:shallot", { size: 256 })
59
+ // https://cdn.jsdelivr.net/npm/@ingredient-icons/core@<version>/icons/webp/256/en_shallot.webp
60
+
61
+ findIcon("en:cherry-tomato") // { id: "en:tomato", file: "en_tomato", exact: false }
62
+ iconName("en:shallot", "fr") // "échalote"
63
+ findIcon("en:unicorn-steak") // undefined: show your own placeholder
16
64
  ```
17
65
 
18
- Icons ship as transparent WebP in 64, 128 and 256 px, under `icons/webp/{size}/`. URLs default to the jsDelivr CDN, pinned to the installed version.
66
+ [React](https://ingredient-icons.vercel.app/docs/guides/react) · [React Native](https://ingredient-icons.vercel.app/docs/guides/react-native) · [Next.js](https://ingredient-icons.vercel.app/docs/guides/nextjs) · [Self-hosting](https://ingredient-icons.vercel.app/docs/guides/self-hosting) · [Without npm](https://ingredient-icons.vercel.app/docs/guides/without-npm) · [API reference](https://ingredient-icons.vercel.app/docs/reference/api)
19
67
 
20
- ## Serving the files yourself
68
+ ## No icon of its own? It borrows its parent's
21
69
 
22
- Expose the package's `icons/` folder and pass `{ baseUrl }`. With Express:
70
+ Ids follow the Open Food Facts taxonomy, which knows that fleur de sel is a sea salt and sea salt is a salt. When an ingredient has no icon, `findIcon` walks up its parents and takes the first one that has. That's how **265 icons cover 2,843 ingredients**.
23
71
 
24
- ```ts
25
- import { createRequire } from "node:module"
26
- import path from "node:path"
27
- import express from "express"
28
- import { iconUrl } from "@ingredient-icons/core"
72
+ <p>
73
+ <code>en:fleur-de-sel</code> → <code>en:sea-salt</code> → <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_salt.png" width="40" alt="" align="center"> <code>en:salt</code><br>
74
+ <code>en:cherry-tomato</code> → <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_tomato.png" width="40" alt="" align="center"> <code>en:tomato</code>
75
+ </p>
76
+
77
+ Try it with any ingredient [on the website](https://ingredient-icons.vercel.app).
29
78
 
30
- const root = path.dirname(createRequire(import.meta.url).resolve("@ingredient-icons/core/package.json"))
31
- const app = express()
32
- app.use("/ingredient-icons/icons", express.static(path.join(root, "icons"), { immutable: true, maxAge: "1y" }))
79
+ The taxonomy is pinned to one [openfoodfacts-server release](https://github.com/openfoodfacts/openfoodfacts-server/releases), exported as `TAXONOMY_RELEASE` (and its commit as `TAXONOMY_COMMIT`). If your own Open Food Facts data comes from a release too, a test can check that both match, so your ids are the ones the package knows:
33
80
 
34
- iconUrl("en:shallot", { baseUrl: "https://api.example.com/ingredient-icons" })
81
+ ```ts
82
+ import { TAXONOMY_RELEASE } from "@ingredient-icons/core"
83
+
84
+ expect(TAXONOMY_RELEASE).toBe("v2.118.0")
35
85
  ```
36
86
 
37
- An icon can change between versions: if you cache forever, put the package version (`VERSION`) in the path.
87
+ ## What's in the package
88
+
89
+ Transparent WebP in 64, 128 and 256 px, under `icons/webp/{size}/`. 128 px covers a 40 pt icon on a 3× screen; 256 px covers almost everything else. Names come in English and French, from Open Food Facts.
90
+
91
+ To serve the files yourself, expose the package's `icons/` folder and pass `{ baseUrl }`: see the [self-hosting guide](https://ingredient-icons.vercel.app/docs/guides/self-hosting). PNG up to 512 px, `manifest.json` and `taxonomy.json` are in the [GitHub repository](https://github.com/EBf-Studio/ingredient-icons).
92
+
93
+ ## Missing an ingredient?
94
+
95
+ New icons ship in batches. [Open an issue](https://github.com/EBf-Studio/ingredient-icons/issues/new) with the Open Food Facts id (`en:yuzu`) or the name of the ingredient, and it goes on the list.
38
96
 
39
97
  ## Licenses
40
98
 
41
- - Icons: CC0 1.0, public domain. Created with Grok.
42
- - Taxonomy data (parents and names): Open Food Facts, ODbL 1.0. Not affiliated with Open Food Facts.
43
- - Code: MIT.
99
+ - Icons: [CC0 1.0](https://github.com/EBf-Studio/ingredient-icons/blob/main/LICENSE-ICONS). Created with Grok. No attribution required, a link back is appreciated.
100
+ - Taxonomy data (parents and names): Open Food Facts, [ODbL 1.0](https://opendatacommons.org/licenses/odbl/1-0/). This project is not affiliated with Open Food Facts.
101
+ - Code: [MIT](https://github.com/EBf-Studio/ingredient-icons/blob/main/LICENSE).
44
102
 
45
- By [Marmalade](https://try-marmalade.com).
103
+ <p align="center">
104
+ <br>
105
+ <img src="https://raw.githubusercontent.com/EBf-Studio/ingredient-icons/main/icons/png/128/en_avocado.png" width="48" alt=""><br>
106
+ Made by <a href="https://try-marmalade.com">Marmalade</a>
107
+ </p>
package/dist/data.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export declare const VERSION = "0.2.0";
1
+ export declare const VERSION = "0.3.0";
2
2
  export declare const STYLE = 1;
3
3
  export declare const SIZES: readonly [64, 128, 256];
4
- export declare const TAXONOMY_COMMIT = "0a430a851cbab2a57ef896e3bd41647ca823dbbb";
4
+ export declare const TAXONOMY_RELEASE = "v2.118.0";
5
+ export declare const TAXONOMY_COMMIT = "bd90d81d0353bf2af1474a9079b6fc2a51ac63d7";
5
6
  /** File name of each id that has its own icon. */
6
7
  export declare const FILES: Readonly<Record<string, string>>;
7
8
  /** Parents of every Open Food Facts taxonomy entry. Open Food Facts data, ODbL 1.0. */