Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist
docs/public
docs/static/leaflet-html.js*
coverage

*storybook.log
14 changes: 14 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
],
framework: {
name: "@storybook/web-components-vite",
options: {},
},
};
export default config;
15 changes: 15 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""
/>
<style>
l-map {
display: block;
aspect-ratio: 16 / 9;
}
</style>



13 changes: 13 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type { import('@storybook/web-components').Preview } */
const preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
</l-map>

<script type="module">
// import "./src/index.js"
import "./dist/leaflet-html.js"
import "./src/index.js"
</script>
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@
"build": "vite build",
"test": "vitest",
"coverage": "vitest run --coverage",
"coverage:watch": "vitest watch --coverage"
"coverage:watch": "vitest watch --coverage",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.9.0",
"@storybook/addon-essentials": "^8.3.6",
"@storybook/addon-links": "^8.3.6",
"@storybook/blocks": "^8.3.6",
"@storybook/test": "^8.3.6",
"@storybook/web-components": "^8.3.6",
"@storybook/web-components-vite": "^8.3.6",
"@vitest/coverage-v8": "^1.6.0",
"happy-dom": "^14.10.1",
"prettier": "3.2.5",
"storybook": "^8.3.6",
"vite": "^5.4.10",
"vitest": "^1.6.0"
},
Expand Down
7 changes: 7 additions & 0 deletions src/stories/Configure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Meta } from "@storybook/blocks";

<Meta title="Leaflet HTML - Modern Hypermedia!" />

# Leaflet HTML - Modern Hypermedia Maps

Make a modern application using modern web platform techniques!
47 changes: 47 additions & 0 deletions src/stories/DivIcon.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import "../index.js"
import "./divicon.css"


// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
export default {
title: 'Example/DivIcon',
tags: ['autodocs'],
render: ({ className }) => {
let icon = "<l-div-icon></l-div-icon>"
if (className) {
icon = `<l-div-icon class-name=${className}></l-div-icon>`
}
return `<l-marker lat-lng="[55, 0]">${ icon }</l-marker>`
},
argTypes: {
className: { type: "string", description: "HTML attribute **class-name**, passed to Leaflet as **className** option.", control: "select", options: ["none", "red", "blue", "yellow"]},
},
args: {
},
decorators: [(story) => `
<l-map center="[53, 0]" zoom="4">
<l-tile-layer
url-template="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
></l-tile-layer>
${story()}
</l-map>
`],
};

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Default = {
args: {
},
};

export const Red = {
args: {
className: "red"
},
};

export const Blue = {
args: {
className: "blue"
},
};
9 changes: 9 additions & 0 deletions src/stories/divicon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}