@weavix/tracker-components 0.1.0 → 0.1.1

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.
@@ -1,40 +1,122 @@
1
1
  # IssueTypeIcon
2
2
 
3
3
  <!-- description:start -->
4
- Component displaying icons for the various issue types
4
+ Displays the icon for a Tracker issue type (task, bug, epic, improvement, etc.). Each issue type maps to a distinct SVG asset. Unknown type keys fall back to a generic icon.
5
5
  <!-- description:end -->
6
6
 
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {IssueTypeIcon} from '@weavix/tracker-components';
11
+
12
+ <IssueTypeIcon issueType="bug" />
13
+ ```
14
+
7
15
  ## Component props
8
16
 
9
17
  <!-- props:start -->
10
18
  ```ts
11
19
  {
12
20
  /**
13
- * Additional class
21
+ * Issue type key. Known values are listed below; any other string is
22
+ * accepted and falls back to a generic icon.
14
23
  */
15
- className?: string;
24
+ issueType:
25
+ | 'task'
26
+ | 'bug'
27
+ | 'design'
28
+ | 'epic'
29
+ | 'improvement'
30
+ | 'incident'
31
+ | 'info'
32
+ | 'milestone'
33
+ | 'newFeature'
34
+ | 'query'
35
+ | 'refactoring'
36
+ | 'release'
37
+ | 'research'
38
+ | 'serviceRequest'
39
+ | 'story'
40
+ | 'subBug'
41
+ | 'subTask'
42
+ | 'technicalDebt'
43
+ | string;
44
+
16
45
  /**
17
- * Issue type key
46
+ * Size of the icon in pixels.
47
+ * @default 16
18
48
  */
19
- issueType:
20
- 'task' |
21
- 'bug' |
22
- 'design' |
23
- 'epic' |
24
- 'improvement' |
25
- 'incident' |
26
- 'info' |
27
- 'newFeature' |
28
- 'query' |
29
- 'refactoring' |
30
- 'release' |
31
- 'serviceRequest' |
32
- 'story' |
33
- 'subBug' |
34
- 'subTask' |
35
- 'technicalDebt' |
36
- 'milestone' |
37
- string;
49
+ size?: number;
50
+
51
+ /**
52
+ * Additional CSS class applied to the root element.
53
+ */
54
+ className?: string;
38
55
  }
39
56
  ```
40
57
  <!-- props:end -->
58
+
59
+ ---
60
+
61
+ ## Examples
62
+
63
+ ### Single icon
64
+
65
+ ```tsx
66
+ import {IssueTypeIcon} from '@weavix/tracker-components';
67
+
68
+ <IssueTypeIcon issueType="task" />
69
+ <IssueTypeIcon issueType="bug" />
70
+ <IssueTypeIcon issueType="epic" />
71
+ ```
72
+
73
+ ### Custom size
74
+
75
+ ```tsx
76
+ <IssueTypeIcon issueType="story" size={24} />
77
+ <IssueTypeIcon issueType="story" size={32} />
78
+ ```
79
+
80
+ ### Alongside issue summary
81
+
82
+ ```tsx
83
+ import {IssueTypeIcon} from '@weavix/tracker-components';
84
+
85
+ export const IssueRow = ({issue}: {issue: {type: string; summary: string}}) => (
86
+ <div style={{display: 'flex', alignItems: 'center', gap: 8}}>
87
+ <IssueTypeIcon issueType={issue.type} size={16} />
88
+ <span>{issue.summary}</span>
89
+ </div>
90
+ );
91
+ ```
92
+
93
+ ### All known issue types
94
+
95
+ ```tsx
96
+ import {IssueTypeIcon} from '@weavix/tracker-components';
97
+
98
+ const ISSUE_TYPES = [
99
+ 'task', 'bug', 'design', 'epic', 'improvement',
100
+ 'incident', 'info', 'milestone', 'newFeature', 'query',
101
+ 'refactoring', 'release', 'research', 'serviceRequest',
102
+ 'story', 'subBug', 'subTask', 'technicalDebt',
103
+ ] as const;
104
+
105
+ export const IssueTypeGallery = () => (
106
+ <div style={{display: 'flex', flexWrap: 'wrap', gap: 16}}>
107
+ {ISSUE_TYPES.map((type) => (
108
+ <div key={type} style={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4}}>
109
+ <IssueTypeIcon issueType={type} size={24} />
110
+ <span style={{fontSize: 11}}>{type}</span>
111
+ </div>
112
+ ))}
113
+ </div>
114
+ );
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Notes
120
+
121
+ - The `issueType` value is matched case-sensitively against the known keys. Values returned by the Tracker API (e.g. `"newFeature"`, `"subTask"`) match directly without transformation.
122
+ - Passing an unknown string does not throw — the component renders a generic fallback icon.
@@ -0,0 +1,73 @@
1
+ # KeyResultIcon
2
+
3
+ <!-- description:start -->
4
+ Displays the icon for a Tracker key result entity. Renders a fixed SVG asset wrapped in a sized container, with a built-in tooltip that shows the localized "Key result" label on hover.
5
+ <!-- description:end -->
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {KeyResultIcon} from '@weavix/tracker-components';
11
+
12
+ <KeyResultIcon />
13
+ ```
14
+
15
+ ## Component props
16
+
17
+ <!-- props:start -->
18
+ ```ts
19
+ {
20
+ /**
21
+ * Size of the SVG icon inside the container in pixels.
22
+ * @default 16
23
+ */
24
+ size?: number;
25
+
26
+ /**
27
+ * Size of the icon container in pixels.
28
+ * @default 24
29
+ */
30
+ refugeSize?: number;
31
+ }
32
+ ```
33
+ <!-- props:end -->
34
+
35
+ ---
36
+
37
+ ## Examples
38
+
39
+ ### Default
40
+
41
+ ```tsx
42
+ import {KeyResultIcon} from '@weavix/tracker-components';
43
+
44
+ <KeyResultIcon />
45
+ ```
46
+
47
+ ### Custom size
48
+
49
+ ```tsx
50
+ // Larger icon for a header row
51
+ <KeyResultIcon size={20} refugeSize={32} />
52
+ ```
53
+
54
+ ### Alongside key result name
55
+
56
+ ```tsx
57
+ import {KeyResultIcon} from '@weavix/tracker-components';
58
+
59
+ export const KeyResultLabel = ({name}: {name: string}) => (
60
+ <div style={{display: 'flex', alignItems: 'center', gap: 8}}>
61
+ <KeyResultIcon />
62
+ <span>{name}</span>
63
+ </div>
64
+ );
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Notes
70
+
71
+ - The tooltip text is **automatically localized** using the Gravity UI `getConfig().lang` setting. No additional i18n setup is required.
72
+ - Unlike [`GoalIcon`](../GoalIcon/README.md), [`ProjectIcon`](../ProjectIcon/README.md), and [`PortfolioIcon`](../PortfolioIcon/README.md), `KeyResultIcon` does **not** accept an entity ID — it always renders the same fixed asset.
73
+ - To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
@@ -0,0 +1,126 @@
1
+ # MetaEntityIcon
2
+
3
+ <!-- description:start -->
4
+ A dispatcher component that renders the correct icon for any Tracker meta entity type — project, portfolio, goal, or key result. Pass the entity object and the component automatically selects and renders the appropriate icon with a deterministic color derived from the entity ID.
5
+ <!-- description:end -->
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {MetaEntityIcon} from '@weavix/tracker-components';
11
+
12
+ <MetaEntityIcon entity={{entityType: 'project', id: 'proj-1', shortId: 42}} />
13
+ ```
14
+
15
+ ## Component props
16
+
17
+ <!-- props:start -->
18
+ ```ts
19
+ {
20
+ /**
21
+ * The meta entity to display an icon for.
22
+ * Only `entityType`, `id`, and `shortId` are required.
23
+ */
24
+ entity: {
25
+ entityType: 'project' | 'portfolio' | 'goal' | 'keyResult';
26
+ /** String entity ID (used for portfolio color generation). */
27
+ id: string;
28
+ /** Numeric short ID (used for project and goal color generation). */
29
+ shortId: number;
30
+ };
31
+
32
+ /**
33
+ * Size of the SVG icon inside the container in pixels.
34
+ * @default 20
35
+ */
36
+ size?: number;
37
+ }
38
+ ```
39
+ <!-- props:end -->
40
+
41
+ ---
42
+
43
+ ## Supported entity types
44
+
45
+ | `entityType` | Rendered component | Color source |
46
+ |---|---|---|
47
+ | `'project'` | [`ProjectIcon`](../ProjectIcon/README.md) | `shortId` |
48
+ | `'portfolio'` | [`PortfolioIcon`](../PortfolioIcon/README.md) | `id` |
49
+ | `'goal'` | [`GoalIcon`](../GoalIcon/README.md) | `shortId` |
50
+ | `'keyResult'` | [`KeyResultIcon`](../KeyResultIcon/README.md) | fixed asset, no color |
51
+ | anything else | `null` (renders nothing) | — |
52
+
53
+ ---
54
+
55
+ ## Examples
56
+
57
+ ### All entity types
58
+
59
+ ```tsx
60
+ import {MetaEntityIcon} from '@weavix/tracker-components';
61
+
62
+ <MetaEntityIcon entity={{entityType: 'project', id: 'proj-1', shortId: 42}} />
63
+ <MetaEntityIcon entity={{entityType: 'portfolio', id: 'port-1', shortId: 7}} />
64
+ <MetaEntityIcon entity={{entityType: 'goal', id: 'goal-1', shortId: 99}} />
65
+ ```
66
+
67
+ ### Custom size
68
+
69
+ ```tsx
70
+ // 32 px icon for a page header
71
+ <MetaEntityIcon
72
+ entity={{entityType: 'project', id: 'proj-1', shortId: 42}}
73
+ size={32}
74
+ />
75
+ ```
76
+
77
+ ### Rendering from a Tracker API response
78
+
79
+ `MetaEntityIcon` accepts the shape returned directly by the Tracker entities search endpoint, so you can pass `result.data[i]` without any mapping:
80
+
81
+ ```tsx
82
+ import React, {useEffect, useState} from 'react';
83
+ import {MetaEntityIcon} from '@weavix/tracker-components';
84
+ import type {MetaEntityV2} from '@weavix/tracker-api-types';
85
+
86
+ interface Props {
87
+ trackerApi: TrackerApi;
88
+ }
89
+
90
+ export const EntityList: React.FC<Props> = ({trackerApi}) => {
91
+ const [entities, setEntities] = useState<MetaEntityV2[]>([]);
92
+
93
+ useEffect(() => {
94
+ trackerApi.v3
95
+ .post['/entities/{entityType}/_search']({
96
+ pathParams: {entityType: 'project'},
97
+ queryParams: {fields: ['summary'], page: 1, perPage: 20},
98
+ bodyParams: {filter: {}, filterTypes: ['ALL'], input: ''},
99
+ })
100
+ .then((result) => setEntities(result.data));
101
+ }, [trackerApi]);
102
+
103
+ return (
104
+ <ul>
105
+ {entities.map((entity) => (
106
+ <li key={entity.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
107
+ <MetaEntityIcon entity={entity} size={20} />
108
+ <span>{entity.fields?.summary?.value ?? entity.id}</span>
109
+ </li>
110
+ ))}
111
+ </ul>
112
+ );
113
+ };
114
+ ```
115
+
116
+ ### Used inside MetaEntitiesSelect
117
+
118
+ `MetaEntityIcon` is used internally by [`MetaEntitiesSelect`](../../MetaEntitiesSelect/README.md) to render each item in the suggest list. You do not need to use it directly when using that component.
119
+
120
+ ---
121
+
122
+ ## Notes
123
+
124
+ - The `entity` prop only requires `entityType`, `id`, and `shortId` — it is compatible with the full `MetaEntityV2` type from `@weavix/tracker-api-types`.
125
+ - For unknown `entityType` values the component renders `null` silently.
126
+ - To render individual entity icons directly, use [`ProjectIcon`](../ProjectIcon/README.md), [`PortfolioIcon`](../PortfolioIcon/README.md), [`GoalIcon`](../GoalIcon/README.md), or [`KeyResultIcon`](../KeyResultIcon/README.md).
@@ -1,51 +1,129 @@
1
1
  # PortfolioIcon
2
2
 
3
3
  <!-- description:start -->
4
- Component displaying an icon for a portfolio entity
4
+ Displays a colored icon for a Tracker portfolio entity. The icon color is deterministically derived from the `portfolioId`, so the same portfolio always renders the same color across sessions and environments.
5
5
  <!-- description:end -->
6
6
 
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {PortfolioIcon} from '@weavix/tracker-components';
11
+
12
+ <PortfolioIcon portfolioId="portfolio-abc" />
13
+ ```
14
+
7
15
  ## Component props
8
16
 
9
17
  <!-- props:start -->
10
18
  ```ts
11
19
  {
12
20
  /**
13
- * Portfolio ID used to generate a deterministic color
21
+ * Portfolio ID used to generate a deterministic color.
22
+ * Typically the string entity ID returned by the Tracker API.
14
23
  */
15
24
  portfolioId: string;
25
+
16
26
  /**
17
- * Additional class
27
+ * Additional CSS class applied to the root element.
18
28
  */
19
29
  className?: string;
30
+
20
31
  /**
21
- * Entity type label (defaults to "portfolio")
32
+ * Entity type label. Defaults to "portfolio".
22
33
  */
23
34
  type?: string;
35
+
24
36
  /**
25
- * Size of the SVG icon inside the container in pixels
37
+ * Size of the SVG icon inside the container in pixels.
26
38
  * @default 16
27
39
  */
28
40
  size?: number;
41
+
29
42
  /**
30
- * Size of the icon container in pixels
43
+ * Size of the icon container (the colored square) in pixels.
31
44
  * @default 24
32
45
  */
33
46
  refugeSize?: number;
47
+
34
48
  /**
35
- * Whether to render a colored background behind the icon
49
+ * Whether to render a colored background behind the icon.
36
50
  * @default false
37
51
  */
38
52
  withBackground?: boolean;
53
+
39
54
  /**
40
- * Border radius variant of the icon container
55
+ * Border radius variant of the icon container.
41
56
  * @default 'm'
42
57
  */
43
58
  radius?: 'm' | 'l';
59
+
44
60
  /**
45
- * Alpha (opacity) of the icon color
61
+ * Alpha (opacity) of the icon foreground color.
46
62
  * @default 1
47
63
  */
48
64
  colorAlpha?: number;
49
65
  }
50
66
  ```
51
67
  <!-- props:end -->
68
+
69
+ ---
70
+
71
+ ## Examples
72
+
73
+ ### Default
74
+
75
+ ```tsx
76
+ import {PortfolioIcon} from '@weavix/tracker-components';
77
+
78
+ <PortfolioIcon portfolioId="portfolio-abc" />
79
+ ```
80
+
81
+ ### With background
82
+
83
+ ```tsx
84
+ <PortfolioIcon portfolioId="portfolio-abc" withBackground />
85
+ ```
86
+
87
+ ### Custom size
88
+
89
+ ```tsx
90
+ <PortfolioIcon portfolioId="portfolio-abc" size={20} refugeSize={32} />
91
+ ```
92
+
93
+ ### Alongside portfolio name
94
+
95
+ ```tsx
96
+ import {PortfolioIcon} from '@weavix/tracker-components';
97
+
98
+ export const PortfolioLabel = ({portfolio}: {portfolio: {id: string; name: string}}) => (
99
+ <div style={{display: 'flex', alignItems: 'center', gap: 8}}>
100
+ <PortfolioIcon portfolioId={portfolio.id} />
101
+ <span>{portfolio.name}</span>
102
+ </div>
103
+ );
104
+ ```
105
+
106
+ ### Multiple portfolios (each gets a unique color)
107
+
108
+ ```tsx
109
+ const portfolios = [
110
+ {id: 'port-1', name: 'Platform'},
111
+ {id: 'port-2', name: 'Growth'},
112
+ {id: 'port-3', name: 'Infrastructure'},
113
+ ];
114
+
115
+ portfolios.map((p) => (
116
+ <div key={p.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
117
+ <PortfolioIcon portfolioId={p.id} />
118
+ <span>{p.name}</span>
119
+ </div>
120
+ ));
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Notes
126
+
127
+ - Unlike [`ProjectIcon`](../ProjectIcon/README.md) and [`GoalIcon`](../GoalIcon/README.md), `PortfolioIcon` uses the **string `id`** (not `shortId`) for color generation.
128
+ - `withBackground` defaults to `false` for portfolios (vs `true` for projects). Pass `withBackground` explicitly if you want the colored square background.
129
+ - To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
@@ -1,51 +1,175 @@
1
1
  # ProjectIcon
2
2
 
3
3
  <!-- description:start -->
4
- Component displaying an icon for a project entity
4
+ Displays a colored icon for a Tracker project entity. The icon color is deterministically derived from the `projectId`, so the same project always renders the same color across sessions and environments.
5
5
  <!-- description:end -->
6
6
 
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {ProjectIcon} from '@weavix/tracker-components';
11
+
12
+ <ProjectIcon projectId={123} />
13
+ ```
14
+
7
15
  ## Component props
8
16
 
9
17
  <!-- props:start -->
10
18
  ```ts
11
19
  {
12
20
  /**
13
- * Project ID used to generate a deterministic color
21
+ * Project ID used to generate a deterministic color.
22
+ * Accepts either the numeric shortId or a string entity ID.
14
23
  */
15
24
  projectId?: number | string;
25
+
16
26
  /**
17
- * Additional class
27
+ * Additional CSS class applied to the root element.
18
28
  */
19
29
  className?: string;
30
+
20
31
  /**
21
- * Entity type label (defaults to "project")
32
+ * Entity type label. Defaults to "project".
22
33
  */
23
34
  type?: string;
35
+
24
36
  /**
25
- * Size of the SVG icon inside the container in pixels
37
+ * Size of the SVG icon inside the container in pixels.
26
38
  * @default 16
27
39
  */
28
40
  size?: number;
41
+
29
42
  /**
30
- * Size of the icon container in pixels
43
+ * Size of the icon container (the colored square) in pixels.
31
44
  * @default 24
32
45
  */
33
46
  refugeSize?: number;
47
+
34
48
  /**
35
- * Whether to render a colored background behind the icon
49
+ * Whether to render a colored background behind the icon.
36
50
  * @default true
37
51
  */
38
52
  withBackground?: boolean;
53
+
39
54
  /**
40
- * Border radius variant of the icon container
55
+ * Border radius variant of the icon container.
41
56
  * @default 'm'
42
57
  */
43
58
  radius?: 'm' | 'l';
59
+
44
60
  /**
45
- * Alpha (opacity) of the icon color
61
+ * Alpha (opacity) of the icon foreground color.
46
62
  * @default 1
47
63
  */
48
64
  colorAlpha?: number;
49
65
  }
50
66
  ```
51
67
  <!-- props:end -->
68
+
69
+ ---
70
+
71
+ ## Examples
72
+
73
+ ### Default
74
+
75
+ ```tsx
76
+ import {ProjectIcon} from '@weavix/tracker-components';
77
+
78
+ <ProjectIcon projectId={123} />
79
+ ```
80
+
81
+ ### Without background
82
+
83
+ ```tsx
84
+ // Renders only the colored SVG, no background square
85
+ <ProjectIcon projectId={123} withBackground={false} />
86
+ ```
87
+
88
+ ### Custom size
89
+
90
+ ```tsx
91
+ <ProjectIcon projectId={123} size={20} refugeSize={32} />
92
+ ```
93
+
94
+ ### Large radius
95
+
96
+ ```tsx
97
+ <ProjectIcon projectId={123} radius="l" />
98
+ ```
99
+
100
+ ### Alongside project name
101
+
102
+ ```tsx
103
+ import {ProjectIcon} from '@weavix/tracker-components';
104
+
105
+ export const ProjectLabel = ({project}: {project: {shortId: number; name: string}}) => (
106
+ <div style={{display: 'flex', alignItems: 'center', gap: 8}}>
107
+ <ProjectIcon projectId={project.shortId} />
108
+ <span>{project.name}</span>
109
+ </div>
110
+ );
111
+ ```
112
+
113
+ ### Multiple projects (each gets a unique color)
114
+
115
+ ```tsx
116
+ const projects = [
117
+ {shortId: 1, name: 'Backend API'},
118
+ {shortId: 2, name: 'Mobile App'},
119
+ {shortId: 3, name: 'Design System'},
120
+ ];
121
+
122
+ projects.map((p) => (
123
+ <div key={p.shortId} style={{display: 'flex', alignItems: 'center', gap: 8}}>
124
+ <ProjectIcon projectId={p.shortId} />
125
+ <span>{p.name}</span>
126
+ </div>
127
+ ));
128
+ ```
129
+
130
+ ### Rendering from a Tracker API response
131
+
132
+ The Tracker entities search endpoint returns `shortId` as a number — pass it directly:
133
+
134
+ ```tsx
135
+ import React, {useEffect, useState} from 'react';
136
+ import {ProjectIcon} from '@weavix/tracker-components';
137
+ import type {MetaEntityV2} from '@weavix/tracker-api-types';
138
+
139
+ interface Props {
140
+ trackerApi: TrackerApi;
141
+ }
142
+
143
+ export const ProjectList: React.FC<Props> = ({trackerApi}) => {
144
+ const [projects, setProjects] = useState<MetaEntityV2[]>([]);
145
+
146
+ useEffect(() => {
147
+ trackerApi.v3
148
+ .post['/entities/{entityType}/_search']({
149
+ pathParams: {entityType: 'project'},
150
+ queryParams: {fields: ['summary'], page: 1, perPage: 20},
151
+ bodyParams: {filter: {}, filterTypes: ['ALL'], input: ''},
152
+ })
153
+ .then((result) => setProjects(result.data));
154
+ }, [trackerApi]);
155
+
156
+ return (
157
+ <ul>
158
+ {projects.map((project) => (
159
+ <li key={project.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
160
+ <ProjectIcon projectId={project.shortId} />
161
+ <span>{project.fields?.summary?.value ?? project.id}</span>
162
+ </li>
163
+ ))}
164
+ </ul>
165
+ );
166
+ };
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Notes
172
+
173
+ - `withBackground` defaults to `true` for projects (vs `false` for [`PortfolioIcon`](../PortfolioIcon/README.md)).
174
+ - Pass `projectId` as the **numeric `shortId`** from the Tracker API for consistent color generation. String IDs are also accepted.
175
+ - To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.