@braudypedrosa/bp-listings 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 +21 -0
- package/README.md +152 -0
- package/docs.html +640 -0
- package/index.html +257 -0
- package/listings-map.css +891 -0
- package/listings-map.js +1042 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Braudy Pedrosa
|
|
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,152 @@
|
|
|
1
|
+
# bp-listings
|
|
2
|
+
|
|
3
|
+
Airbnb-style listings + map widget built with vanilla JavaScript and CSS.
|
|
4
|
+
|
|
5
|
+
Current version: **1.0.0**
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`bp-listings` renders a listings grid and interactive map in one widget container.
|
|
10
|
+
It is framework-agnostic, distributed as standalone JS/CSS, and uses Leaflet for map rendering.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Standalone UMD distribution (`ListingsMap.init(...)`)
|
|
15
|
+
- Auto-loads Leaflet CSS/JS when `window.L` is not present
|
|
16
|
+
- Listings cards with image carousel and badges
|
|
17
|
+
- Favorite toggle with callback
|
|
18
|
+
- Click-through callback for listing cards
|
|
19
|
+
- Sort controls (`default`, `price-asc`, `price-desc`)
|
|
20
|
+
- Optional pagination with configurable page size
|
|
21
|
+
- Show/hide map toggle and fullscreen map action
|
|
22
|
+
- Marker-to-card and card-to-marker highlighting behavior
|
|
23
|
+
- Consumer-controlled search slot renderer
|
|
24
|
+
- Runtime methods to update listings and navigate map/pagination state
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### npm
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @braudypedrosa/bp-listings
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import '@braudypedrosa/bp-listings';
|
|
36
|
+
import '@braudypedrosa/bp-listings/styles';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Browser
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<link rel="stylesheet" href="./listings-map.css" />
|
|
43
|
+
<script src="./listings-map.js"></script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<div id="widget" style="width:100%;height:100vh;"></div>
|
|
50
|
+
<script>
|
|
51
|
+
const widget = ListingsMap.init({
|
|
52
|
+
container: '#widget',
|
|
53
|
+
currency: '₱',
|
|
54
|
+
mapOptions: { center: [14.58, 121.05], zoom: 12 },
|
|
55
|
+
listings: [
|
|
56
|
+
{
|
|
57
|
+
id: '1',
|
|
58
|
+
title: 'Apartment in Quezon City',
|
|
59
|
+
price: 13689,
|
|
60
|
+
pricePeriod: 'for 5 nights',
|
|
61
|
+
lat: 14.628,
|
|
62
|
+
lng: 121.055,
|
|
63
|
+
images: ['photo-1.jpg', 'photo-2.jpg']
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
onFavorite: (listing, isFavorited) => {
|
|
67
|
+
console.log(listing.id, isFavorited);
|
|
68
|
+
},
|
|
69
|
+
onListingClick: (listing) => {
|
|
70
|
+
console.log('clicked', listing.id);
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Listing Data Schema
|
|
77
|
+
|
|
78
|
+
Each listing object can include:
|
|
79
|
+
|
|
80
|
+
- `id: string` (required)
|
|
81
|
+
- `title: string` (required)
|
|
82
|
+
- `price: number | string` (required)
|
|
83
|
+
- `lat: number` (required)
|
|
84
|
+
- `lng: number` (required)
|
|
85
|
+
- `subtitle?: string`
|
|
86
|
+
- `details?: string`
|
|
87
|
+
- `dates?: string`
|
|
88
|
+
- `pricePeriod?: string`
|
|
89
|
+
- `tag?: string`
|
|
90
|
+
- `rating?: number`
|
|
91
|
+
- `reviewCount?: number`
|
|
92
|
+
- `badge?: string` (e.g. `Guest favorite`, `Superhost`)
|
|
93
|
+
- `images?: string[]`
|
|
94
|
+
- `favorited?: boolean`
|
|
95
|
+
|
|
96
|
+
## Config Options
|
|
97
|
+
|
|
98
|
+
- `container: HTMLElement | string` (required)
|
|
99
|
+
- `listings: Array<Listing>` default `[]`
|
|
100
|
+
- `currency: string` default `'$'`
|
|
101
|
+
- `mapOptions.center: [number, number]` default `[14.55, 121.03]`
|
|
102
|
+
- `mapOptions.zoom: number` default `12`
|
|
103
|
+
- `tileUrl: string` (OpenStreetMap by default)
|
|
104
|
+
- `tileAttribution: string`
|
|
105
|
+
- `showMapToggle: boolean` default `true`
|
|
106
|
+
- `showSort: boolean` default `true`
|
|
107
|
+
- `showPagination: boolean` default `true`
|
|
108
|
+
- `pageSize: number` default `0` (`0` disables paging)
|
|
109
|
+
- `renderSearchSlot: (containerEl: HTMLElement) => void`
|
|
110
|
+
- `onFavorite: (listing, isFavorited) => void`
|
|
111
|
+
- `onListingClick: (listing) => void`
|
|
112
|
+
- `onMapMoveEnd: ({bounds, center, zoom}) => void`
|
|
113
|
+
|
|
114
|
+
## Public Methods
|
|
115
|
+
|
|
116
|
+
Returned widget instance exposes:
|
|
117
|
+
|
|
118
|
+
- `setListings(listings)`
|
|
119
|
+
- `panToListing(id)`
|
|
120
|
+
- `toggleMap()`
|
|
121
|
+
- `goToPage(pageNumber)`
|
|
122
|
+
- `destroy()`
|
|
123
|
+
|
|
124
|
+
## Styling and Theming
|
|
125
|
+
|
|
126
|
+
All classes are scoped with `.lm-*`.
|
|
127
|
+
|
|
128
|
+
You can customize appearance via CSS variables on `.lm-widget`, including:
|
|
129
|
+
- typography (`--lm-font`)
|
|
130
|
+
- text and border colors
|
|
131
|
+
- badge colors
|
|
132
|
+
- price marker colors
|
|
133
|
+
- radii
|
|
134
|
+
|
|
135
|
+
The included stylesheet is standalone and does not require a CSS framework.
|
|
136
|
+
|
|
137
|
+
## Notes
|
|
138
|
+
|
|
139
|
+
- Leaflet is loaded from `unpkg` automatically if it is not already available on the page.
|
|
140
|
+
- If your app already loads Leaflet, the widget reuses existing `window.L`.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
|
145
|
+
|
|
146
|
+
## Maintainer Workflow
|
|
147
|
+
|
|
148
|
+
Edit source files in this repository:
|
|
149
|
+
- `listings-map.js`
|
|
150
|
+
- `listings-map.css`
|
|
151
|
+
|
|
152
|
+
Then release updates by bumping `package.json` version, tagging (`vX.Y.Z`), and publishing.
|