diff --git a/assets/images/utils/edit.svg b/assets/images/utils/edit.svg new file mode 100644 index 000000000..18163ed17 --- /dev/null +++ b/assets/images/utils/edit.svg @@ -0,0 +1,15 @@ + + + + diff --git a/assets/images/utils/plus.svg b/assets/images/utils/plus.svg new file mode 100644 index 000000000..4e58130e0 --- /dev/null +++ b/assets/images/utils/plus.svg @@ -0,0 +1,12 @@ + + + + diff --git a/assets/images/utils/save.svg b/assets/images/utils/save.svg new file mode 100644 index 000000000..a7be5d637 --- /dev/null +++ b/assets/images/utils/save.svg @@ -0,0 +1 @@ + diff --git a/assets/images/utils/trash.svg b/assets/images/utils/trash.svg new file mode 100644 index 000000000..1b9952838 --- /dev/null +++ b/assets/images/utils/trash.svg @@ -0,0 +1,13 @@ + + + + diff --git a/assets/styles/components.scss b/assets/styles/components.scss index 51b45cc94..c1a362d7e 100644 --- a/assets/styles/components.scss +++ b/assets/styles/components.scss @@ -43,4 +43,9 @@ background-color: #c6f6d5; color: #276749; } + + &.yellow { + background-color: #f6e8c6; + color: #675027; + } } diff --git a/pages/mod/create.vue b/pages/mod/create.vue index 38ba961ee..85286d280 100644 --- a/pages/mod/create.vue +++ b/pages/mod/create.vue @@ -1,7 +1,7 @@ Create Mod - + Error {{ currentError }} @@ -17,13 +17,13 @@ " /> - Upload Icon + Upload Icon Name @@ -59,7 +59,7 @@ :limit="6" :hide-selected="true" placeholder="Choose categories..." - > + /> @@ -79,7 +79,125 @@ - Versions + + + + New Version + + + + + + + + Version Title + + + + Version Number + + + + Release Channel + + + + Loaders + + + + Game Versions + + + Changelog + + + Version Files + + + Upload files + + + Versions + + + + {{ value.version_number }} + {{ value.version_title }} + Forge + Beta + + Release + + Alpha + + + + + Extras @@ -112,31 +230,52 @@ import axios from 'axios' import Multiselect from 'vue-multiselect' +import TrashIcon from '~/assets/images/utils/trash.svg?inline' +import EditIcon from '~/assets/images/utils/edit.svg?inline' +import PlusIcon from '~/assets/images/utils/plus.svg?inline' +import SaveIcon from '~/assets/images/utils/save.svg?inline' + export default { components: { Multiselect, + TrashIcon, + EditIcon, + PlusIcon, + SaveIcon, }, async asyncData() { - const res = await axios.get(`https://api.modrinth.com/api/v1/tag/category`) + let res = await axios.get(`https://api.modrinth.com/api/v1/tag/category`) + const categories = res.data + + res = await axios.get(`https://api.modrinth.com/api/v1/tag/loader`) + const loaders = res.data + + res = await axios.get(`https://api.modrinth.com/api/v1/tag/game_version`) + const versions = res.data + return { - selectableCategories: res.data, + selectableCategories: categories, + selectableLoaders: loaders, + selectableVersions: versions, } }, data() { return { previewImage: null, + currentError: null, + compiledBody: '', + releaseChannels: ['beta', 'alpha', 'release'], + currentVersionIndex: -1, + name: '', - namespace: '', description: '', body: '', - compiledBody: '', versions: [], categories: [], issues_url: null, source_url: null, wiki_url: null, icon: null, - currentError: null, } }, methods: { @@ -171,6 +310,15 @@ export default { if (this.icon) formData.append('icon', new Blob([this.icon]), this.icon.name) + for (const version of this.versions) { + for (let i = 0; i < version.file_parts; i++) { + formData.append( + version.file_parts[i], + new Blob([version.raw_files[i]]) + ) + } + } + try { const result = await axios({ url: 'https://api.modrinth.com/api/v1/mod', @@ -189,6 +337,7 @@ export default { } catch (err) { this.currentError = err.response.data.description window.scrollTo({ top: 0, behavior: 'smooth' }) + this.$nuxt.$loading.stop() } this.$nuxt.$loading.stop() @@ -202,6 +351,50 @@ export default { this.previewImage = event.target.result } }, + updateVersionFiles(e) { + this.versions[this.currentVersionIndex].raw_files = e.target.files + + const newFileParts = [] + for (const rawFile of e.target.files) { + newFileParts.push( + rawFile.name.concat( + Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .substr(0, 5) + ) + ) + } + + this.versions[this.currentVersionIndex].file_parts = newFileParts + }, + createVersion() { + this.versions.push({ + mod_id: 'qFcDZRhp', + raw_files: [], + file_parts: [], + version_number: '', + version_title: '', + version_body: '', + dependencies: [], + game_versions: [], + release_channel: 'release', + loaders: [], + }) + + this.currentVersionIndex = this.versions.length - 1 + }, + deleteVersion() { + this.versions.splice(this.currentVersionIndex, 1) + this.currentVersionIndex = -1 + }, + }, + head() { + return { + bodyAttrs: { + class: this.currentVersionIndex > -1 ? 'no-scroll' : '', + }, + } }, } @@ -233,6 +426,31 @@ input { margin-top: 0.5rem; } +[type='file'] { + border: 0; + clip: rect(0, 0, 0, 0); + height: 1px; + overflow: hidden; + padding: 0; + position: absolute !important; + white-space: nowrap; + width: 1px; + + + label { + border-radius: 5px; + color: var(--color-grey-5); + background-color: var(--color-grey-1); + padding: 10px 20px; + } + + &:focus + label, + + label:hover, + &:focus + label { + background-color: var(--color-grey-2); + color: var(--color-text); + } +} + .initial { display: flex; .image-data { @@ -244,30 +462,6 @@ input { height: 85%; margin-bottom: 20px; } - [type='file'] { - border: 0; - clip: rect(0, 0, 0, 0); - height: 1px; - overflow: hidden; - padding: 0; - position: absolute !important; - white-space: nowrap; - width: 1px; - - + label { - border-radius: 5px; - color: var(--color-grey-5); - background-color: var(--color-grey-1); - padding: 10px 20px; - } - - &:focus + label, - + label:hover, - &:focus + label { - background-color: var(--color-grey-2); - color: var(--color-text); - } - } } .mod-data { @@ -343,4 +537,98 @@ button { content: ' *'; color: red; } + +.create-version-popup { + top: 0; + left: 0; + z-index: 1; + position: fixed; + width: 100%; + height: 100%; + background-color: var(--color-grey-0); + opacity: 0.6; + overflow-x: hidden; +} + +.create-version-popup-body { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 2; + box-shadow: 0 2px 3px 1px var(--color-grey-2); + padding: 5px 60px 60px 20px; + border-radius: 10px; + max-height: 80%; + overflow-y: auto; + background-color: var(--color-bg); + + .popup-icons { + margin-top: 10px; + margin-right: -20px; + margin-left: auto; + } + + .changelog-editor { + padding: 20px; + width: 100%; + height: 200px; + resize: none; + outline: none; + border: none; + margin: 10px 0 30px; + background-color: var(--color-grey-1); + color: var(--color-text); + font-family: monospace; + } +} + +.versions-header { + display: flex; + align-items: center; +} + +.new-version { + display: inline-block; + color: var(--color-grey-5); + background-color: var(--color-grey-1); + border-radius: 5px; + padding: 5px; + cursor: pointer; + margin-left: auto; + float: right; + + &:hover { + background-color: var(--color-grey-2); + color: var(--color-text); + } +} + +.version { + padding: 5px; + border-radius: 5px; + margin-bottom: 10px; + display: flex; + align-items: center; + justify-content: space-around; + background-color: var(--color-grey-1); +} + +svg { + color: var(--color-grey-5); + cursor: pointer; + + &:hover, + &:focus { + color: inherit; + } +} + +.categories-input { + margin-bottom: 15px; +} + +.no-scroll { + overflow: hidden; +} diff --git a/pages/mods.vue b/pages/mods.vue index 83bdf9946..a069dcbb2 100644 --- a/pages/mods.vue +++ b/pages/mods.vue @@ -336,19 +336,10 @@ export default { async fillInitialVersions() { try { const res = await axios.get( - 'https://launchermeta.mojang.com/mc/game/version_manifest.json' + 'https://api.modrinth.com/api/v1/tag/game_version' ) - const versions = res.data.versions - const betaVersions = [] - const legacyVersions = [] - for (const version of versions) { - if (version.type === 'release') this.versions.push(version.id) - if (version.type === 'snapshot') betaVersions.push(version.id) - if (version.type === 'old_beta' || version.type === 'old_alpha') - legacyVersions.push(version.id) - } - this.versions = this.versions.concat(betaVersions, legacyVersions) + this.versions = res.data } catch (err) { // eslint-disable-next-line no-console console.error(err) @@ -668,7 +659,6 @@ select { .sort-types { min-width: 200px; - padding-y: 1rem; border: 2px solid var(--color-grey-3); border-radius: var(--size-rounded-sm);
{{ currentError }}
{{ value.version_number }}
{{ value.version_title }}
Forge
Beta
+ Release +
Alpha