Skip to content

Commit 0e3b5a4

Browse files
Merge pull request #1 from Chia-Chi-Shen/storybook
Storybook to production
2 parents 3a8a9e1 + 9fbfbbc commit 0e3b5a4

26 files changed

+1160
-110
lines changed

package-lock.json

Lines changed: 254 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"azure-maps-control": "^3.0.1",
6+
"azure-maps-control": "^3.3.0",
77
"react": "^18.2.0",
88
"react-azure-maps": "^1.0.0",
99
"react-dom": "^18.2.0",

src/Storybook.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
width: 700px;
33
height: 300px;
44
}
5+
6+
.atlas-map .azure-map-copyright a {
7+
font-size: 9px;
8+
}

src/Test.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { useContext, useEffect } from 'react';
2+
import { useAzureMaps } from 'react-azure-maps';
3+
import { AzureMapLayerContext, IAzureMapLayerProps } from 'react-azure-maps';
4+
5+
const Test = () => {
6+
const { layerRef } = useContext<IAzureMapLayerProps>(AzureMapLayerContext);
7+
const { mapRef, isMapReady } = useAzureMaps();
8+
9+
const onClick = () => {
10+
console.log(layerRef); // returns undefined
11+
console.log(mapRef?.layers); // this works
12+
};
13+
14+
useEffect(() => {
15+
if (isMapReady) {
16+
console.log('Map is ready');
17+
onClick();
18+
}
19+
}, [isMapReady]);
20+
21+
return (
22+
<button
23+
style={{
24+
width: '50px',
25+
height: '50px',
26+
backgroundColor: 'white',
27+
position: 'relative',
28+
top: '-50px',
29+
left: '-50px',
30+
}}
31+
onClick={onClick}
32+
>
33+
Test
34+
</button>
35+
);
36+
};
37+
38+
export default Test;

src/stories/BasicUsage/MapControls/MapControl.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Source, Meta } from '@storybook/addon-docs/blocks';
22

33
import MapControl, { controls } from './MapControl';
44

5-
<Meta title="Basic Usage/MapControl" />
5+
<Meta title="Basic Usage/Map Control" />
66

77
# MapControl
88
These examples show all the map navigation controls on the map and how to customize different option settings.

src/stories/BasicUsage/MapStyles/MapStyles.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Your_Component = () => {
1818
showLabels: false,
1919
showLogo: false,
2020
renderWorldCopies: false,
21+
showFeedbackLink: false,
2122
}}
2223
></AzureMap>
2324
</AzureMapsProvider>

src/stories/BasicUsage/MapStyles/MapStyles.stories.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ export const Example: Story = {
3737
showLabels: true,
3838
showLogo: true,
3939
renderWorldCopies: true,
40+
showFeedbackLink: true,
4041
},
4142
};

src/stories/BasicUsage/MapStyles/MapStyles.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ export interface MapStylesProps {
55
showLogo?: boolean;
66
showLabels?: boolean;
77
renderWorldCopies?: boolean;
8+
showFeedbackLink?: boolean;
89
}
910

10-
const MapStyles = ({ showLabels, showLogo, renderWorldCopies }: MapStylesProps) => {
11+
const MapStyles = ({ showLabels, showLogo, renderWorldCopies, showFeedbackLink }: MapStylesProps) => {
1112
return (
1213
<div className="defaultMap">
1314
<AzureMapsProvider>
1415
<AzureMap
1516
options={mapOptions}
1617
styleOptions={{
17-
showLabels: showLabels,
18-
showLogo: showLogo,
19-
renderWorldCopies: renderWorldCopies,
18+
showLabels,
19+
showLogo,
20+
renderWorldCopies,
21+
showFeedbackLink,
2022
}}
2123
></AzureMap>
2224
</AzureMapsProvider>

src/stories/DataVisualization/BubbleLayer/BubbleLayer.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Canvas, Meta, Source } from '@storybook/blocks';
22

3-
import { code } from './code';
4-
53
import * as BubbleLayerStories from './BubbleLayer.stories';
64

75
import BubbleLayer from './BubbleLayer';
@@ -19,8 +17,6 @@ For more available properties, see the documentation [BubbleLayerOptions](https:
1917
{/* <Canvas of={BubbleLayerStories.Example} sourceState="none" /> */}
2018

2119
<Source code={`
22-
import { AzureMapLayerProvider } from 'react-azure-maps';
23-
2420
<AzureMapLayerProvider
2521
type="BubbleLayer"
2622
options={{

src/stories/DataVisualization/BubbleLayer/BubbleLayer.stories.ts

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import BubbleLayer from './BubbleLayer';
3-
import { code } from './code';
43

54
const meta: Meta<typeof BubbleLayer> = {
65
title: 'Data Visualization/Bubble Layer',
76
component: BubbleLayer,
87
parameters: {
98
layout: 'centered',
109
storySource: {
11-
source: code,
10+
source: `import { AzureMap, AzureMapsProvider, AzureMapDataSourceProvider, AzureMapLayerProvider } from 'react-azure-maps';
11+
import atlas, { BubbleLayerOptions } from 'azure-maps-control';
12+
13+
// Generate random points to build the data source for the BubbleLayer.
14+
const collection = generateRandomPoints();
15+
16+
const BubbleLayer = () => {
17+
<AzureMapsProvider>
18+
<div className="defaultMap">
19+
<AzureMap options={your_options}>
20+
21+
<AzureMapDataSourceProvider
22+
id="BubbleLayer DataSourceProvider"
23+
collection={collection}>
24+
<AzureMapLayerProvider
25+
type="BubbleLayer"
26+
options={{
27+
radius: 10,
28+
color: 'DodgerBlue',
29+
opacity: 1,
30+
strokeColor: 'DarkBlue',
31+
strokeWidth: 2,
32+
strokeOpacity: 1,
33+
blur: 0,
34+
}}
35+
/>
36+
</AzureMapDataSourceProvider>
37+
38+
</AzureMap>
39+
</div>
40+
</AzureMapsProvider>
41+
);
42+
};
43+
44+
function generateRandomPoints() {
45+
var layerData = [];
46+
47+
for (var i = 0; i < 50; i++) {
48+
layerData.push(
49+
new atlas.data.Feature(new atlas.data.Point([Math.random() * 360 - 180, Math.random() * 170 - 85]), {
50+
title: 'Pin_' + i,
51+
}),
52+
);
53+
}
54+
55+
return layerData;
56+
}
57+
58+
`,
1259
},
1360
},
1461
args: {
@@ -31,7 +78,4 @@ export default meta;
3178

3279
type Story = StoryObj<typeof BubbleLayer>;
3380

34-
export const Example: Story = {
35-
name: 'Example',
36-
args: {},
37-
};
81+
export const Example: Story = {};

0 commit comments

Comments
 (0)