Skip to content

Fix(GUI) Stretched Logo on Mobile and Safari #86

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

227 changes: 138 additions & 89 deletions src/ConcertoEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,108 +1,157 @@
import * as monaco from '@monaco-editor/react';
import { editor, MarkerSeverity } from 'monaco-editor';
import useAppStore from './store';
import { useEffect, useMemo } from 'react';
import * as monaco from "@monaco-editor/react";
import { editor, MarkerSeverity } from "monaco-editor";
import useAppStore from "./store";
import { useEffect, useMemo } from "react";

const options:editor.IStandaloneEditorConstructionOptions = {
const options: editor.IStandaloneEditorConstructionOptions = {
minimap: { enabled: false },
wordWrap: "on",
automaticLayout:true,
automaticLayout: true,
scrollBeyondLastLine: false,
}
const concertoKeywords = ['map','concept','from','optional','default','range','regex','length','abstract','namespace','import', 'enum', 'scalar', 'extends', 'default', 'participant','asset', 'o','identified by','transaction','event'];
const concertoTypes = ['String','Integer','Double','DateTime','Long','Boolean']
};

export default function ConcertoEditor( {value, onChange} : {value: string, onChange?: (value:string|undefined) => void} ) {
const concertoKeywords = [
"map",
"concept",
"from",
"optional",
"default",
"range",
"regex",
"length",
"abstract",
"namespace",
"import",
"enum",
"scalar",
"extends",
"default",
"participant",
"asset",
"o",
"identified by",
"transaction",
"event",
];

const monacoEditor = monaco.useMonaco();
const error = useAppStore((state) => state.error);
const ctoErr = useMemo(() => {
if (error && error.startsWith("c:")) {
return error;
}
}, [error]);
useEffect(() => {
let model = monacoEditor?.editor.getModels()[0];
if (ctoErr && monacoEditor) {
const match = ctoErr.match(/Line (\d+) column (\d+)/);
const concertoTypes = [
"String",
"Integer",
"Double",
"DateTime",
"Long",
"Boolean",
];

const lineNumber = parseInt(match[1]);
const columnNumber = parseInt(match[2]) ;
monacoEditor?.editor.setModelMarkers(model, "customMarker", [
{
export default function ConcertoEditor({
value,
onChange,
}: {
value: string;
onChange?: (value: string | undefined) => void;
}) {
const monacoEditor = monaco.useMonaco();
const error = useAppStore((state) => state.error);
const ctoErr = useMemo(() => {
if (error && error.startsWith("c:")) {
return error;
}
}, [error]);

useEffect(() => {
const model = monacoEditor?.editor.getModels()[0];
if (ctoErr && monacoEditor && model) {
const match = ctoErr.match(/Line (\d+) column (\d+)/);
if (match) {
const lineNumber = parseInt(match[1], 10);
const columnNumber = parseInt(match[2], 10);
monacoEditor.editor.setModelMarkers(model, "customMarker", [
{
startLineNumber: lineNumber,
startColumn: columnNumber - 1,
endLineNumber: lineNumber,
endColumn: columnNumber + 1,
message: ctoErr,
severity: MarkerSeverity.Error,
},
},
]);
} else {
monacoEditor?.editor.setModelMarkers(model, "customMarker", []);
}
}, [ctoErr,monacoEditor]);
function handleEditorWillMount(monaco:monaco.Monaco) {
monaco.languages.register({
id: 'concerto',
extensions: ['.cto'],
aliases: ['Concerto', 'concerto'],
mimetypes: ['application/vnd.accordproject.concerto'],
});

monaco.languages.setMonarchTokensProvider('concerto', {
keywords: concertoKeywords,
typeKeywords: concertoTypes,
operators: ['=', '{', '}', '@', '"'],
symbols: /[=}{@"]+/,
escapes: /\\(?:[btnfru"'\\]|\\u[0-9A-Fa-f]{4})/,
tokenizer: {
root: [
{ include: '@whitespace' },
[/[a-zA-Z_]\w*/, {
cases: {
'@keywords': 'keyword',
'@typeKeywords': 'type',
'@default': 'identifier',
},
}],
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-terminated string
[/"/, 'string', '@string'],
],
string: [
[/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop'],
],
whitespace: [
[/\s+/, 'white'],
[/(\/\/.*)/, 'comment'],
],
},
});
monaco.editor.defineTheme('concertoTheme', {
base: 'vs',
inherit: true,
rules: [
{ token: 'keyword', foreground: 'cd2184' },
{ token: 'type', foreground: '008080' },
{ token: 'identifier', foreground: '000000' },
{ token: 'string', foreground: '008000' },
{ token: 'string.escape', foreground: '800000' },
{ token: 'comment', foreground: '808080' },
{ token: 'white', foreground: 'FFFFFF' },
],
colors: {},
});

monaco.editor.setTheme('concertoTheme');
}
} else if (monacoEditor && model) {
monacoEditor.editor.setModelMarkers(model, "customMarker", []);
}

return (
}, [ctoErr, monacoEditor]);

function handleEditorWillMount(monaco: monaco.Monaco) {
monaco.languages.register({
id: "concerto",
extensions: [".cto"],
aliases: ["Concerto", "concerto"],
mimetypes: ["application/vnd.accordproject.concerto"],
});

monaco.languages.setMonarchTokensProvider("concerto", {
keywords: concertoKeywords,
typeKeywords: concertoTypes,
operators: ["=", "{", "}", "@", '"'],
symbols: /[=}{@"]+/,
escapes: /\\(?:[btnfru"'\\]|\\u[0-9A-Fa-f]{4})/,
tokenizer: {
root: [
{ include: "@whitespace" },
[
/[a-zA-Z_]\w*/,
{
cases: {
"@keywords": "keyword",
"@typeKeywords": "type",
"@default": "identifier",
},
},
],
[/"([^"\\]|\\.)*$/, "string.invalid"], // non-terminated string
[/"/, "string", "@string"],
],
string: [
[/[^\\"]+/, "string"],
[/@escapes/, "string.escape"],
[/\\./, "string.escape.invalid"],
[/"/, "string", "@pop"],
],
whitespace: [
[/\s+/, "white"],
[/(\/\/.*)/, "comment"],
],
},
});

monaco.editor.defineTheme("concertoTheme", {
base: "vs",
inherit: true,
rules: [
{ token: "keyword", foreground: "cd2184" },
{ token: "type", foreground: "008080" },
{ token: "identifier", foreground: "000000" },
{ token: "string", foreground: "008000" },
{ token: "string.escape", foreground: "800000" },
{ token: "comment", foreground: "808080" },
{ token: "white", foreground: "FFFFFF" },
],
colors: {},
});

monaco.editor.setTheme("concertoTheme");
}

return (
<div className="editorwrapper">
<monaco.Editor options={ options }
language='concerto' height="60vh" value={value} onChange={onChange} beforeMount={handleEditorWillMount}/>
<monaco.Editor
options={options}
language="concerto"
height="60vh"
value={value}
onChange={onChange}
beforeMount={handleEditorWillMount}
/>
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function Navbar({ scrollToExplore }: { scrollToExplore: any }) {
preview={false}
style={{
paddingRight: screens.md ? "1.5em" : "10px",
Copy link
Collaborator

Choose a reason for hiding this comment

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

okay @nitro56565 can you change this: 1.5em in the paddingRight, to the equivalent of 24 pixels from the base format 16px.

so change 1.5em to 24px to ensure consistency here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright I'll do that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Vinyl-Davyl done with these changes

height: "26px",
height: "26px", maxWidth: screens.md ? '184.17px' : '36.67px',
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now. @Vinyl-Davyl @nitro56565 can we please look into having a consistent unit for styles, we are using em, px both. Let's please fix this as well.

}}
/>
<span style={{ color: "white" }}>Template Playground</span>
Expand Down
Loading