Skip to content

Commit

Permalink
Init project with common components
Browse files Browse the repository at this point in the history
  • Loading branch information
saalihou committed Jan 3, 2024
0 parents commit 0950f03
Show file tree
Hide file tree
Showing 24 changed files with 5,310 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pipeline

on:
push:
branches: ['main']

jobs:
build-and-publish:
name: Build & Publish
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions lib/components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// material UI empty state
import React from 'react';
import { NoTransfer } from "@mui/icons-material";
import { Box, Typography } from "@mui/material";

type EmptyStateProps = {
title?: string;
description?: string;
};

const EmptyState = ({ title, description }: EmptyStateProps) => {
return (
<Box sx={{ width: "100%", textAlign: "center" }}>
<NoTransfer fontSize="large" color="disabled" />
<Typography variant="h6" gutterBottom color="grey">
{title || "Aucun résultat trouvé"}
</Typography>
<Typography variant="subtitle1" gutterBottom color="grey">
{description || ""}
</Typography>
</Box>
);
};

export default EmptyState;
3 changes: 3 additions & 0 deletions lib/components/EmptyState/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import EmptyState from "./EmptyState";

export default EmptyState;
11 changes: 11 additions & 0 deletions lib/components/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import ErrorMessage from "../ErrorMessage";

export default function ErrorBoundary({ error }: { error: Error }) {
return (
<ErrorMessage
error={error}
message="Une erreur est survenue. Veuillez contacter le support."
/>
);
}
7 changes: 7 additions & 0 deletions lib/components/ErrorBoundary/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useRouteError } from "react-router-dom";
import ErrorBoundary from "./ErrorBoundary";

export default function ErrorBoundaryContainer() {
const error = useRouteError();
return <ErrorBoundary error={error as Error} />;
}
20 changes: 20 additions & 0 deletions lib/components/ErrorMessage/ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Alert, Typography } from "@mui/material";

type ErrorMessageProps = {
error: Error | null;
message?: string;
};

const ErrorMessage = ({ error, message }: ErrorMessageProps) => {
return error ? (
<Alert severity="error">
{message || "Une erreur est survenue. Veuillez réessayer"}
<br />
<Typography variant="caption">
Code d'erreur: {error.message || "Erreur inconnue"}
</Typography>
</Alert>
) : null;
};

export default ErrorMessage;
3 changes: 3 additions & 0 deletions lib/components/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ErrorMessage from "./ErrorMessage";

export default ErrorMessage;
12 changes: 12 additions & 0 deletions lib/components/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

export default function ScrollToTop() {
const { pathname } = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

return null;
}
6 changes: 6 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import EmptyState from "./components/EmptyState/EmptyState";
import ErrorBoundary from "./components/ErrorBoundary/ErrorBoundary";
import ErrorMessage from "./components/ErrorMessage";
import ScrollToTop from "./components/ScrollToTop";

export { ScrollToTop, EmptyState, ErrorBoundary, ErrorMessage };
Loading

0 comments on commit 0950f03

Please sign in to comment.