33 |
34 |
35 |
Hovered: {hovered && {hovered}
}
36 |
Focused: {focused && {focused}
}
37 |
Clicked: {clicked && {clicked}
}
38 |
39 | );
40 | }`,
41 | },
42 | {
43 | title: 'Styling a map',
44 | description: `This example uses [styled-components](https://www.styled-components.com/) for css-in-js styling but you can use any css styling method you want.`,
45 | scope: { nzMap, styled },
46 | exampleProps: { noInline: true },
47 | code: `const Map = styled.div\`
48 | margin: 1rem auto;
49 | width: 300px;
50 |
51 | svg {
52 | stroke: #fff;
53 |
54 | // All layers are just path elements
55 | path {
56 | fill: #a82b2b;
57 | cursor: pointer;
58 | outline: none;
59 |
60 | // When a layer is hovered
61 | &:hover {
62 | fill: ${rgba('#a82b2b', 0.83)};
63 | }
64 |
65 | // When a layer is focused.
66 | &:focus {
67 | fill: ${rgba('#a82b2b', 0.6)};
68 | }
69 |
70 | // When a layer is 'checked' (via checkedLayers prop).
71 | &[aria-checked='true'] {
72 | fill: ${rgba('#382ba8', 1)};
73 | }
74 |
75 | // When a layer is 'selected' (via currentLayers prop).
76 | &[aria-current='true'] {
77 | fill: ${rgba('#382ba8', 0.83)};
78 | }
79 |
80 | // You can also highlight a specific layer via it's id
81 | &[id="nz-can"] {
82 | fill: ${rgba('#382ba8', 0.6)};
83 | }
84 | }
85 | }
86 | \`;
87 |
88 | render(
89 |
57 | -
58 |
React Vector Maps
59 |
60 | A React component for creating simple maps with interactive elements, 100+ maps ready for use and an
61 | online SVG to JSON converter for creating new maps.
62 |
63 |
64 |
65 | -
66 |
67 |
68 |
69 | }
70 | >
71 | 👋 Welcome!
72 |
73 | Below you'll find a getting start guide for using the package in your app.
74 | There is also a collection of 100+ maps that are ready to use with the component.
75 |
76 |
77 | You might be interested in some examples of how the component can be used and note
78 | that you can also turn your own SVG into a valid map with our converter.
79 |
80 | Stars on the project are always appreciated! 🙂
81 |
82 | To report an issue or contribute to the project please visit our{' '}
83 | Github.
84 |
85 |
86 |
87 |
88 | Getting started
89 | Install the package with either
90 |
91 | -
92 |
npm i @south-paw/react-vector-maps
93 |
94 | -
95 |
yarn add @south-paw/react-vector-maps
96 |
97 |
98 | You can then use the component as follows
99 |
100 | {`import { VectorMap } from '@south-paw/react-vector-maps';`}
101 |
102 |
103 | The VectorMap
component accepts a correctly structured object being spread onto it.
104 |
105 |
106 | You can download and save a valid JSON object from the maps page or you can create your
107 | own using our online SVG to JSON converter.
108 |
109 | When you've got your map file, just import it and then combine it with the component as follows:
110 | ;
115 | }
116 | }`}
117 | scope={{ VectorMap, worldLowRes }}
118 | />
119 |
120 | );
121 | }
122 |
--------------------------------------------------------------------------------
/docs/src/pages/maps.tsx:
--------------------------------------------------------------------------------
1 | import { graphql, HeadProps, Link, PageProps } from 'gatsby';
2 | import React from 'react';
3 | import { Layout } from '../components/Layout';
4 | import { Seo } from '../components/Seo';
5 |
6 | export function Head(props: HeadProps) {
7 | return