From 2760451dafa9f626b15f1b0e5cce22fa7df1e66e Mon Sep 17 00:00:00 2001
From: Rangga Fajar Oktariansyah <86386385+FajarKim@users.noreply.github.com>
Date: Thu, 26 Oct 2023 19:37:17 +0700
Subject: [PATCH] change: update card style if disabled_animations is true
(#47)
---
src/card.ts | 331 ++++++++++++++++++++--------------------------------
1 file changed, 127 insertions(+), 204 deletions(-)
diff --git a/src/card.ts b/src/card.ts
index ac05e37..4b57f7d 100644
--- a/src/card.ts
+++ b/src/card.ts
@@ -2,28 +2,30 @@ import type { GetData } from "./getData";
import type { UiConfig } from "../api/index";
import { locales, Locales } from "./translations";
+type CardsUi = {
+ direction?: string;
+ titleXAngle?: number | string;
+ titleYAngle?: number | string;
+ textXAngle?: number | string;
+ textYAngle?: number | string;
+ dataXAngle?: number | string;
+ dataYAngle?: number | string;
+ iconXAngle?: number | string;
+ iconYAngle?: number | string;
+ imageXAngle?: number | string;
+ imageYAngle?: number | string;
+ userXAngle?: number | string;
+ userYAngle?: number | string;
+ follXAngle?: number | string;
+ follYAngle?: number | string;
+};
+
export default function cardStyle(data: GetData, uiConfig: UiConfig): string {
let fallbackLocale = "en";
const defaultLocale: Locales[keyof Locales] = locales[fallbackLocale];
const selectLocale: Locales[keyof Locales] = locales[uiConfig.Locale] || defaultLocale;
- var direction = "ltr",
- titleXAngle = "5",
- iconXAngle = "0",
- textXAngle = "25",
- dataXAngle = "225";
-
- if (selectLocale.rtlDirection == "true" || selectLocale.rtlDirection == true || selectLocale.rtlDirection) {
- var direction = "rtl",
- titleXAngle = "510",
- iconXAngle = "225",
- textXAngle = "215",
- dataXAngle = "15";
- };
-
- var cardAnimations = ``;
+ var cardsUi: CardsUi = {
+ direction: "ltr",
+ titleXAngle: 5,
+ titleYAngle: -10,
+ textXAngle: 25,
+ textYAngle: 12.5,
+ dataXAngle: 225,
+ dataYAngle: 12.5,
+ iconXAngle: 0,
+ iconYAngle: 0,
+ imageXAngle: 125,
+ imageYAngle: 65,
+ userXAngle: 109.9,
+ userYAngle: 130,
+ follXAngle: 110,
+ follYAngle: 151,
+ };
- var titleXAngle = "15";
- if (selectLocale.rtlDirection == "true" || selectLocale.rtlDirection == true || selectLocale.rtlDirection) {
- var titleXAngle = "520";
+ if (selectLocale.rtlDirection == "true" || selectLocale.rtlDirection) {
+ var cardsUi: CardsUi = {
+ direction: "rtl",
+ titleXAngle: 510,
+ titleYAngle: -10,
+ textXAngle: 215,
+ textYAngle: 12.5,
+ dataXAngle: 15,
+ dataYAngle: 12.5,
+ iconXAngle: 225,
+ iconYAngle: 0,
+ imageXAngle: 125,
+ imageYAngle: 65,
+ userXAngle: 109.9,
+ userYAngle: 130,
+ follXAngle: 110,
+ follYAngle: 151,
+ };
+ };
+
+ if (uiConfig.disabledAnimations == "true" || uiConfig.disabledAnimations) {
+ var animations = "";
+ var cardsUi: CardsUi = {
+ direction: "ltr",
+ titleXAngle: 15,
+ titleYAngle: 0,
+ textXAngle: 25,
+ textYAngle: 12.5,
+ dataXAngle: 225,
+ dataYAngle: 12.5,
+ iconXAngle: 0,
+ iconYAngle: 0,
+ imageXAngle: 120,
+ imageYAngle: 70,
+ userXAngle: 119.9,
+ userYAngle: 140,
+ follXAngle: 120,
+ follYAngle: 161,
+ };
+
+ if (selectLocale.rtlDirection == "true" || selectLocale.rtlDirection) {
+ var cardsUi: CardsUi = {
+ direction: "rtl",
+ titleXAngle: 520,
+ titleYAngle: 0,
+ textXAngle: 215,
+ textYAngle: 12.5,
+ dataXAngle: 15,
+ dataYAngle: 12.5,
+ iconXAngle: 225,
+ iconYAngle: 0,
+ imageXAngle: 120,
+ imageYAngle: 70,
+ userXAngle: 119.9,
+ userYAngle: 140,
+ follXAngle: 120,
+ follYAngle: 161,
+ };
+ };
};
- var cardAnimationsDisabled = `
+ var card = `