lost-sia 2.0.1-alpha13 → 2.0.1-alpha14
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/dist/Annotation/ui/AnnotationComponent.js +1 -1
- package/dist/Annotation/ui/atoms/DaviIcon.d.ts +1 -1
- package/dist/Canvas/Canvas.js +1 -1
- package/dist/IconButton.d.ts +25 -0
- package/dist/IconButton.js +1 -0
- package/dist/Sia.js +1 -1
- package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -1
- package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/models/index.d.ts +1 -1
- package/package.json +3 -2
- package/src/AnnoExampleViewer.jsx +18 -18
- package/src/Annotation/logic/Annotation.ts +24 -24
- package/src/Annotation/ui/AnnotationComponent.tsx +89 -96
- package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
- package/src/Annotation/ui/atoms/PolygonArea.tsx +35 -35
- package/src/Annotation/ui/tools/Point.tsx +17 -17
- package/src/Canvas/Canvas.tsx +36 -13
- package/src/Canvas/LabelInput.tsx +27 -34
- package/src/IconButton.tsx +119 -0
- package/src/InfoBoxes/AnnoDetails.jsx +53 -53
- package/src/InfoBoxes/AnnoStats.jsx +41 -41
- package/src/InfoBoxes/InfoBox.jsx +16 -16
- package/src/InfoBoxes/LabelInfo.jsx +30 -30
- package/src/SIASettingButton.jsx +25 -25
- package/src/Sia.tsx +29 -12
- package/src/Toolbar/Toolbar.tsx +25 -25
- package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +23 -43
- package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -43
- package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +71 -71
- package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +24 -24
- package/src/Toolbar/ToolbarItems/ImageTools.tsx +28 -30
- package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
- package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
- package/src/index.ts +1 -0
- package/src/models/AnnotationMode.ts +1 -1
- package/src/models/AnnotationStatus.ts +1 -1
- package/src/models/AnnotationTool.ts +1 -1
- package/src/models/CanvasAction.ts +1 -1
- package/src/models/Direction.ts +1 -1
- package/src/models/EditorModes.ts +1 -1
- package/src/models/KeyAction.ts +1 -1
- package/src/models/NotificationType.ts +1 -1
- package/src/models/index.ts +6 -12
- package/src/siaDummyData.js +71 -71
- package/src/stories/Button.jsx +11 -15
- package/src/stories/Button.stories.js +17 -17
- package/src/stories/Canvas/CanvasWithOffset.stories.tsx +25 -25
- package/src/stories/FilterDropdown.stories.ts +10 -10
- package/src/stories/Header.jsx +8 -13
- package/src/stories/Header.stories.js +9 -9
- package/src/stories/Page.jsx +21 -26
- package/src/stories/Page.stories.js +14 -14
- package/src/stories/SIA2/DemoWrapper.stories.tsx +22 -22
- package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -11
- package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
- package/src/stories/Toolbar/Toolbar.stories.tsx +20 -20
- package/src/stories/siaDummyData.js +71 -71
- package/src/stories/siaDummyData2.ts +72 -72
- package/src/types.ts +47 -47
- package/src/utils/KeyMapper.ts +56 -61
- package/src/utils/TimeUtils.ts +7 -10
- package/src/utils/color.ts +25 -25
- package/src/utils/hist.js +22 -22
- package/src/utils/index.ts +3 -3
- package/src/utils/keyActions.js +81 -81
- package/src/utils/mouse.ts +9 -9
- package/src/utils/transform.ts +66 -72
- package/src/utils/uiConfig.js +19 -22
- package/src/utils/windowViewport.ts +10 -10
package/src/stories/Button.jsx
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import './button.css'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Primary UI component for user interaction
|
|
7
7
|
*/
|
|
8
8
|
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
|
|
9
|
-
const mode = primary
|
|
10
|
-
? "storybook-button--primary"
|
|
11
|
-
: "storybook-button--secondary";
|
|
9
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'
|
|
12
10
|
return (
|
|
13
11
|
<button
|
|
14
12
|
type="button"
|
|
15
|
-
className={[
|
|
16
|
-
" ",
|
|
17
|
-
)}
|
|
13
|
+
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
18
14
|
style={backgroundColor && { backgroundColor }}
|
|
19
15
|
{...props}
|
|
20
16
|
>
|
|
21
17
|
{label}
|
|
22
18
|
</button>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
19
|
+
)
|
|
20
|
+
}
|
|
25
21
|
|
|
26
22
|
Button.propTypes = {
|
|
27
23
|
/**
|
|
@@ -35,7 +31,7 @@ Button.propTypes = {
|
|
|
35
31
|
/**
|
|
36
32
|
* How large should the button be?
|
|
37
33
|
*/
|
|
38
|
-
size: PropTypes.oneOf([
|
|
34
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
39
35
|
/**
|
|
40
36
|
* Button contents
|
|
41
37
|
*/
|
|
@@ -44,11 +40,11 @@ Button.propTypes = {
|
|
|
44
40
|
* Optional click handler
|
|
45
41
|
*/
|
|
46
42
|
onClick: PropTypes.func,
|
|
47
|
-
}
|
|
43
|
+
}
|
|
48
44
|
|
|
49
45
|
Button.defaultProps = {
|
|
50
46
|
backgroundColor: null,
|
|
51
47
|
primary: false,
|
|
52
|
-
size:
|
|
48
|
+
size: 'medium',
|
|
53
49
|
onClick: undefined,
|
|
54
|
-
}
|
|
50
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { fn } from
|
|
2
|
-
import { Button } from
|
|
1
|
+
import { fn } from '@storybook/test'
|
|
2
|
+
import { Button } from './Button'
|
|
3
3
|
|
|
4
4
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
5
5
|
export default {
|
|
6
|
-
title:
|
|
6
|
+
title: 'Example/Button',
|
|
7
7
|
component: Button,
|
|
8
8
|
parameters: {
|
|
9
9
|
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
-
layout:
|
|
10
|
+
layout: 'centered',
|
|
11
11
|
},
|
|
12
12
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
13
|
-
tags: [
|
|
13
|
+
tags: ['autodocs'],
|
|
14
14
|
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
15
15
|
argTypes: {
|
|
16
|
-
backgroundColor: { control:
|
|
16
|
+
backgroundColor: { control: 'color' },
|
|
17
17
|
},
|
|
18
18
|
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
19
19
|
args: { onClick: fn() },
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
23
23
|
export const Primary = {
|
|
24
24
|
args: {
|
|
25
25
|
primary: true,
|
|
26
|
-
label:
|
|
26
|
+
label: 'Button',
|
|
27
27
|
},
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
|
|
30
30
|
export const Secondary = {
|
|
31
31
|
args: {
|
|
32
|
-
label:
|
|
32
|
+
label: 'Button',
|
|
33
33
|
},
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
export const Large = {
|
|
37
37
|
args: {
|
|
38
|
-
size:
|
|
39
|
-
label:
|
|
38
|
+
size: 'large',
|
|
39
|
+
label: 'Button',
|
|
40
40
|
},
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
export const Small = {
|
|
44
44
|
args: {
|
|
45
|
-
size:
|
|
46
|
-
label:
|
|
45
|
+
size: 'small',
|
|
46
|
+
label: 'Button',
|
|
47
47
|
},
|
|
48
|
-
}
|
|
48
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { fn } from
|
|
3
|
-
import { imgBlob } from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import { fn } from '@storybook/test'
|
|
3
|
+
import { imgBlob } from '../siaDummyData'
|
|
4
4
|
|
|
5
|
-
import AnnotationTool from
|
|
6
|
-
import Annotation from
|
|
5
|
+
import AnnotationTool from '../../models/AnnotationTool'
|
|
6
|
+
import Annotation from '../../Annotation/logic/Annotation'
|
|
7
7
|
|
|
8
|
-
import { possibleLabels } from
|
|
9
|
-
import { UiConfig } from
|
|
10
|
-
import CanvasWithOffset from
|
|
8
|
+
import { possibleLabels } from '../siaDummyData2'
|
|
9
|
+
import { UiConfig } from '../../types'
|
|
10
|
+
import CanvasWithOffset from './CanvasOffset'
|
|
11
11
|
|
|
12
12
|
export const ActionsData = {
|
|
13
13
|
onAnnoEvent: fn(),
|
|
14
14
|
onKeyDown: fn(),
|
|
15
15
|
onKeyUp: fn(),
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
|
|
18
18
|
const meta = {
|
|
19
|
-
title:
|
|
19
|
+
title: 'Components/CanvasWithOffset',
|
|
20
20
|
component: CanvasWithOffset,
|
|
21
21
|
parameters: {
|
|
22
22
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
23
|
-
layout:
|
|
23
|
+
layout: 'fullscreen',
|
|
24
24
|
},
|
|
25
|
-
tags: [
|
|
25
|
+
tags: ['!autodocs'],
|
|
26
26
|
excludeStories: /.*Data$/,
|
|
27
27
|
args: {
|
|
28
28
|
...ActionsData,
|
|
29
29
|
},
|
|
30
|
-
} satisfies Meta<typeof CanvasWithOffset
|
|
30
|
+
} satisfies Meta<typeof CanvasWithOffset>
|
|
31
31
|
|
|
32
|
-
export default meta
|
|
33
|
-
type Story = StoryObj<typeof meta
|
|
32
|
+
export default meta
|
|
33
|
+
type Story = StoryObj<typeof meta>
|
|
34
34
|
|
|
35
35
|
const uiConfig: UiConfig = {
|
|
36
36
|
nodeRadius: 4,
|
|
37
37
|
strokeWidth: 4,
|
|
38
38
|
imageCentered: false,
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
|
|
41
41
|
export const Default: Story = {
|
|
42
42
|
args: {
|
|
@@ -47,7 +47,7 @@ export const Default: Story = {
|
|
|
47
47
|
preventScrolling: true,
|
|
48
48
|
uiConfig,
|
|
49
49
|
},
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
|
|
52
52
|
const samplePointAnnotations: Annotation[] = [
|
|
53
53
|
new Annotation(0, AnnotationTool.Point, [{ x: 10, y: 10 }]),
|
|
@@ -58,7 +58,7 @@ const samplePointAnnotations: Annotation[] = [
|
|
|
58
58
|
new Annotation(5, AnnotationTool.Point, [{ x: 250, y: 250 }]),
|
|
59
59
|
new Annotation(6, AnnotationTool.Point, [{ x: 300, y: 300 }]),
|
|
60
60
|
new Annotation(7, AnnotationTool.Point, [{ x: 350, y: 350 }]),
|
|
61
|
-
]
|
|
61
|
+
]
|
|
62
62
|
|
|
63
63
|
export const WithPoints: Story = {
|
|
64
64
|
args: {
|
|
@@ -70,7 +70,7 @@ export const WithPoints: Story = {
|
|
|
70
70
|
preventScrolling: true,
|
|
71
71
|
uiConfig,
|
|
72
72
|
},
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
74
|
|
|
75
75
|
const sampleLineAnnotations: Annotation[] = [
|
|
76
76
|
new Annotation(0, AnnotationTool.Line, [
|
|
@@ -87,7 +87,7 @@ const sampleLineAnnotations: Annotation[] = [
|
|
|
87
87
|
]),
|
|
88
88
|
new Annotation(2, AnnotationTool.Line, [{ x: 150, y: 150 }]),
|
|
89
89
|
new Annotation(3, AnnotationTool.Line, [{ x: 200, y: 200 }]),
|
|
90
|
-
]
|
|
90
|
+
]
|
|
91
91
|
|
|
92
92
|
export const WithLines: Story = {
|
|
93
93
|
args: {
|
|
@@ -99,7 +99,7 @@ export const WithLines: Story = {
|
|
|
99
99
|
preventScrolling: true,
|
|
100
100
|
uiConfig,
|
|
101
101
|
},
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
|
|
104
104
|
const sampleBBoxAnnotations: Annotation[] = [
|
|
105
105
|
new Annotation(0, AnnotationTool.BBox, [
|
|
@@ -114,7 +114,7 @@ const sampleBBoxAnnotations: Annotation[] = [
|
|
|
114
114
|
{ x: 400, y: 325 },
|
|
115
115
|
{ x: 500, y: 375 },
|
|
116
116
|
]),
|
|
117
|
-
]
|
|
117
|
+
]
|
|
118
118
|
|
|
119
119
|
export const WithBBoxes: Story = {
|
|
120
120
|
args: {
|
|
@@ -126,7 +126,7 @@ export const WithBBoxes: Story = {
|
|
|
126
126
|
preventScrolling: true,
|
|
127
127
|
uiConfig,
|
|
128
128
|
},
|
|
129
|
-
}
|
|
129
|
+
}
|
|
130
130
|
|
|
131
131
|
const samplePolygonAnnotations: Annotation[] = [
|
|
132
132
|
new Annotation(0, AnnotationTool.Polygon, [
|
|
@@ -142,7 +142,7 @@ const samplePolygonAnnotations: Annotation[] = [
|
|
|
142
142
|
{ x: 600, y: 350 },
|
|
143
143
|
{ x: 550, y: 450 },
|
|
144
144
|
]),
|
|
145
|
-
]
|
|
145
|
+
]
|
|
146
146
|
|
|
147
147
|
export const WithPolygonAnnotations: Story = {
|
|
148
148
|
args: {
|
|
@@ -154,4 +154,4 @@ export const WithPolygonAnnotations: Story = {
|
|
|
154
154
|
preventScrolling: true,
|
|
155
155
|
uiConfig,
|
|
156
156
|
},
|
|
157
|
-
}
|
|
157
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { possibleLabels } from
|
|
3
|
-
import { fn } from
|
|
4
|
-
import LabelInput from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import { possibleLabels } from './siaDummyData2'
|
|
3
|
+
import { fn } from '@storybook/test'
|
|
4
|
+
import LabelInput from '../Canvas/LabelInput'
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
|
-
title:
|
|
7
|
+
title: 'Components/LabelFilter',
|
|
8
8
|
component: LabelInput,
|
|
9
9
|
argTypes: {},
|
|
10
10
|
parameters: {
|
|
11
|
-
layout:
|
|
11
|
+
layout: 'centered',
|
|
12
12
|
},
|
|
13
|
-
} satisfies Meta<typeof LabelInput
|
|
13
|
+
} satisfies Meta<typeof LabelInput>
|
|
14
14
|
|
|
15
|
-
export default meta
|
|
16
|
-
type Story = StoryObj<typeof meta
|
|
15
|
+
export default meta
|
|
16
|
+
type Story = StoryObj<typeof meta>
|
|
17
17
|
|
|
18
18
|
export const Default: Story = {
|
|
19
19
|
args: {
|
|
@@ -22,4 +22,4 @@ export const Default: Story = {
|
|
|
22
22
|
selectedLabelsIds: [],
|
|
23
23
|
onLabelSelect: fn(),
|
|
24
24
|
},
|
|
25
|
-
}
|
|
25
|
+
}
|
package/src/stories/Header.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import PropTypes from
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import { Button } from
|
|
5
|
-
import
|
|
4
|
+
import { Button } from './Button'
|
|
5
|
+
import './header.css'
|
|
6
6
|
|
|
7
7
|
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
|
|
8
8
|
<header>
|
|
@@ -42,18 +42,13 @@ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
|
|
|
42
42
|
) : (
|
|
43
43
|
<>
|
|
44
44
|
<Button size="small" onClick={onLogin} label="Log in" />
|
|
45
|
-
<Button
|
|
46
|
-
primary
|
|
47
|
-
size="small"
|
|
48
|
-
onClick={onCreateAccount}
|
|
49
|
-
label="Sign up"
|
|
50
|
-
/>
|
|
45
|
+
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
|
|
51
46
|
</>
|
|
52
47
|
)}
|
|
53
48
|
</div>
|
|
54
49
|
</div>
|
|
55
50
|
</header>
|
|
56
|
-
)
|
|
51
|
+
)
|
|
57
52
|
|
|
58
53
|
Header.propTypes = {
|
|
59
54
|
user: PropTypes.shape({
|
|
@@ -62,8 +57,8 @@ Header.propTypes = {
|
|
|
62
57
|
onLogin: PropTypes.func.isRequired,
|
|
63
58
|
onLogout: PropTypes.func.isRequired,
|
|
64
59
|
onCreateAccount: PropTypes.func.isRequired,
|
|
65
|
-
}
|
|
60
|
+
}
|
|
66
61
|
|
|
67
62
|
Header.defaultProps = {
|
|
68
63
|
user: null,
|
|
69
|
-
}
|
|
64
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Header } from
|
|
2
|
-
import { fn } from
|
|
1
|
+
import { Header } from './Header'
|
|
2
|
+
import { fn } from '@storybook/test'
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
title:
|
|
5
|
+
title: 'Example/Header',
|
|
6
6
|
component: Header,
|
|
7
7
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
8
|
-
tags: [
|
|
8
|
+
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
10
10
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
-
layout:
|
|
11
|
+
layout: 'fullscreen',
|
|
12
12
|
},
|
|
13
13
|
args: {
|
|
14
14
|
onLogin: fn(),
|
|
15
15
|
onLogout: fn(),
|
|
16
16
|
onCreateAccount: fn(),
|
|
17
17
|
},
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
export const LoggedIn = {
|
|
21
21
|
args: {
|
|
22
22
|
user: {
|
|
23
|
-
name:
|
|
23
|
+
name: 'Jane Doe',
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
export const LoggedOut = {}
|
|
28
|
+
export const LoggedOut = {}
|
package/src/stories/Page.jsx
CHANGED
|
@@ -1,50 +1,46 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import { Header } from
|
|
4
|
-
import
|
|
3
|
+
import { Header } from './Header'
|
|
4
|
+
import './page.css'
|
|
5
5
|
|
|
6
6
|
export const Page = () => {
|
|
7
|
-
const [user, setUser] = React.useState()
|
|
7
|
+
const [user, setUser] = React.useState()
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<article>
|
|
11
11
|
<Header
|
|
12
12
|
user={user}
|
|
13
|
-
onLogin={() => setUser({ name:
|
|
13
|
+
onLogin={() => setUser({ name: 'Jane Doe' })}
|
|
14
14
|
onLogout={() => setUser(undefined)}
|
|
15
|
-
onCreateAccount={() => setUser({ name:
|
|
15
|
+
onCreateAccount={() => setUser({ name: 'Jane Doe' })}
|
|
16
16
|
/>
|
|
17
17
|
|
|
18
18
|
<section className="storybook-page">
|
|
19
19
|
<h2>Pages in Storybook</h2>
|
|
20
20
|
<p>
|
|
21
|
-
We recommend building UIs with a{
|
|
22
|
-
<a
|
|
23
|
-
href="https://componentdriven.org"
|
|
24
|
-
target="_blank"
|
|
25
|
-
rel="noopener noreferrer"
|
|
26
|
-
>
|
|
21
|
+
We recommend building UIs with a{' '}
|
|
22
|
+
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
27
23
|
<strong>component-driven</strong>
|
|
28
|
-
</a>{
|
|
24
|
+
</a>{' '}
|
|
29
25
|
process starting with atomic components and ending with pages.
|
|
30
26
|
</p>
|
|
31
27
|
<p>
|
|
32
|
-
Render pages with mock data. This makes it easy to build and review
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
Render pages with mock data. This makes it easy to build and review page states
|
|
29
|
+
without needing to navigate to them in your app. Here are some handy patterns
|
|
30
|
+
for managing page data in Storybook:
|
|
35
31
|
</p>
|
|
36
32
|
<ul>
|
|
37
33
|
<li>
|
|
38
|
-
Use a higher-level connected component. Storybook helps you compose
|
|
39
|
-
|
|
34
|
+
Use a higher-level connected component. Storybook helps you compose such data
|
|
35
|
+
from the "args" of child component stories
|
|
40
36
|
</li>
|
|
41
37
|
<li>
|
|
42
|
-
Assemble data in the page component from your services. You can mock
|
|
43
|
-
|
|
38
|
+
Assemble data in the page component from your services. You can mock these
|
|
39
|
+
services out using Storybook.
|
|
44
40
|
</li>
|
|
45
41
|
</ul>
|
|
46
42
|
<p>
|
|
47
|
-
Get a guided tutorial on component-driven development at{
|
|
43
|
+
Get a guided tutorial on component-driven development at{' '}
|
|
48
44
|
<a
|
|
49
45
|
href="https://storybook.js.org/tutorials/"
|
|
50
46
|
target="_blank"
|
|
@@ -52,7 +48,7 @@ export const Page = () => {
|
|
|
52
48
|
>
|
|
53
49
|
Storybook tutorials
|
|
54
50
|
</a>
|
|
55
|
-
. Read more in the{
|
|
51
|
+
. Read more in the{' '}
|
|
56
52
|
<a
|
|
57
53
|
href="https://storybook.js.org/docs"
|
|
58
54
|
target="_blank"
|
|
@@ -63,8 +59,7 @@ export const Page = () => {
|
|
|
63
59
|
.
|
|
64
60
|
</p>
|
|
65
61
|
<div className="tip-wrapper">
|
|
66
|
-
<span className="tip">Tip</span> Adjust the width of the canvas with
|
|
67
|
-
the{" "}
|
|
62
|
+
<span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
|
|
68
63
|
<svg
|
|
69
64
|
width="10"
|
|
70
65
|
height="10"
|
|
@@ -83,5 +78,5 @@ export const Page = () => {
|
|
|
83
78
|
</div>
|
|
84
79
|
</section>
|
|
85
80
|
</article>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { within, userEvent, expect } from
|
|
1
|
+
import { within, userEvent, expect } from '@storybook/test'
|
|
2
2
|
|
|
3
|
-
import { Page } from
|
|
3
|
+
import { Page } from './Page'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title:
|
|
6
|
+
title: 'Example/Page',
|
|
7
7
|
component: Page,
|
|
8
8
|
parameters: {
|
|
9
9
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
-
layout:
|
|
10
|
+
layout: 'fullscreen',
|
|
11
11
|
},
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
export const LoggedOut = {}
|
|
14
|
+
export const LoggedOut = {}
|
|
15
15
|
|
|
16
16
|
// More on interaction testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
17
17
|
export const LoggedIn = {
|
|
18
18
|
play: async ({ canvasElement }) => {
|
|
19
|
-
const canvas = within(canvasElement)
|
|
20
|
-
const loginButton = canvas.getByRole(
|
|
21
|
-
await expect(loginButton).toBeInTheDocument()
|
|
22
|
-
await userEvent.click(loginButton)
|
|
23
|
-
await expect(loginButton).not.toBeInTheDocument()
|
|
19
|
+
const canvas = within(canvasElement)
|
|
20
|
+
const loginButton = canvas.getByRole('button', { name: /Log in/i })
|
|
21
|
+
await expect(loginButton).toBeInTheDocument()
|
|
22
|
+
await userEvent.click(loginButton)
|
|
23
|
+
await expect(loginButton).not.toBeInTheDocument()
|
|
24
24
|
|
|
25
|
-
const logoutButton = canvas.getByRole(
|
|
26
|
-
await expect(logoutButton).toBeInTheDocument()
|
|
25
|
+
const logoutButton = canvas.getByRole('button', { name: /Log out/i })
|
|
26
|
+
await expect(logoutButton).toBeInTheDocument()
|
|
27
27
|
},
|
|
28
|
-
}
|
|
28
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
2
|
|
|
3
|
-
import DemoWrapper from
|
|
4
|
-
import AnnotationTool from
|
|
3
|
+
import DemoWrapper from './DemoWrapper'
|
|
4
|
+
import AnnotationTool from '../../models/AnnotationTool'
|
|
5
5
|
|
|
6
|
-
import { AnnotationSettings, ExternalAnnotation } from
|
|
7
|
-
import { AnnotationStatus } from
|
|
6
|
+
import { AnnotationSettings, ExternalAnnotation } from '../../types'
|
|
7
|
+
import { AnnotationStatus } from '../../models'
|
|
8
8
|
|
|
9
|
-
export const ActionsData = {}
|
|
9
|
+
export const ActionsData = {}
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title:
|
|
12
|
+
title: 'Components/DemoWrapper',
|
|
13
13
|
component: DemoWrapper,
|
|
14
14
|
parameters: {
|
|
15
15
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
16
|
-
layout:
|
|
16
|
+
layout: 'padded',
|
|
17
17
|
},
|
|
18
|
-
tags: [
|
|
18
|
+
tags: ['!autodocs'],
|
|
19
19
|
excludeStories: /.*Data$/,
|
|
20
20
|
args: {
|
|
21
21
|
...ActionsData,
|
|
22
22
|
},
|
|
23
|
-
} satisfies Meta<typeof DemoWrapper
|
|
23
|
+
} satisfies Meta<typeof DemoWrapper>
|
|
24
24
|
|
|
25
|
-
export default meta
|
|
26
|
-
type Story = StoryObj<typeof meta
|
|
25
|
+
export default meta
|
|
26
|
+
type Story = StoryObj<typeof meta>
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* SIA with dummy data
|
|
@@ -32,7 +32,7 @@ export const Default: Story = {
|
|
|
32
32
|
args: {
|
|
33
33
|
...ActionsData,
|
|
34
34
|
},
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
37
|
const polygonAnnotations: ExternalAnnotation[] = [
|
|
38
38
|
{
|
|
@@ -58,13 +58,13 @@ const polygonAnnotations: ExternalAnnotation[] = [
|
|
|
58
58
|
status: AnnotationStatus.LOADED,
|
|
59
59
|
type: AnnotationTool.Polygon,
|
|
60
60
|
},
|
|
61
|
-
]
|
|
61
|
+
]
|
|
62
62
|
|
|
63
63
|
const annotationSettings: AnnotationSettings = {
|
|
64
64
|
canCreate: true,
|
|
65
65
|
canHaveMultipleLabels: true,
|
|
66
66
|
canLabel: true,
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
|
|
69
69
|
export const WithPolygonAnnotations: Story = {
|
|
70
70
|
args: {
|
|
@@ -72,7 +72,7 @@ export const WithPolygonAnnotations: Story = {
|
|
|
72
72
|
annotations: polygonAnnotations,
|
|
73
73
|
annotationSettings,
|
|
74
74
|
},
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
76
|
|
|
77
77
|
const bboxAnnotations: ExternalAnnotation[] = [
|
|
78
78
|
{
|
|
@@ -93,7 +93,7 @@ const bboxAnnotations: ExternalAnnotation[] = [
|
|
|
93
93
|
type: AnnotationTool.BBox,
|
|
94
94
|
status: AnnotationStatus.LOADED,
|
|
95
95
|
},
|
|
96
|
-
]
|
|
96
|
+
]
|
|
97
97
|
|
|
98
98
|
export const WithBBoxAnnotations: Story = {
|
|
99
99
|
args: {
|
|
@@ -101,7 +101,7 @@ export const WithBBoxAnnotations: Story = {
|
|
|
101
101
|
annotations: bboxAnnotations,
|
|
102
102
|
annotationSettings,
|
|
103
103
|
},
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
105
|
|
|
106
106
|
const lineAnnotations: ExternalAnnotation[] = [
|
|
107
107
|
{
|
|
@@ -127,7 +127,7 @@ const lineAnnotations: ExternalAnnotation[] = [
|
|
|
127
127
|
type: AnnotationTool.Line,
|
|
128
128
|
status: AnnotationStatus.LOADED,
|
|
129
129
|
},
|
|
130
|
-
]
|
|
130
|
+
]
|
|
131
131
|
|
|
132
132
|
export const WithLineAnnotations: Story = {
|
|
133
133
|
args: {
|
|
@@ -135,7 +135,7 @@ export const WithLineAnnotations: Story = {
|
|
|
135
135
|
annotations: lineAnnotations,
|
|
136
136
|
annotationSettings,
|
|
137
137
|
},
|
|
138
|
-
}
|
|
138
|
+
}
|
|
139
139
|
|
|
140
140
|
const pointAnnotations: ExternalAnnotation[] = [
|
|
141
141
|
{
|
|
@@ -168,7 +168,7 @@ const pointAnnotations: ExternalAnnotation[] = [
|
|
|
168
168
|
type: AnnotationTool.Point,
|
|
169
169
|
status: AnnotationStatus.LOADED,
|
|
170
170
|
},
|
|
171
|
-
]
|
|
171
|
+
]
|
|
172
172
|
|
|
173
173
|
export const WithPointAnnotations: Story = {
|
|
174
174
|
args: {
|
|
@@ -176,4 +176,4 @@ export const WithPointAnnotations: Story = {
|
|
|
176
176
|
annotations: pointAnnotations,
|
|
177
177
|
annotationSettings,
|
|
178
178
|
},
|
|
179
|
-
}
|
|
179
|
+
}
|