From 5df44ceddc1f2c68ee2ac02ddadb3d89be666088 Mon Sep 17 00:00:00 2001 From: Daniel Soares Date: Wed, 15 Dec 2021 08:11:58 -0300 Subject: [PATCH] fix: some details --- .eslintrc.json | 3 +- prisma/seed.ts | 11 +- src/components/Button/index.tsx | 3 +- src/components/Button/styles.ts | 15 ++- .../Dash/ButtonsStyleSelect/index.tsx | 25 +++++ src/components/Dash/ColorSelect/index.tsx | 8 +- src/components/Dash/ColorSelect/styles.ts | 3 +- src/components/Dash/ColorsSettings/index.tsx | 19 ++++ src/components/Dash/DataSettings/index.tsx | 17 +++ .../Dash/DescriptionInput/index.tsx | 2 +- src/components/Dash/FontsSelect/index.tsx | 25 +++++ src/components/Dash/OutlineCheckbox/index.tsx | 21 ++++ .../Dash/SaveChangesAlert/index.tsx | 62 +++++++++++ .../Dash/SaveChangesAlert/styles.ts | 38 +++++++ src/components/Dash/index.tsx | 100 ++++-------------- src/components/Dash/styles.ts | 16 +-- src/components/Home/index.tsx | 14 ++- src/pages/api/data.ts | 41 ++++--- src/services/fetchData.ts | 10 +- src/styles/globals.ts | 5 +- src/styles/stitches.config.ts | 8 ++ src/types/Data.ts | 2 +- 22 files changed, 330 insertions(+), 118 deletions(-) create mode 100644 src/components/Dash/ButtonsStyleSelect/index.tsx create mode 100644 src/components/Dash/ColorsSettings/index.tsx create mode 100644 src/components/Dash/DataSettings/index.tsx create mode 100644 src/components/Dash/FontsSelect/index.tsx create mode 100644 src/components/Dash/OutlineCheckbox/index.tsx create mode 100644 src/components/Dash/SaveChangesAlert/index.tsx create mode 100644 src/components/Dash/SaveChangesAlert/styles.ts diff --git a/.eslintrc.json b/.eslintrc.json index dd1b004..d77ee0f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,6 +4,7 @@ "rules": { "prettier/prettier": "error", "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error" + "simple-import-sort/exports": "error", + "no-unused-vars": "error" } } diff --git a/prisma/seed.ts b/prisma/seed.ts index 888956f..3c2134a 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -61,13 +61,20 @@ async function main() { ] } - const hasData = await prisma.data.findFirst() + const hasData = await prisma.data.findUnique({ + where: { + id: 1 + } + }) if (!hasData) { console.log(`Start seeding...`) await prisma.data.create({ - data: { data: JSON.stringify(data) } + data: { + id: 1, + data: JSON.stringify(data) + } }) } } diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index 14df8d9..cc18572 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -7,8 +7,9 @@ type ButtonProps = ButtonHTMLAttributes & { children: ReactNode colorSchema?: ButtonVariantProps['colorSchema'] styleSchema?: ButtonVariantProps['styleSchema'] + size?: ButtonVariantProps['size'] font?: ButtonVariantProps['font'] - outline?: ButtonVariantProps['outline'] + outline?: boolean } export function Button({ children, ...rest }: ButtonProps) { diff --git a/src/components/Button/styles.ts b/src/components/Button/styles.ts index a76fdea..3bb751d 100644 --- a/src/components/Button/styles.ts +++ b/src/components/Button/styles.ts @@ -38,10 +38,9 @@ export const Wrapper = styled('button', { alignItems: 'center', justifyContent: 'center', width: '100%', - height: '3rem', + padding: '0 1rem', borderWidth: '2.5px', borderStyle: 'solid', - fontSize: '1rem', fontWeight: 500, cursor: 'pointer', transition: 'all 0.25s ease-in-out', @@ -84,6 +83,17 @@ export const Wrapper = styled('button', { } }, + size: { + small: { + height: '2rem', + fontSize: '0.875rem' + }, + medium: { + height: '3rem', + fontSize: '1rem' + } + }, + font: { baloo: { fontFamily: theme.fonts.baloo @@ -199,6 +209,7 @@ export const Wrapper = styled('button', { defaultVariants: { colorSchema: 'teal', styleSchema: 'pill', + size: 'medium', font: 'roboto', outline: false } diff --git a/src/components/Dash/ButtonsStyleSelect/index.tsx b/src/components/Dash/ButtonsStyleSelect/index.tsx new file mode 100644 index 0000000..81c89e8 --- /dev/null +++ b/src/components/Dash/ButtonsStyleSelect/index.tsx @@ -0,0 +1,25 @@ +import { useData } from '../../../hooks/useData' +import type { ButtonVariantProps } from '../../Button' + +export function ButtonsStyleSelect() { + const { data, setData } = useData() + + return ( + + ) +} diff --git a/src/components/Dash/ColorSelect/index.tsx b/src/components/Dash/ColorSelect/index.tsx index ad1fca1..8a9f055 100644 --- a/src/components/Dash/ColorSelect/index.tsx +++ b/src/components/Dash/ColorSelect/index.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { useData } from '../../../hooks/useData' import type { Colors } from '../../../styles/stitches.config' @@ -11,7 +11,11 @@ type ColorSelectProps = { export function ColorSelect({ prop }: ColorSelectProps) { const { data, setData } = useData() - const [activeColor, setActiveColor] = useState(data.settings.colors[prop] as string) + const [activeColor, setActiveColor] = useState(data.settings.colors[prop] as string) + + useEffect(() => { + setActiveColor(data.settings.colors[prop] as string) + }, [data, prop]) const allColors = Object.keys(theme.colors) as Colors[] const colorsSchema = [ diff --git a/src/components/Dash/ColorSelect/styles.ts b/src/components/Dash/ColorSelect/styles.ts index b0e0d8d..ea518ee 100644 --- a/src/components/Dash/ColorSelect/styles.ts +++ b/src/components/Dash/ColorSelect/styles.ts @@ -10,10 +10,11 @@ export const SelectButton = styled('button', { width: '100%', height: '3rem', padding: '0.25rem', - borderRadius: '0.25rem', + borderRadius: '0.2rem', borderWidth: '3px', borderStyle: 'solid', borderColor: theme.colors.slate200, + background: 'transparent', cursor: 'pointer', variants: { diff --git a/src/components/Dash/ColorsSettings/index.tsx b/src/components/Dash/ColorsSettings/index.tsx new file mode 100644 index 0000000..3d4d80a --- /dev/null +++ b/src/components/Dash/ColorsSettings/index.tsx @@ -0,0 +1,19 @@ +import { ColorSelect } from '../ColorSelect' + +export function ColorsSettings() { + return ( +
+

Texts

+ + +

Icons

+ + +

Buttons

+ + +

Background

+ +
+ ) +} diff --git a/src/components/Dash/DataSettings/index.tsx b/src/components/Dash/DataSettings/index.tsx new file mode 100644 index 0000000..41cabbc --- /dev/null +++ b/src/components/Dash/DataSettings/index.tsx @@ -0,0 +1,17 @@ +import { ButtonsStyleSelect } from '../ButtonsStyleSelect' +import { DescriptionInput } from '../DescriptionInput' +import { FontsSelect } from '../FontsSelect' +import { NameInput } from '../NameInput' +import { OutlineCheckbox } from '../OutlineCheckbox' + +export function DataSettings() { + return ( +
+ + + + + +
+ ) +} diff --git a/src/components/Dash/DescriptionInput/index.tsx b/src/components/Dash/DescriptionInput/index.tsx index bc07bf2..fe0a083 100644 --- a/src/components/Dash/DescriptionInput/index.tsx +++ b/src/components/Dash/DescriptionInput/index.tsx @@ -5,7 +5,7 @@ export function DescriptionInput() { return (