-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs in resolving icon and color for file extension (#10059)
- Loading branch information
1 parent
cfa3bad
commit 7d85a4d
Showing
9 changed files
with
250 additions
and
669 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bugfix: Icon extension mapping | ||
|
||
We have simplified the mapping between file extensions and their display in the web UI (icon and its color). | ||
Now, further formats/extensions (`.tar.gz`,`.tar.xz`,`.bz2`, ...) get displayed correctly. | ||
|
||
https://github.com/owncloud/web/issues/10031 | ||
https://github.com/owncloud/web/pull/10059 |
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
225 changes: 225 additions & 0 deletions
225
packages/design-system/src/helpers/createDefaultFileIconMapping.ts
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,225 @@ | ||
import { IconType } from './types' | ||
|
||
const fileIcon = { | ||
archive: { | ||
icon: { name: 'resource-type-archive', color: 'var(--oc-color-icon-archive)' }, | ||
extensions: [ | ||
'7z', | ||
'apk', | ||
'bz2', | ||
'deb', | ||
'gz', | ||
'gzip', | ||
'rar', | ||
'tar', | ||
'tar.bz2', | ||
'tar.gz', | ||
'tar.xz', | ||
'tbz2', | ||
'tgz', | ||
'zip' | ||
] | ||
}, | ||
audio: { | ||
icon: { name: 'resource-type-audio', color: 'var(--oc-color-icon-audio)' }, | ||
extensions: [ | ||
'3gp', | ||
'8svx', | ||
'aa', | ||
'aac', | ||
'aax', | ||
'act', | ||
'aiff', | ||
'alac', | ||
'amr', | ||
'ape', | ||
'au', | ||
'awb', | ||
'cda', | ||
'dss', | ||
'dvf', | ||
'flac', | ||
'gsm', | ||
'iklax', | ||
'ivs', | ||
'm4a', | ||
'm4b', | ||
'm4p', | ||
'mmf', | ||
'mogg', | ||
'movpkg', | ||
'mp3', | ||
'mpc', | ||
'msv', | ||
'nmf', | ||
'oga', | ||
'ogga', | ||
'opus', | ||
'ra', | ||
'raw', | ||
'rf64', | ||
'rm', | ||
'sln', | ||
'tta', | ||
'voc', | ||
'vox', | ||
'wav', | ||
'wma', | ||
'wv' | ||
] | ||
}, | ||
code: { | ||
icon: { name: 'resource-type-code', color: 'var(--oc-color-text-default)' }, | ||
extensions: [ | ||
'bash', | ||
'c++', | ||
'c', | ||
'cc', | ||
'cpp', | ||
'css', | ||
'feature', | ||
'go', | ||
'h', | ||
'hh', | ||
'hpp', | ||
'htm', | ||
'html', | ||
'java', | ||
'js', | ||
'json', | ||
'php', | ||
'pl', | ||
'py', | ||
'scss', | ||
'sh', | ||
'sh-lib', | ||
'sql', | ||
'ts', | ||
'xml', | ||
'yaml', | ||
'yml' | ||
] | ||
}, | ||
default: { | ||
icon: { name: 'resource-type-file', color: 'var(--oc-color-text-default)' }, | ||
extensions: ['accdb', 'rss', 'swf'] | ||
}, | ||
drawio: { | ||
icon: { name: 'resource-type-drawio', color: 'var(--oc-color-icon-drawio)' }, | ||
extensions: ['drawio'] | ||
}, | ||
document: { | ||
icon: { name: 'resource-type-document', color: 'var(--oc-color-icon-document)' }, | ||
extensions: ['doc', 'docm', 'docx', 'dot', 'dotx', 'lwp', 'odt', 'one', 'vsd', 'wpd'] | ||
}, | ||
ifc: { | ||
icon: { name: 'resource-type-ifc', color: 'var(--oc-color-icon-ifc)' }, | ||
extensions: ['ifc'] | ||
}, | ||
ipynb: { | ||
icon: { name: 'resource-type-jupyter', color: 'var(--oc-color-icon-jupyter)' }, | ||
extensions: ['ipynb'] | ||
}, | ||
image: { | ||
icon: { name: 'resource-type-image', color: 'var(--oc-color-icon-image)' }, | ||
extensions: [ | ||
'ai', | ||
'cdr', | ||
'eot', | ||
'eps', | ||
'gif', | ||
'jpeg', | ||
'jpg', | ||
'otf', | ||
'pfb', | ||
'png', | ||
'ps', | ||
'psd', | ||
'svg', | ||
'ttf', | ||
'woff', | ||
'xcf' | ||
] | ||
}, | ||
form: { | ||
icon: { name: 'resource-type-form', color: 'var(--oc-color-icon-form)' }, | ||
extensions: ['docf', 'docxf', 'oform'] | ||
}, | ||
markdown: { | ||
icon: { name: 'resource-type-markdown', color: 'var(--oc-color-icon-markdown)' }, | ||
extensions: ['md'] | ||
}, | ||
odg: { | ||
icon: { name: 'resource-type-graphic', color: 'var(--oc-color-icon-graphic)' }, | ||
extensions: ['odg'] | ||
}, | ||
pdf: { | ||
icon: { name: 'resource-type-pdf', color: 'var(--oc-color-icon-pdf)' }, | ||
extensions: ['pdf'] | ||
}, | ||
presentation: { | ||
icon: { name: 'resource-type-presentation', color: 'var(--oc-color-icon-presentation)' }, | ||
extensions: [ | ||
'odp', | ||
'pot', | ||
'potm', | ||
'potx', | ||
'ppa', | ||
'ppam', | ||
'pps', | ||
'ppsm', | ||
'ppsx', | ||
'ppt', | ||
'pptm', | ||
'pptx' | ||
] | ||
}, | ||
root: { | ||
icon: { name: 'resource-type-root', color: 'var(--oc-color-icon-root)' }, | ||
extensions: ['root'] | ||
}, | ||
spreadsheet: { | ||
icon: { name: 'resource-type-spreadsheet', color: 'var(--oc-color-icon-spreadsheet)' }, | ||
extensions: ['csv', 'ods', 'xla', 'xlam', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx'] | ||
}, | ||
text: { | ||
icon: { name: 'resource-type-text', color: 'var(--oc-color-text-default)' }, | ||
extensions: [ | ||
'cb7', | ||
'cba', | ||
'cbr', | ||
'cbt', | ||
'cbtc', | ||
'cbz', | ||
'cvbdl', | ||
'eml', | ||
'epub', | ||
'mdb', | ||
'tex', | ||
'txt' | ||
] | ||
}, | ||
url: { | ||
icon: { name: 'resource-type-url', color: 'var(--oc-color-text-default)' }, | ||
extensions: ['url'] | ||
}, | ||
video: { | ||
icon: { | ||
name: 'resource-type-video', | ||
color: 'var(--oc-color-icon-video)' | ||
}, | ||
extensions: ['mov', 'mp4', 'webm', 'wmv'] | ||
} | ||
} | ||
|
||
export function createDefaultFileIconMapping() { | ||
const fileIconMapping: Record<string, IconType> = {} | ||
|
||
Object.values(fileIcon).forEach((value) => { | ||
value.extensions.forEach((extension) => { | ||
fileIconMapping[extension] = value.icon | ||
}) | ||
}) | ||
|
||
return fileIconMapping | ||
} |
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,3 +1,4 @@ | ||
export * from './colors' | ||
export * from './constants' | ||
export * from './createDefaultFileIconMapping' | ||
export * from './types' | ||
export * from './colors' |
Oops, something went wrong.