Skip to content

Commit c617c09

Browse files
api: dropdowns are optional
1 parent 53cd286 commit c617c09

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { linksDemo } from './demos/links';
77
import { ProfileApp } from './demos/ProfileApp';
88
import { sideBySideDemo } from './demos/sideBySide';
99
import { inputsDemo } from './demos/inputs';
10-
import { WrapperProps } from './components/registry/componentWrapper';
10+
import { WrapperProps } from './components';
1111
import { ProfileScreenDemo } from './demos/ProfileScreenDemo';
12-
import { DropDowns } from './components/viewer/dropdown/DropDowns';
12+
import { DropDowns } from './components';
1313

1414
const registries = new Registries({componentWrapper: DemoWrapper});
1515
registries.add('components')

src/components/viewer/ComponentViewer.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import './ComponentViewer.css';
3131

3232
export interface Props {
3333
registries: Registries;
34-
dropDowns: DropDowns;
34+
dropDowns?: DropDowns;
3535
}
3636

3737
class ComponentViewer extends Component<Props, ComponentViewerState> {
@@ -82,7 +82,10 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
8282
}
8383

8484
renderSelectionPanelAndDemo(demoEntry: DemoEntry | null) {
85-
const {registries, dropDowns} = this.props;
85+
const {
86+
registries,
87+
dropDowns = new DropDowns()
88+
} = this.props;
8689

8790
const {
8891
registryName,
@@ -173,7 +176,7 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
173176

174177
triggerDropDownSelection() {
175178
const {dropDowns} = this.props;
176-
if (dropDowns.isEmpty()) {
179+
if (!dropDowns) {
177180
return;
178181
}
179182

@@ -200,7 +203,7 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
200203
const result: HotKeyBoundActions = {};
201204

202205
const {dropDowns} = this.props;
203-
if (dropDowns.isEmpty()) {
206+
if (!dropDowns) {
204207
return result;
205208
}
206209

@@ -307,7 +310,7 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
307310
}
308311
}});
309312

310-
const found = dropDowns.findDropDownByLabel(dropDownLabel);
313+
const found = dropDowns && dropDowns.findDropDownByLabel(dropDownLabel);
311314
if (found) {
312315
found.triggerSelectHandler(itemLabel);
313316
}

0 commit comments

Comments
 (0)