Skip to content
Snippets Groups Projects
Commit 1785e024 authored by Alexa Valentová's avatar Alexa Valentová
Browse files

fix automatic line breaking on chrome, add mobile support

parent 73381f86
Branches
No related tags found
No related merge requests found
...@@ -5,6 +5,14 @@ ...@@ -5,6 +5,14 @@
<link rel="icon" href="/static/favicon.ico"> <link rel="icon" href="/static/favicon.ico">
<link rel="stylesheet" href="https://styleguide.pirati.cz/2.12.x/css/styles.css"> <link rel="stylesheet" href="https://styleguide.pirati.cz/2.12.x/css/styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
;(function () {
var src = '//cdn.jsdelivr.net/npm/eruda';
if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return;
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
document.write('<scr' + 'ipt>eruda.init();</scr' + 'ipt>');
})();
</script>
<title>Generátor grafiky</title> <title>Generátor grafiky</title>
</head> </head>
<body> <body>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite --host",
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
......
...@@ -75,7 +75,7 @@ export default { ...@@ -75,7 +75,7 @@ export default {
</button> </button>
</div> </div>
</div> </div>
<div class="object-contain"> <div class="object-contain h-[115vw] md:h-[unset]">
<canvas <canvas
ref="canvas" ref="canvas"
class="w-full border border-gray-300 drop-shadow-md duration-150" class="w-full border border-gray-300 drop-shadow-md duration-150"
......
...@@ -85,12 +85,23 @@ const transformTextLineBreaks = ( ...@@ -85,12 +85,23 @@ const transformTextLineBreaks = (
} }
); );
currentWidth += wordText.width // This is really ugly, I have no idea why Chromium thinks the text is shorter than it really is.
// (Or why Firefox thinks it's longer.)
// But, it works.
currentWidth += wordText.width * (
(!!window.chrome)
? 1.183
: 1
)
if (!skipNewLineGeneration && currentWidth > maxWidth) { if (!skipNewLineGeneration && currentWidth > maxWidth) {
if ( if (
["a", "i", "o", "u", "s", "se", "v", "z"]. ["a", "i", "o", "u", "s", "se", "v", "z"].
includes(splitWords[wordPosition - 1].replace("*", "")) includes(splitWords[
(wordPosition !== 0)
? (wordPosition - 1)
: (wordPosition)
].replace("*", ""))
) { // Previous word is not a, i, o, u, s, ... ) { // Previous word is not a, i, o, u, s, ...
const lineBreakPosition = ( const lineBreakPosition = (
positionWithinString positionWithinString
...@@ -100,7 +111,11 @@ const transformTextLineBreaks = ( ...@@ -100,7 +111,11 @@ const transformTextLineBreaks = (
) )
- currentWord.length - currentWord.length
- 1 - 1
- splitWords[wordPosition - 1].length - splitWords[
(wordPosition !== 0)
? (wordPosition - 1)
: (wordPosition)
].length
) )
text = setCharAt(text, lineBreakPosition, "\n") text = setCharAt(text, lineBreakPosition, "\n")
......
...@@ -21,7 +21,6 @@ const router = createRouter({ ...@@ -21,7 +21,6 @@ const router = createRouter({
router.beforeEach( router.beforeEach(
(to, from, next) => { (to, from, next) => {
// BEGIN Title
document.title = 'Generátor grafiky' document.title = 'Generátor grafiky'
if (to.meta.title) { if (to.meta.title) {
......
...@@ -2,9 +2,5 @@ ...@@ -2,9 +2,5 @@
"name": "graphics-generator", "name": "graphics-generator",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {}
"": {
"name": "graphics-generator"
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment