Skip to content

Commit

Permalink
feat: middleware for non supported screens
Browse files Browse the repository at this point in the history
  • Loading branch information
raulwwq0 committed Jun 18, 2023
1 parent 279a17d commit 3ead4af
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 5 deletions.
14 changes: 14 additions & 0 deletions apps/web/middleware/valid-screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enum ScreenSize {
WIDTH = 1820,
HEIGHT = 1080,
}

export default defineNuxtRouteMiddleware(() => {
const { width } = useWindowSize();

const isValidResolutions = width.value >= ScreenSize.WIDTH;

if (!isValidResolutions) {
return navigateTo('/non-supported-screen');
}
});
7 changes: 6 additions & 1 deletion apps/web/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
} from '~~/interfaces/profile.interface';
definePageMeta({
middleware: ['authenticated', 'empty-profile', 'is-admin'],
middleware: [
'authenticated',
'empty-profile',
'is-admin',
'valid-screen',
],
});
useServerSeoMeta({
Expand Down
3 changes: 3 additions & 0 deletions apps/web/pages/auth/processing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
title: 'NuChat | Processing',
description: 'Just a chat app built with Nuxt 3 and Supabase',
});
definePageMeta({
middleware: ['valid-screen'],
});
preloadRouteComponents('/chats');
setTimeout(() => {
navigateTo('/chats');
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/auth/sign-in.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
definePageMeta({
middleware: ['already-authenticated'],
middleware: ['already-authenticated', 'valid-screen'],
});
useServerSeoMeta({
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/chats/[id]/messages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Profile } from '~~/interfaces/profile.interface';
definePageMeta({
middleware: ['authenticated', 'empty-profile'],
middleware: ['authenticated', 'empty-profile', 'valid-screen'],
layout: 'chats',
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/chats/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
definePageMeta({
middleware: ['authenticated', 'empty-profile'],
middleware: ['authenticated', 'empty-profile', 'valid-screen'],
layout: 'chats',
});
useSeoMeta({
Expand Down
3 changes: 3 additions & 0 deletions apps/web/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
title: 'NuChat | Home',
description: 'Just a chat app built with Nuxt 3 and Supabase',
});
definePageMeta({
middleware: ['valid-screen'],
});
</script>

<template>
Expand Down
44 changes: 44 additions & 0 deletions apps/web/pages/non-supported-screen.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<main>
<div>;-;</div>
<h1>Non supported screen</h1>
<p>Sorry, NuChat is not supported on this screen size yet.</p>
</main>
</template>

<style lang="scss" scoped>
main {
width: 80%;
height: 100vh;
margin: 0 auto;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
div {
font-size: 10rem;
font-weight: 700;
color: #ccc;
text-align: center;
margin-bottom: 2rem;
}
h1 {
font-size: 3rem;
font-weight: 700;
color: $primary;
text-align: center;
margin-bottom: 2rem;
}
p {
font-size: 1.5rem;
font-weight: 500;
color: #333;
text-align: center;
width: 50%;
margin-bottom: 1rem;
}
}
</style>
2 changes: 1 addition & 1 deletion apps/web/pages/profile/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
definePageMeta({
middleware: ['empty-profile', 'authenticated'],
middleware: ['empty-profile', 'authenticated', 'valid-screen'],
});
useServerSeoMeta({
Expand Down
3 changes: 3 additions & 0 deletions apps/web/pages/profile/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
title: 'NuChat | Complete your profile',
description: 'Create a new profile',
});
definePageMeta({
middleware: ['valid-screen'],
});
</script>

<template>
Expand Down

0 comments on commit 3ead4af

Please sign in to comment.