-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from React-Automation-Studio/V5WithStoryBook
Update to V5.0.0
- Loading branch information
Showing
46 changed files
with
1,249 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { useContext } from "react"; | ||
import { DocsContext, Source } from "@storybook/addon-docs"; | ||
|
||
export const ImportPath = (props): JSX.Element => { | ||
const context = useContext(DocsContext); | ||
console.log(context); | ||
console.log(context?.primaryStory.parameters.fileName); | ||
const arr = context?.primaryStory?.kind?.split("/"); | ||
|
||
const componentName = arr[arr.length - 1]; | ||
|
||
const path = `import ${componentName} from '${context?.primaryStory.parameters.fileName.toString().replace(".stories.jsx","").replace(".stories.tsx","").replace(".stories.ts","").replace(".stories.js","").replace("./","")}';`; | ||
|
||
return <Source language="js" code={props.fullPath?props.fullPath:path} />; | ||
}; | ||
|
||
export default ImportPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import React, { Component } from "react"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import "typeface-roboto"; | ||
import { | ||
ThemeProvider, | ||
StyledEngineProvider, | ||
createTheme, | ||
} from "@mui/material/styles"; | ||
import CssBaseline from "@mui/material/CssBaseline"; | ||
|
||
import AutomationStudioContext from "React-Automation-Studio/components/SystemComponents/AutomationStudioContext"; | ||
|
||
import { io } from "socket.io-client"; | ||
import lightTheme from "React-Automation-Studio/components/UI/Themes/lightTheme"; | ||
import ReactVisCssBaseline from "React-Automation-Studio/components/SystemComponents/ReactVisCssBaseline"; | ||
|
||
if (typeof window.socket === "undefined") { | ||
window.socket = io("/pvServer", { | ||
transports: ["websocket"], | ||
}); | ||
} | ||
|
||
const themes = { Light: lightTheme }; | ||
class Wrapper extends Component { | ||
constructor(props) { | ||
super(props); | ||
let theme = null; | ||
let storedThemeStyle = localStorage.getItem("themeStyle"); | ||
const defaultTheme = "Light"; | ||
|
||
let themeStyle = | ||
storedThemeStyle === null ? defaultTheme : JSON.parse(storedThemeStyle); | ||
let themeKeys = Object.keys(themes); | ||
if (themeKeys.includes(themeStyle)) { | ||
theme = createTheme(themes[themeStyle]); | ||
} else { | ||
themeStyle = themeKeys[0]; | ||
theme = createTheme(themes[themeStyle]); | ||
localStorage.setItem("themeStyle", JSON.stringify(themeStyle)); | ||
} | ||
|
||
this.changeTheme = (event) => { | ||
let themeStyle = event.target.value; | ||
|
||
let theme = null; | ||
let themeStyles = this.state.system.themeStyles; | ||
if (themeStyles.includes(themeStyle)) { | ||
theme = createTheme(themes[themeStyle]); | ||
} else { | ||
themeStyle = themeStyles[0]; | ||
theme = createTheme(themes[themeStyle]); | ||
localStorage.setItem("themeStyle", JSON.stringify(themeStyle)); | ||
} | ||
|
||
let system = this.state.system; | ||
system.themeStyle = themeStyle; | ||
this.setState({ system: system, theme: theme }); | ||
localStorage.setItem("themeStyle", JSON.stringify(themeStyle)); | ||
}; | ||
|
||
this.updateLocalVariable = (name, data) => { | ||
let system = this.state.system; | ||
let localVariables = system.localVariables; | ||
|
||
localVariables[name] = data; | ||
system.localVariables = localVariables; | ||
|
||
this.setState({ | ||
system: system, | ||
key: this.state.key + 1, | ||
}); | ||
}; | ||
|
||
let localVariables = {}; | ||
let userTokens = { | ||
accessToken: "unauthenticated", | ||
}; | ||
let system = { | ||
socket: window.socket, | ||
userTokens: userTokens, | ||
userData: { | ||
username: "", | ||
roles: [], | ||
loggedIn: false, | ||
loggingIn: false, | ||
}, | ||
localVariables: localVariables, | ||
updateLocalVariable: this.updateLocalVariable, | ||
enableProbe: false, | ||
styleGuideRedirect: false, | ||
themeStyles: themeKeys, | ||
changeTheme: this.changeTheme, | ||
}; | ||
this.state = { | ||
theme: theme, | ||
system: system, | ||
key: 1, | ||
}; | ||
} | ||
render() { | ||
return ( | ||
<BrowserRouter> | ||
<AutomationStudioContext.Provider value={this.state.system}> | ||
<StyledEngineProvider injectFirst> | ||
<ThemeProvider theme={this.state.theme}> | ||
<CssBaseline> | ||
<ReactVisCssBaseline>{this.props.children}</ReactVisCssBaseline> | ||
</CssBaseline> | ||
</ThemeProvider> | ||
</StyledEngineProvider> | ||
</AutomationStudioContext.Provider> | ||
</BrowserRouter> | ||
); | ||
} | ||
} | ||
|
||
export default Wrapper; |
Oops, something went wrong.