-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathpreview.js
More file actions
109 lines (95 loc) · 2.74 KB
/
preview.js
File metadata and controls
109 lines (95 loc) · 2.74 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
import React, { useEffect } from "react";
import { useAccessibleOutlineStyle } from "../src/react-components/input/useAccessibleOutlineStyle";
import { WrappedIntlProvider } from "../src/react-components/wrapped-intl-provider";
import { MINIMAL_VIEWPORTS } from "@storybook/addon-viewport";
import { AVAILABLE_LOCALES } from "../src/assets/locales/locale_config";
import { setLocale } from "../src/utils/i18n";
import { themes } from "../src/utils/theme";
import { useTheme } from "../src/react-components/styles/theme";
import "../src/react-components/styles/global.scss";
// Add debug styles for storybook to help visualize components
const debugStyles = `
/* Make room layout container visible */
[class*="roomLayout"] {
background: #f5f5f5;
min-height: 500px;
}
/* Make viewport areas visible */
[class*="viewport"] {
background: rgba(200, 220, 255, 0.1);
border: 1px dashed #ccc;
min-height: 400px;
}
/* Ensure absolutely positioned elements are visible */
[class*="contentMenu"] {
background: rgba(255, 255, 255, 0.9) !important;
border: 2px solid #333 !important;
box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}
[class*="spectatingLabel"] {
background: rgba(0, 0, 0, 0.8) !important;
padding: 8px !important;
border-radius: 4px !important;
}
`;
if (typeof document !== 'undefined') {
const style = document.createElement('style');
style.textContent = debugStyles;
document.head.appendChild(style);
}
const Layout = ({ children, locale, theme }) => {
useTheme(theme);
useAccessibleOutlineStyle();
useEffect(
() => {
setLocale(locale);
},
[locale]
);
return <WrappedIntlProvider>{children}</WrappedIntlProvider>;
};
export const decorators = [
(Story, context) => (
<Layout locale={context.globals.locale} theme={context.globals.theme}>
<Story />
</Layout>
)
];
export const parameters = {
viewport: {
viewports: {
...MINIMAL_VIEWPORTS,
oculusQuest: {
name: "Oculus Quest",
styles: {
width: "800px",
height: "450px"
}
}
}
}
};
const locales = Object.entries(AVAILABLE_LOCALES).map(([value, title]) => ({ title, value }));
locales.unshift({ title: "Browser Default", value: "browser" });
const themeOptions = themes.map(({ id, name }) => ({ title: name, value: id }));
themeOptions.unshift({ title: "Browser Default", value: null });
export const globalTypes = {
locale: {
name: "Locale",
description: "Active locale",
defaultValue: "browser",
toolbar: {
icon: "globe",
items: locales
}
},
theme: {
name: "Theme",
description: "Active theme",
defaultValue: null,
toolbar: {
icon: "globe",
items: themeOptions
}
}
};