Skip to content

Commit

Permalink
refactor: folder stracture (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js authored Oct 27, 2023
1 parent cd0311d commit b3b4c74
Show file tree
Hide file tree
Showing 29 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-bun.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Linting
name: Code Linting with Bun

on: push

Expand Down
10 changes: 0 additions & 10 deletions app/Loading.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getManufacturers } from './api'
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Loader from '@/components/loader'

export default function Loading() {
// Or a custom loading skeleton component
return <Loader />
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/page.tsx → src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { useEffect, useState } from 'react';

import Table from '@/components/table';
import { getManufacturers } from './api';
import { getManufacturers } from '@/api/index';

import styles from '@/components/layout/grid.module.css';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions src/components/loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import loader from './loader.module.css';

const Loader = () => (
<>
<div className={loader['loading-icon_animated']} />
<h3>Loading...</h3>
</>
);

export default Loader;
1 change: 1 addition & 0 deletions src/components/loader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Loader';
2 changes: 2 additions & 0 deletions app/Loading.css → src/components/loader/loader.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
transform: rotate(220deg);
}
}

.loading-icon_animated:after {
animation: animate2 1.5s ease-in-out infinite;
clip: rect(0, 80px, 80px, 40px);
Expand All @@ -25,6 +26,7 @@
height: 80px;
content: '';
}

@keyframes animate2 {
0% {
transform: rotate(-140deg);
Expand Down
24 changes: 12 additions & 12 deletions app/components/Table/Table.tsx → src/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getFlagByCountryName } from '@/helpers/getEmojiFlagByISO';
// import { toLamaCase } from './toLamaCase';

import '@/helpers/helpers.css';
import styles from './table.module.css';
import table from './table.module.css';

interface TableProps {
manufacturers: Array<any> | null;
Expand All @@ -17,34 +17,34 @@ const Table = ({ manufacturers }: TableProps) => {
const router = useRouter();

return (
<table className={styles.table}>
<table className={table.default}>
<thead>
<tr>
<td className={[styles.heading, 'txt-right'].join(' ')}>ID</td>
<td className={[styles.heading, 'txt-right'].join(' ')}>
<td className={[table.heading, 'txt-right'].join(' ')}>ID</td>
<td className={[table.heading, 'txt-right'].join(' ')}>
Common name
</td>
<td className={styles.heading}>Country</td>
<td className={styles.heading} />
<td className={table.heading}>Country</td>
<td className={table.heading} />
</tr>
</thead>
<tbody>
{manufacturers?.map(
({ Mfr_ID: Id, Country, Mfr_CommonName: Name, Mfr_Name }) => (
<tr key={Id} className={styles.row}>
<tr key={Id} className={table.row}>
<td
className={[
styles.cell,
table.cell,
'txt-right',
styles['table-cell_secondary'],
table['cell_secondary'],
].join(' ')}
>
{Id}
</td>
<td className={[styles.cell, 'txt-left'].join(' ')}>
<td className={[table.cell, 'txt-left'].join(' ')}>
{Name ? Name : Mfr_Name}
</td>
<td className={styles.cell}>
<td className={table.cell}>
{Country} {getFlagByCountryName(Country)}
</td>
<td>
Expand All @@ -54,7 +54,7 @@ const Table = ({ manufacturers }: TableProps) => {
router.push(`/manufacturers/${Id}`);
}}
href={`/manufacturers/${Id}`}
className={styles['table-cell__link']}
className={table['cell__link']}
>
<ArrowTopRightOnSquareIcon width={18} height={18} />
</a>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.table {
.default {
margin-bottom: 20px;
border-collapse: collapse;
border-spacing: 0;
Expand All @@ -21,10 +21,10 @@
padding: 1px 8px 1px 1px;
}

.table-cell_secondary {
.cell_secondary {
color: #5c5c5c;
}

.table-cell__link {
.cell__link {
color: #373737;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 5 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
{ "name": "typescript-plugin-css-modules" }
],
"paths": {
"@/components/*": ["./app/components/*"],
"@/helpers/*": ["./app/helpers/*"]
"@/components/*": ["./src/components/*"],
"@/helpers/*": ["./src/helpers/*"],
"@/api/*": ["./src/api/*"],
}
},
"include": [
"app/page.tsx",
"app/manufacturers/[id]/page.tsx",
"app/components",
"app/helpers",
"app/api.ts",
"app/**/*.tsx",
"./src/**/*.ts",
"./src/**/*.tsx",
".next/types/**/*.ts"
],
"references": [
Expand Down

0 comments on commit b3b4c74

Please sign in to comment.