From dd96bdb9f68bee8fd63868d580a154dac587dbb0 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Tue, 5 May 2020 16:07:06 +0200 Subject: [PATCH] first draft of media picker --- zero.Core/Renderer/Options/MediaOptions.cs | 14 +- .../Renderer/Options/MediaOptionsDisplay.cs | 9 + .../Renderer/Options/MediaOptionsType.cs | 8 +- zero.Web/App/Components/Forms/media.vue | 294 ++++++++++++++++++ zero.Web/App/Components/Tabs/tabs.vue | 7 +- zero.Web/App/Pages/settings/application.vue | 37 +-- zero.Web/App/app.vue | 1 + zero.Web/App/zero.config.js | 11 + .../Resources/Localization/zero.en-us.json | 7 + zero.Web/Sass/Modules/Buttons/_button.scss | 3 +- 10 files changed, 365 insertions(+), 26 deletions(-) create mode 100644 zero.Core/Renderer/Options/MediaOptionsDisplay.cs create mode 100644 zero.Web/App/Components/Forms/media.vue create mode 100644 zero.Web/App/zero.config.js diff --git a/zero.Core/Renderer/Options/MediaOptions.cs b/zero.Core/Renderer/Options/MediaOptions.cs index e3dc7f52..e9987c14 100644 --- a/zero.Core/Renderer/Options/MediaOptions.cs +++ b/zero.Core/Renderer/Options/MediaOptions.cs @@ -6,6 +6,18 @@ namespace zero.Core.Renderer { public class MediaOptions : AbstractFieldOptions { + public uint Limit { get; set; } = 1; + + public decimal MaxFileSize { get; set; } = 10; + public MediaOptionsType Type { get; set; } + + public MediaOptionsDisplay Display { get; set; } + + public List FileExtensions { get; set; } = new List(); + + public bool DisallowSelect { get; set; } + + public bool DisallowUpload { get; set; } } -} +} \ No newline at end of file diff --git a/zero.Core/Renderer/Options/MediaOptionsDisplay.cs b/zero.Core/Renderer/Options/MediaOptionsDisplay.cs new file mode 100644 index 00000000..40d488d4 --- /dev/null +++ b/zero.Core/Renderer/Options/MediaOptionsDisplay.cs @@ -0,0 +1,9 @@ +namespace zero.Core.Renderer +{ + public enum MediaOptionsDisplay + { + Default = 0, + Big = 1, + Grid = 2 + } +} diff --git a/zero.Core/Renderer/Options/MediaOptionsType.cs b/zero.Core/Renderer/Options/MediaOptionsType.cs index 702f40f4..87aa06ed 100644 --- a/zero.Core/Renderer/Options/MediaOptionsType.cs +++ b/zero.Core/Renderer/Options/MediaOptionsType.cs @@ -6,8 +6,10 @@ namespace zero.Core.Renderer { public enum MediaOptionsType { - All, - Image, - Video + All = 0, + Image = 1, + Video = 2, + Document = 3, + Other = 99 } } diff --git a/zero.Web/App/Components/Forms/media.vue b/zero.Web/App/Components/Forms/media.vue new file mode 100644 index 00000000..6c3a4484 --- /dev/null +++ b/zero.Web/App/Components/Forms/media.vue @@ -0,0 +1,294 @@ + + + + + + \ No newline at end of file diff --git a/zero.Web/App/Components/Tabs/tabs.vue b/zero.Web/App/Components/Tabs/tabs.vue index 3a5a2858..b12a3d44 100644 --- a/zero.Web/App/Components/Tabs/tabs.vue +++ b/zero.Web/App/Components/Tabs/tabs.vue @@ -114,7 +114,12 @@ position: relative; transition: color 0.2s ease; border-radius: var(--radius) var(--radius) 0 0; - background: rgba(white, 0.5); // TODO + background: var(--color-bg); + + .theme-dark & + { + background: rgba(black, 0.5); + } & + .ui-tabs-list-item { diff --git a/zero.Web/App/Pages/settings/application.vue b/zero.Web/App/Pages/settings/application.vue index 5b95479a..ee891c30 100644 --- a/zero.Web/App/Pages/settings/application.vue +++ b/zero.Web/App/Pages/settings/application.vue @@ -26,14 +26,10 @@ - upload + - upload - - - -

+
@@ -51,6 +47,13 @@ + + + +

+
+
+ @@ -73,7 +76,10 @@ actions: [], model: { name: null, features: [] }, disabled: false, - features: [] + features: [], + mediaConfig: { + fileExtensions: zero.config.media.defaults.images_artificial + } }), created() @@ -111,6 +117,9 @@ onSubmit(form) { + console.info(JSON.parse(JSON.stringify(this.model))); + return; + form.handle(ApplicationsApi.save(this.model)).then(response => { console.info(response); @@ -160,16 +169,4 @@ } } } - - - \ No newline at end of file + \ No newline at end of file diff --git a/zero.Web/App/app.vue b/zero.Web/App/app.vue index 39949971..0161db0e 100644 --- a/zero.Web/App/app.vue +++ b/zero.Web/App/app.vue @@ -21,6 +21,7 @@ import AuthApi from 'zero/services/auth.js' import 'zero/vue.config.js' import 'zero/axios.config.js' + import 'zero/zero.config.js' export default { name: 'app', diff --git a/zero.Web/App/zero.config.js b/zero.Web/App/zero.config.js new file mode 100644 index 00000000..d574a55b --- /dev/null +++ b/zero.Web/App/zero.config.js @@ -0,0 +1,11 @@ + +window.zero = window.zero || {}; +window.zero.config = window.zero.config || {}; + +window.zero.config.media = { + defaults: { + images: ['.jpg', '.jpeg', '.png', '.webp', '.svg'], + images_natural: ['.jpg', '.jpeg', '.webp'], + images_artificial: ['.png', '.webp', '.svg'] + } +}; \ No newline at end of file diff --git a/zero.Web/Resources/Localization/zero.en-us.json b/zero.Web/Resources/Localization/zero.en-us.json index c0ccb50a..e2fe0ac4 100644 --- a/zero.Web/Resources/Localization/zero.en-us.json +++ b/zero.Web/Resources/Localization/zero.en-us.json @@ -261,6 +261,13 @@ "title": "Pick an icon" }, + "mediapicker": { + "select_text": "Select", + "select_description": "Choose from library", + "upload_text": "Upload", + "upload_description": "Upload a new file" + }, + "application": { "list": "Applications", "name": "Application", diff --git a/zero.Web/Sass/Modules/Buttons/_button.scss b/zero.Web/Sass/Modules/Buttons/_button.scss index 7378f06c..559a38bb 100644 --- a/zero.Web/Sass/Modules/Buttons/_button.scss +++ b/zero.Web/Sass/Modules/Buttons/_button.scss @@ -292,7 +292,7 @@ button::-moz-focus-inner background: var(--color-bg-mid); color: var(--color-fg); text-align: center; - font-size: 20px; + font-size: 16px; margin-right: 16px; } @@ -310,4 +310,5 @@ button::-moz-focus-inner { color: var(--color-fg-mid); margin-top: 3px; + font-size: var(--font-size-xs); } \ No newline at end of file