-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
196 additions
and
89 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright Gemeente Amsterdam | ||
*/ | ||
|
||
/** | ||
* | ||
* @param fileType | ||
* @returns Human readable file size | ||
*/ | ||
export const formatFileSize = (fileSize: number, precision = 3) => { | ||
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] | ||
|
||
if (fileSize === 0) return '0 B' | ||
|
||
const exponent = Math.floor(Math.log10(fileSize) / 3) | ||
const size = (fileSize / Math.pow(1000, exponent)).toPrecision(precision) | ||
|
||
return `${size}${UNITS[exponent]}` | ||
} |
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,38 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright Gemeente Amsterdam | ||
*/ | ||
|
||
/** | ||
* | ||
* @param fileType | ||
* @returns Human readable file type | ||
*/ | ||
export const formatFileType = (fileType: string) => { | ||
switch (fileType) { | ||
case 'image/gif': | ||
return 'gif' | ||
case 'image/jpeg': | ||
return 'jpg' | ||
case 'image/png': | ||
return 'png' | ||
case 'text/plain': | ||
return 'txt' | ||
case 'application/pdf': | ||
return 'pdf' | ||
case 'application/msword': | ||
return 'Word' | ||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': | ||
return 'Word' | ||
case 'application/vnd.ms-excel': | ||
return 'Excel' | ||
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': | ||
return 'Excel' | ||
case 'application/vnd.ms-powerpoint': | ||
return 'PowerPoint' | ||
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': | ||
return 'PowerPoint' | ||
default: | ||
return fileType | ||
} | ||
} |
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 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright Gemeente Amsterdam | ||
*/ | ||
|
||
export * from './formatFileType' | ||
export * from './formatFileSize' | ||
export * from './useKeyboardFocus' |
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
15 changes: 14 additions & 1 deletion
15
proprietary/tokens/src/components/ams/file-list.tokens.json
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 |
---|---|---|
@@ -1,5 +1,18 @@ | ||
{ | ||
"ams": { | ||
"file-list": {} | ||
"file-list": { | ||
"gap": { "value": "{ams.space.md}" }, | ||
"padding-block": { "value": "{ams.space.md}" }, | ||
"file": { | ||
"font-family": { "value": "{ams.text.font-family}" }, | ||
"font-size": { "value": "{ams.text.level.6.font-size}" }, | ||
"font-weight": { "value": "{ams.text.font-weight.normal}" }, | ||
"gap": { "value": "{ams.space.sm}" }, | ||
"line-height": { "value": "{ams.text.level.6.line-height}" }, | ||
"details": { | ||
"color": { "value": "{ams.color.neutral-grey3}" } | ||
} | ||
} | ||
} | ||
} | ||
} |
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