From c954adf8b4cddc30db13202319bb09c368b4b0b5 Mon Sep 17 00:00:00 2001 From: Ana Garcia Date: Fri, 7 Jun 2024 20:30:38 +0200 Subject: [PATCH] Delete default examples --- src/webapp/components/card-grid/CardGrid.tsx | 50 ------------ src/webapp/components/card-grid/MenuCard.tsx | 76 ------------------- .../components/page-header/PageHeader.tsx | 72 ------------------ src/webapp/pages/example/ExamplePage.tsx | 30 -------- .../example/__tests__/ExamplePage.spec.tsx | 15 ---- .../__snapshots__/ExamplePage.spec.tsx.snap | 40 ---------- 6 files changed, 283 deletions(-) delete mode 100644 src/webapp/components/card-grid/CardGrid.tsx delete mode 100644 src/webapp/components/card-grid/MenuCard.tsx delete mode 100644 src/webapp/components/page-header/PageHeader.tsx delete mode 100644 src/webapp/pages/example/ExamplePage.tsx delete mode 100644 src/webapp/pages/example/__tests__/ExamplePage.spec.tsx delete mode 100644 src/webapp/pages/example/__tests__/__snapshots__/ExamplePage.spec.tsx.snap diff --git a/src/webapp/components/card-grid/CardGrid.tsx b/src/webapp/components/card-grid/CardGrid.tsx deleted file mode 100644 index 13656ae0..00000000 --- a/src/webapp/components/card-grid/CardGrid.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; -import styled from "styled-components"; -import { PageHeader } from "../page-header/PageHeader"; -import { MenuCard, MenuCardProps } from "./MenuCard"; - -export const CardGrid: React.FC = React.memo(({ title, cards, onBackClick }) => { - return ( - - {!!title && } - - - {cards.map(({ key, title, children }) => ( -
- {!!title && {title}} - - {children.map(props => ( - - ))} -
- ))} -
-
- ); -}); - -export interface CardGridProps { - cards: Card[]; - title?: string; - onBackClick?: () => void; -} - -export interface Card { - title?: string; - key: string; - children: MenuCardProps[]; -} - -const Container = styled.div` - margin-left: 30px; - display: flex; - flex-direction: column; -`; - -const Title = styled.h1` - font-size: 24px; - font-weight: 300; - color: rgba(0, 0, 0, 0.87); - padding: 15px 0px 15px; - margin: 0; -`; diff --git a/src/webapp/components/card-grid/MenuCard.tsx b/src/webapp/components/card-grid/MenuCard.tsx deleted file mode 100644 index 7221e846..00000000 --- a/src/webapp/components/card-grid/MenuCard.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { - Card as MUICard, - CardActions as MUICardActions, - CardContent as MUICardContent, - CardHeader as MUICardHeader, - IconButton, - Tooltip, -} from "@material-ui/core"; -import AddIcon from "@material-ui/icons/Add"; -import ViewListIcon from "@material-ui/icons/ViewList"; -import React from "react"; -import styled from "styled-components"; -import i18n from "../../../utils/i18n"; - -export const MenuCard: React.FC = React.memo( - ({ name, description, addAction, listAction = () => {} }) => { - return ( - -
- - {description} - - - {addAction && ( - - - - - - )} - - {listAction && ( - - - - - - )} - - - ); - } -); - -export interface MenuCardProps { - name: string; - description?: string; - addAction?: () => void; - listAction?: () => void; -} - -const Card = styled(MUICard)` - padding: 0; - margin: 0.5rem; - float: left; - width: 230px; -`; - -const Content = styled(MUICardContent)` - height: 120px; - padding: 0.5rem 1rem; - font-size: 14px; -`; - -const Actions = styled(MUICardActions)` - margin-left: auto; -`; - -const Header = styled(MUICardHeader)` - padding: 1rem; - height: auto; - border-bottom: 1px solid #ddd; - cursor: pointer; - font-size: 15px; - font-weight: 500; -`; diff --git a/src/webapp/components/page-header/PageHeader.tsx b/src/webapp/components/page-header/PageHeader.tsx deleted file mode 100644 index ef8de55f..00000000 --- a/src/webapp/components/page-header/PageHeader.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { ButtonProps, Icon, IconButton as MUIIConButton, Tooltip } from "@material-ui/core"; -import { Variant } from "@material-ui/core/styles/createTypography"; -import Typography from "@material-ui/core/Typography"; -import { DialogButton } from "@eyeseetea/d2-ui-components"; -import React, { PropsWithChildren } from "react"; -import styled from "styled-components"; -import i18n from "../../../utils/i18n"; - -export const PageHeader: React.FC = React.memo(props => { - const { variant = "h5", title, onBackClick, helpText, children } = props; - return ( -
- {!!onBackClick && ( - - arrow_back - - )} - - - {title} - - - {helpText && } - - {children} -
- ); -}); - -export interface PageHeaderProps extends PropsWithChildren { - variant?: Variant; - title: string; - onBackClick?: () => void; - helpText?: string; -} - -const Title = styled(Typography)` - display: inline-block; - font-weight: 300; -`; - -const Button: React.FC = ({ onClick }) => ( - - - help - - -); - -const HelpButton: React.FC<{ text: string }> = ({ text }) => ( - -); - -const IconButton = styled(MUIIConButton)` - margin-bottom: 8px; -`; - -const BackButton = styled(IconButton)` - padding-top: 10px; - margin-bottom: 5px; -`; diff --git a/src/webapp/pages/example/ExamplePage.tsx b/src/webapp/pages/example/ExamplePage.tsx deleted file mode 100644 index 56e86e65..00000000 --- a/src/webapp/pages/example/ExamplePage.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import { useHistory } from "react-router-dom"; -import styled from "styled-components"; -import i18n from "../../../utils/i18n"; -import { PageHeader } from "../../components/page-header/PageHeader"; - -export const ExamplePage: React.FC = React.memo(props => { - const { name } = props; - const title = i18n.t("Hello {{name}}", { name }); - const history = useHistory(); - - const goBack = React.useCallback(() => { - history.goBack(); - }, [history]); - - return ( - - - {title} - - ); -}); - -const Title = styled.h2` - color: blue; -`; - -interface ExamplePageProps { - name: string; -} diff --git a/src/webapp/pages/example/__tests__/ExamplePage.spec.tsx b/src/webapp/pages/example/__tests__/ExamplePage.spec.tsx deleted file mode 100644 index 983c3ac5..00000000 --- a/src/webapp/pages/example/__tests__/ExamplePage.spec.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { getReactComponent } from "../../../../utils/tests"; -import { ExamplePage } from "../../example/ExamplePage"; - -describe("ExamplePage", () => { - it("renders the feedback component", async () => { - const view = getView(); - - expect(await view.findByText("Hello Mary")).toBeInTheDocument(); - expect(view.asFragment()).toMatchSnapshot(); - }); -}); - -function getView() { - return getReactComponent(); -} diff --git a/src/webapp/pages/example/__tests__/__snapshots__/ExamplePage.spec.tsx.snap b/src/webapp/pages/example/__tests__/__snapshots__/ExamplePage.spec.tsx.snap deleted file mode 100644 index cb916185..00000000 --- a/src/webapp/pages/example/__tests__/__snapshots__/ExamplePage.spec.tsx.snap +++ /dev/null @@ -1,40 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`ExamplePage > renders the feedback component 1`] = ` - -
- -
- Detail page -
-
-

- Hello Mary -

-
-`;