[refactor,#59][s]: move packages/portal => examples/catalog as per plan in #59.
What is currently packages/portal is example of a running portal and should move to examples (it will get replaced by an actual portal lib soon).
This commit is contained in:
15
examples/catalog/components/_shared/CustomLink.tsx
Normal file
15
examples/catalog/components/_shared/CustomLink.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
type LinkProps = {
|
||||
url: string;
|
||||
format: any;
|
||||
};
|
||||
|
||||
const CustomLink: React.FC<LinkProps> = ({ url, format }: LinkProps) => (
|
||||
<a
|
||||
href={url}
|
||||
className="bg-white hover:bg-gray-200 border text-black font-semibold py-2 px-4 rounded"
|
||||
>
|
||||
{format}
|
||||
</a>
|
||||
);
|
||||
|
||||
export default CustomLink;
|
||||
17
examples/catalog/components/_shared/Error.tsx
Normal file
17
examples/catalog/components/_shared/Error.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
const ErrorMessage: React.FC<{ message: any }> = ({ message }) => {
|
||||
return (
|
||||
<aside>
|
||||
{message}
|
||||
<style jsx>{`
|
||||
aside {
|
||||
padding: 1.5em;
|
||||
font-size: 14px;
|
||||
color: white;
|
||||
background-color: red;
|
||||
}
|
||||
`}</style>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorMessage;
|
||||
36
examples/catalog/components/_shared/Table.tsx
Normal file
36
examples/catalog/components/_shared/Table.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
interface TableProps {
|
||||
columns: Array<any>;
|
||||
data: Array<any>;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const Table: React.FC<TableProps> = ({ columns, data, className }) => {
|
||||
return (
|
||||
<table className={`table-auto w-full text-sm text-left my-6 ${className}`}>
|
||||
<thead>
|
||||
<tr>
|
||||
{columns.map(({ key, name }) => (
|
||||
<th key={key} className="px-4 py-2">
|
||||
{name}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map((item) => (
|
||||
<tr key={item.id}>
|
||||
{columns.map(({ key, render }) => (
|
||||
<td key={key} className="px-4 py-2">
|
||||
{(render && typeof render === 'function' && render(item)) ||
|
||||
item[key] ||
|
||||
''}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
5
examples/catalog/components/_shared/index.ts
Normal file
5
examples/catalog/components/_shared/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import Table from './Table';
|
||||
import ErrorMessage from './Error';
|
||||
import CustomLink from './CustomLink';
|
||||
|
||||
export { Table, ErrorMessage, CustomLink };
|
||||
Reference in New Issue
Block a user