Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(website): make Playground Mobile Responsive #2028

Merged
14 changes: 14 additions & 0 deletions modelina-website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modelina-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@tailwindcss/line-clamp": "^0.4.0",
"@tailwindcss/typography": "^0.5.9",
"@tippyjs/react": "^4.2.6",
"clsx": "^2.1.1",
"cssnano": "^5.1.14",
"js-base64": "^3.7.4",
"lodash": "^4.17.21",
Expand Down
153 changes: 86 additions & 67 deletions modelina-website/src/components/contexts/PlaygroundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface LoadedState {
}

interface PlaygroundContextProps {
showInputEditor: boolean;
setShowInputEditor: Dispatch<SetStateAction<boolean>>;
showOptions: boolean;
setShowOptions: Dispatch<SetStateAction<boolean>>;
showOutputNavigation: boolean;
Expand Down Expand Up @@ -50,9 +52,13 @@ interface PlaygroundContextProps {
setRenderModels: (models: React.ReactNode) => void;
}

const PlaygroundContext = createContext<PlaygroundContextProps | undefined>(undefined);
const PlaygroundContext = createContext<PlaygroundContextProps | undefined>(
undefined
);

export const PlaygroundContextProvider: React.FC<{ children: React.ReactNode; }> = ({ children }) => {
export const PlaygroundContextProvider: React.FC<{
children: React.ReactNode;
}> = ({ children }) => {
const defaultConfig: ModelinaOptions = {
language: 'typescript',
propertyNamingFormat: 'default',
Expand Down Expand Up @@ -94,95 +100,108 @@ export const PlaygroundContextProvider: React.FC<{ children: React.ReactNode; }>
kotlinPackageName: 'asyncapi.models'
};

const [showInputEditor, setShowInputEditor] = useState(true);
const [showOptions, setShowOptions] = useState(true);
const [showOutputNavigation, setShowOutputNavigation] = useState(true);
const [config, setConfig] = useState<ModelinaOptions>(defaultConfig);
const [input, setInput] = useState(JSON.stringify(defaultAsyncapiDocument, null, 4));
const [input, setInput] = useState(
JSON.stringify(defaultAsyncapiDocument, null, 4)
);
const [models, setModels] = useState<ModelsGeneratorProps[]>([]);
const [generatorCode, setGeneratorCode] = useState('');
const [loaded, setLoaded] = useState({
editorLoaded: false,
hasReceivedCode: false,
hasReceivedCode: false
});
const [showGeneratorCode, setShowGeneratorCode] = useState(false);
const [error, setError] = useState(false);
const [statusCode, setStatusCode] = useState(400);
const [errorMessage, setErrorMessage] = useState('Bad Request');
const [isLoaded, setIsLoaded] = useState(false);
const [hasLoadedQuery, setHasLoadedQuery] = useState(false);
const [renderModels, setRenderModels] = React.useState<React.ReactNode | null>(null);
const [renderModels, setRenderModels] =
React.useState<React.ReactNode | null>(null);

const contextValue = useMemo(() => ({
showOptions,
setShowOptions,
showOutputNavigation,
setShowOutputNavigation,
config,
setConfig,
input,
setInput,
models,
setModels,
generatorCode,
setGeneratorCode,
loaded,
setLoaded,
showGeneratorCode,
setShowGeneratorCode,
error,
setError,
statusCode,
setStatusCode,
errorMessage,
setErrorMessage,
isLoaded,
setIsLoaded,
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels
}), [
showOptions,
setShowOptions,
showOutputNavigation,
setShowOutputNavigation,
config,
setConfig,
input,
setInput,
models,
setModels,
generatorCode,
setGeneratorCode,
loaded,
setLoaded,
showGeneratorCode,
setShowGeneratorCode,
error,
setError,
statusCode,
setStatusCode,
errorMessage,
setErrorMessage,
isLoaded,
setIsLoaded,
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels,
]);
const contextValue = useMemo(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't make unnecessary formatting changes, revert these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been part of the eslint-config-prettier rule and done automatically by prettier from the parent eslint rules, can we have npm run lint:fix as we did in the parent directory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sure, can you please create a separate PR for adding the npm run lint:fix command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

() => ({
showInputEditor,
setShowInputEditor,
showOptions,
setShowOptions,
showOutputNavigation,
setShowOutputNavigation,
config,
setConfig,
input,
setInput,
models,
setModels,
generatorCode,
setGeneratorCode,
loaded,
setLoaded,
showGeneratorCode,
setShowGeneratorCode,
error,
setError,
statusCode,
setStatusCode,
errorMessage,
setErrorMessage,
isLoaded,
setIsLoaded,
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels
}),
[
showInputEditor,
setShowInputEditor,
showOptions,
setShowOptions,
showOutputNavigation,
setShowOutputNavigation,
config,
setConfig,
input,
setInput,
models,
setModels,
generatorCode,
setGeneratorCode,
loaded,
setLoaded,
showGeneratorCode,
setShowGeneratorCode,
error,
setError,
statusCode,
setStatusCode,
errorMessage,
setErrorMessage,
isLoaded,
setIsLoaded,
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels
]
);

return (
<PlaygroundContext.Provider value={contextValue}>
{children}
</PlaygroundContext.Provider>
);
}
};

export const usePlaygroundContext = () => {
const context = useContext(PlaygroundContext);
if (!context) {
throw new Error('Playground was unable to load the context to display, please report this problem on GitHub.');
throw new Error(
'Playground was unable to load the context to display, please report this problem on GitHub.'
);
}
return context;
};
};
Loading
Loading