Skip to content

Commit 7f426a8

Browse files
authored
show text when the scope/workspace is empty (teambit#3929)
1 parent 8b8b35b commit 7f426a8

File tree

13 files changed

+55
-4
lines changed

13 files changed

+55
-4
lines changed

.bitmap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,12 @@
10151015
"mainFile": "index.ts",
10161016
"rootDir": "scopes/design/ui/styles/ellipsis"
10171017
},
1018+
"ui/styles/muted-italic": {
1019+
"scope": "",
1020+
"version": "",
1021+
"mainFile": "index.ts",
1022+
"rootDir": "scopes/design/ui/styles/muted-italic"
1023+
},
10181024
"ui/surfaces/menu/item": {
10191025
"scope": "teambit.design",
10201026
"version": "0.0.312",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import styles from './muted-italic.module.scss';
2+
3+
export const mutedItalic = styles.mutedItalic;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
labels: ['react', 'typescript', 'text', 'css']
3+
description: 'A css component for text.'
4+
---
5+
6+
import { mutedItalic } from './index';
7+
8+
A CSS component that displays the text with muted-text and italic font-style.
9+
Example:
10+
11+
```js live
12+
<span className={mutedItalic}>Italic muted text.</span>
13+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.mutedItalic {
2+
color: var(--text-muted, #6c707c);
3+
font-style: italic;
4+
}

scopes/scope/scope/scope.ui.runtime.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ScopeMenu } from './ui/menu';
1616
import { ScopeAspect } from './scope.aspect';
1717
import { Scope } from './ui/scope';
1818
import { ScopeModel } from './ui/scope-model';
19-
import { ComponentsDrawer } from './components.drawer';
19+
import { ComponentsDrawer } from './ui/components-drawer';
2020

2121
export type ScopeBadge = ComponentType;
2222

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.emptyScope {
2+
padding: 8px 8px 0 28px;
3+
display: block;
4+
}

scopes/scope/scope/components.drawer.tsx renamed to scopes/scope/scope/ui/components-drawer/components.drawer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import React, { useCallback } from 'react';
2+
import classNames from 'classnames';
23
import { ComponentTree, ComponentView, NamespaceTreeNode, PayloadType, ScopePayload } from '@teambit/ui.side-bar';
34
import { TreeNodeProps } from '@teambit/base-ui.graph.tree.recursive-tree';
45

56
import { FullLoader } from '@teambit/ui.full-loader';
67
import { ComponentTreeSlot } from '@teambit/component-tree';
78
import type { DrawerType } from '@teambit/ui.tree.drawer';
8-
import { useScope } from './ui/use-scope';
9+
import { Text } from '@teambit/base-ui.text.text';
10+
import { mutedItalic } from '@teambit/ui.styles.muted-italic';
11+
import { ellipsis } from '@teambit/ui.styles.ellipsis';
12+
import { useScope } from '../use-scope';
13+
import styles from './components.drawer.module.scss';
914

1015
export class ComponentsDrawer implements DrawerType {
1116
constructor(private treeNodeSlot: ComponentTreeSlot) {}
@@ -39,6 +44,8 @@ export class ComponentsDrawer implements DrawerType {
3944
);
4045

4146
if (!scope) return <FullLoader />;
47+
if (scope.components.length === 0)
48+
return <Text className={classNames(mutedItalic, ellipsis, styles.emptyScope)}>Scope is empty</Text>;
4249
return <ComponentTree components={scope.components} TreeNode={TreeNodeRenderer} />;
4350
};
4451
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ComponentsDrawer } from './components.drawer';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { WorkspaceComponentsDrawer } from './workspace-components.drawer';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.emptyWorkspace {
2+
padding: 8px 8px 0 28px;
3+
display: block;
4+
}

0 commit comments

Comments
 (0)