@teambit/compositions 0.0.554 → 0.0.558
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/composition.d.ts +22 -1
- package/dist/composition.section.d.ts +8 -1
- package/dist/compositions.main.runtime.d.ts +56 -1
- package/dist/compositions.preview.runtime.d.ts +9 -1
- package/dist/compositions.ui.runtime.d.ts +3 -0
- package/dist/ui/composition-preview.d.ts +15 -0
- package/package.json +34 -26
- package/tsconfig.json +1 -2
- package/composition.section.tsx +0 -29
- package/composition.ts +0 -44
- package/compositions.aspect.ts +0 -9
- package/compositions.docs.mdx +0 -8
- package/compositions.graphql.ts +0 -32
- package/compositions.main.runtime.ts +0 -164
- package/compositions.module.scss +0 -100
- package/compositions.preview-definition.ts +0 -21
- package/compositions.preview.runtime.ts +0 -67
- package/compositions.tsx +0 -185
- package/compositions.ui.runtime.tsx +0 -53
- package/index.ts +0 -10
- package/package-tar/teambit-compositions-0.0.554.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/ui/composition-preview.tsx +0 -60
- package/ui/compositions-overview/compositions-overview.module.scss +0 -16
- package/ui/compositions-overview/compositions-overview.tsx +0 -21
- package/ui/compositions-overview/index.ts +0 -1
- package/ui/compositions-panel/compositions-panel.module.scss +0 -119
- package/ui/compositions-panel/compositions-panel.tsx +0 -58
- package/ui/compositions-panel/index.ts +0 -0
- package/ui/compositions-panel-node/compositions-panel-node.module.scss +0 -15
- package/ui/compositions-panel-node/compositions-panel-node.tsx +0 -22
- package/ui/compositions-panel-node/index.ts +0 -1
- package/ui/index.ts +0 -1
- package/ui/use-compositions.tsx +0 -14
package/compositions.module.scss
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
-
$panelBg: #fafafa;
|
|
3
|
-
|
|
4
|
-
.compositionsPage {
|
|
5
|
-
height: 100%;
|
|
6
|
-
width: 100%;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.compositionPreview {
|
|
10
|
-
padding-top: 20px;
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.left {
|
|
15
|
-
min-width: 200px;
|
|
16
|
-
|
|
17
|
-
//cannot assign max-width directly to right side
|
|
18
|
-
max-width: calc(100% - 200px);
|
|
19
|
-
|
|
20
|
-
display: flex;
|
|
21
|
-
overflow-y: auto;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.right {
|
|
26
|
-
background: $panelBg;
|
|
27
|
-
overflow-y: auto;
|
|
28
|
-
// this is to fix the right panel when it gets too big or too small
|
|
29
|
-
min-width: 200px;
|
|
30
|
-
max-width: calc(100% - 200px);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.menuBar {
|
|
34
|
-
border-bottom: 1px solid var(--bit-border-color-lightest, #ededed);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.splitter {
|
|
38
|
-
position: relative;
|
|
39
|
-
|
|
40
|
-
> :first-child {
|
|
41
|
-
z-index: $nav-z-index + 1;
|
|
42
|
-
position: absolute;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.collapser {
|
|
47
|
-
right: 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.tabsContainer {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
height: 100%;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.tabs {
|
|
57
|
-
flex: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.tabContent {
|
|
61
|
-
flex: 1 1;
|
|
62
|
-
overflow: auto;
|
|
63
|
-
|
|
64
|
-
&:empty {
|
|
65
|
-
display: none;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.compositions {
|
|
70
|
-
padding: 16px 8px 0 8px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.openInNewTab {
|
|
74
|
-
text-decoration: none;
|
|
75
|
-
color: inherit;
|
|
76
|
-
|
|
77
|
-
&:active {
|
|
78
|
-
color: inherit;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.noCompositionsPage {
|
|
83
|
-
padding: 50px 40px 100px 40px;
|
|
84
|
-
width: 100%;
|
|
85
|
-
box-sizing: border-box;
|
|
86
|
-
max-width: 1440px;
|
|
87
|
-
margin: 0 auto;
|
|
88
|
-
|
|
89
|
-
.title {
|
|
90
|
-
margin-bottom: 24px;
|
|
91
|
-
font-size: var(--bit-h-xs, 26px);
|
|
92
|
-
}
|
|
93
|
-
.separator {
|
|
94
|
-
margin-bottom: 41px;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.buildStatusMessage {
|
|
99
|
-
margin: auto;
|
|
100
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentMap } from '@teambit/component';
|
|
2
|
-
import { ExecutionContext } from '@teambit/envs';
|
|
3
|
-
import { PreviewDefinition } from '@teambit/preview';
|
|
4
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
5
|
-
|
|
6
|
-
import { CompositionsMain } from './compositions.main.runtime';
|
|
7
|
-
|
|
8
|
-
export class CompositionPreviewDefinition implements PreviewDefinition {
|
|
9
|
-
readonly prefix = 'compositions';
|
|
10
|
-
|
|
11
|
-
constructor(private compositions: CompositionsMain) {}
|
|
12
|
-
|
|
13
|
-
async renderTemplatePath(context: ExecutionContext): Promise<string> {
|
|
14
|
-
return context.env.getMounter();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async getModuleMap(components: Component[]): Promise<ComponentMap<AbstractVinyl[]>> {
|
|
18
|
-
const map = this.compositions.getPreviewFiles(components);
|
|
19
|
-
return map.filter((value) => value.length !== 0);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PreviewAspect,
|
|
3
|
-
PreviewPreview,
|
|
4
|
-
RenderingContext,
|
|
5
|
-
PreviewRuntime,
|
|
6
|
-
PreviewModule,
|
|
7
|
-
ModuleFile,
|
|
8
|
-
} from '@teambit/preview';
|
|
9
|
-
import head from 'lodash.head';
|
|
10
|
-
|
|
11
|
-
import { CompositionsAspect } from './compositions.aspect';
|
|
12
|
-
|
|
13
|
-
export class CompositionsPreview {
|
|
14
|
-
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* preview extension.
|
|
17
|
-
*/
|
|
18
|
-
private preview: PreviewPreview
|
|
19
|
-
) {}
|
|
20
|
-
|
|
21
|
-
render(componentId: string, modules: PreviewModule, otherPreviewDefs, context: RenderingContext) {
|
|
22
|
-
if (!modules.componentMap[componentId]) return;
|
|
23
|
-
|
|
24
|
-
const compositions = this.selectPreviewModel(componentId, modules);
|
|
25
|
-
const active = this.getActiveComposition(compositions);
|
|
26
|
-
|
|
27
|
-
modules.mainModule.default(active, context);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** gets relevant information for this preview to render */
|
|
31
|
-
selectPreviewModel(componentId: string, previewModule: PreviewModule) {
|
|
32
|
-
const files = previewModule.componentMap[componentId] || [];
|
|
33
|
-
|
|
34
|
-
// allow compositions to come from many files. It is assumed they will have unique named
|
|
35
|
-
const combined = Object.assign({}, ...files);
|
|
36
|
-
return combined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private getActiveComposition(module: ModuleFile) {
|
|
40
|
-
const chosen = window.location.hash.split('&')[1];
|
|
41
|
-
|
|
42
|
-
if (!chosen) {
|
|
43
|
-
const first = head(Object.values(module));
|
|
44
|
-
return first;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return module[chosen];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static runtime = PreviewRuntime;
|
|
51
|
-
|
|
52
|
-
static dependencies = [PreviewAspect];
|
|
53
|
-
|
|
54
|
-
static async provider([preview]: [PreviewPreview]) {
|
|
55
|
-
const compPreview = new CompositionsPreview(preview);
|
|
56
|
-
preview.registerPreview({
|
|
57
|
-
name: 'compositions',
|
|
58
|
-
render: compPreview.render.bind(compPreview),
|
|
59
|
-
selectPreviewModel: compPreview.selectPreviewModel.bind(compPreview),
|
|
60
|
-
default: true,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return compPreview;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
CompositionsAspect.addRuntime(CompositionsPreview);
|
package/compositions.tsx
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState, useMemo, useRef, ReactNode } from 'react';
|
|
2
|
-
import head from 'lodash.head';
|
|
3
|
-
import queryString from 'query-string';
|
|
4
|
-
import { ThemeContext } from '@teambit/documenter.theme.theme-context';
|
|
5
|
-
import { SplitPane, Pane, Layout } from '@teambit/base-ui.surfaces.split-pane.split-pane';
|
|
6
|
-
import { HoverSplitter } from '@teambit/base-ui.surfaces.split-pane.hover-splitter';
|
|
7
|
-
import { ComponentContext, ComponentModel } from '@teambit/component';
|
|
8
|
-
import { PropTable } from '@teambit/documenter.ui.property-table';
|
|
9
|
-
import { Tab, TabContainer, TabList, TabPanel } from '@teambit/panels';
|
|
10
|
-
import { useDocs } from '@teambit/docs.ui.queries.get-docs';
|
|
11
|
-
import { Collapser } from '@teambit/ui-foundation.ui.buttons.collapser';
|
|
12
|
-
import { EmptyBox } from '@teambit/design.ui.empty-box';
|
|
13
|
-
import { toPreviewUrl } from '@teambit/preview.ui.component-preview';
|
|
14
|
-
import { useIsMobile } from '@teambit/ui-foundation.ui.hooks.use-is-mobile';
|
|
15
|
-
import { CompositionsMenuBar } from '@teambit/compositions.ui.compositions-menu-bar';
|
|
16
|
-
import { CompositionContextProvider } from '@teambit/compositions.ui.hooks.use-composition';
|
|
17
|
-
import { MDXLayout } from '@teambit/mdx.ui.mdx-layout';
|
|
18
|
-
import { Separator } from '@teambit/design.ui.separator';
|
|
19
|
-
import { H1 } from '@teambit/documenter.ui.heading';
|
|
20
|
-
import { AlertCard } from '@teambit/design.ui.alert-card';
|
|
21
|
-
import { NativeLink } from '@teambit/base-ui.routing.native-link';
|
|
22
|
-
import { OptionButton } from '@teambit/design.ui.input.option-button';
|
|
23
|
-
import { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';
|
|
24
|
-
import { EmptyStateSlot } from './compositions.ui.runtime';
|
|
25
|
-
import { Composition } from './composition';
|
|
26
|
-
import styles from './compositions.module.scss';
|
|
27
|
-
import { ComponentComposition } from './ui';
|
|
28
|
-
import { CompositionsPanel } from './ui/compositions-panel/compositions-panel';
|
|
29
|
-
import type { CompositionsMenuSlot } from './compositions.ui.runtime';
|
|
30
|
-
|
|
31
|
-
export type MenuBarWidget = {
|
|
32
|
-
location: 'start' | 'end';
|
|
33
|
-
content: ReactNode;
|
|
34
|
-
};
|
|
35
|
-
export type CompositionsProp = { menuBarWidgets?: CompositionsMenuSlot; emptyState?: EmptyStateSlot };
|
|
36
|
-
|
|
37
|
-
export function Compositions({ menuBarWidgets, emptyState }: CompositionsProp) {
|
|
38
|
-
const component = useContext(ComponentContext);
|
|
39
|
-
const [selected, selectComposition] = useState(head(component.compositions));
|
|
40
|
-
const selectedRef = useRef(selected);
|
|
41
|
-
selectedRef.current = selected;
|
|
42
|
-
|
|
43
|
-
const properties = useDocs(component.id);
|
|
44
|
-
|
|
45
|
-
// reset selected composition when component changes.
|
|
46
|
-
// this does trigger renderer, but perf seems to be ok
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const prevId = selectedRef.current?.identifier;
|
|
49
|
-
const next = component.compositions.find((c) => c.identifier === prevId) || component.compositions[0];
|
|
50
|
-
|
|
51
|
-
selectComposition(next);
|
|
52
|
-
}, [component]);
|
|
53
|
-
const isMobile = useIsMobile();
|
|
54
|
-
const showSidebar = !isMobile && component.compositions.length > 0;
|
|
55
|
-
const [isSidebarOpen, setSidebarOpenness] = useState(showSidebar);
|
|
56
|
-
|
|
57
|
-
const sidebarOpenness = isSidebarOpen ? Layout.row : Layout.left;
|
|
58
|
-
|
|
59
|
-
const compositionUrl = toPreviewUrl(component, 'compositions');
|
|
60
|
-
const currentCompositionUrl = toPreviewUrl(component, 'compositions', selected?.identifier);
|
|
61
|
-
|
|
62
|
-
const [compositionParams, setCompositionParams] = useState<Record<string, any>>({});
|
|
63
|
-
const queryParams = useMemo(() => queryString.stringify(compositionParams), [compositionParams]);
|
|
64
|
-
|
|
65
|
-
// collapse sidebar when empty, reopen when not
|
|
66
|
-
useEffect(() => setSidebarOpenness(showSidebar), [showSidebar]);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<CompositionContextProvider queryParams={compositionParams} setQueryParams={setCompositionParams}>
|
|
70
|
-
<SplitPane layout={sidebarOpenness} size="85%" className={styles.compositionsPage}>
|
|
71
|
-
<Pane className={styles.left}>
|
|
72
|
-
<CompositionsMenuBar menuBarWidgets={menuBarWidgets} className={styles.menuBar}>
|
|
73
|
-
<NativeLink external href={currentCompositionUrl} className={styles.openInNewTab}>
|
|
74
|
-
<OptionButton icon="open-tab" />
|
|
75
|
-
</NativeLink>
|
|
76
|
-
</CompositionsMenuBar>
|
|
77
|
-
<CompositionContent
|
|
78
|
-
emptyState={emptyState}
|
|
79
|
-
component={component}
|
|
80
|
-
selected={selected}
|
|
81
|
-
queryParams={queryParams}
|
|
82
|
-
/>
|
|
83
|
-
</Pane>
|
|
84
|
-
<HoverSplitter className={styles.splitter}>
|
|
85
|
-
<Collapser
|
|
86
|
-
placement="left"
|
|
87
|
-
isOpen={isSidebarOpen}
|
|
88
|
-
onMouseDown={(e) => e.stopPropagation()} // avoid split-pane drag
|
|
89
|
-
onClick={() => setSidebarOpenness((x) => !x)}
|
|
90
|
-
tooltipContent={`${isSidebarOpen ? 'Hide' : 'Show'} side compositions`}
|
|
91
|
-
className={styles.collapser}
|
|
92
|
-
/>
|
|
93
|
-
</HoverSplitter>
|
|
94
|
-
<Pane className={styles.right}>
|
|
95
|
-
<ThemeContext>
|
|
96
|
-
<TabContainer className={styles.tabsContainer}>
|
|
97
|
-
<TabList className={styles.tabs}>
|
|
98
|
-
<Tab>compositions</Tab>
|
|
99
|
-
<Tab>properties</Tab>
|
|
100
|
-
</TabList>
|
|
101
|
-
<TabPanel className={styles.tabContent}>
|
|
102
|
-
<CompositionsPanel
|
|
103
|
-
onSelectComposition={selectComposition}
|
|
104
|
-
url={compositionUrl}
|
|
105
|
-
compositions={component.compositions}
|
|
106
|
-
active={selected}
|
|
107
|
-
className={styles.compost}
|
|
108
|
-
/>
|
|
109
|
-
</TabPanel>
|
|
110
|
-
<TabPanel className={styles.tabContent}>
|
|
111
|
-
{properties && properties.length > 0 ? <PropTable rows={properties} showListView /> : <div />}
|
|
112
|
-
</TabPanel>
|
|
113
|
-
</TabContainer>
|
|
114
|
-
</ThemeContext>
|
|
115
|
-
</Pane>
|
|
116
|
-
</SplitPane>
|
|
117
|
-
</CompositionContextProvider>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
type CompositionContentProps = {
|
|
122
|
-
component: ComponentModel;
|
|
123
|
-
selected?: Composition;
|
|
124
|
-
queryParams?: string | string[];
|
|
125
|
-
emptyState?: EmptyStateSlot;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
function CompositionContent({ component, selected, queryParams, emptyState }: CompositionContentProps) {
|
|
129
|
-
const env = component.environment?.id;
|
|
130
|
-
const EmptyStateTemplate = emptyState?.get(env || ''); // || defaultTemplate;
|
|
131
|
-
|
|
132
|
-
if (component.compositions.length === 0 && component.host === 'teambit.workspace/workspace' && EmptyStateTemplate) {
|
|
133
|
-
return (
|
|
134
|
-
<div className={styles.noCompositionsPage}>
|
|
135
|
-
<div>
|
|
136
|
-
<H1 className={styles.title}>Compositions</H1>
|
|
137
|
-
<Separator isPresentational className={styles.separator} />
|
|
138
|
-
<AlertCard
|
|
139
|
-
level="info"
|
|
140
|
-
title="There are no
|
|
141
|
-
compositions for this Component. Learn how to add compositions:"
|
|
142
|
-
>
|
|
143
|
-
<MDXLayout>
|
|
144
|
-
<EmptyStateTemplate />
|
|
145
|
-
</MDXLayout>
|
|
146
|
-
</AlertCard>
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (component?.buildStatus === 'pending' && component?.host === 'teambit.scope/scope')
|
|
153
|
-
return (
|
|
154
|
-
<StatusMessageCard className={styles.buildStatusMessage} status="PROCESSING" title="component preview pending">
|
|
155
|
-
this might take some time
|
|
156
|
-
</StatusMessageCard>
|
|
157
|
-
);
|
|
158
|
-
if (component?.buildStatus === 'failed' && component?.host === 'teambit.scope/scope')
|
|
159
|
-
return (
|
|
160
|
-
<StatusMessageCard
|
|
161
|
-
className={styles.buildStatusMessage}
|
|
162
|
-
status="FAILURE"
|
|
163
|
-
title="failed to get component preview "
|
|
164
|
-
></StatusMessageCard>
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
if (component.compositions.length === 0) {
|
|
168
|
-
return (
|
|
169
|
-
<EmptyBox
|
|
170
|
-
title="There are no compositions for this component."
|
|
171
|
-
linkText="Learn how to create compositions"
|
|
172
|
-
link="https://harmony-docs.bit.dev/compositions/overview/"
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<ComponentComposition
|
|
179
|
-
className={styles.compositionsIframe}
|
|
180
|
-
component={component}
|
|
181
|
-
composition={selected}
|
|
182
|
-
queryParams={queryParams}
|
|
183
|
-
/>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { ComponentType } from 'react';
|
|
3
|
-
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
4
|
-
import { ComponentAspect, ComponentUI } from '@teambit/component';
|
|
5
|
-
import { UIRuntime } from '@teambit/ui';
|
|
6
|
-
import { CompositionsSection } from './composition.section';
|
|
7
|
-
import { CompositionsAspect } from './compositions.aspect';
|
|
8
|
-
import { MenuBarWidget } from './compositions';
|
|
9
|
-
|
|
10
|
-
export type CompositionsMenuSlot = SlotRegistry<MenuBarWidget[]>;
|
|
11
|
-
export type EmptyStateSlot = SlotRegistry<ComponentType>;
|
|
12
|
-
|
|
13
|
-
export class CompositionsUI {
|
|
14
|
-
constructor(private menuBarWidgetSlot: CompositionsMenuSlot, private emptyStateSlot: EmptyStateSlot) {}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* register a new tester empty state. this allows to register a different empty state from each environment for example.
|
|
18
|
-
*/
|
|
19
|
-
registerEmptyState(emptyStateComponent: ComponentType) {
|
|
20
|
-
this.emptyStateSlot.register(emptyStateComponent);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
registerMenuWidget(...widget: MenuBarWidget[]) {
|
|
25
|
-
this.menuBarWidgetSlot.register(widget);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static dependencies = [ComponentAspect];
|
|
29
|
-
static runtime = UIRuntime;
|
|
30
|
-
static slots = [Slot.withType<ReactNode>(), Slot.withType<ComponentType>()];
|
|
31
|
-
|
|
32
|
-
static async provider(
|
|
33
|
-
[component]: [ComponentUI],
|
|
34
|
-
config: {},
|
|
35
|
-
[compositionMenuSlot, emptyStateSlot]: [CompositionsMenuSlot, EmptyStateSlot]
|
|
36
|
-
) {
|
|
37
|
-
const compositions = new CompositionsUI(compositionMenuSlot, emptyStateSlot);
|
|
38
|
-
const section = new CompositionsSection(
|
|
39
|
-
compositions,
|
|
40
|
-
{ menuBarWidgetSlot: compositions.menuBarWidgetSlot },
|
|
41
|
-
emptyStateSlot
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
component.registerRoute(section.route);
|
|
45
|
-
component.registerNavigation(section.navigationLink, section.order);
|
|
46
|
-
|
|
47
|
-
return compositions;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default CompositionsUI;
|
|
52
|
-
|
|
53
|
-
CompositionsAspect.addRuntime(CompositionsUI);
|
package/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CompositionsAspect } from './compositions.aspect';
|
|
2
|
-
|
|
3
|
-
export { CompositionsAspect };
|
|
4
|
-
export type { CompositionsMain } from './compositions.main.runtime';
|
|
5
|
-
export type { CompositionsUI, CompositionsMenuSlot } from './compositions.ui.runtime';
|
|
6
|
-
export { Composition, CompositionProps } from './composition';
|
|
7
|
-
export type { CompositionsPreview } from './compositions.preview.runtime';
|
|
8
|
-
export { CompositionsOverview } from './ui/compositions-overview';
|
|
9
|
-
export { ComponentComposition } from './ui';
|
|
10
|
-
export default CompositionsAspect;
|
|
Binary file
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { ComponentModel } from '@teambit/component';
|
|
3
|
-
import { ComponentPreview } from '@teambit/preview.ui.component-preview';
|
|
4
|
-
|
|
5
|
-
import { Composition } from '../composition';
|
|
6
|
-
|
|
7
|
-
export type ComponentCompositionProps = {
|
|
8
|
-
/**
|
|
9
|
-
* HTML class
|
|
10
|
-
*/
|
|
11
|
-
className?: string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* component to render.
|
|
15
|
-
*/
|
|
16
|
-
component: ComponentModel;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* composition to use for component rendering.
|
|
20
|
-
*/
|
|
21
|
-
composition?: Composition;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Additional query params to append at the end of the *hash*. Changing this property will not reload the composition.
|
|
25
|
-
*/
|
|
26
|
-
queryParams?: string | string[];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* skip hot reload
|
|
30
|
-
*/
|
|
31
|
-
hotReload?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export function ComponentComposition({
|
|
35
|
-
component,
|
|
36
|
-
composition,
|
|
37
|
-
hotReload,
|
|
38
|
-
className,
|
|
39
|
-
queryParams = [],
|
|
40
|
-
}: ComponentCompositionProps) {
|
|
41
|
-
const compositionParams = useMemo(() => (composition ? [composition.identifier] : []).concat(queryParams), [
|
|
42
|
-
composition?.identifier,
|
|
43
|
-
queryParams,
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<ComponentPreview
|
|
48
|
-
className={className}
|
|
49
|
-
component={component}
|
|
50
|
-
style={{ width: '100%', height: '100%' }}
|
|
51
|
-
previewName="compositions"
|
|
52
|
-
queryParams={compositionParams}
|
|
53
|
-
hotReload={hotReload}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
ComponentComposition.defaultProps = {
|
|
59
|
-
skipHotReload: true,
|
|
60
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.background {
|
|
2
|
-
background: var(--bit-bg-dent, #f6f6f6);
|
|
3
|
-
padding: 12px;
|
|
4
|
-
border-radius: 6px;
|
|
5
|
-
border: 1px solid var(--bit-border-color-lightest, #ededed);
|
|
6
|
-
display: flex;
|
|
7
|
-
overflow-x: auto;
|
|
8
|
-
|
|
9
|
-
> * {
|
|
10
|
-
margin-right: 16px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
> :last-child {
|
|
14
|
-
margin: 0;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CompositionCard } from '@teambit/compositions.ui.composition-card';
|
|
3
|
-
import { CompositionsModule } from '@teambit/compositions.model.composition-type';
|
|
4
|
-
|
|
5
|
-
import styles from './compositions-overview.module.scss';
|
|
6
|
-
|
|
7
|
-
export type CompositionsOverviewProps = {
|
|
8
|
-
compositions?: CompositionsModule;
|
|
9
|
-
compositionCardClass?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function CompositionsOverview({ compositions, compositionCardClass }: CompositionsOverviewProps) {
|
|
13
|
-
return (
|
|
14
|
-
<div className={styles.background}>
|
|
15
|
-
{compositions &&
|
|
16
|
-
Object.entries(compositions).map(([key, composition]) => (
|
|
17
|
-
<CompositionCard key={key} Composition={composition} name={key} className={compositionCardClass} />
|
|
18
|
-
))}
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './compositions-overview';
|