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

Telegram UI guidlines #9

Merged
merged 4 commits into from
Nov 15, 2023
Merged
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "vite build",
"typecheck": "npx tsc",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"dev:frontend:start": "vite",
"dev:api:start": "npx wrangler pages dev /functions --compatibility-date=2023-09-22",
"dev:tunnel": "../ngrok http --domain=causal-magpie-closing.ngrok-free.app 5173",
"build": "vite build",
"typecheck": "npx tsc",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"test:api": "npx vitest --dir functions/",
"test:api:coverage:": "npx vitest run --dir functions/ --coverage",
"test:frontend": "npx vitest --dir src/",
Expand Down
3 changes: 2 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
font-family: -apple-system, Inter, system-ui, Avenir, Helvetica, Arial,
sans-serif;
line-height: 1.5;
font-weight: 400;
font-synthesis: none;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/deck-form/deck-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const DeckForm = observer(() => {
className={css({
cursor: "pointer",
backgroundColor: theme.secondaryBgColor,
borderRadius: 8,
borderRadius: theme.borderRadius,
padding: 12,
})}
>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/deck-list/deck-loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const DeckLoading = () => {
justifyContent: "space-between",
cursor: "pointer",
gap: 4,
borderRadius: 8,
borderRadius: theme.borderRadius,
padding: "13px 12px",
background: theme.secondaryBgColor,
})}
Expand Down
82 changes: 42 additions & 40 deletions src/screens/deck-list/main-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Button } from "../../ui/button.tsx";
import { DeckLoading } from "./deck-loading.tsx";
import WebApp from "@twa-dev/sdk";
import { assert } from "../../lib/typescript/assert.ts";
import { ListHeader } from "../../ui/list-header.tsx";

export const MainScreen = observer(() => {
useMount(() => {
Expand All @@ -37,11 +38,8 @@ export const MainScreen = observer(() => {

return (
<div className={css({ display: "flex", flexDirection: "column", gap: 12 })}>
<h2 className={css({ margin: 0, padding: 0, paddingTop: 4 })}>
My decks
</h2>

<div>
<ListHeader text={"My decks"} />
<div
className={css({
display: "flex",
Expand Down Expand Up @@ -96,47 +94,51 @@ export const MainScreen = observer(() => {
</div>
</div>

<h2 className={css({ margin: 0, padding: 0 })}>Public decks</h2>
<div
className={css({
display: "flex",
flexDirection: "column",
gap: 6,
})}
>
{deckListStore.myInfo?.state === "fulfilled" &&
!deckListStore.publicDecks.length ? (
<Hint>
Wow! 🌟 You've added them all! There are no more public decks left
to discover.
</Hint>
) : null}
<div>
<ListHeader text={"Public decks"} />
<div
className={css({
display: "flex",
flexDirection: "column",
gap: 6,
})}
>
{deckListStore.myInfo?.state === "fulfilled" &&
!deckListStore.publicDecks.length ? (
<Hint>
Wow! 🌟 You've added them all! There are no more public decks left
to discover.
</Hint>
) : null}

{deckListStore.myInfo?.state === "fulfilled" ? (
<>
{deckListStore.publicDecks.map((deck) => (
<PublicDeck key={deck.id} deck={deck} />
))}
</>
) : null}
{deckListStore.myInfo?.state === "fulfilled" ? (
<>
{deckListStore.publicDecks.map((deck) => (
<PublicDeck key={deck.id} deck={deck} />
))}
</>
) : null}

{deckListStore.myInfo?.state === "pending" &&
[1, 2, 3].map((i) => <DeckLoading key={i} />)}
{deckListStore.myInfo?.state === "pending" &&
[1, 2, 3].map((i) => <DeckLoading key={i} />)}
</div>
</div>

<h2 className={css({ margin: 0, padding: 0 })}>News and updates</h2>
<div className={css({ paddingBottom: 16 })}>
<Button
icon={"mdi-call-made"}
onClick={() => {
const channelLink = import.meta.env.VITE_CHANNEL_LINK;
assert(channelLink, "Channel link env variable is empty");
<div>
<ListHeader text={"News and updates"} />
<div className={css({ paddingBottom: 16 })}>
<Button
icon={"mdi-call-made"}
onClick={() => {
const channelLink = import.meta.env.VITE_CHANNEL_LINK;
assert(channelLink, "Channel link env variable is empty");

WebApp.openTelegramLink(channelLink);
}}
>
Telegram channel
</Button>
WebApp.openTelegramLink(channelLink);
}}
>
Telegram channel
</Button>
</div>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/deck-list/my-deck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const MyDeck = observer((props: Props) => {
alignItems: "center",
cursor: "pointer",
gap: 4,
borderRadius: 8,
borderRadius: theme.borderRadius,
padding: 12,
background: theme.secondaryBgColor,
})}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/deck-list/public-deck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const PublicDeck = observer((props: Props) => {
display: "flex",
flexDirection: "column",
gap: 4,
borderRadius: 8,
borderRadius: theme.borderRadius,
padding: 12,
cursor: "pointer",
background: theme.secondaryBgColor,
Expand Down
8 changes: 4 additions & 4 deletions src/screens/deck-review/deck-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ export const DeckPreview = observer(() => {
display: "flex",
flexDirection: "column",
gap: 16,
paddingTop: 12,
})}
>
<div
className={css({
display: "flex",
flexDirection: "column",
gap: 16,
borderRadius: 8,
padding: "8px 12px",
borderRadius: theme.borderRadius,
padding: "8px 16px",
paddingBottom: 12,
background: theme.secondaryBgColor,
})}
Expand Down Expand Up @@ -74,9 +75,8 @@ export const DeckPreview = observer(() => {
{deckListStore.myId && deck.author_id === deckListStore.myId ? (
<Button
icon={"mdi-pencil"}
noPseudoClasses
outline
mainColor={theme.textColor}
transparent
onClick={() => {
screenStore.navigateToDeckForm(deck.id);
}}
Expand Down
9 changes: 1 addition & 8 deletions src/screens/deck-review/share-deck-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { assert } from "../../lib/typescript/assert.ts";
import { trimEnd } from "../../lib/string/trim.ts";
import WebApp from "@twa-dev/sdk";
import { Button } from "../../ui/button.tsx";
import { theme } from "../../ui/theme.tsx";

type Props = {
deckId: number;
Expand All @@ -22,13 +21,7 @@ export const ShareDeckButton = (props: Props) => {
};

return (
<Button
icon={"mdi-share"}
mainColor={theme.textColor}
onClick={onClick}
transparent
outline
>
<Button icon={"mdi-share"} noPseudoClasses outline onClick={onClick}>
Share deck
</Button>
);
Expand Down
23 changes: 11 additions & 12 deletions src/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { theme } from "./theme.tsx";
type Props = {
mainColor?: string;
outline?: boolean;
transparent?: boolean;
noPseudoClasses?: boolean;
icon?: string;
} & React.ButtonHTMLAttributes<HTMLButtonElement>;

Expand All @@ -18,6 +18,7 @@ export const Button = (props: Props) => {
outline,
children,
icon,
noPseudoClasses,
...restProps
} = props;

Expand All @@ -36,17 +37,17 @@ export const Button = (props: Props) => {
alignItems: "center",
backgroundColor: mainColor,
cursor: "pointer",
":hover": props.transparent
":hover": noPseudoClasses
? undefined
: {
backgroundColor: parsedColor.darken(0.1).toHex(),
},
":focus": props.transparent
":focus": noPseudoClasses
? undefined
: {
boxShadow: `0 0 0 0.2rem ${parsedColor.alpha(0.4).toHex()}`,
},
":active": props.transparent
":active": noPseudoClasses
? undefined
: {
backgroundColor: parsedColor.darken(0.1).toHex(),
Expand All @@ -69,17 +70,15 @@ export const Button = (props: Props) => {
}),
outline &&
css({
backgroundColor: props.transparent
? "rgba(0,0,0,0)"
: theme.bgColor,
backgroundColor: parsedColor.lighten(0.4).toHex(),
color: mainColor,
transform: "scale(0.98)",
outline: `1px solid ${mainColor}`,
":hover": props.transparent
":hover": noPseudoClasses
? undefined
: {
backgroundColor: parsedColor.darken(0.08).toHex(),
color: theme.bgColor,
backgroundColor: parsedColor
.lighten(0.4)
.darken(0.08)
.toHex(),
},
}),
className,
Expand Down
23 changes: 23 additions & 0 deletions src/ui/list-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { css } from "@emotion/css";
import { theme } from "./theme.tsx";
import React from "react";

export const ListHeader = (props: { text: string }) => {
return (
<h5
className={css({
fontWeight: 400,
margin: 0,
padding: 0,
paddingLeft: 12,
paddingTop: 4,
paddingBottom: 0,
marginBottom: 4,
color: theme.hintColor,
textTransform: "uppercase",
})}
>
{props.text}
</h5>
);
};
2 changes: 1 addition & 1 deletion src/ui/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ProgressBar = ({ value, max }: Props) => {
className={css({
width: "100%",
backgroundColor: theme.secondaryBgColor,
borderRadius: 8,
borderRadius: theme.borderRadius,
position: "relative",
overflow: "hidden",
})}
Expand Down
15 changes: 10 additions & 5 deletions src/ui/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ const cssVarToValue = (cssProperty: string) => {
const secondaryBgColor = "var(--tg-theme-secondary-bg-color)";
const buttonColor = "var(--tg-theme-button-color)";
const buttonTextColor = "var(--tg-theme-button-text-color)";
const bgColor = "var(--tg-theme-bg-color)";
const textColor = "var(--tg-theme-text-color)";
const hintColor = "var(--tg-theme-hint-color)";
const linkColor = "var(--tg-theme-link-color)";

export const theme = {
bgColor: "var(--tg-theme-bg-color)",
textColor: "var(--tg-theme-text-color)",
hintColor: "var(--tg-theme-hint-color)",
linkColor: "var(--tg-theme-link-color)",
bgColor,
textColor,
hintColor,
hintColorComputed: cssVarToValue(hintColor),
linkColor,
buttonColor,
buttonTextColor,
secondaryBgColor,
Expand All @@ -35,5 +40,5 @@ export const theme = {
danger: "#fc2025",
dangerLight: colord("#fc2025").alpha(0.4).toHex(),

borderRadius: 8,
borderRadius: 12,
};