trainfyi-embed 1.0.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) 2026 FYIPedia
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,184 @@
1
+ # trainfyi-embed
2
+
3
+ [![npm](https://img.shields.io/npm/v/trainfyi-embed)](https://www.npmjs.com/package/trainfyi-embed)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue)](https://www.typescriptlang.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://www.npmjs.com/package/trainfyi-embed)
7
+
8
+ Embed **TrainFYI** widgets — stations, glossary terms, interactive tools, and inline elements — on any website. **6 widget types**, zero dependencies, Shadow DOM style isolation, 4 built-in themes (light, dark, sepia, auto), 2 styles (modern, clean), and live data from the [TrainFYI](https://trainfyi.com) database.
9
+
10
+ Every widget includes a "Powered by TrainFYI" backlink directing readers to the full reference.
11
+
12
+ > **Try the interactive widget builder at [widget.trainfyi.com](https://widget.trainfyi.com)**
13
+
14
+ ## Quick Start
15
+
16
+ ```html
17
+ <!-- Place widget div where you want it to appear -->
18
+ <div data-trainfyi="entity" data-slug="stations" data-theme="light"></div>
19
+
20
+ <!-- Load the embed script once, anywhere on the page -->
21
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
22
+ ```
23
+
24
+ That's it. The widget fetches data from the TrainFYI API and renders with full style isolation.
25
+
26
+ ## Widget Types
27
+
28
+ | Type | Usage | Description |
29
+ |------|-------|-------------|
30
+ | `entity` | `<div data-trainfyi="entity" data-slug="..."></div>` | Entity detail card — airport, airline, aircraft, or station |
31
+ | `faq` | `<div data-trainfyi="faq" data-slug="..."></div>` | FAQ accordion with expand/collapse |
32
+ | `search` | `<div data-trainfyi="search" data-slug="..."></div>` | Search box linking to the full database |
33
+ | `compare` | `<div data-trainfyi="compare" data-slug="..."></div>` | Side-by-side entity comparison |
34
+ | `type-badge` | `<div data-trainfyi="type-badge" data-slug="..."></div>` | Inline station type badge (e.g. "Terminal", "Junction") |
35
+ | `amenities` | `<div data-trainfyi="amenities" data-slug="..."></div>` | Inline amenities strip showing station facilities |
36
+
37
+ ## Widget Options
38
+
39
+ | Attribute | Values | Default | Description |
40
+ |-----------|--------|---------|-------------|
41
+ | `data-trainfyi` | entity, faq, search, compare, [tools] | required | Widget type |
42
+ | `data-slug` | e.g. "stations" | — | Entity slug from the TrainFYI database |
43
+ | `data-theme` | light, dark, sepia, auto | light | Visual theme (`auto` follows OS preference) |
44
+ | `data-style` | modern, clean | modern | Widget design style |
45
+ | `data-size` | default, compact, large | default | Widget size |
46
+ | `data-placeholder` | any string | "Search Stations..." | Search box placeholder |
47
+
48
+ ## Themes
49
+
50
+ ```html
51
+ <!-- Light (default) -->
52
+ <div data-trainfyi="entity" data-slug="stations" data-theme="light"></div>
53
+
54
+ <!-- Dark -->
55
+ <div data-trainfyi="entity" data-slug="stations" data-theme="dark"></div>
56
+
57
+ <!-- Sepia -->
58
+ <div data-trainfyi="entity" data-slug="stations" data-theme="sepia"></div>
59
+
60
+ <!-- Auto — follows OS dark/light preference -->
61
+ <div data-trainfyi="entity" data-slug="stations" data-theme="auto"></div>
62
+ ```
63
+
64
+ ## Styles
65
+
66
+ ```html
67
+ <!-- Modern (default) — clean lines, rounded corners, accent gradients -->
68
+ <div data-trainfyi="entity" data-slug="stations" data-style="modern"></div>
69
+
70
+ <!-- Clean — minimal borders, utility-focused, data-first aesthetic -->
71
+ <div data-trainfyi="entity" data-slug="stations" data-style="clean"></div>
72
+ ```
73
+
74
+ ## Web Components (Custom Elements)
75
+
76
+ As an alternative to `data-*` attributes, you can use native HTML custom elements:
77
+
78
+ ```html
79
+ <!-- Custom element form -->
80
+ <trainfyi-entity slug="stations" theme="light"></trainfyi-entity>
81
+ <trainfyi-compare slugs="stations,other-slug"></trainfyi-compare>
82
+ <trainfyi-search placeholder="Search Stations..."></trainfyi-search>
83
+
84
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
85
+ ```
86
+
87
+ Use `style-variant` (not `style`) to avoid conflicts with the HTML reserved `style` attribute.
88
+
89
+ ## Examples
90
+
91
+ ### Entity Card
92
+
93
+ ```html
94
+ <div data-trainfyi="entity" data-slug="stations" data-theme="light"></div>
95
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
96
+ ```
97
+
98
+ ### Side-by-Side Comparison
99
+
100
+ ```html
101
+ <div data-trainfyi="compare" data-slugs="stations,other-slug"></div>
102
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
103
+ ```
104
+
105
+ ### Search Box
106
+
107
+ ```html
108
+ <div data-trainfyi="search" data-placeholder="Search Stations..."></div>
109
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
110
+ ```
111
+
112
+ ## CDN Options
113
+
114
+ ### jsDelivr (recommended — global CDN, auto-updates with npm)
115
+
116
+ ```html
117
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1/dist/embed.min.js"></script>
118
+ ```
119
+
120
+ ### Specific version (production stability)
121
+
122
+ ```html
123
+ <script src="https://cdn.jsdelivr.net/npm/trainfyi-embed@1.0.0/dist/embed.min.js"></script>
124
+ ```
125
+
126
+ ### npm (for bundlers)
127
+
128
+ ```bash
129
+ npm install trainfyi-embed
130
+ ```
131
+
132
+ ```javascript
133
+ import 'trainfyi-embed';
134
+ ```
135
+
136
+ ## Technical Details
137
+
138
+ - **Shadow DOM**: Complete style isolation — no CSS conflicts with your site
139
+ - **Zero dependencies**: No jQuery, React, or any external library
140
+ - **2 styles**: Modern (accent gradients) and Clean (minimal, data-first)
141
+ - **4 themes**: Light, Dark, Sepia, Auto (OS preference detection)
142
+ - **CORS**: TrainFYI API has CORS enabled for all origins
143
+ - **MutationObserver**: Works with dynamically added elements (SPAs)
144
+ - **IntersectionObserver**: Lazy loading — widgets only fetch when entering viewport (200px margin)
145
+ - **Rich Snippets**: DefinedTerm JSON-LD injected for glossary widgets
146
+ - **Bundle size**: Tree-shaken per site — only includes tools available on TrainFYI
147
+
148
+ ## Learn More About Stations
149
+
150
+ Visit [trainfyi.com](https://trainfyi.com) — TrainFYI is a comprehensive stations reference with interactive tools, guides, and developer resources.
151
+
152
+ - **API docs**: [trainfyi.com/developers/](https://trainfyi.com/developers/)
153
+ - **Widget builder**: [widget.trainfyi.com](https://widget.trainfyi.com)
154
+ - **npm package**: [npmjs.com/package/trainfyi-embed](https://www.npmjs.com/package/trainfyi-embed)
155
+ - **GitHub**: [github.com/fyipedia/trainfyi-embed](https://github.com/fyipedia/trainfyi-embed)
156
+
157
+ ## Transport FYI Family
158
+
159
+ Part of [FYIPedia](https://fyipedia.com) — open-source developer tools ecosystem. Transport FYI covers airports, airlines, aircraft, and railway networks. Hub: [transitfyi.com](https://transitfyi.com).
160
+
161
+ | Site | Domain | Focus | Package |
162
+ |------|--------|-------|---------|
163
+ | AirportFYI | [airportfyi.com](https://airportfyi.com) | 71,631 airports, IATA/ICAO codes, runways, routes | [npm](https://www.npmjs.com/package/airportfyi-embed) |
164
+ | AirlineFYI | [airlinefyi.com](https://airlinefyi.com) | 6,161 airlines, fleets, alliances, routes | [npm](https://www.npmjs.com/package/airlinefyi-embed) |
165
+ | PlaneFYI | [planefyi.com](https://planefyi.com) | 81 aircraft types, specs, manufacturers, fleet data | [npm](https://www.npmjs.com/package/planefyi-embed) |
166
+ | **TrainFYI** | [trainfyi.com](https://trainfyi.com) | 51,425 stations, operators, route pairs | **[npm](https://www.npmjs.com/package/trainfyi-embed)** |
167
+
168
+ ## FYIPedia Developer Tools
169
+
170
+ | Package | PyPI | npm | Description |
171
+ |---------|------|-----|-------------|
172
+ | colorfyi | [PyPI](https://pypi.org/project/colorfyi/) | [npm](https://www.npmjs.com/package/@fyipedia/colorfyi) | Color conversion, WCAG contrast, harmonies — [colorfyi.com](https://colorfyi.com) |
173
+ | emojifyi | [PyPI](https://pypi.org/project/emojifyi/) | [npm](https://www.npmjs.com/package/emojifyi) | Emoji encoding & metadata for 3,953 emojis — [emojifyi.com](https://emojifyi.com) |
174
+ | unitfyi | [PyPI](https://pypi.org/project/unitfyi/) | [npm](https://www.npmjs.com/package/unitfyi) | Unit conversion, 220 units — [unitfyi.com](https://unitfyi.com) |
175
+ | timefyi | [PyPI](https://pypi.org/project/timefyi/) | [npm](https://www.npmjs.com/package/timefyi) | Timezone ops & business hours — [timefyi.com](https://timefyi.com) |
176
+ | holidayfyi | [PyPI](https://pypi.org/project/holidayfyi/) | [npm](https://www.npmjs.com/package/holidayfyi) | Holiday dates & Easter calculation — [holidayfyi.com](https://holidayfyi.com) |
177
+ | namefyi | [PyPI](https://pypi.org/project/namefyi/) | [npm](https://www.npmjs.com/package/namefyi) | Korean romanization & Five Elements — [namefyi.com](https://namefyi.com) |
178
+ | fyipedia | [PyPI](https://pypi.org/project/fyipedia/) | — | Unified CLI for all FYI tools — [fyipedia.com](https://fyipedia.com) |
179
+
180
+ ## License
181
+
182
+ MIT — see [LICENSE](./LICENSE).
183
+
184
+ Built with care by [FYIPedia](https://fyipedia.com).