tgui-core 1.0.2 → 1.0.4
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/{src/components → components}/AnimatedNumber.tsx +185 -185
- package/{src/components → components}/BlockQuote.tsx +15 -15
- package/{src/components → components}/BodyZoneSelector.tsx +149 -149
- package/{src/components → components}/Box.tsx +255 -255
- package/{src/components → components}/Button.tsx +415 -415
- package/{src/components → components}/ByondUi.jsx +121 -121
- package/{src/components → components}/Chart.tsx +160 -160
- package/{src/components → components}/ColorBox.tsx +30 -30
- package/{src/components → components}/Dimmer.tsx +19 -19
- package/{src/components → components}/Divider.tsx +26 -26
- package/{src/components → components}/DmIcon.tsx +72 -72
- package/{src/components → components}/DraggableControl.jsx +282 -282
- package/{src/components → components}/Dropdown.tsx +246 -246
- package/{src/components → components}/Flex.tsx +105 -105
- package/{src/components → components}/Icon.tsx +91 -91
- package/{src/components → components}/Input.tsx +181 -181
- package/{src/components → components}/KeyListener.tsx +40 -40
- package/{src/components → components}/Knob.tsx +185 -185
- package/{src/components → components}/LabeledList.tsx +130 -130
- package/{src/components → components}/MenuBar.tsx +233 -238
- package/{src/components → components}/Modal.tsx +25 -25
- package/{src/components → components}/NoticeBox.tsx +48 -48
- package/{src/components → components}/NumberInput.tsx +328 -328
- package/{src/components → components}/ProgressBar.tsx +79 -79
- package/{src/components → components}/RestrictedInput.jsx +301 -301
- package/{src/components → components}/RoundGauge.tsx +189 -189
- package/{src/components → components}/Section.tsx +125 -125
- package/{src/components → components}/Slider.tsx +173 -173
- package/{src/components → components}/Stack.tsx +101 -101
- package/{src/components → components}/Table.tsx +90 -90
- package/{src/components → components}/Tabs.tsx +90 -90
- package/{src/components → components}/TextArea.tsx +198 -198
- package/{src/components → components}/TimeDisplay.jsx +64 -64
- package/components/index.ts +51 -0
- package/{src/debug/KitchenSink.jsx → debug/KitchenSink.tsx} +56 -56
- package/{src/debug/actions.js → debug/actions.ts} +11 -11
- package/{src/debug/hooks.js → debug/hooks.ts} +10 -10
- package/{src/debug/middleware.js → debug/middleware.ts} +67 -86
- package/{src/debug/reducer.js → debug/reducer.ts} +27 -22
- package/{src/debug/selectors.js → debug/selectors.ts} +7 -7
- package/{src/layouts → layouts}/Layout.tsx +75 -75
- package/{src/layouts → layouts}/NtosWindow.tsx +162 -162
- package/{src/layouts → layouts}/Pane.tsx +56 -56
- package/{src/layouts → layouts}/Window.tsx +227 -227
- package/layouts/index.ts +10 -0
- package/package.json +3 -2
- package/src/assets.ts +43 -43
- package/src/backend.ts +368 -369
- package/src/drag.ts +280 -280
- package/src/events.ts +237 -237
- package/src/hotkeys.ts +212 -212
- package/src/renderer.ts +50 -50
- package/stories/Blink.stories.tsx +20 -0
- package/stories/BlockQuote.stories.tsx +23 -0
- package/stories/Box.stories.tsx +27 -0
- package/stories/Button.stories.tsx +68 -0
- package/stories/ByondUi.stories.tsx +45 -0
- package/stories/Collapsible.stories.tsx +23 -0
- package/stories/Flex.stories.tsx +68 -0
- package/stories/Input.stories.tsx +124 -0
- package/stories/LabeledList.stories.tsx +73 -0
- package/stories/Popper.stories.tsx +58 -0
- package/stories/ProgressBar.stories.tsx +58 -0
- package/stories/Stack.stories.tsx +55 -0
- package/stories/Storage.stories.tsx +46 -0
- package/stories/Themes.stories.tsx +30 -0
- package/stories/Tooltip.stories.tsx +48 -0
- package/stories/common.tsx +19 -0
- package/tsconfig.json +0 -21
- package/src/components/Grid.tsx +0 -44
- /package/{src/common → common}/collections.ts +0 -0
- /package/{src/common → common}/color.ts +0 -0
- /package/{src/common → common}/events.ts +0 -0
- /package/{src/common → common}/exhaustive.ts +0 -0
- /package/{src/common → common}/fp.ts +0 -0
- /package/{src/common → common}/keycodes.ts +0 -0
- /package/{src/common → common}/keys.ts +0 -0
- /package/{src/common → common}/math.ts +0 -0
- /package/{src/common → common}/perf.ts +0 -0
- /package/{src/common → common}/random.ts +0 -0
- /package/{src/common → common}/react.ts +0 -0
- /package/{src/common → common}/redux.ts +0 -0
- /package/{src/common → common}/storage.js +0 -0
- /package/{src/common → common}/string.ts +0 -0
- /package/{src/common → common}/timer.ts +0 -0
- /package/{src/common → common}/type-utils.ts +0 -0
- /package/{src/common → common}/types.ts +0 -0
- /package/{src/common → common}/uuid.ts +0 -0
- /package/{src/common → common}/vector.ts +0 -0
- /package/{src/components → components}/Autofocus.tsx +0 -0
- /package/{src/components → components}/Blink.jsx +0 -0
- /package/{src/components → components}/Collapsible.tsx +0 -0
- /package/{src/components → components}/Dialog.tsx +0 -0
- /package/{src/components → components}/FakeTerminal.jsx +0 -0
- /package/{src/components → components}/FitText.tsx +0 -0
- /package/{src/components → components}/Image.tsx +0 -0
- /package/{src/components → components}/InfinitePlane.jsx +0 -0
- /package/{src/components → components}/LabeledControls.tsx +0 -0
- /package/{src/components → components}/Popper.tsx +0 -0
- /package/{src/components → components}/StyleableSection.tsx +0 -0
- /package/{src/components → components}/Tooltip.tsx +0 -0
- /package/{src/components → components}/TrackOutsideClicks.tsx +0 -0
- /package/{src/components → components}/VirtualList.tsx +0 -0
- /package/{src/debug → debug}/index.ts +0 -0
- /package/{src/styles → styles}/base.scss +0 -0
- /package/{src/styles → styles}/colors.scss +0 -0
- /package/{src/styles → styles}/components/BlockQuote.scss +0 -0
- /package/{src/styles → styles}/components/Button.scss +0 -0
- /package/{src/styles → styles}/components/ColorBox.scss +0 -0
- /package/{src/styles → styles}/components/Dialog.scss +0 -0
- /package/{src/styles → styles}/components/Dimmer.scss +0 -0
- /package/{src/styles → styles}/components/Divider.scss +0 -0
- /package/{src/styles → styles}/components/Dropdown.scss +0 -0
- /package/{src/styles → styles}/components/Flex.scss +0 -0
- /package/{src/styles → styles}/components/Icon.scss +0 -0
- /package/{src/styles → styles}/components/Input.scss +0 -0
- /package/{src/styles → styles}/components/Knob.scss +0 -0
- /package/{src/styles → styles}/components/LabeledList.scss +0 -0
- /package/{src/styles → styles}/components/MenuBar.scss +0 -0
- /package/{src/styles → styles}/components/Modal.scss +0 -0
- /package/{src/styles → styles}/components/NoticeBox.scss +0 -0
- /package/{src/styles → styles}/components/NumberInput.scss +0 -0
- /package/{src/styles → styles}/components/ProgressBar.scss +0 -0
- /package/{src/styles → styles}/components/RoundGauge.scss +0 -0
- /package/{src/styles → styles}/components/Section.scss +0 -0
- /package/{src/styles → styles}/components/Slider.scss +0 -0
- /package/{src/styles → styles}/components/Stack.scss +0 -0
- /package/{src/styles → styles}/components/Table.scss +0 -0
- /package/{src/styles → styles}/components/Tabs.scss +0 -0
- /package/{src/styles → styles}/components/TextArea.scss +0 -0
- /package/{src/styles → styles}/components/Tooltip.scss +0 -0
- /package/{src/styles → styles}/functions.scss +0 -0
- /package/{src/styles → styles}/layouts/Layout.scss +0 -0
- /package/{src/styles → styles}/layouts/NtosHeader.scss +0 -0
- /package/{src/styles → styles}/layouts/NtosWindow.scss +0 -0
- /package/{src/styles → styles}/layouts/TitleBar.scss +0 -0
- /package/{src/styles → styles}/layouts/Window.scss +0 -0
- /package/{src/styles → styles}/main.scss +0 -0
- /package/{src/styles → styles}/reset.scss +0 -0
- /package/{src/styles → styles}/themes/abductor.scss +0 -0
- /package/{src/styles → styles}/themes/admin.scss +0 -0
- /package/{src/styles → styles}/themes/cardtable.scss +0 -0
- /package/{src/styles → styles}/themes/hackerman.scss +0 -0
- /package/{src/styles → styles}/themes/malfunction.scss +0 -0
- /package/{src/styles → styles}/themes/neutral.scss +0 -0
- /package/{src/styles → styles}/themes/ntOS95.scss +0 -0
- /package/{src/styles → styles}/themes/ntos.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_cat.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_darkmode.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_lightmode.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_spooky.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_synth.scss +0 -0
- /package/{src/styles → styles}/themes/ntos_terminal.scss +0 -0
- /package/{src/styles → styles}/themes/paper.scss +0 -0
- /package/{src/styles → styles}/themes/retro.scss +0 -0
- /package/{src/styles → styles}/themes/spookyconsole.scss +0 -0
- /package/{src/styles → styles}/themes/syndicate.scss +0 -0
- /package/{src/styles → styles}/themes/wizard.scss +0 -0
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
|
|
9
|
-
import { Flex, Section, Tabs } from '../components';
|
|
10
|
-
import { Pane, Window } from '../layouts';
|
|
11
|
-
|
|
12
|
-
const r = require.context('../stories', false, /\.stories\.jsx$/);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @returns {{
|
|
16
|
-
* meta: {
|
|
17
|
-
* title: string,
|
|
18
|
-
* render: () => any,
|
|
19
|
-
* },
|
|
20
|
-
* }[]}
|
|
21
|
-
*/
|
|
22
|
-
const getStories = () => r.keys().map((path) => r(path));
|
|
23
|
-
|
|
24
|
-
export const KitchenSink = (props) => {
|
|
25
|
-
const { panel } = props;
|
|
26
|
-
const [theme] = useState(
|
|
27
|
-
const [pageIndex, setPageIndex] = useState(0);
|
|
28
|
-
const stories = getStories();
|
|
29
|
-
const story = stories[pageIndex];
|
|
30
|
-
const Layout = panel ? Pane : Window;
|
|
31
|
-
return (
|
|
32
|
-
<Layout title="Kitchen Sink" width={600} height={500} theme={theme}>
|
|
33
|
-
<Flex height="100%">
|
|
34
|
-
<Flex.Item m={1} mr={0}>
|
|
35
|
-
<Section fill fitted>
|
|
36
|
-
<Tabs vertical>
|
|
37
|
-
{stories.map((story, i) => (
|
|
38
|
-
<Tabs.Tab
|
|
39
|
-
key={i}
|
|
40
|
-
color="transparent"
|
|
41
|
-
selected={i === pageIndex}
|
|
42
|
-
onClick={() => setPageIndex(i)}
|
|
43
|
-
>
|
|
44
|
-
{story.meta.title}
|
|
45
|
-
</Tabs.Tab>
|
|
46
|
-
))}
|
|
47
|
-
</Tabs>
|
|
48
|
-
</Section>
|
|
49
|
-
</Flex.Item>
|
|
50
|
-
<Flex.Item position="relative" grow={1}>
|
|
51
|
-
<Layout.Content scrollable>{story.meta.render()}</Layout.Content>
|
|
52
|
-
</Flex.Item>
|
|
53
|
-
</Flex>
|
|
54
|
-
</Layout>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Flex, Section, Tabs } from '../components';
|
|
10
|
+
import { Pane, Window } from '../layouts';
|
|
11
|
+
|
|
12
|
+
const r = require.context('../stories', false, /\.stories\.jsx$/);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @returns {{
|
|
16
|
+
* meta: {
|
|
17
|
+
* title: string,
|
|
18
|
+
* render: () => any,
|
|
19
|
+
* },
|
|
20
|
+
* }[]}
|
|
21
|
+
*/
|
|
22
|
+
const getStories = () => r.keys().map((path) => r(path));
|
|
23
|
+
|
|
24
|
+
export const KitchenSink = (props) => {
|
|
25
|
+
const { panel } = props;
|
|
26
|
+
const [theme] = useState('');
|
|
27
|
+
const [pageIndex, setPageIndex] = useState(0);
|
|
28
|
+
const stories = getStories();
|
|
29
|
+
const story = stories[pageIndex];
|
|
30
|
+
const Layout = panel ? Pane : Window;
|
|
31
|
+
return (
|
|
32
|
+
<Layout title="Kitchen Sink" width={600} height={500} theme={theme}>
|
|
33
|
+
<Flex height="100%">
|
|
34
|
+
<Flex.Item m={1} mr={0}>
|
|
35
|
+
<Section fill fitted>
|
|
36
|
+
<Tabs vertical>
|
|
37
|
+
{stories.map((story, i) => (
|
|
38
|
+
<Tabs.Tab
|
|
39
|
+
key={i}
|
|
40
|
+
color="transparent"
|
|
41
|
+
selected={i === pageIndex}
|
|
42
|
+
onClick={() => setPageIndex(i)}
|
|
43
|
+
>
|
|
44
|
+
{story.meta.title}
|
|
45
|
+
</Tabs.Tab>
|
|
46
|
+
))}
|
|
47
|
+
</Tabs>
|
|
48
|
+
</Section>
|
|
49
|
+
</Flex.Item>
|
|
50
|
+
<Flex.Item position="relative" grow={1}>
|
|
51
|
+
<Layout.Content scrollable>{story.meta.render()}</Layout.Content>
|
|
52
|
+
</Flex.Item>
|
|
53
|
+
</Flex>
|
|
54
|
+
</Layout>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createAction } from 'common/redux';
|
|
8
|
-
|
|
9
|
-
export const toggleKitchenSink = createAction('debug/toggleKitchenSink');
|
|
10
|
-
export const toggleDebugLayout = createAction('debug/toggleDebugLayout');
|
|
11
|
-
export const openExternalBrowser = createAction('debug/openExternalBrowser');
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createAction } from '../common/redux';
|
|
8
|
+
|
|
9
|
+
export const toggleKitchenSink = createAction('debug/toggleKitchenSink');
|
|
10
|
+
export const toggleDebugLayout = createAction('debug/toggleDebugLayout');
|
|
11
|
+
export const openExternalBrowser = createAction('debug/openExternalBrowser');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useSelector } from '../backend';
|
|
8
|
-
import { selectDebug } from './selectors';
|
|
9
|
-
|
|
10
|
-
export const useDebug = () => useSelector(selectDebug);
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { useSelector } from '../src/backend';
|
|
8
|
+
import { selectDebug } from './selectors';
|
|
9
|
+
|
|
10
|
+
export const useDebug = () => useSelector(selectDebug);
|
|
@@ -1,86 +1,67 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { KEY_BACKSPACE, KEY_F10, KEY_F11, KEY_F12 } from 'common/keycodes';
|
|
8
|
-
|
|
9
|
-
import { globalEvents } from '../events';
|
|
10
|
-
import { acquireHotKey } from '../hotkeys';
|
|
11
|
-
import {
|
|
12
|
-
openExternalBrowser,
|
|
13
|
-
toggleDebugLayout,
|
|
14
|
-
toggleKitchenSink,
|
|
15
|
-
} from './actions';
|
|
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
|
-
return (next) => (action) => {
|
|
70
|
-
const { type, payload, relayed } = action;
|
|
71
|
-
if (type === openExternalBrowser.type) {
|
|
72
|
-
window.open(location.href + '?external', '_blank');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (relayedTypes.includes(type) && !relayed && !externalBrowser) {
|
|
76
|
-
devServer.sendMessage({
|
|
77
|
-
type: 'relay',
|
|
78
|
-
payload: {
|
|
79
|
-
windowId: Byond.windowId,
|
|
80
|
-
action,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return next(action);
|
|
85
|
-
};
|
|
86
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { KEY_BACKSPACE, KEY_F10, KEY_F11, KEY_F12 } from '../common/keycodes';
|
|
8
|
+
|
|
9
|
+
import { globalEvents } from '../src/events';
|
|
10
|
+
import { acquireHotKey } from '../src/hotkeys';
|
|
11
|
+
import {
|
|
12
|
+
openExternalBrowser,
|
|
13
|
+
toggleDebugLayout,
|
|
14
|
+
toggleKitchenSink,
|
|
15
|
+
} from './actions';
|
|
16
|
+
|
|
17
|
+
const relayedTypes = ['backend/update', 'chat/message'];
|
|
18
|
+
|
|
19
|
+
export const debugMiddleware = (store) => {
|
|
20
|
+
acquireHotKey(KEY_F11);
|
|
21
|
+
acquireHotKey(KEY_F12);
|
|
22
|
+
globalEvents.on('keydown', (key) => {
|
|
23
|
+
if (key.code === KEY_F11) {
|
|
24
|
+
store.dispatch(toggleDebugLayout());
|
|
25
|
+
}
|
|
26
|
+
if (key.code === KEY_F12) {
|
|
27
|
+
store.dispatch(toggleKitchenSink());
|
|
28
|
+
}
|
|
29
|
+
if (key.ctrl && key.alt && key.code === KEY_BACKSPACE) {
|
|
30
|
+
// NOTE: We need to call this in a timeout, because we need a clean
|
|
31
|
+
// stack in order for this to be a fatal error.
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
throw new Error(
|
|
34
|
+
'OOPSIE WOOPSIE!! UwU We made a fucky wucky!! A wittle' +
|
|
35
|
+
' fucko boingo! The code monkeys at our headquarters are' +
|
|
36
|
+
' working VEWY HAWD to fix this!'
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return (next) => (action) => next(action);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const relayMiddleware = (store) => {
|
|
45
|
+
const externalBrowser = location.search === '?external';
|
|
46
|
+
if (externalBrowser) {
|
|
47
|
+
// todo: implement
|
|
48
|
+
} else {
|
|
49
|
+
acquireHotKey(KEY_F10);
|
|
50
|
+
globalEvents.on('keydown', (key) => {
|
|
51
|
+
if (key === KEY_F10) {
|
|
52
|
+
store.dispatch(openExternalBrowser());
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return (next) => (action) => {
|
|
57
|
+
const { type, payload, relayed } = action;
|
|
58
|
+
if (type === openExternalBrowser.type) {
|
|
59
|
+
window.open(location.href + '?external', '_blank');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (relayedTypes.includes(type) && !relayed && !externalBrowser) {
|
|
63
|
+
// todo: implement
|
|
64
|
+
}
|
|
65
|
+
return next(action);
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
type DebugState = {
|
|
8
|
+
kitchenSink: boolean;
|
|
9
|
+
debugLayout: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const debugReducer = (state: DebugState, action) => {
|
|
13
|
+
const { type } = action;
|
|
14
|
+
if (type === 'debug/toggleKitchenSink') {
|
|
15
|
+
return {
|
|
16
|
+
...state,
|
|
17
|
+
kitchenSink: !state.kitchenSink,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (type === 'debug/toggleDebugLayout') {
|
|
21
|
+
return {
|
|
22
|
+
...state,
|
|
23
|
+
debugLayout: !state.debugLayout,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return state;
|
|
27
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const selectDebug = (state) => state.debug;
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const selectDebug = (state) => state.debug;
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { classes } from '../common/react';
|
|
8
|
-
import { useEffect, useRef } from 'react';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
BoxProps,
|
|
12
|
-
computeBoxClassName,
|
|
13
|
-
computeBoxProps,
|
|
14
|
-
} from '../components/Box';
|
|
15
|
-
import { addScrollableNode, removeScrollableNode } from '../events';
|
|
16
|
-
|
|
17
|
-
type Props = Partial<{
|
|
18
|
-
theme: string;
|
|
19
|
-
}> &
|
|
20
|
-
BoxProps;
|
|
21
|
-
|
|
22
|
-
export function Layout(props: Props) {
|
|
23
|
-
const { className, theme = 'nanotrasen', children, ...rest } = props;
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className={'theme-' + theme}>
|
|
27
|
-
<div
|
|
28
|
-
className={classes(['Layout', className, computeBoxClassName(rest)])}
|
|
29
|
-
{...computeBoxProps(rest)}
|
|
30
|
-
>
|
|
31
|
-
{children}
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type ContentProps = Partial<{
|
|
38
|
-
scrollable: boolean;
|
|
39
|
-
}> &
|
|
40
|
-
BoxProps;
|
|
41
|
-
|
|
42
|
-
function LayoutContent(props: ContentProps) {
|
|
43
|
-
const { className, scrollable, children, ...rest } = props;
|
|
44
|
-
const node = useRef<HTMLDivElement>(null);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const self = node.current;
|
|
48
|
-
|
|
49
|
-
if (self && scrollable) {
|
|
50
|
-
addScrollableNode(self);
|
|
51
|
-
}
|
|
52
|
-
return () => {
|
|
53
|
-
if (self && scrollable) {
|
|
54
|
-
removeScrollableNode(self);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div
|
|
61
|
-
className={classes([
|
|
62
|
-
'Layout__content',
|
|
63
|
-
scrollable && 'Layout__content--scrollable',
|
|
64
|
-
className,
|
|
65
|
-
computeBoxClassName(rest),
|
|
66
|
-
])}
|
|
67
|
-
ref={node}
|
|
68
|
-
{...computeBoxProps(rest)}
|
|
69
|
-
>
|
|
70
|
-
{children}
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
Layout.Content = LayoutContent;
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { classes } from '../common/react';
|
|
8
|
+
import { useEffect, useRef } from 'react';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BoxProps,
|
|
12
|
+
computeBoxClassName,
|
|
13
|
+
computeBoxProps,
|
|
14
|
+
} from '../components/Box';
|
|
15
|
+
import { addScrollableNode, removeScrollableNode } from '../src/events';
|
|
16
|
+
|
|
17
|
+
type Props = Partial<{
|
|
18
|
+
theme: string;
|
|
19
|
+
}> &
|
|
20
|
+
BoxProps;
|
|
21
|
+
|
|
22
|
+
export function Layout(props: Props) {
|
|
23
|
+
const { className, theme = 'nanotrasen', children, ...rest } = props;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={'theme-' + theme}>
|
|
27
|
+
<div
|
|
28
|
+
className={classes(['Layout', className, computeBoxClassName(rest)])}
|
|
29
|
+
{...computeBoxProps(rest)}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ContentProps = Partial<{
|
|
38
|
+
scrollable: boolean;
|
|
39
|
+
}> &
|
|
40
|
+
BoxProps;
|
|
41
|
+
|
|
42
|
+
function LayoutContent(props: ContentProps) {
|
|
43
|
+
const { className, scrollable, children, ...rest } = props;
|
|
44
|
+
const node = useRef<HTMLDivElement>(null);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const self = node.current;
|
|
48
|
+
|
|
49
|
+
if (self && scrollable) {
|
|
50
|
+
addScrollableNode(self);
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
if (self && scrollable) {
|
|
54
|
+
removeScrollableNode(self);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
className={classes([
|
|
62
|
+
'Layout__content',
|
|
63
|
+
scrollable && 'Layout__content--scrollable',
|
|
64
|
+
className,
|
|
65
|
+
computeBoxClassName(rest),
|
|
66
|
+
])}
|
|
67
|
+
ref={node}
|
|
68
|
+
{...computeBoxProps(rest)}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Layout.Content = LayoutContent;
|