diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index e029bfea8..5ddf33fb1 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -22,6 +22,8 @@ export default { { text: 'Card', link: '/components/card' }, { text: 'Checkbox', link: '/components/checkbox' }, { text: 'Chips', link: '/components/chips' }, + { text: 'File Input', link: '/components/file-input' }, + { text: 'Drop Area', link: '/components/drop-area' }, { text: 'Icons', link: '/components/icons' }, { text: 'Pagination', link: '/components/pagination' }, { text: 'Project Card', link: '/components/project-card' }, @@ -31,6 +33,7 @@ export default { { text: 'Text Logo', link: '/components/text-logo' }, { text: 'Slider', link: '/components/slider' }, { text: 'Text Inputs', link: '/components/text-inputs' }, + { text: 'Search Filter', link: '/components/search-filter' }, ], }, ], diff --git a/docs/.vitepress/theme/DemoContainer.vue b/docs/.vitepress/theme/DemoContainer.vue index 41ff6f75c..2cb11e8ab 100644 --- a/docs/.vitepress/theme/DemoContainer.vue +++ b/docs/.vitepress/theme/DemoContainer.vue @@ -1,5 +1,5 @@ + + + + + + +```vue + + + + +``` diff --git a/lib/components/base/DropArea.vue b/lib/components/base/DropArea.vue new file mode 100644 index 000000000..4e459e7ea --- /dev/null +++ b/lib/components/base/DropArea.vue @@ -0,0 +1,87 @@ + + + + diff --git a/lib/components/base/FileInput.vue b/lib/components/base/FileInput.vue new file mode 100644 index 000000000..9bc463b70 --- /dev/null +++ b/lib/components/base/FileInput.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/lib/components/index.js b/lib/components/index.js index 53d75e4ed..f3d9214a9 100644 --- a/lib/components/index.js +++ b/lib/components/index.js @@ -11,8 +11,11 @@ export { default as TextLogo } from './brand/TextLogo.vue' export { default as Pagination } from './base/Pagination.vue' export { default as ProjectCard } from './base/ProjectCard.vue' export { default as EnvironmentIndicator } from './base/EnvironmentIndicator.vue' +export { default as FileInput } from './base/FileInput.vue' +export { default as DropArea } from './base/DropArea.vue' export { default as Categories } from './search/Categories.vue' +export { default as SearchFilter } from './search/SearchFilter.vue' export { default as NavItem } from './nav/NavItem.vue' export { default as NavRow } from './nav/NavRow.vue' diff --git a/lib/components/search/Categories.vue b/lib/components/search/Categories.vue index 676b92494..267e37720 100644 --- a/lib/components/search/Categories.vue +++ b/lib/components/search/Categories.vue @@ -39,7 +39,7 @@ export default { flex-wrap: wrap; gap: var(--gap-sm); - span ::v-deep { + :deep(span) { display: flex; flex-direction: row; color: var(--color-icon); diff --git a/lib/components/search/SearchFilter.vue b/lib/components/search/SearchFilter.vue new file mode 100644 index 000000000..5627d5393 --- /dev/null +++ b/lib/components/search/SearchFilter.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/lib/components/utils.js b/lib/components/utils.js index 03112ddf3..25c0c7ee5 100644 --- a/lib/components/utils.js +++ b/lib/components/utils.js @@ -189,3 +189,34 @@ export function cycleValue(value, values) { const index = values.indexOf(value) + 1 return values[index % values.length] } + +export const fileIsValid = (file, validationOptions) => { + const { maxSize, alertOnInvalid } = validationOptions + if (maxSize !== null && maxSize !== undefined && file.size > maxSize) { + if (alertOnInvalid) { + alert(`File ${file.name} is too big! Must be less than ${formatBytes(maxSize)}`) + } + return false + } + + return true +} + +export const acceptFileFromProjectType = (projectType) => { + switch (projectType) { + case 'mod': + return '.jar,.zip,.litemod,application/java-archive,application/x-java-archive,application/zip' + case 'plugin': + return '.jar,.zip,application/java-archive,application/x-java-archive,application/zip' + case 'resourcepack': + return '.zip,application/zip' + case 'shader': + return '.zip,application/zip' + case 'datapack': + return '.zip,application/zip' + case 'modpack': + return '.mrpack,application/x-modrinth-modpack+zip,application/zip' + default: + return '*' + } +}