Skip to content

Commit

Permalink
Too late but it was fun btw...
Browse files Browse the repository at this point in the history
  • Loading branch information
iaroslavkrasikov committed Oct 10, 2023
1 parent 5fc39f9 commit 5d4a0ad
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 50 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Telesim Mini App [@telesimbot](http://t.me/telesimbot).

Built with Svelte and Telebot, deployed at Vercel with serverless functions.

## Usage


1. Put `TOKEN` and `DEV_WEBHOOK_URL` in your `.env.local` file
2. Run
```
pip -r requirements.txt
npm install
vercel dev
```
6 changes: 1 addition & 5 deletions api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
app = flask.Flask(__name__)
app.url_map.strict_slashes = False

@app.route("/")
def web_app():
return "Web app"

@app.route("/api")
def index():
return env.WEBHOOK_URL
return flask.Response(status=200)

@app.route("/api/bot", methods=["POST"])
def bot_webhook():
Expand Down
1 change: 0 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta charset="UTF-8">
<link rel="icon" type="image/svg+xml" href="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="./src/app.css">
<title>Telesim</title>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion app/public/vite.svg

This file was deleted.

30 changes: 19 additions & 11 deletions app/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,49 @@
import WebApp from "@twa-dev/sdk";
import Logo from "./lib/Logo.svelte";
import Plans from "./lib/Plans.svelte";
import Sim from "./lib/SIM.svelte";
import Plans from "./lib/Plans/Plans.svelte";
import Sim from "./lib/SIM/SIM.svelte";
import History from "./lib/History.svelte";
import Info from "./lib/Info.svelte";
import Info from "./lib/Info/Info.svelte";
import { setContext } from "svelte";
setContext("webapp", WebApp);
const checkInitData = (unsafeInitData) => {
true
}
return true;
};
const isUserActive = (userId)
const isUserActive = (userId) => {
return false;
};
let initData = checkInitData(WebApp.initData)
? WebApp.initDataUnsafe
: undefined;
: null;
const user = {
name: initData.user.id,
isActive: isUserActive(initData.user.id)
isActive: isUserActive(initData.user.id),
};
</script>

<main>
<div class="container">
{#if !user.isActive}
<Logo />
<Info />
<Plans />
<History />
{:else}
<Sim />
Buy More:
<!-- Buy More: -->
<Plans />
<History />
<Info />
{/if}
</main>
</div>

<style>
.container {
padding: 0 1em 0 1em;
}
</style>
59 changes: 46 additions & 13 deletions app/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@
}

body {
display: flex;
margin: 0;
min-width: 320px;
/* width: 100%; */
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Arial", sans-serif;
font-size: 17px;
font-style: normal;
font-weight: 400;
font-synthesis: none;
line-height: 1.5;
line-height: 22px;
letter-spacing: -0.43px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}

a {
font-weight: 500;
text-decoration: inherit;
Expand All @@ -29,11 +37,6 @@ a:hover {
color: #535bf2;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
font-size: 1em;
Expand All @@ -56,9 +59,39 @@ button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

.logo {
display: flex;
height: 162px;
place-items: center;
text-align: center;
.title {
font-size: 22px;
font-style: normal;
font-weight: 400;
line-height: 28px;
/* 127.273% */
letter-spacing: -0.264px;
}

.headline {
margin: 1em 0 .5em 0.25em;
font-size: 22px;
font-style: normal;
font-weight: 700;
line-height: 28px;
/* 127.273% */
letter-spacing: -0.264px;
}

.subheadline {
margin-top: .1em;
font-size: 15px;
font-style: normal;
font-weight: 400;
line-height: 18px;
/* 120% */
letter-spacing: -0.23px;
}

.body-semibold {
font-size: 17px;
font-style: normal;
font-weight: 590;
line-height: 22px;
letter-spacing: -0.43px;
}
21 changes: 21 additions & 0 deletions app/src/assets/icon/devices.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/assets/icon/faq.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/assets/icon/support.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/src/assets/svelte.svg

This file was deleted.

Binary file added app/src/assets/telesim-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions app/src/lib/Counter.svelte

This file was deleted.

23 changes: 23 additions & 0 deletions app/src/lib/Info/Info.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script>
import faqIcon from "../../assets/icon/faq.svg";
import devicesIcon from "../../assets/icon/devices.svg";
import supportIcon from "../../assets/icon/support.svg";
import InfoButton from "./InfoButton.svelte";
</script>

<div class="info">
<InfoButton link="faq" icon={faqIcon} text="FAQ" />
<InfoButton link="devices" icon={devicesIcon} text="eSIM Devices" />
<InfoButton link="support" icon={supportIcon} text="Support" />
</div>

<style>
.info {
display: flex;
margin-top: 2em;
flex-wrap: wrap;
color: var(--tg-theme-button-text-color);
gap: 9px;
}
</style>
32 changes: 32 additions & 0 deletions app/src/lib/Info/InfoButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script>
export let link;
export let icon;
export let text;
// TODO: Button action
</script>

<button class="button" {link}>
<img src={icon} class="icon" alt="" />
<div>{text}</div>
</button>

<style>
.button {
display: inline-flex;
height: 36px;
padding: 0px 24px 0px 12px;
align-items: center;
flex-shrink: 0;
font-weight: 590;
line-height: 100%;
vertical-align: middle;
background: var(--tg-theme-button-color);
border-radius: 12px;
gap: 6px;
}
.icon {
width: 24px;
height: 24px;
}
</style>
21 changes: 18 additions & 3 deletions app/src/lib/Logo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<script></script>
<script>
import telesimLogo from "../assets/telesim-logo.png";
</script>

<main>Logo</main>
<div class="logo">
<img src={telesimLogo} alt="" />
<span class="title">Telesim</span>
<span class="subheadline">Your SIM-card across the world</span>
</div>

<style></style>
<style>
.logo {
display: flex;
height: 162px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
Empty file removed app/src/lib/Plans.svelte
Empty file.
File renamed without changes.
15 changes: 15 additions & 0 deletions app/src/lib/Plans/Plans.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
import PlanRegions from "./Regions/Regions.svelte";
import PlanLimits from "./Limits.svelte";
</script>

<div class="plans">
<PlanRegions />
<PlanLimits />
</div>

<style>
.plans {
margin-top: 2em;
}
</style>
50 changes: 50 additions & 0 deletions app/src/lib/Plans/Regions/Region.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script>
export let double = false;
export let selector = false;
</script>

<div>
{#if !selector}
{#if double}
<div class="region region-double">
<div class="body-semibold"><slot /></div>
</div>
{:else}
<div class="region">
<div class="body-semibold"><slot /></div>
</div>
{/if}
{:else}
<div class="region region-selector">
<div class="body-semibold"><slot /></div>
</div>
{/if}
</div>

<style>
.region {
--W: calc(var(--vw) - 2em);
--g: 9px;
--w: calc((var(--W) - 2 * var(--g)) / 3);
display: flex;
width: var(--w);
height: var(--w);
padding: 8px 12px;
flex-direction: column;
justify-content: flex-end;
align-items: flex-start;
flex-shrink: 0;
background: var(--bg-color);
color: #fff;
border-radius: 12px;
}
.region-double {
--u: calc(var(--W) - var(--w) - var(--g));
width: var(--u);
}
.region-selector {
background: var(--tg-theme-hint-color);
}
</style>

0 comments on commit 5d4a0ad

Please sign in to comment.