Files
cloudron-box/dashboard/src/index.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-11-01 14:16:09 +01:00
import { createApp } from 'vue';
2025-08-05 16:39:57 +02:00
import '@fontsource/inter';
2024-11-01 14:16:09 +01:00
2025-07-10 11:55:11 +02:00
import { tooltip, fallbackImage } from '@cloudron/pankow';
2024-12-26 12:19:48 +01:00
const fitText = {
mounted(el) {
let fontSize = 14;
function attempt() {
setTimeout(() => {
const curWidth = el.getBoundingClientRect().width;
const parentWidth = el.parentElement.getBoundingClientRect().width;
if (!curWidth && !parentWidth) return attempt();
if (curWidth < parentWidth-12) return;
fontSize -= 0.2;
el.style.fontSize = fontSize + 'px';
attempt();
}, 1);
}
attempt();
}
};
// Override the link rendering method for markdown renderings to open in new tab
import { marked } from 'marked';
const renderer = new marked.Renderer();
renderer.link = function(item) {
const titleAttr = item.title ? ` title="${item.title}"` : '';
return `<a href="${item.href}" target="_blank" ${titleAttr}>${item.text}</a>`;
};
marked.setOptions({ renderer });
2024-11-01 14:16:09 +01:00
import i18n from './i18n.js';
2025-01-21 17:08:09 +01:00
import Index from './Index.vue';
2024-11-01 14:16:09 +01:00
import './style.css';
2024-11-01 14:16:09 +01:00
(async function init() {
const app = createApp(Index);
app.use(await i18n());
2024-12-26 12:19:48 +01:00
app.directive('tooltip', tooltip);
2025-01-06 21:28:01 +01:00
app.directive('fallback-image', fallbackImage);
app.directive('fit-text', fitText);
2024-12-26 12:19:48 +01:00
app.mount('#app');
2024-11-01 14:16:09 +01:00
})();