From 1c6e7611692c8618d27502c5fdc592802b39ccc3 Mon Sep 17 00:00:00 2001 From: G Date: Wed, 11 Sep 2024 10:51:39 +0000 Subject: [PATCH] decoupled button variants too. we do not have quick type check for properties now but visually it is worth it. --- src/themes/Theme.tsx | 36 ++---------------------------------- src/themes/Variants.tsx | 10 ---------- src/themes/variants/buttonVariants.ts | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 src/themes/variants/buttonVariants.ts diff --git a/src/themes/Theme.tsx b/src/themes/Theme.tsx index 017245a..ccf6f12 100644 --- a/src/themes/Theme.tsx +++ b/src/themes/Theme.tsx @@ -1,4 +1,5 @@ import { createTheme } from "@shopify/restyle"; +import { buttonVariants } from "./variants/buttonVariants"; import { cardVariants } from "./variants/cardVariants"; const palette = { @@ -107,40 +108,7 @@ const theme = createTheme({ }, }, cardVariants, - buttonVariants: { - defaults: { - // We can define defaults for the variant here. - }, - noMargin: { - margin: { - phone: undefined, - tablet: undefined, - }, - }, - full: { - backgroundColor: "secondary", - color: "white", - }, - danger: { - backgroundColor: "softRed", - }, - fullError: { - backgroundColor: "softRed", - color: "white", - }, - fullInformation: { - backgroundColor: "softYellow", - color: "white", - }, - clean: { - backgroundColor: "primary", - color: "secondary", - }, - lightGray: { - backgroundColor: "lightGray", - color: "black", - }, - }, + buttonVariants, }); export type Theme = typeof theme; diff --git a/src/themes/Variants.tsx b/src/themes/Variants.tsx index b91a959..c43835f 100644 --- a/src/themes/Variants.tsx +++ b/src/themes/Variants.tsx @@ -7,16 +7,6 @@ export const cardVariants = createVariant({ export const buttonVariants = createVariant({ themeKey: "buttonVariants", - defaults: { - backgroundColor: "primary", - color: "secondary", - height: 50, - borderRadius: 10, - margin: { - phone: "s", - tablet: "m", - }, - }, }); export const textVariants = createVariant({ diff --git a/src/themes/variants/buttonVariants.ts b/src/themes/variants/buttonVariants.ts new file mode 100644 index 0000000..b09621b --- /dev/null +++ b/src/themes/variants/buttonVariants.ts @@ -0,0 +1,70 @@ +export const buttonVariants = { + defaults: { + // We can define defaults for the variant here. + }, + noMargin: { + margin: { + phone: undefined, + tablet: undefined, + }, + }, + full: { + backgroundColor: "secondary", + color: "white", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, + danger: { + backgroundColor: "softRed", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, + fullError: { + backgroundColor: "softRed", + color: "white", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, + fullInformation: { + backgroundColor: "softYellow", + color: "white", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, + clean: { + backgroundColor: "primary", + color: "secondary", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, + lightGray: { + backgroundColor: "lightGray", + color: "black", + height: 50, + borderRadius: 10, + margin: { + phone: "s", + tablet: "m", + }, + }, +}; -- libgit2 0.27.1