From 3b9ef4946ff92aef4ff501542e49dcb2c36b11c1 Mon Sep 17 00:00:00 2001 From: Thomas Simmer Date: Tue, 12 Mar 2024 17:41:05 +0100 Subject: [PATCH] Customize both end and start shapes + disabling system more explicit --- README.md | 10 +- example/App.tsx | 6 +- example/EighthExample.tsx | 2 +- example/NinthExample.tsx | 4 +- example/TenthExample.tsx | 101 ++++++++++ .../ArcherContainer.constants.ts | 2 +- .../ArcherContainer.helpers.tsx | 35 ++-- src/ArcherContainer/ArcherContainer.tsx | 25 ++- src/ArcherContainer/ArcherContainer.types.ts | 15 +- .../__tests__/ArcherContainer.test.tsx | 51 ++++- .../ArcherContainer.test.tsx.snap | 129 +++++++++++-- src/ArcherContainer/components/Markers.tsx | 177 ++++++++++++------ src/ArcherContainer/components/SvgArrows.tsx | 27 +-- src/SvgArrow/SvgArrow.test.tsx | 21 ++- src/SvgArrow/SvgArrow.tsx | 29 ++- .../Archer-integration.test.tsx.snap | 12 +- src/types.ts | 5 +- 17 files changed, 491 insertions(+), 160 deletions(-) create mode 100644 example/TenthExample.tsx diff --git a/README.md b/README.md index 7d29a67..5ee86dc 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,10 @@ export default App; | `offset` | `number` | Optional number for space between element and start/end of stroke | `svgContainerStyle` | `Style` | Style of the SVG container element. Useful if you want to add a z-index to your SVG container to draw the arrows under your elements, for example. | `children` | `React.Node` | +| `startShape` | `Object` | An object containing the props to configure the "start shape" of the arrow. Can be one of `arrow` (default) or `circle`. See [`ShapeType`](flow-typed/archer-types.js) for a complete list of available options. | `endShape` | `Object` | An object containing the props to configure the "end shape" of the arrow. Can be one of `arrow` (default) or `circle`. See [`ShapeType`](flow-typed/archer-types.js) for a complete list of available options. -| `startMarker` | `boolean` | Optional flag (default `false`) to also add a marker at the start of the arrow. -| `endMarker` | `boolean` | Optional flag (default `true`) to remove the marker at the end of the arrow. +| `enableStartMarker` | `boolean` | Optional flag (default `false`) to also add a marker at the start of the arrow. +| `enableEndMarker` | `boolean` | Optional flag (default `true`) to remove the marker at the end of the arrow. #### Instance methods @@ -144,9 +145,10 @@ The `ArcherStyle` type has the following shape: strokeDasharray: number, noCurves: boolean, lineStyle: string, + startShape: Object, endShape: Object, - startMarker: boolean, - endMarker: boolean, + enableStartMarker: boolean, + enableEndMarker: boolean, } ``` diff --git a/example/App.tsx b/example/App.tsx index cf5ad83..8e69807 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -8,6 +8,7 @@ import SixthExample from './SixthExample'; import SeventhExample from './SeventhExample'; import EighthExample from './EighthExample'; import NinthExample from './NinthExample'; +import TenthExample from './TenthExample'; const getExample = (id: number) => { switch (id) { @@ -38,6 +39,9 @@ const getExample = (id: number) => { case 9: return NinthExample; + case 10: + return TenthExample; + default: return SecondExample; } @@ -54,7 +58,7 @@ const App = () => {

Example {exampleId}

Choose an example:

- {[...Array(9).keys()].map((value) => ( + {[...Array(10).keys()].map((value) => (