@weavix/tracker-components 0.1.0 → 0.1.2
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/README.md +191 -19
- package/build/cjs/components/Icon/EntityIcon/EntityIcon.js +2 -3
- package/build/cjs/components/Icon/EntityIcon/EntityIcon.js.map +1 -1
- package/build/cjs/components/Icon/GoalIcon/README.md +123 -0
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.classname.js.map +1 -1
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.css +0 -3
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.css.map +1 -1
- package/build/cjs/components/Icon/IssueTypeIcon/IssueTypeIcon.js +30 -50
- package/build/cjs/components/Icon/IssueTypeIcon/IssueTypeIcon.js.map +1 -1
- package/build/cjs/components/Icon/IssueTypeIcon/README.md +146 -22
- package/build/cjs/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/cjs/components/Icon/MetaEntityIcon/README.md +136 -0
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.d.ts +4 -1
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.js +1 -0
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.js.map +1 -1
- package/build/cjs/components/Icon/PortfolioIcon/README.md +94 -9
- package/build/cjs/components/Icon/ProjectIcon/README.md +133 -9
- package/build/cjs/components/MetaEntitiesSelect/README.md +10 -0
- package/build/cjs/components/PluginFieldsSelect/README.md +18 -0
- package/build/cjs/components/QueueSelect/README.md +10 -0
- package/build/cjs/components/TrackerDisclosure/README.md +205 -0
- package/build/esm/components/Icon/EntityIcon/EntityIcon.js +2 -3
- package/build/esm/components/Icon/EntityIcon/EntityIcon.js.map +1 -1
- package/build/esm/components/Icon/GoalIcon/README.md +123 -0
- package/build/esm/components/Icon/IconRefuge/IconRefuge.classname.js.map +1 -1
- package/build/esm/components/Icon/IconRefuge/IconRefuge.css +0 -3
- package/build/esm/components/Icon/IconRefuge/IconRefuge.css.map +1 -1
- package/build/esm/components/Icon/IconRefuge/IconRefuge.scss +0 -4
- package/build/esm/components/Icon/IssueTypeIcon/IssueTypeIcon.js +30 -50
- package/build/esm/components/Icon/IssueTypeIcon/IssueTypeIcon.js.map +1 -1
- package/build/esm/components/Icon/IssueTypeIcon/README.md +146 -22
- package/build/esm/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/esm/components/Icon/MetaEntityIcon/README.md +136 -0
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.d.ts +4 -1
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.js +1 -0
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.js.map +1 -1
- package/build/esm/components/Icon/PortfolioIcon/README.md +94 -9
- package/build/esm/components/Icon/ProjectIcon/README.md +133 -9
- package/build/esm/components/MetaEntitiesSelect/README.md +10 -0
- package/build/esm/components/PluginFieldsSelect/README.md +18 -0
- package/build/esm/components/QueueSelect/README.md +10 -0
- package/build/esm/components/TrackerDisclosure/README.md +205 -0
- package/package.json +1 -1
- package/build/cjs/components/Icon/Icon.css +0 -33
- package/build/cjs/components/Icon/Icon.css.map +0 -1
- package/build/esm/components/Icon/Icon.css +0 -33
- package/build/esm/components/Icon/Icon.css.map +0 -1
- package/build/esm/components/Icon/Icon.scss +0 -46
|
@@ -1,40 +1,164 @@
|
|
|
1
1
|
# IssueTypeIcon
|
|
2
2
|
|
|
3
3
|
<!-- description:start -->
|
|
4
|
-
|
|
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
|
-
*
|
|
21
|
+
* Issue type key. Known values are listed below; any other string is
|
|
22
|
+
* accepted and falls back to a generic icon.
|
|
23
|
+
*/
|
|
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
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Size of the icon in pixels.
|
|
47
|
+
* @default 16
|
|
48
|
+
*/
|
|
49
|
+
size?: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Additional CSS class applied to the root element.
|
|
14
53
|
*/
|
|
15
54
|
className?: string;
|
|
55
|
+
|
|
16
56
|
/**
|
|
17
|
-
*
|
|
57
|
+
* Additional CSS class applied to the outer container element.
|
|
18
58
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'query' |
|
|
29
|
-
'refactoring' |
|
|
30
|
-
'release' |
|
|
31
|
-
'serviceRequest' |
|
|
32
|
-
'story' |
|
|
33
|
-
'subBug' |
|
|
34
|
-
'subTask' |
|
|
35
|
-
'technicalDebt' |
|
|
36
|
-
'milestone' |
|
|
37
|
-
string;
|
|
59
|
+
containerClassName?: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Human-readable display name for the issue type (e.g. `"Bug"`, `"Story"`).
|
|
63
|
+
* When provided, an accessible label `"Type: <issueType>"` is rendered for
|
|
64
|
+
* screen readers and `title` is forwarded to the icon container.
|
|
65
|
+
* When omitted, the icon is treated as decorative (`aria-hidden`).
|
|
66
|
+
*/
|
|
67
|
+
title?: string;
|
|
38
68
|
}
|
|
39
69
|
```
|
|
40
70
|
<!-- props:end -->
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### Single icon
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
80
|
+
|
|
81
|
+
<IssueTypeIcon issueType="task" />
|
|
82
|
+
<IssueTypeIcon issueType="bug" />
|
|
83
|
+
<IssueTypeIcon issueType="epic" />
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Custom size
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<IssueTypeIcon issueType="story" size={24} />
|
|
90
|
+
<IssueTypeIcon issueType="story" size={32} />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Alongside issue summary
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
97
|
+
|
|
98
|
+
export const IssueRow = ({issue}: {issue: {type: string; summary: string}}) => (
|
|
99
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
100
|
+
<IssueTypeIcon issueType={issue.type} size={16} />
|
|
101
|
+
<span>{issue.summary}</span>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### All known issue types
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
110
|
+
|
|
111
|
+
const ISSUE_TYPES = [
|
|
112
|
+
'task', 'bug', 'design', 'epic', 'improvement',
|
|
113
|
+
'incident', 'info', 'milestone', 'newFeature', 'query',
|
|
114
|
+
'refactoring', 'release', 'research', 'serviceRequest',
|
|
115
|
+
'story', 'subBug', 'subTask', 'technicalDebt',
|
|
116
|
+
] as const;
|
|
117
|
+
|
|
118
|
+
export const IssueTypeGallery = () => (
|
|
119
|
+
<div style={{display: 'flex', flexWrap: 'wrap', gap: 16}}>
|
|
120
|
+
{ISSUE_TYPES.map((type) => (
|
|
121
|
+
<div key={type} style={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4}}>
|
|
122
|
+
<IssueTypeIcon issueType={type} size={24} />
|
|
123
|
+
<span style={{fontSize: 11}}>{type}</span>
|
|
124
|
+
</div>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### From Tracker API
|
|
131
|
+
|
|
132
|
+
Requires the `"tracker:issuetypes:read"` permission in your plugin's `manifest.json`:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"permissions": {
|
|
137
|
+
"data": ["tracker:issuetypes:read"]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
144
|
+
|
|
145
|
+
const issueType = await trackerApi.v3.get['/issues/{id}/{field}']({
|
|
146
|
+
pathParams: {
|
|
147
|
+
id: 'ISSUEKEY-1',
|
|
148
|
+
field: 'type',
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
<IssueTypeIcon
|
|
153
|
+
issueType={issueType.data.key}
|
|
154
|
+
title={issueType.data.display}
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Notes
|
|
161
|
+
|
|
162
|
+
- 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.
|
|
163
|
+
- Passing an unknown string does not throw — the component renders a generic fallback icon.
|
|
164
|
+
- When `title` is omitted the icon is treated as decorative and gets `aria-hidden="true"`. Pass `title` (e.g. `type.display` from the API) to make the icon accessible.
|
|
@@ -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,136 @@
|
|
|
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
|
+
Requires the `"tracker:entities:write"` permission in your plugin's `manifest.json`:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"permissions": {
|
|
84
|
+
"data": ["tracker:entities:write"]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`MetaEntityIcon` accepts the shape returned directly by the Tracker entities search endpoint, so you can pass `result.data[i]` without any mapping:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import React, {useEffect, useState} from 'react';
|
|
93
|
+
import {MetaEntityIcon} from '@weavix/tracker-components';
|
|
94
|
+
import type {MetaEntityV2} from '@weavix/tracker-api-types';
|
|
95
|
+
|
|
96
|
+
interface Props {
|
|
97
|
+
trackerApi: TrackerApi;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const EntityList: React.FC<Props> = ({trackerApi}) => {
|
|
101
|
+
const [entities, setEntities] = useState<MetaEntityV2[]>([]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
trackerApi.v3
|
|
105
|
+
.post['/entities/{entityType}/_search']({
|
|
106
|
+
pathParams: {entityType: 'project'},
|
|
107
|
+
queryParams: {fields: ['summary'], page: 1, perPage: 20},
|
|
108
|
+
bodyParams: {filter: {}, filterTypes: ['ALL'], input: ''},
|
|
109
|
+
})
|
|
110
|
+
.then((result) => setEntities(result.data));
|
|
111
|
+
}, [trackerApi]);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<ul>
|
|
115
|
+
{entities.map((entity) => (
|
|
116
|
+
<li key={entity.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
117
|
+
<MetaEntityIcon entity={entity} size={20} />
|
|
118
|
+
<span>{entity.fields?.summary?.value ?? entity.id}</span>
|
|
119
|
+
</li>
|
|
120
|
+
))}
|
|
121
|
+
</ul>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Used inside MetaEntitiesSelect
|
|
127
|
+
|
|
128
|
+
`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.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Notes
|
|
133
|
+
|
|
134
|
+
- The `entity` prop only requires `entityType`, `id`, and `shortId` — it is compatible with the full `MetaEntityV2` type from `@weavix/tracker-api-types`.
|
|
135
|
+
- For unknown `entityType` values the component renders `null` silently.
|
|
136
|
+
- To render individual entity icons directly, use [`ProjectIcon`](../ProjectIcon/README.md), [`PortfolioIcon`](../PortfolioIcon/README.md), [`GoalIcon`](../GoalIcon/README.md), or [`KeyResultIcon`](../KeyResultIcon/README.md).
|
|
@@ -3,4 +3,7 @@ import type { EntityIconProps } from '../EntityIcon';
|
|
|
3
3
|
export type PortfolioIconProps = {
|
|
4
4
|
portfolioId: string;
|
|
5
5
|
} & Omit<EntityIconProps, 'data' | 'id' | 'alpha'>;
|
|
6
|
-
export declare const PortfolioIcon:
|
|
6
|
+
export declare const PortfolioIcon: {
|
|
7
|
+
({ portfolioId, ...props }: PortfolioIconProps): React.JSX.Element;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_EntityIcon","_portfolio","_jsxRuntime","e","__esModule","default","PortfolioIcon","exports","_ref","portfolioId","props","_objectWithoutProperties","_excluded","_jsx","EntityIcon","_objectSpread","data","portfolioIcon","id","type","alpha","withBackground"],"sources":["PortfolioIcon.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {EntityIconProps} from '../EntityIcon';\nimport {EntityIcon} from '../EntityIcon';\n\nimport portfolioIcon from '../../../../assets/icons/portfolio.svg';\n\nexport type PortfolioIconProps = {portfolioId: string} & Omit<\n EntityIconProps,\n 'data' | 'id' | 'alpha'\n>;\n\nexport const PortfolioIcon = ({portfolioId, ...props}: PortfolioIconProps) => (\n <EntityIcon\n data={portfolioIcon}\n id={portfolioId}\n type=\"portfolio\"\n alpha={0.5}\n withBackground={false}\n {...props}\n />\n);\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAmE,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;;AAO5D,IAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA;EAAA,IAAKC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAKC,KAAK,OAAAC,iCAAA,EAAAH,IAAA,EAAAI,SAAA;EAAA,oBAChD,IAAAC,eAAA,EAACC,sBAAU,MAAAC,sBAAA;IACPC,IAAI,EAAEC,kBAAc;IACpBC,EAAE,EAAET,WAAY;IAChBU,IAAI,EAAC,WAAW;IAChBC,KAAK,EAAE,GAAI;IACXC,cAAc,EAAE;EAAM,GAClBX,KAAK,CACZ,CAAC;AAAA,CACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_EntityIcon","_portfolio","_jsxRuntime","e","__esModule","default","PortfolioIcon","exports","_ref","portfolioId","props","_objectWithoutProperties","_excluded","_jsx","EntityIcon","_objectSpread","data","portfolioIcon","id","type","alpha","withBackground","displayName"],"sources":["PortfolioIcon.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {EntityIconProps} from '../EntityIcon';\nimport {EntityIcon} from '../EntityIcon';\n\nimport portfolioIcon from '../../../../assets/icons/portfolio.svg';\n\nexport type PortfolioIconProps = {portfolioId: string} & Omit<\n EntityIconProps,\n 'data' | 'id' | 'alpha'\n>;\n\nexport const PortfolioIcon = ({portfolioId, ...props}: PortfolioIconProps) => (\n <EntityIcon\n data={portfolioIcon}\n id={portfolioId}\n type=\"portfolio\"\n alpha={0.5}\n withBackground={false}\n {...props}\n />\n);\n\nPortfolioIcon.displayName = 'PortfolioIcon';\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAmE,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;;AAO5D,IAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA;EAAA,IAAKC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAKC,KAAK,OAAAC,iCAAA,EAAAH,IAAA,EAAAI,SAAA;EAAA,oBAChD,IAAAC,eAAA,EAACC,sBAAU,MAAAC,sBAAA;IACPC,IAAI,EAAEC,kBAAc;IACpBC,EAAE,EAAET,WAAY;IAChBU,IAAI,EAAC,WAAW;IAChBC,KAAK,EAAE,GAAI;IACXC,cAAc,EAAE;EAAM,GAClBX,KAAK,CACZ,CAAC;AAAA,CACL;AAEDJ,aAAa,CAACgB,WAAW,GAAG,eAAe","ignoreList":[]}
|
|
@@ -1,51 +1,136 @@
|
|
|
1
1
|
# PortfolioIcon
|
|
2
2
|
|
|
3
3
|
<!-- description:start -->
|
|
4
|
-
|
|
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
|
|
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.
|
|
50
|
+
* `PortfolioIcon` defaults this to `false`; `EntityIcon`'s own default is `true`.
|
|
36
51
|
* @default false
|
|
37
52
|
*/
|
|
38
53
|
withBackground?: boolean;
|
|
54
|
+
|
|
39
55
|
/**
|
|
40
|
-
*
|
|
56
|
+
* Alpha (opacity) of the icon foreground color, in the range 0–1.
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
colorAlpha?: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Border radius variant of the icon container.
|
|
41
63
|
* @default 'm'
|
|
42
64
|
*/
|
|
43
65
|
radius?: 'm' | 'l';
|
|
66
|
+
|
|
44
67
|
/**
|
|
45
|
-
* Alpha (opacity) of the icon color
|
|
68
|
+
* Alpha (opacity) of the icon foreground color.
|
|
46
69
|
* @default 1
|
|
47
70
|
*/
|
|
48
71
|
colorAlpha?: number;
|
|
49
72
|
}
|
|
50
73
|
```
|
|
51
74
|
<!-- props:end -->
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### Default
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import {PortfolioIcon} from '@weavix/tracker-components';
|
|
84
|
+
|
|
85
|
+
<PortfolioIcon portfolioId="portfolio-abc" />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### With background
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<PortfolioIcon portfolioId="portfolio-abc" withBackground />
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Custom size
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<PortfolioIcon portfolioId="portfolio-abc" size={20} refugeSize={32} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Alongside portfolio name
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import {PortfolioIcon} from '@weavix/tracker-components';
|
|
104
|
+
|
|
105
|
+
export const PortfolioLabel = ({portfolio}: {portfolio: {id: string; name: string}}) => (
|
|
106
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
107
|
+
<PortfolioIcon portfolioId={portfolio.id} />
|
|
108
|
+
<span>{portfolio.name}</span>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Multiple portfolios (each gets a unique color)
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const portfolios = [
|
|
117
|
+
{id: 'port-1', name: 'Platform'},
|
|
118
|
+
{id: 'port-2', name: 'Growth'},
|
|
119
|
+
{id: 'port-3', name: 'Infrastructure'},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
portfolios.map((p) => (
|
|
123
|
+
<div key={p.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
124
|
+
<PortfolioIcon portfolioId={p.id} />
|
|
125
|
+
<span>{p.name}</span>
|
|
126
|
+
</div>
|
|
127
|
+
));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Notes
|
|
133
|
+
|
|
134
|
+
- Unlike [`ProjectIcon`](../ProjectIcon/README.md) and [`GoalIcon`](../GoalIcon/README.md), `PortfolioIcon` uses the **string `id`** (not `shortId`) for color generation.
|
|
135
|
+
- `withBackground` defaults to `false` for portfolios (vs `true` for projects). Pass `withBackground` explicitly if you want the colored square background.
|
|
136
|
+
- To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
|