@teambit/component 0.0.565 → 0.0.569

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.
Files changed (54) hide show
  1. package/aspect.section.tsx +16 -0
  2. package/component-map/component-map.ts +106 -0
  3. package/component-map/index.ts +1 -0
  4. package/component.ui.runtime.tsx +216 -0
  5. package/dependencies/dependencies.ts +74 -0
  6. package/dependencies/index.ts +1 -0
  7. package/dist/component.js +7 -13
  8. package/dist/component.js.map +1 -1
  9. package/exceptions/could-not-find-latest.ts +8 -0
  10. package/exceptions/host-not-found.ts +14 -0
  11. package/exceptions/index.ts +4 -0
  12. package/exceptions/nothing-to-snap.ts +1 -0
  13. package/host/component-host-model.ts +9 -0
  14. package/host/index.ts +2 -0
  15. package/host/use-component-host.ts +39 -0
  16. package/package-tar/teambit-component-0.0.569.tgz +0 -0
  17. package/package.json +34 -49
  18. package/section/index.ts +1 -0
  19. package/section/section.tsx +8 -0
  20. package/show/extensions.fragment.ts +23 -0
  21. package/show/files.fragment.ts +24 -0
  22. package/show/id.fragment.ts +20 -0
  23. package/show/index.ts +8 -0
  24. package/show/main-file.fragment.ts +13 -0
  25. package/show/name.fragment.ts +13 -0
  26. package/show/scope.fragment.ts +15 -0
  27. package/show/show-fragment.ts +44 -0
  28. package/show/show.cmd.ts +85 -0
  29. package/snap/author.ts +19 -0
  30. package/snap/index.ts +2 -0
  31. package/snap/snap.ts +63 -0
  32. package/tag/index.ts +1 -0
  33. package/tag/tag.ts +37 -0
  34. package/types/asset.d.ts +29 -0
  35. package/types/style.d.ts +42 -0
  36. package/ui/aspect-page/aspect-page.tsx +64 -0
  37. package/ui/aspect-page/index.ts +1 -0
  38. package/ui/component-error/component-error.tsx +22 -0
  39. package/ui/component-error/index.ts +1 -0
  40. package/ui/component-model/component-model.ts +169 -0
  41. package/ui/component-model/index.ts +1 -0
  42. package/ui/component.tsx +48 -0
  43. package/ui/context/component-context.ts +5 -0
  44. package/ui/context/component-provider.tsx +20 -0
  45. package/ui/context/index.ts +2 -0
  46. package/ui/index.ts +3 -0
  47. package/ui/menu/index.ts +2 -0
  48. package/ui/menu/menu-nav.tsx +37 -0
  49. package/ui/menu/menu.tsx +94 -0
  50. package/ui/menu/nav-plugin.tsx +9 -0
  51. package/ui/top-bar-nav/index.ts +1 -0
  52. package/ui/top-bar-nav/top-bar-nav.tsx +26 -0
  53. package/ui/use-component-query.ts +195 -0
  54. package/ui/use-component.tsx +34 -0
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "0.0.565",
3
+ "version": "0.0.569",
4
4
  "homepage": "https://bit.dev/teambit/component/component",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component",
9
- "version": "0.0.565"
9
+ "version": "0.0.569"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -26,38 +26,38 @@
26
26
  "@teambit/base-ui.routing.nav-link": "1.0.0",
27
27
  "@teambit/documenter.ui.heading": "4.1.1",
28
28
  "@teambit/documenter.ui.separator": "4.1.1",
29
- "@teambit/component-id": "0.0.382",
30
- "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.471",
31
- "@teambit/aspect-loader": "0.0.565",
32
- "@teambit/legacy-bit-id": "0.0.381",
33
- "@teambit/toolbox.string.capitalize": "0.0.466",
34
- "@teambit/cli": "0.0.392",
35
- "@teambit/config": "0.0.404",
36
- "@teambit/express": "0.0.481",
37
- "@teambit/graphql": "0.0.565",
38
- "@teambit/bit-error": "0.0.378",
39
- "@teambit/command-bar": "0.0.565",
40
- "@teambit/preview": "0.0.565",
41
- "@teambit/pubsub": "0.0.565",
42
- "@teambit/ui-foundation.ui.is-browser": "0.0.469",
43
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.469",
44
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.471",
45
- "@teambit/ui": "0.0.565",
46
- "@teambit/component-issues": "0.0.27",
47
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.470",
48
- "@teambit/cli-table": "0.0.15",
49
- "@teambit/ui-foundation.ui.react-router.use-query": "0.0.469",
29
+ "@teambit/component-id": "0.0.385",
30
+ "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.474",
31
+ "@teambit/aspect-loader": "0.0.569",
32
+ "@teambit/legacy-bit-id": "0.0.384",
33
+ "@teambit/toolbox.string.capitalize": "0.0.469",
34
+ "@teambit/cli": "0.0.395",
35
+ "@teambit/config": "0.0.407",
36
+ "@teambit/express": "0.0.485",
37
+ "@teambit/graphql": "0.0.569",
38
+ "@teambit/bit-error": "0.0.381",
39
+ "@teambit/command-bar": "0.0.569",
40
+ "@teambit/preview": "0.0.569",
41
+ "@teambit/pubsub": "0.0.569",
42
+ "@teambit/ui-foundation.ui.is-browser": "0.0.472",
43
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.472",
44
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.474",
45
+ "@teambit/ui": "0.0.569",
46
+ "@teambit/component-issues": "0.0.30",
47
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.473",
48
+ "@teambit/cli-table": "0.0.18",
49
+ "@teambit/ui-foundation.ui.react-router.use-query": "0.0.472",
50
50
  "@teambit/design.ui.empty-box": "0.0.352",
51
- "@teambit/harmony.ui.aspect-box": "0.0.469",
51
+ "@teambit/harmony.ui.aspect-box": "0.0.472",
52
52
  "@teambit/design.ui.pages.not-found": "0.0.352",
53
53
  "@teambit/design.ui.pages.server-error": "0.0.352",
54
- "@teambit/compositions": "0.0.565",
55
- "@teambit/deprecation": "0.0.565",
56
- "@teambit/envs": "0.0.565",
57
- "@teambit/component.ui.version-dropdown": "0.0.473",
58
- "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.90",
59
- "@teambit/ui-foundation.ui.use-box.menu": "0.0.90",
60
- "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.469"
54
+ "@teambit/compositions": "0.0.569",
55
+ "@teambit/deprecation": "0.0.569",
56
+ "@teambit/envs": "0.0.569",
57
+ "@teambit/component.ui.version-dropdown": "0.0.476",
58
+ "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.93",
59
+ "@teambit/ui-foundation.ui.use-box.menu": "0.0.93",
60
+ "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.472"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/lodash": "4.14.165",
@@ -72,11 +72,11 @@
72
72
  "@types/jest": "^26.0.0",
73
73
  "@types/react-dom": "^17.0.5",
74
74
  "@types/node": "12.20.4",
75
- "@teambit/component.aspect-docs.component": "0.0.111"
75
+ "@teambit/component.aspect-docs.component": "0.0.115"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@apollo/client": "^3.0.0",
79
- "@teambit/legacy": "1.0.178",
79
+ "@teambit/legacy": "1.0.181",
80
80
  "react-dom": "^16.8.0 || ^17.0.0",
81
81
  "react": "^16.8.0 || ^17.0.0"
82
82
  },
@@ -104,27 +104,12 @@
104
104
  "react": "-"
105
105
  },
106
106
  "peerDependencies": {
107
- "@teambit/legacy": "1.0.178",
107
+ "@teambit/legacy": "1.0.181",
108
108
  "react-dom": "^16.8.0 || ^17.0.0",
109
109
  "react": "^16.8.0 || ^17.0.0"
110
110
  }
111
111
  }
112
112
  },
113
- "files": [
114
- "dist",
115
- "!dist/tsconfig.tsbuildinfo",
116
- "**/*.md",
117
- "**/*.mdx",
118
- "**/*.js",
119
- "**/*.json",
120
- "**/*.sass",
121
- "**/*.scss",
122
- "**/*.less",
123
- "**/*.css",
124
- "**/*.css",
125
- "**/*.jpeg",
126
- "**/*.gif"
127
- ],
128
113
  "private": false,
129
114
  "engines": {
130
115
  "node": ">=12.22.0"
@@ -0,0 +1 @@
1
+ export { Section } from './section';
@@ -0,0 +1,8 @@
1
+ import { NavLinkProps } from '@teambit/base-ui.routing.nav-link';
2
+ import { RouteProps } from 'react-router-dom';
3
+
4
+ export interface Section {
5
+ route: RouteProps;
6
+ navigationLink: NavLinkProps;
7
+ order?: number;
8
+ }
@@ -0,0 +1,23 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class ExtensionsFragment implements ShowFragment {
5
+ private renderList(component: Component) {
6
+ const aspects = component.state.aspects.entries.map((entry) => entry.id.toString());
7
+ return aspects.join('\n');
8
+ }
9
+
10
+ async renderRow(component: Component) {
11
+ return {
12
+ title: 'extensions',
13
+ content: this.renderList(component),
14
+ };
15
+ }
16
+
17
+ async json(component: Component) {
18
+ return {
19
+ title: 'configuration',
20
+ json: component.state.aspects.serialize() as any,
21
+ };
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class FilesFragment implements ShowFragment {
5
+ async renderRow(component: Component) {
6
+ return {
7
+ title: 'files',
8
+ content: this.getRelativePaths(component).join('\n'),
9
+ };
10
+ }
11
+
12
+ async json(component: Component) {
13
+ return {
14
+ title: 'files',
15
+ json: this.getRelativePaths(component),
16
+ };
17
+ }
18
+
19
+ private getRelativePaths(component: Component) {
20
+ return component.state.filesystem.files.map((file) => file.relative);
21
+ }
22
+
23
+ weight = 4;
24
+ }
@@ -0,0 +1,20 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class IDFragment implements ShowFragment {
5
+ async renderRow(component: Component) {
6
+ return {
7
+ title: 'id',
8
+ content: component.id.toString(),
9
+ };
10
+ }
11
+
12
+ async json(component: Component) {
13
+ return {
14
+ title: 'id',
15
+ json: component.id.toString(),
16
+ };
17
+ }
18
+
19
+ weight = 0;
20
+ }
package/show/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export { ShowFragment, ShowRow } from './show-fragment';
2
+ export { ShowCmd } from './show.cmd';
3
+ export { MainFileFragment } from './main-file.fragment';
4
+ export { NameFragment } from './name.fragment';
5
+ export { IDFragment } from './id.fragment';
6
+ export { ScopeFragment } from './scope.fragment';
7
+ export { FilesFragment } from './files.fragment';
8
+ export { ExtensionsFragment } from './extensions.fragment';
@@ -0,0 +1,13 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class MainFileFragment implements ShowFragment {
5
+ async renderRow(component: Component) {
6
+ return {
7
+ title: 'main file',
8
+ content: component.state._consumer.mainFile,
9
+ };
10
+ }
11
+
12
+ weight = 4;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class NameFragment implements ShowFragment {
5
+ async renderRow(component: Component) {
6
+ return {
7
+ title: 'name',
8
+ content: component.id.fullName,
9
+ };
10
+ }
11
+
12
+ weight = 2;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { ShowFragment } from './show-fragment';
2
+ import { Component } from '../component';
3
+
4
+ export class ScopeFragment implements ShowFragment {
5
+ async renderRow(component: Component) {
6
+ return {
7
+ title: 'scope',
8
+ content: component.id.scope || '',
9
+ };
10
+ }
11
+
12
+ getRow() {}
13
+
14
+ weight = 1;
15
+ }
@@ -0,0 +1,44 @@
1
+ import { Component } from '../component';
2
+
3
+ export interface ShowFragment {
4
+ /**
5
+ * render a row into the `show` CLI.
6
+ */
7
+ renderRow(component: Component): Promise<ShowRow>;
8
+
9
+ /**
10
+ * return a json output.
11
+ */
12
+ json?(component: Component): Promise<JSONRow>;
13
+
14
+ /**
15
+ * weight is used to determine the position of the fragment
16
+ * within the `show` table.
17
+ */
18
+ weight?: number;
19
+ }
20
+
21
+ export interface JSONRow {
22
+ /**
23
+ * name of the field.
24
+ */
25
+ title: string;
26
+
27
+ /**
28
+ * json content.
29
+ * TODO: change this from any to a more structured type (e.g. Serializable).
30
+ */
31
+ json: any;
32
+ }
33
+
34
+ export interface ShowRow {
35
+ /**
36
+ * title of the fragment
37
+ */
38
+ title: string;
39
+
40
+ /**
41
+ * content to render within the fragment.
42
+ */
43
+ content: string;
44
+ }
@@ -0,0 +1,85 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ // import { Logger } from '@teambit/logger';
3
+ // import chalk from 'chalk';
4
+ import { CLITable } from '@teambit/cli-table';
5
+ import { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';
6
+ import { BitId } from '@teambit/legacy-bit-id';
7
+ import LegacyShow from '@teambit/legacy/dist/cli/commands/public-cmds/show-cmd';
8
+ import { ComponentMain } from '../component.main.runtime';
9
+
10
+ export class ShowCmd implements Command {
11
+ name = 'show <id>';
12
+ description = 'show a component';
13
+ alias = '';
14
+ group = 'info';
15
+ options = [
16
+ ['j', 'json', 'return the component data in json format'],
17
+ ['l', 'legacy', 'use the legacy bit show.'],
18
+ ['r', 'remote', 'show a remote component'],
19
+ [
20
+ 'c',
21
+ 'compare',
22
+ 'compare current file system component to latest tagged component [default=latest]. only works in legacy.',
23
+ ],
24
+ ] as CommandOptions;
25
+
26
+ constructor(private component: ComponentMain) {}
27
+
28
+ private async getComponent(idStr: string, remote: boolean) {
29
+ if (remote) {
30
+ const bitId: BitId = BitId.parse(idStr, true); // user used --remote so we know it has a scope
31
+ const host = this.component.getHost('teambit.scope/scope');
32
+ const id = await host.resolveComponentId(bitId);
33
+ if (!host.getRemoteComponent) {
34
+ throw new Error('Component Host does not implement getRemoteComponent()');
35
+ }
36
+ const component = await host.getRemoteComponent(id);
37
+ return component;
38
+ }
39
+ const host = this.component.getHost();
40
+ const id = await host.resolveComponentId(idStr);
41
+ const component = await host.get(id);
42
+ if (!component) throw new MissingBitMapComponent(idStr);
43
+ return component;
44
+ }
45
+
46
+ async useLegacy(id: string, json = false, remote = false, compare = false) {
47
+ const legacyShow = new LegacyShow();
48
+ const showData = await legacyShow.action([id], {
49
+ json,
50
+ versions: undefined,
51
+ remote,
52
+ compare,
53
+ });
54
+
55
+ return legacyShow.report(showData);
56
+ }
57
+
58
+ async report([idStr]: [string], { legacy, remote, compare }: { legacy: boolean; remote: boolean; compare: boolean }) {
59
+ if (legacy) return this.useLegacy(idStr, false, remote, compare);
60
+ const component = await this.getComponent(idStr, remote);
61
+ const fragments = this.component.getShowFragments();
62
+ const rows = await Promise.all(
63
+ fragments.map(async (fragment) => {
64
+ const row = await fragment.renderRow(component);
65
+ return [row.title, row.content];
66
+ })
67
+ );
68
+
69
+ const table = new CLITable([], rows);
70
+ return table.render();
71
+ }
72
+
73
+ async json([idStr]: [string], { remote, legacy }: { remote: boolean; legacy: boolean }) {
74
+ if (legacy) return JSON.parse(await this.useLegacy(idStr, true, remote));
75
+ const component = await this.getComponent(idStr, remote);
76
+ const fragments = this.component.getShowFragments();
77
+ const rows = await Promise.all(
78
+ fragments.map(async (fragment) => {
79
+ return fragment.json ? fragment.json(component) : undefined;
80
+ })
81
+ );
82
+
83
+ return rows.filter((row) => !!row);
84
+ }
85
+ }
package/snap/author.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * author type.
3
+ */
4
+ export type Author = {
5
+ /**
6
+ * author full name (for example: "Ran Mizrahi")
7
+ */
8
+ displayName: string;
9
+ /**
10
+ * author username (for example: "ranm8")
11
+ */
12
+ name?: string; // added this to support the usual structure of an author
13
+ // TODO - @ran, is this ok with you?
14
+
15
+ /**
16
+ * author email in a proper format (e.g. "ran@bit.dev")
17
+ */
18
+ email: string;
19
+ };
package/snap/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Author } from './author';
2
+ export { Snap, SnapProps } from './snap';
package/snap/snap.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { Author } from './author';
2
+
3
+ export type SnapProps = {
4
+ hash: string;
5
+ timestamp: string;
6
+ parents: string[];
7
+ author: Author;
8
+ message: string;
9
+ };
10
+
11
+ /**
12
+ * `Snap` represents a sealed state of the component in the working tree.
13
+ */
14
+ export class Snap {
15
+ constructor(
16
+ /**
17
+ * hash of the snap.
18
+ */
19
+ readonly hash: string,
20
+
21
+ /**
22
+ * date time of the snap.
23
+ */
24
+ readonly timestamp: Date,
25
+
26
+ /**
27
+ * parent snap
28
+ */
29
+ readonly parents: string[],
30
+
31
+ /**
32
+ * author of the component `Snap`.
33
+ */
34
+ readonly author: Author,
35
+
36
+ /**
37
+ * message added by the `Snap` author.
38
+ */
39
+ readonly message: string
40
+ ) {}
41
+
42
+ static fromObject(snapObject: SnapProps) {
43
+ const parents = snapObject.parents || [];
44
+
45
+ return new Snap(
46
+ snapObject.hash,
47
+ new Date(parseInt(snapObject.timestamp)),
48
+ parents,
49
+ snapObject.author,
50
+ snapObject.message
51
+ );
52
+ }
53
+
54
+ toObject(): SnapProps {
55
+ return {
56
+ timestamp: this.timestamp.getTime().toString(),
57
+ hash: this.hash,
58
+ author: this.author,
59
+ message: this.message,
60
+ parents: this.parents,
61
+ };
62
+ }
63
+ }
package/tag/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { Tag } from './tag';
package/tag/tag.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { SemVer } from 'semver';
2
+
3
+ export type TagProps = {
4
+ hash: string;
5
+ version: string;
6
+ };
7
+
8
+ /**
9
+ * `Tag` provides a sematic reference to a specific state `Snap` in the working tree.
10
+ */
11
+ export class Tag {
12
+ constructor(
13
+ /**
14
+ * tag hash, can be used to load it by component-factory.getSnap
15
+ */
16
+ readonly hash: string,
17
+
18
+ /**
19
+ * sematic version of the snap.
20
+ */
21
+ readonly version: SemVer
22
+ ) {}
23
+
24
+ /**
25
+ * create a plain tag object.
26
+ */
27
+ toObject(): TagProps {
28
+ return {
29
+ hash: this.hash,
30
+ version: this.version.raw,
31
+ };
32
+ }
33
+
34
+ static fromObject(tag: TagProps) {
35
+ return new Tag(tag.hash, new SemVer(tag.version));
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
+ const src: string;
10
+ export default src;
11
+ }
12
+
13
+ // @TODO Gilad
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }
@@ -0,0 +1,64 @@
1
+ import { AspectBox } from '@teambit/harmony.ui.aspect-box';
2
+ import { ComponentContext } from '@teambit/component';
3
+ import React, { useContext } from 'react';
4
+ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
5
+ import { gql } from '@apollo/client';
6
+ import { EmptyBox } from '@teambit/design.ui.empty-box';
7
+ import { H1 } from '@teambit/documenter.ui.heading';
8
+ import { Separator } from '@teambit/documenter.ui.separator';
9
+ import styles from './aspect-page.module.scss';
10
+
11
+ const GET_COMPONENT = gql`
12
+ query($id: String!) {
13
+ getHost {
14
+ get(id: $id) {
15
+ aspects {
16
+ id
17
+ config
18
+ data
19
+ icon
20
+ }
21
+ }
22
+ }
23
+ }
24
+ `;
25
+
26
+ export function AspectPage() {
27
+ const component = useContext(ComponentContext);
28
+ const { data } = useDataQuery(GET_COMPONENT, {
29
+ variables: { id: component.id._legacy.name },
30
+ });
31
+ const aspectList = data?.getHost?.get?.aspects;
32
+
33
+ if (aspectList && aspectList.length === 0) {
34
+ return (
35
+ <EmptyBox
36
+ title="This component is new and doesn’t have any aspects."
37
+ linkText="Learn more about component aspects"
38
+ link="https://harmony-docs.bit.dev/aspects/aspects-overview"
39
+ />
40
+ );
41
+ }
42
+
43
+ return (
44
+ <div className={styles.aspectPage}>
45
+ <div>
46
+ <H1 className={styles.title}>Configuration</H1>
47
+ <Separator className={styles.separator} />
48
+ {aspectList &&
49
+ aspectList.map((aspect, index) => {
50
+ return (
51
+ <AspectBox
52
+ key={index}
53
+ className={styles.aspectBox}
54
+ name={aspect.id}
55
+ icon={aspect.icon}
56
+ config={aspect.config}
57
+ data={aspect.data}
58
+ />
59
+ );
60
+ })}
61
+ </div>
62
+ </div>
63
+ );
64
+ }
@@ -0,0 +1 @@
1
+ export { AspectPage } from './aspect-page';