From 01f6b2479a770a207b76219a2d64b4db731bfef2 Mon Sep 17 00:00:00 2001 From: G Date: Wed, 11 Sep 2024 10:41:48 +0000 Subject: [PATCH] decoupled the card variants stuffs. specific file to check and write all variants of a card without being distracted with other components definition --- src/themes/Theme.tsx | 44 ++------------------------------------------ src/themes/Variants.tsx | 7 ------- src/themes/variants/cardVariants.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 src/themes/variants/cardVariants.ts diff --git a/src/themes/Theme.tsx b/src/themes/Theme.tsx index ca10c70..017245a 100644 --- a/src/themes/Theme.tsx +++ b/src/themes/Theme.tsx @@ -1,5 +1,5 @@ import { createTheme } from "@shopify/restyle"; -import { Dimensions } from "react-native"; +import { cardVariants } from "./variants/cardVariants"; const palette = { purpleLight: "#8C6FF7", @@ -106,47 +106,7 @@ const theme = createTheme({ color: "softYellow", }, }, - cardVariants: { - defaults: { - // We can define defaults for the variant here. - // This will be applied after the defaults passed to createVariant and before the variant defined below. - }, - regular: { - // We can refer to other values in the theme here, and use responsive props - padding: { - phone: "s", - tablet: "m", - }, - }, - elevated: { - padding: { - phone: "s", - tablet: "m", - }, - shadowColor: "black", - shadowOpacity: 0.5, - shadowOffset: { width: 10, height: 10 }, - shadowRadius: 10, - elevation: 5, - }, - modal: { - width: 300, - // height: 200, - backgroundColor: "white", - alignItems: "center", - justifyContent: "center", - alignSelf: "center", - top: Dimensions.get("window").height / 2 - 150, - position: "absolute", - zIndex: 10, - borderRadius: 15, - gap: "m", - shadowColor: "black", - shadowOffset: { width: 0, height: 0 }, - shadowOpacity: 0.5, - p: "m", - }, - }, + cardVariants, buttonVariants: { defaults: { // We can define defaults for the variant here. diff --git a/src/themes/Variants.tsx b/src/themes/Variants.tsx index a4d79ac..b91a959 100644 --- a/src/themes/Variants.tsx +++ b/src/themes/Variants.tsx @@ -3,13 +3,6 @@ import type { Theme } from "@themes/Theme"; export const cardVariants = createVariant({ themeKey: "cardVariants", - defaults: { - margin: { - phone: "s", - tablet: "m", - }, - backgroundColor: "white", - }, }); export const buttonVariants = createVariant({ diff --git a/src/themes/variants/cardVariants.ts b/src/themes/variants/cardVariants.ts new file mode 100644 index 0000000..98f49d0 --- /dev/null +++ b/src/themes/variants/cardVariants.ts @@ -0,0 +1,54 @@ +import { Dimensions } from "react-native"; + +export const cardVariants = { + defaults: { + // margin: { + // phone: "s", + // tablet: "m", + // }, + // backgroundColor: "red", + }, + regular: { + padding: { + phone: "s", + tablet: "m", + }, + }, + elevated: { + padding: { + phone: "s", + tablet: "m", + }, + shadowColor: "black", + shadowOpacity: 0.5, + shadowOffset: { width: 10, height: 10 }, + shadowRadius: 10, + elevation: 5, + }, + + modal: { + width: 300, + // height: 200, + backgroundColor: "white", + alignItems: "center", + justifyContent: "center", + alignSelf: "center", + top: Dimensions.get("window").height / 2 - 150, + position: "absolute", + zIndex: 10, + borderRadius: 15, + gap: "m", + shadowColor: "black", + shadowOffset: { width: 0, height: 0 }, + shadowOpacity: 0.5, + p: "m", + }, + curvedTopContainer: { + width: "100%", + height: Dimensions.get("window").height / 2, + backgroundColor: "white", + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + margin: 0, + }, +}; -- libgit2 0.27.1