Implement SmartMenuiserie API + added bun test-server
This commit is contained in:
parent
281cd92194
commit
b4806db91a
21 changed files with 377 additions and 244 deletions
41
src/App.scss
41
src/App.scss
|
@ -1,41 +0,0 @@
|
|||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
62
src/App.tsx
62
src/App.tsx
|
@ -1,10 +1,58 @@
|
|||
import './App.scss'
|
||||
import React from 'react';
|
||||
import './App.scss';
|
||||
import Sidebar from './Components/Sidebar/Sidebar';
|
||||
import { IAvailableContainerModel } from './Interfaces/IAvailableContainerModel';
|
||||
import { IConfigurationResponseModel } from './Interfaces/IConfigurationResponseModel';
|
||||
|
||||
interface IAppProps {
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
interface IAppState {
|
||||
componentOptions: IAvailableContainerModel[]
|
||||
}
|
||||
class App extends React.Component<IAppProps> {
|
||||
public state: IAppState;
|
||||
|
||||
constructor(props: IAppProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
componentOptions: []
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
fetchConfiguration().then((configuration: IConfigurationResponseModel) => {
|
||||
this.setState({
|
||||
componentOptions: configuration.AvailableContainers
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="App">
|
||||
<Sidebar componentOptions={this.state.componentOptions} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchConfiguration(): Promise<IConfigurationResponseModel> {
|
||||
const url = `${import.meta.env.VITE_SMARTMENUISERIE_URL}`;
|
||||
const myHeaders = new Headers({
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: myHeaders
|
||||
};
|
||||
|
||||
return await fetch(url, myInit)
|
||||
.then((response) =>
|
||||
response.json()
|
||||
) as IConfigurationResponseModel;
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
|
16
src/Components/Sidebar/Sidebar.tsx
Normal file
16
src/Components/Sidebar/Sidebar.tsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
import * as React from 'react';
|
||||
import { IAvailableContainerModel } from '../../Interfaces/IAvailableContainerModel';
|
||||
|
||||
interface ISidebarProps {
|
||||
componentOptions: IAvailableContainerModel[]
|
||||
}
|
||||
|
||||
export default class Sidebar extends React.PureComponent<ISidebarProps> {
|
||||
public render() {
|
||||
return (
|
||||
<nav className='bg-blue min-h-full'>
|
||||
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
}
|
12
src/Components/SidebarRow/SidebarRow.tsx
Normal file
12
src/Components/SidebarRow/SidebarRow.tsx
Normal file
|
@ -0,0 +1,12 @@
|
|||
import * as React from 'react';
|
||||
|
||||
interface ISidebarRowProps {
|
||||
}
|
||||
|
||||
export const SidebarRow: React.FC<ISidebarRowProps> = (props) => {
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
4
src/Enums/AddingBehavior.ts
Normal file
4
src/Enums/AddingBehavior.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export enum AddingBehavior {
|
||||
InsertInto,
|
||||
Replace
|
||||
}
|
5
src/Enums/XPositionReference.ts
Normal file
5
src/Enums/XPositionReference.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export enum XPositionReference {
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
}
|
11
src/Interfaces/ActionContainerModel.ts
Normal file
11
src/Interfaces/ActionContainerModel.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { AddingBehavior } from '../Enums/AddingBehavior';
|
||||
import { IImageModel } from './IImageModel';
|
||||
|
||||
export interface IActionContainerModel {
|
||||
Id: string
|
||||
CustomLogo: IImageModel
|
||||
Label: string
|
||||
Description: string
|
||||
Action: string
|
||||
AddingBehavior: AddingBehavior
|
||||
}
|
28
src/Interfaces/IAvailableContainerModel.ts
Normal file
28
src/Interfaces/IAvailableContainerModel.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { IActionContainerModel } from './ActionContainerModel'
|
||||
import { IAvailableDefaultContainerModel } from './IAvailableDefaultContainerModel'
|
||||
|
||||
/** Model of available container used in application configuration */
|
||||
export interface IAvailableContainerModel {
|
||||
Type: string
|
||||
BodyColor: string
|
||||
BorderColor: string
|
||||
BorderWidth: number
|
||||
Width: number
|
||||
Height: number
|
||||
Padding: number
|
||||
MinWidth: number
|
||||
MaxWidth: number
|
||||
MinHeight: number
|
||||
MaxHeight: number
|
||||
IsWidthFixed: boolean
|
||||
IsPositionFixed: boolean
|
||||
|
||||
ShowCotation: boolean
|
||||
|
||||
/** Default Type container to add with this container (Priority on DefaultChildrenContainers property) */
|
||||
TypeChildContainerDefault: string
|
||||
|
||||
/** Default children container to add with this container */
|
||||
DefaultChildrenContainers: IAvailableDefaultContainerModel[]
|
||||
ContainerActions: IActionContainerModel[]
|
||||
}
|
4
src/Interfaces/IAvailableDefaultContainerModel.ts
Normal file
4
src/Interfaces/IAvailableDefaultContainerModel.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface IAvailableDefaultContainerModel {
|
||||
Type: string
|
||||
DefaultChildrenContainers: IAvailableDefaultContainerModel[]
|
||||
}
|
12
src/Interfaces/IAvailableSymbolModel.ts
Normal file
12
src/Interfaces/IAvailableSymbolModel.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { XPositionReference } from '../Enums/XPositionReference';
|
||||
import { IImageModel } from './IImageModel';
|
||||
|
||||
/**
|
||||
* Model of available symbol to configure the application */
|
||||
export interface IAvailableSymbolModel {
|
||||
Name: string
|
||||
XPositionReference: XPositionReference
|
||||
Image: IImageModel
|
||||
Width: number
|
||||
Height: number
|
||||
}
|
9
src/Interfaces/IConfigurationResponseModel.ts
Normal file
9
src/Interfaces/IConfigurationResponseModel.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { IAvailableContainerModel } from './IAvailableContainerModel';
|
||||
import { IAvailableSymbolModel } from './IAvailableSymbolModel';
|
||||
|
||||
/** Model of configuration for the application to configure it */
|
||||
export interface IConfigurationResponseModel {
|
||||
AvailableContainers: IAvailableContainerModel[];
|
||||
AvailableSymbols: IAvailableSymbolModel[];
|
||||
MainContainer: IAvailableContainerModel;
|
||||
}
|
7
src/Interfaces/IImageModel.ts
Normal file
7
src/Interfaces/IImageModel.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
/** Model of an image with multiple source */
|
||||
export interface IImageModel {
|
||||
Name: string;
|
||||
Url: string;
|
||||
Base64Image: string;
|
||||
Svg: string;
|
||||
}
|
10
src/main.tsx
10
src/main.tsx
|
@ -1,10 +1,10 @@
|
|||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
import './index.css';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
)
|
||||
);
|
||||
|
|
9
src/vite-env.d.ts
vendored
9
src/vite-env.d.ts
vendored
|
@ -1 +1,10 @@
|
|||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_SMARTMENUISERIE_URL: string
|
||||
// more env variables...
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue