forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabs.js
More file actions
172 lines (162 loc) · 4.47 KB
/
Copy pathtabs.js
File metadata and controls
172 lines (162 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
import PropTypes from "prop-types";
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import Tabs from "../Editor/Tabs";
import fromJS from "../../utils/fromJS";
import { L10N } from "devtools-launchpad";
import { times } from "lodash";
import "../App.css";
import "../Editor/Editor.css";
import "devtools-modules/src/themes/dark-theme.css";
if (typeof window == "object") {
window.L10N = L10N;
window.L10N.setBundle(require("../../../assets/panel/debugger.properties"));
}
const tabs = {
foo: { id: "foo", url: "http://example.com/foo.js" },
bar: { id: "bar", url: "http://example.com/bar.js" },
pretty: { id: "pretty", url: "http://example.com/pretty.js:formatted" },
blackboxed: {
id: "blackboxed",
url: "http://example.com/black.js",
isBlackBoxed: true
}
};
function TabsFactory({ dir = "ltr", theme = "light", ...props }) {
const themeClass = `theme-${theme}`;
document.body.parentNode.className = themeClass;
document.dir = dir;
return (
<div
className={`editor-pane ${themeClass}`}
dir={dir}
style={{
width: "450px",
height: "200px",
margin: "40px 40px",
border: "1px solid var(--theme-splitter-color)"
}}
>
<div className="editor-container">
<Tabs
sourceTabs={fromJS([])}
searchOn={false}
selectedSource={null}
selectLocation={action("selectLocation")}
closeActiveSearch={() => {}}
moveTab={action("moveTab")}
closeTab={action("closeTab")}
closeTabs={action("closeTabs")}
setActiveSearch={action("setActiveSearch")}
toggleProjectSearch={action("toggleProjectSearch")}
togglePrettyPrint={action("togglePrettyPrint")}
togglePaneCollapse={action("togglePaneCollapse")}
showSource={action("showSource")}
horizontal={true}
startPanelCollapsed={false}
endPanelCollapsed={false}
{...props}
/>
<div
className="editor-wrapper"
style={{ background: "var(--theme-body-background)" }}
/>
</div>
</div>
);
}
TabsFactory.propTypes = {
dir: PropTypes.string,
theme: PropTypes.string
};
storiesOf("Editor Tabs", module)
.add("No Tabs", () => {
return <TabsFactory />;
})
.add("1 Tab", () => {
return <TabsFactory sourceTabs={fromJS([tabs.foo])} />;
})
.add("2 Tabs", () => {
return (
<TabsFactory
sourceTabs={fromJS([tabs.foo, tabs.bar])}
selectedSource={fromJS(tabs.foo)}
/>
);
})
.add("2 Tabs (not selected)", () => {
return <TabsFactory sourceTabs={fromJS([tabs.foo, tabs.bar])} />;
})
.add("10 Tabs", () => {
const localTabs = times(10).map(i => ({
id: `id${i}`,
url: `http://example.com/example${i}`
}));
return (
<TabsFactory
sourceTabs={fromJS(localTabs)}
selectedSource={fromJS(localTabs[2])}
/>
);
})
.add("special tabs", () => {
return (
<TabsFactory
sourceTabs={fromJS([tabs.pretty, tabs.blackboxed])}
selectedSource={fromJS(tabs.pretty)}
/>
);
})
.add("2 Tabs (RTL)", () => {
return (
<TabsFactory
dir="rtl"
sourceTabs={fromJS([tabs.foo, tabs.bar])}
selectedSource={fromJS(tabs.foo)}
/>
);
})
.add("special tabs (RTL)", () => {
return (
<TabsFactory
dir="rtl"
sourceTabs={fromJS([tabs.pretty, tabs.blackboxed])}
selectedSource={fromJS(tabs.pretty)}
/>
);
})
.add("10 Tabs (RTL)", () => {
const localTabs = times(10).map(i => ({
id: `id${i}`,
url: `http://example.com/example${i}`
}));
return (
<TabsFactory
sourceTabs={fromJS(localTabs)}
selectedSource={fromJS(localTabs[2])}
dir="rtl"
/>
);
})
.add("2 Tabs (DARK)", () => {
return (
<TabsFactory
theme="dark"
sourceTabs={fromJS([tabs.foo, tabs.bar])}
selectedSource={fromJS(tabs.foo)}
/>
);
})
.add("special tabs (DARK)", () => {
return (
<TabsFactory
theme="dark"
sourceTabs={fromJS([tabs.pretty, tabs.blackboxed])}
selectedSource={fromJS(tabs.pretty)}
/>
);
});