From efa87a249b2e58d05a444ce66e1b4a7d7604bf12 Mon Sep 17 00:00:00 2001 From: Erik Figueiredo Date: Thu, 12 Sep 2024 10:04:43 -0300 Subject: [PATCH] feat: responsividade --- src/components/Typography/index.tsx | 7 ++++++- src/components/card/card-status.tsx | 4 ++-- src/components/data-table/data-table.tsx | 2 +- src/components/form/toggle/index.tsx | 2 +- src/layouts/default/default.layout.tsx | 20 ++++++++++++-------- src/pages/forms.tsx | 6 +++--- src/pages/home.tsx | 18 ++++++++++-------- 7 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/components/Typography/index.tsx b/src/components/Typography/index.tsx index 40d4062..a2ac185 100644 --- a/src/components/Typography/index.tsx +++ b/src/components/Typography/index.tsx @@ -3,9 +3,10 @@ import { createElement, HTMLAttributes, ReactNode } from 'react' export type TypographyProps = { type?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'display' | undefined, children: ReactNode, + ellipsis?: boolean } & HTMLAttributes -export const Typography = ({ children, type = 'p', ...props }: TypographyProps) => { +export const Typography = ({ children, type = 'p', ellipsis, ...props }: TypographyProps) => { let localType: string = type const typeClasses = { @@ -26,6 +27,10 @@ export const Typography = ({ children, type = 'p', ...props }: TypographyProps) className.push(props.className) } + if (ellipsis) { + className.push('text-nowrap text-ellipsis overflow-hidden') + } + if (type === 'display') { localType = 'div' } diff --git a/src/components/card/card-status.tsx b/src/components/card/card-status.tsx index 014b0c3..37b924f 100644 --- a/src/components/card/card-status.tsx +++ b/src/components/card/card-status.tsx @@ -15,12 +15,12 @@ const icons = { } export const CardStatus = ({ title, message, status }: CardStatusProps) => ( - +
{title} {message}
-
+
{icons[status]}
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx index 467c2b7..aa597f1 100644 --- a/src/components/data-table/data-table.tsx +++ b/src/components/data-table/data-table.tsx @@ -6,7 +6,7 @@ import { Typography } from '../Typography' type DataTableProps = { title?: string } & TableProps & PaginationProps export const DataTable = ({ title, columns, rows, perPage, current, total, onChange, isLoading }: DataTableProps) => ( - + {title && {title} } diff --git a/src/components/form/toggle/index.tsx b/src/components/form/toggle/index.tsx index b778de3..04273e6 100644 --- a/src/components/form/toggle/index.tsx +++ b/src/components/form/toggle/index.tsx @@ -9,7 +9,7 @@ type ToggleProps = { export const Toggle = ({ checked, onClick, children }: ToggleProps) => ( ) diff --git a/src/layouts/default/default.layout.tsx b/src/layouts/default/default.layout.tsx index 2245a0e..096b48f 100644 --- a/src/layouts/default/default.layout.tsx +++ b/src/layouts/default/default.layout.tsx @@ -1,4 +1,4 @@ -import { useCallback } from 'react' +import { useCallback, useState } from 'react' import { Rounded } from '../../components/rounded' import { useDarkMode } from '../../contexts/dark-mode' import './style.css' @@ -14,6 +14,7 @@ type DefaultLayoutProps = { } export const DefaultLayout = ({ title }: DefaultLayoutProps) => { + const [isMenuOpen, setIsMenuOpen] = useState(false) const { isDarkMode, toggleDarkMode } = useDarkMode() const menuItems = RoutesConfig @@ -39,16 +40,16 @@ export const DefaultLayout = ({ title }: DefaultLayoutProps) => { const darkModeHandler = useCallback(() => { toggleDarkMode() - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, [isDarkMode]) return (
-
-
+
+
-
+
setIsMenuOpen(!isMenuOpen)}> close
@@ -90,14 +91,17 @@ export const DefaultLayout = ({ title }: DefaultLayoutProps) => {
-
- +
+ +
setIsMenuOpen(true)}> + menu +
{title}
- {isDarkMode ? 'brightness_4' : 'brightness_7'} Dark Mode + {isDarkMode ? 'brightness_4' : 'brightness_7'} Dark Mode diff --git a/src/pages/forms.tsx b/src/pages/forms.tsx index e812c90..5229511 100644 --- a/src/pages/forms.tsx +++ b/src/pages/forms.tsx @@ -49,7 +49,7 @@ export const Forms = () => { />
-
+
{ />
-
+
{ error /> -
+
{ return ( <> -
+
Likes (30 days) @@ -68,29 +68,31 @@ export const Home = () => {
-
+
-
- +
+ Radial Chart - +
+ +
- + Column Chart
-
+
setPage(p)} /> - + Erik Figueiredo Desenvolvedor FullStack SĂȘnior com mais de 15 anos de experiĂȘncia, especializado em Node.js, TypeScript e PHP.