-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from ashik-75/work
Mimetype 1.0
- Loading branch information
Showing
12 changed files
with
160 additions
and
15 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Table } from "antd"; | ||
import React from "react"; | ||
import { MIME_COLUMNS, MIME_DATA } from "./utils/constants"; | ||
|
||
const Mimetype: React.FC = () => { | ||
return ( | ||
<div> | ||
<Table | ||
columns={MIME_COLUMNS} | ||
dataSource={MIME_DATA} | ||
pagination={false} | ||
title={() => "Features"} | ||
bordered | ||
scroll={{ x: "calc(50%)" }} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Mimetype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { ColumnsType } from "antd/es/table"; | ||
import { MIME_TABLE_TYPE } from "./types"; | ||
|
||
// Define a function to render different MIME types | ||
const renderMIMEType = (value: string) => { | ||
if ( | ||
value.endsWith(".jpg") || | ||
value.endsWith(".jpeg") || | ||
value.endsWith(".png") || | ||
value.endsWith(".avif") | ||
) { | ||
return ( | ||
<div> | ||
<img | ||
style={{ | ||
width: "80px", | ||
height: "50px", | ||
objectFit: "contain", | ||
}} | ||
src={value} | ||
alt="" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (value.endsWith(".mp3")) { | ||
return ( | ||
<div> | ||
<audio src={value} controls></audio> | ||
</div> | ||
); | ||
} | ||
if (value.endsWith(".mp4")) { | ||
return ( | ||
<div> | ||
<video width={200} height={100} src={value} controls></video> | ||
</div> | ||
); | ||
} | ||
return <code>{value}</code>; | ||
}; | ||
|
||
// Define MIME_COLUMNS as a constant array of column configurations | ||
const MIME_COLUMNS: ColumnsType<MIME_TABLE_TYPE> = [ | ||
{ | ||
title: "Name", | ||
dataIndex: "name", | ||
key: "name", | ||
}, | ||
{ | ||
title: "Example", | ||
dataIndex: "example", | ||
key: "example", | ||
render: renderMIMEType, | ||
}, | ||
{ | ||
title: "Code", | ||
dataIndex: "code", | ||
key: "code", | ||
}, | ||
]; | ||
|
||
// Define MIME_DATA as a constant array of data | ||
const MIME_DATA: MIME_TABLE_TYPE[] = [ | ||
{ | ||
key: "1", | ||
name: ".json", | ||
example: `{"x": 1}`, | ||
code: "application/json", | ||
}, | ||
{ | ||
key: "2", | ||
name: ".jpeg or .jpg", | ||
example: `/mime/image.jpg`, | ||
code: "image/jpeg", | ||
}, | ||
{ | ||
key: "3", | ||
name: ".js", | ||
example: `let x = 10;`, | ||
code: "text/javascript", | ||
}, | ||
{ | ||
key: "4", | ||
name: ".mp3", | ||
example: `/mime/applause.mp3`, | ||
code: "audio/mpeg", | ||
}, | ||
{ | ||
key: "5", | ||
name: ".mp4", | ||
example: `/mime/video.mp4`, | ||
code: "video/mp4", | ||
}, | ||
{ | ||
key: "6", | ||
name: ".avif", | ||
example: `/mime/avif.avif`, | ||
code: "video/mp4", | ||
}, | ||
{ | ||
key: "7", | ||
name: ".mp4", | ||
example: `/mime/pdf.png`, | ||
code: "video/mp4", | ||
}, | ||
]; | ||
|
||
export { MIME_COLUMNS, MIME_DATA }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
interface MIME_TABLE_TYPE { | ||
key: string; | ||
name: string; | ||
example: string; | ||
code: string; | ||
} | ||
|
||
export type { MIME_TABLE_TYPE }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters