Skip to content

Commit

Permalink
Telegram Mini App
Browse files Browse the repository at this point in the history
  • Loading branch information
efiand committed Jul 20, 2024
1 parent caf4a53 commit a8b2337
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
globals: {
document: 'readonly',
window: 'readonly',
URL: 'readonly',
},
parserOptions: {
ecmaVersion: 'latest',
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ <h1 class="rules__header">Пасьянс «Колодец»</h1>
Вернуться к игре
</button>
<button class="rules__button rules__restart" type="button">Разложить</button>
<a class="rules__button rules__telegram" href="https://t.me/WellCardGameBot" target="_blank">
Играть в Telegram
</a>
</div>
<p class="rules__text">
Цель игры — собрать 104 карты (2 колоды) в четырёх угловых слотах, повёрнутых на 45°. На каждый слот кладутся карты одной масти в порядке уменьшения достоинства — от короля до туза, затем король и так далее до второго туза.
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/assets/scss/base/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ html {
scroll-behavior: smooth;
overflow-anchor: none;

@media (max-width: 480px) and (min-height: 150vw) {
@media (max-width: 767px), (min-height: 150vw) {
font-size: 14px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scss/base/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $green: #096312;
$black: #000000;

@mixin mobile {
@media (max-width: 600px), (max-height: 600px) {
@media (max-width: 767px), (max-height: 600px) {
@content;
}
}
6 changes: 6 additions & 0 deletions src/assets/scss/blocks/rules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
padding: 1rem 0;
font-size: 1rem;
font-family: inherit;
text-align: center;
text-decoration: none;
background-color: $gray;
border: none;
border-radius: 1.25rem;
Expand All @@ -56,6 +58,10 @@
transition: all 0.3s ease-in-out;
user-select: none;

@include mobile {
max-width: none;
}

&:hover,
&:focus {
color: #ffffff;
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getDropCoords } from '@/modules/functions/get-drop-coords';
import { reloadHandler } from '@/modules/functions/reload-handler';
import { restartHandler } from '@/modules/functions/restart-handler';
import { rulesOpenHandler } from '@/modules/functions/rules-open-handler';
import '@/modules/tg';

const CARDS_IN_KEYS = 14;

Expand Down
1 change: 1 addition & 0 deletions src/modules/functions/drag-drop-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Coords {

export const dragDropHandler = (evt) => {
evt.preventDefault();
evt.stopPropagation();

const startCoords = new Coords(evt.clientX, evt.clientY);

Expand Down
14 changes: 14 additions & 0 deletions src/modules/tg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { rules } from '@/modules/settings';

const params = new URL(window.location.toString()).searchParams;
const tgMode = typeof params.get('tg') === 'string';

if (tgMode) {
rules.querySelector('.rules__telegram').remove();
const script = document.createElement('script');
script.src = 'https://telegram.org/js/telegram-web-app.js';
script.addEventListener('load', () => {
window.Telegram?.WebApp?.expand();
});
document.head.append(script);
}

0 comments on commit a8b2337

Please sign in to comment.