- Install ESLint 9 with flat config, TypeScript, Vue plugins - Configure Prettier (140 char, 2-space indent, single quotes) - Add pre-commit hooks via husky + lint-staged for auto-fix - Rename components to multi-word (Countdown → CountdownTimer, etc.) - Add explicit TypeScript prop/emit interfaces - Remove all console.log statements - Fix all ESLint violations and type errors - Verify type-check, build, and HMR working resolves #43 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/50
30 lines
667 B
TypeScript
30 lines
667 B
TypeScript
import { ref, onMounted, onUnmounted } from 'vue';
|
|
|
|
// by convention, composable function names start with "use"
|
|
export function useMobile() {
|
|
const isMobile = ref<boolean>(false);
|
|
|
|
const handleWindowSizeChange = () => {
|
|
isMobile.value = isMobileFunc();
|
|
};
|
|
|
|
isMobile.value = isMobileFunc();
|
|
function isMobileFunc() {
|
|
if (screen.width <= 768) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
onMounted(async () => {
|
|
window.addEventListener('resize', handleWindowSizeChange);
|
|
handleWindowSizeChange();
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
});
|
|
|
|
return isMobile;
|
|
}
|