Skip to content
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

feat: add 404 page #1233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions frontend/html/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "layout.html" %}

{% block content %}
<div class="not-found container">
<div class="not-found__close"></div>
<h1 class="not-found__logo">vas404k</h1>
<p class="not-found__description">Запрошеная страница выгорела и уехала в отпуск</p>
Copy link
Owner

Choose a reason for hiding this comment

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

Запрошеная страница выгорела и уехала в отпуск

Чот мне не нравится эта фраза. Какая-то одновременно душная, инфантильная и несмешная, в стиле сайтов с айтишниками из нулевых. Нужна другая.

Copy link
Owner

Choose a reason for hiding this comment

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

Можно обсудить в дев-чате идеи


<emoji-clicker></emoji-clicker>

<a href="{% url "index" %}" class="button not-found__button">На главную</a>
</div>
{% endblock %}
25 changes: 25 additions & 0 deletions frontend/static/css/components/emoji-clicker.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.emoji-clicker {
display: block;
margin: 0 auto;
font-size: 100px;
padding-bottom: 35px;
cursor: pointer;
user-select: none;
}

.bounce-enter-active {
cursor: pointer;
animation: bounce-in 0.5s;
}

@keyframes bounce-in {
0% {
transform: scale(0.25);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
2 changes: 2 additions & 0 deletions frontend/static/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import "./theme.css";
@import "./base.css";
@import "./layout.css";
@import "./not-found.css";
@import "./components.css";
@import "./components/menu.css";
@import "./components/auth.css";
Expand All @@ -29,3 +30,4 @@
@import "./components/select.css";
@import "./components/intro.css";
@import "./components/apps.css";
@import "./components/emoji-clicker.css";
60 changes: 60 additions & 0 deletions frontend/static/css/not-found.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.not-found {
position: relative;
padding-top: 75px;
padding-bottom: 75px;
text-align: center;
font-size: 110%;
max-width: var(--max-content-width);
margin: 0 auto;
}

.not-found__logo {
color: white;
font-size: 4em;
font-weight: 100;
mix-blend-mode: difference;
}

.not-found__close {
top: 13%;
left: 47%;
right: 0;
position: absolute;
display: block;
width: 125px;
height: 125px;
overflow: hidden;

&::before, &::after {
content: '';
position: absolute;
height: 40px;
width: 100%;
top: 40%;
left: 0;
margin-top: -1px;
background: #000;
}

&::before {
transform: rotate(45deg);
}

&::after {
transform: rotate(-45deg);

}
}

.not-found__description {
padding-top: 50px;
padding-bottom: 50px;
max-width: 50%;
margin: 0 auto;
font-size: 2em;
}

.not-found__button {
width: 100%;
max-width: 200px;
}
36 changes: 36 additions & 0 deletions frontend/static/js/components/EmojiClicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div class="emoji-clicker" @click="handleClick">
{{ emojis[currentEmojiIndex] }}
</div>
</template>

<script>
const EMOJIS = ["✈️", "🏖️", "🏔️", "🏝️"];
Copy link
Owner

Choose a reason for hiding this comment

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

Я не уверен, но что-то меня смущает в идее, чтобы делать для этого отдельный Vue компонент с отдельными CSS'ами и подключать его на КАЖДОЙ странице Клуба чисто ради одного юзкейса "переключения эмодзей по кругу"

Я попросил ChatGPT написать мне код который бы делал это просто инлайн и в целом меня всё устраивает:

    <div id="emoji" onclick="(function() { const emojis = ['😀', '😎', '😂', '😍', '🤔', '😭', '😡', '😱', '😴', '🤖']; this.index = (this.index || 0) + 1; this.innerHTML = emojis[this.index % emojis.length]; })()">
        😀
    </div>

Copy link
Author

Choose a reason for hiding this comment

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

Стили - для страницы они нужны, куда их деть если не отдельный файл?

VUE - можно переписать, но твой код не меняет классы, они нужны для анимации, а тогда, с красивого однострочника будет - каша.

Чем плох VUE - если я так понимаю, он все равно маунтится на страницы глобально, тоесть на перфоманс никак не влияет, но код более понятен, чем inline в атрибутах?

Copy link
Collaborator

@nlopin nlopin Jul 15, 2024

Choose a reason for hiding this comment

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

,Можно триггерить анимацию без джаваскрипта с помощью скрытого чекбокса, тогда можно заинлайнить выбор эмодзи

Тогда кажется вообще можно не грузить джаваскрипт на этой странице, если это возможно.

Copy link
Author

Choose a reason for hiding this comment

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

Разве vue не маунтится на рут ноду? Тоесть там и так есть весь vue и его бандл.

Заяв чекбокс и економия на спичках?

Я поверю есть ли vue на 404

Copy link
Collaborator

@nlopin nlopin Jul 16, 2024

Choose a reason for hiding this comment

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

зачем нам вообще что-то маунтить, если можно вообще не тащить джаваскрипт и основной бандл. 160 килобайт нефиговые такие спички

@vas3k можно же эту страницу отдавать как статику? я так понимаю нужно не использовать layout.html

Copy link
Author

Choose a reason for hiding this comment

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

Я не проверил, но я же написал Vue скорее всего УЖЕ маунтится на рут. Тоесть весь JS и так уже там

Я отдельно не тяну его


export default {
name: "EmojiClicker",
data() {
return {
emojis: EMOJIS,
currentEmojiIndex: 0
};
},
methods: {
triggerAnimation(event) {
setTimeout(() => {
event.target.classList.remove("bounce-enter-active");
}, 500);
event.target.classList.add("bounce-enter-active");
},
handleClick(event) {
if (this.currentEmojiIndex < this.emojis.length - 1) {
this.triggerAnimation(event);
this.currentEmojiIndex++;
} else {
this.triggerAnimation(event);
this.currentEmojiIndex = 0; // Reset to initial state
}
}
}
};
</script>
1 change: 1 addition & 0 deletions frontend/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Vue.component("v-select", vSelect);
Vue.component("tag-select", () => import("./components/TagSelect.vue"));
Vue.component("simple-select", () => import("./components/SimpleSelect.vue"));
Vue.component("reply-form", () => import("./components/ReplyForm.vue"));
Vue.component("emoji-clicker", () => import("./components/EmojiClicker.vue"));

// Since our pages have user-generated content, any fool can insert "{{" on the page and break it.
// We have no other choice but to completely turn off template matching and leave it on only for components.
Expand Down