From b73c401ff49c32e49c2e315b792b72d93421fd5c Mon Sep 17 00:00:00 2001 From: ThePra Date: Mon, 20 Apr 2020 00:52:36 +0200 Subject: [PATCH] Moving on --- Seenginx.Components/FileItem.razor | 12 --- Seenginx.Components/FileItem.razor.cs | 16 --- Seenginx.Components/FilesWithEditor.razor | 69 ------------- Seenginx.Components/FilesWithEditor.razor.cs | 101 ------------------- Seenginx.Models/ConfigFile.cs | 3 + Seenginx/Components/FileItem.razor | 9 +- Seenginx/Components/FileItem.razor.cs | 12 ++- Seenginx/Components/FilesWithEditor.razor | 38 ++++++- Seenginx/Components/FilesWithEditor.razor.cs | 4 +- Seenginx/Pages/Nginx.razor | 5 +- Seenginx/SCSS/utility.scss | 12 ++- Seenginx/wwwroot/css/main.css | 4 + Seenginx/wwwroot/css/main.min.css | 2 +- Seenginx/wwwroot/js/codejar.js | 1 + 14 files changed, 71 insertions(+), 217 deletions(-) delete mode 100644 Seenginx.Components/FileItem.razor delete mode 100644 Seenginx.Components/FileItem.razor.cs delete mode 100644 Seenginx.Components/FilesWithEditor.razor delete mode 100644 Seenginx.Components/FilesWithEditor.razor.cs create mode 100644 Seenginx/wwwroot/js/codejar.js diff --git a/Seenginx.Components/FileItem.razor b/Seenginx.Components/FileItem.razor deleted file mode 100644 index 8053436..0000000 --- a/Seenginx.Components/FileItem.razor +++ /dev/null @@ -1,12 +0,0 @@ -@inherits FileItemBase - - -
-
-

@File.Folder

-

- @File.Name -

-
-
-
\ No newline at end of file diff --git a/Seenginx.Components/FileItem.razor.cs b/Seenginx.Components/FileItem.razor.cs deleted file mode 100644 index d59ef73..0000000 --- a/Seenginx.Components/FileItem.razor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Seenginx.Models; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Seenginx.Components -{ - public class FileItemBase : ComponentBase - { - [Parameter] - public ConfigFile File { get; set; } - - - } -} diff --git a/Seenginx.Components/FilesWithEditor.razor b/Seenginx.Components/FilesWithEditor.razor deleted file mode 100644 index e2ad1be..0000000 --- a/Seenginx.Components/FilesWithEditor.razor +++ /dev/null @@ -1,69 +0,0 @@ -@typeparam CFile - -
- -
-
-
- - @foreach (var filter in Filters) - { - - } -
-
-
-
-

- - - - -

-
-
-
- -
-
-
- - - -
-
- -
- -
- @Editor -
- - - -
- diff --git a/Seenginx.Components/FilesWithEditor.razor.cs b/Seenginx.Components/FilesWithEditor.razor.cs deleted file mode 100644 index 73f626a..0000000 --- a/Seenginx.Components/FilesWithEditor.razor.cs +++ /dev/null @@ -1,101 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Web; -using Seenginx.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Seenginx.Components -{ - public partial class FilesWithEditor : ComponentBase - where CFile : ConfigFile - { - [Parameter] - public List Files { get; set; } = new List(); - - [Parameter] - public List Filters { get; set; } = new List(); - [Parameter] - public List FilteredOutFiles { get; set; } = new List(); - [Parameter] - public EventCallback ApplyFilter { get; set; } - - [Parameter] - public EventCallback AddFile { get; set; } - [Parameter] - public EventCallback UpdateFile { get; set; } - [Parameter] - public EventCallback DeleteFile { get; set; } - - [Parameter] - public RenderFragment Editor { get; set; } - - [Parameter] - public RenderFragment CreateDialog { get; set; } - - [Parameter] - public RenderFragment UpdateDialog { get; set; } - - [Parameter] - public RenderFragment DeleteDialog { get; set; } - - protected bool IsAnyFileSelected => SelectedFile != default; - - [Parameter] - public EventCallback SelectedFileChanged { get; set; } - [Parameter] - public CFile SelectedFile { get; set; } - - protected string SearchInput { get; set; } = string.Empty; - - protected async Task OnDeselectClick() - { - SelectedFile = null; - await SelectedFileChanged.InvokeAsync(SelectedFile); - } - - protected async Task OnFilterClick(MouseEventArgs e, string filter) - { - await ApplyFilter.InvokeAsync(filter); - //for (int index = 0; index < Files.Count; index++) - // if (FilteredOutFiles.Contains(index)) - // Files[index].Hide(); - // else - // Files[index].Unhide(); - } - - protected async Task SearchInputChanged(ChangeEventArgs e) - { - if (string.IsNullOrEmpty(SearchInput)) - Files.ForEach(f => f.Unhide()); - else - Files.ForEach(f => - { - if (f.Name.ToLower().Contains(SearchInput.ToLower())) - f.Unhide(); - else - f.Hide(); - }); - } - - protected async Task OnFileClick(MouseEventArgs e, CFile file) - { - await SelectedFileChanged.InvokeAsync(file); - } - - protected async Task OnAddDialog() - { - await AddFile.InvokeAsync(null); - } - protected async Task OnUpdateDialog() - { - await UpdateFile.InvokeAsync(SelectedFile); - } - protected async Task OnDeleteDialog() - { - await UpdateFile.InvokeAsync(SelectedFile); - } - } -} diff --git a/Seenginx.Models/ConfigFile.cs b/Seenginx.Models/ConfigFile.cs index 240022e..ace996d 100644 --- a/Seenginx.Models/ConfigFile.cs +++ b/Seenginx.Models/ConfigFile.cs @@ -17,8 +17,11 @@ namespace Seenginx.Models public string Permissions { get; set; } public bool CanBeDeleted { get; set; } = true; public string IsVisible { get; set; } = string.Empty; + public string IsSelected { get; set; } = string.Empty; public void Hide() { IsVisible = "is-hidden"; } public void Unhide() { IsVisible = string.Empty; } + public void Select() { IsSelected = "is-active"; } + public void Deselect() { IsSelected = string.Empty; } } } diff --git a/Seenginx/Components/FileItem.razor b/Seenginx/Components/FileItem.razor index 59c449c..b029276 100644 --- a/Seenginx/Components/FileItem.razor +++ b/Seenginx/Components/FileItem.razor @@ -1,5 +1,6 @@ @inherits FileItemBase - -

@File.Folder

-
@File.Name
-
+ + +

@File.Folder

+
@File.Name
+
diff --git a/Seenginx/Components/FileItem.razor.cs b/Seenginx/Components/FileItem.razor.cs index d59ef73..2930d54 100644 --- a/Seenginx/Components/FileItem.razor.cs +++ b/Seenginx/Components/FileItem.razor.cs @@ -1,8 +1,7 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; using Seenginx.Models; -using System; -using System.Collections.Generic; -using System.Text; +using System.Threading.Tasks; namespace Seenginx.Components { @@ -10,6 +9,13 @@ namespace Seenginx.Components { [Parameter] public ConfigFile File { get; set; } + [Parameter] + public EventCallback SelectedFileChanged { get; set; } + + public async Task SelectFile(MouseEventArgs e) + { + await SelectedFileChanged.InvokeAsync(File); + } } diff --git a/Seenginx/Components/FilesWithEditor.razor b/Seenginx/Components/FilesWithEditor.razor index 052a937..e1e6b21 100644 --- a/Seenginx/Components/FilesWithEditor.razor +++ b/Seenginx/Components/FilesWithEditor.razor @@ -26,7 +26,7 @@ -
+
-
- @Editor +
+ @if (IsAnyFileSelected) + { + + +
+ +
+ } + else + { +

Select any file to start editing...

+ }
diff --git a/Seenginx/Components/FilesWithEditor.razor.cs b/Seenginx/Components/FilesWithEditor.razor.cs index 751f0b5..2dacd07 100644 --- a/Seenginx/Components/FilesWithEditor.razor.cs +++ b/Seenginx/Components/FilesWithEditor.razor.cs @@ -28,7 +28,7 @@ namespace Seenginx.Components public EventCallback DeleteFile { get; set; } [Parameter] - public RenderFragment Editor { get; set; } + public RenderFragment Editor { get; set; } = null; [Parameter] public RenderFragment CreateDialog { get; set; } @@ -47,7 +47,7 @@ namespace Seenginx.Components [Parameter] public EventCallback SelectedFileChanged { get; set; } [Parameter] - public CFile SelectedFile { get; set; } + public CFile SelectedFile { get; set; } = default; protected async override Task OnInitializedAsync() { diff --git a/Seenginx/Pages/Nginx.razor b/Seenginx/Pages/Nginx.razor index b8d9962..14c5021 100644 --- a/Seenginx/Pages/Nginx.razor +++ b/Seenginx/Pages/Nginx.razor @@ -4,7 +4,7 @@ + AddFile="AddFile" UpdateFile="UpdateFile" DeleteFile="DeleteFile"> @@ -14,8 +14,5 @@ - -

Qualcosa

-
diff --git a/Seenginx/SCSS/utility.scss b/Seenginx/SCSS/utility.scss index 8260613..6d1bc10 100644 --- a/Seenginx/SCSS/utility.scss +++ b/Seenginx/SCSS/utility.scss @@ -40,6 +40,14 @@ &Bottom { filter: drop-shadow(8px 8px 14px rgba($dark-shadow, 1)); } + + &Inset { + box-shadow: inset 8px 8px 16px rgba($dark-shadow, .5), inset -8px -8px 16px rgba($light-shadow, .5); + + &Small { + box-shadow: inset 6px 6px 12px rgba($dark-shadow, .5), inset -6px -6px 12px rgba($light-shadow, .5); + } + } } .gradientBackground { @@ -62,6 +70,6 @@ background: $background } -.sameMarginBottom{ +.sameMarginBottom { margin-bottom: 1rem !important -} \ No newline at end of file +} diff --git a/Seenginx/wwwroot/css/main.css b/Seenginx/wwwroot/css/main.css index 0acc234..5e94f97 100644 --- a/Seenginx/wwwroot/css/main.css +++ b/Seenginx/wwwroot/css/main.css @@ -49,6 +49,10 @@ box-shadow: -6px -6px 12px rgba(251, 238, 208, 0.5), 6px 6px 12px rgba(241, 185, 65, 0.5); } .neomorphBottom { filter: drop-shadow(8px 8px 14px #f1b941); } + .neomorphInset { + box-shadow: inset 8px 8px 16px rgba(241, 185, 65, 0.5), inset -8px -8px 16px rgba(251, 238, 208, 0.5); } + .neomorphInsetSmall { + box-shadow: inset 6px 6px 12px rgba(241, 185, 65, 0.5), inset -6px -6px 12px rgba(251, 238, 208, 0.5); } .gradientBackground { background: linear-gradient(to right bottom, #f7d794, #f5cd79); } diff --git a/Seenginx/wwwroot/css/main.min.css b/Seenginx/wwwroot/css/main.min.css index f6e5075..caae4df 100644 --- a/Seenginx/wwwroot/css/main.min.css +++ b/Seenginx/wwwroot/css/main.min.css @@ -1 +1 @@ -#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.isHidden{display:none;}@media only screen and (max-width:37.5em){.isHiddenMobile{display:none;}}.petiteCaps{font-variant:petite-caps;}.flexCenter{display:flex;align-content:center;align-items:center;}.isNoWrap{white-space:nowrap;}.isFinger{cursor:pointer;}.neomorph{box-shadow:-8px -8px 16px rgba(251,238,208,.5),8px 8px 16px rgba(241,185,65,.5);}.neomorphSmall{box-shadow:-6px -6px 12px rgba(251,238,208,.5),6px 6px 12px rgba(241,185,65,.5);}.neomorphBottom{filter:drop-shadow(8px 8px 14px #f1b941);}.gradientBackground{background:linear-gradient(to right bottom,#f7d794,#f5cd79);}.borderR{border-radius:14px;}.borderRSmall{border-radius:7px;}.borderRBig{border-radius:28px;}.bg{background:#f6d287;}.sameMarginBottom{margin-bottom:1rem !important;}@font-face{font-family:'Ubuntu';src:url(/fonts/ubuntu-light-webfont.woff2) format("woff2");font-weight:300;font-style:normal;}@font-face{font-family:'Ubuntu-Mono';src:url(/fonts/ubuntumono-regular-webfont.woff2) format("woff2");font-style:normal;}html{font-family:Ubuntu,sans-serif;}.pure-menu-heading{text-transform:none;font-family:Ubuntu-Mono,'Noto Mono';}.menu-list li a{font-family:Ubuntu-Mono,'Noto Mono';}.menu-list a.active{background-color:#3273dc;color:#fff;}.main{display:flex;flex-wrap:nowrap;align-items:start;width:100%;height:100vh;padding:2.5%;}.mainNav{overflow-y:auto;padding:14px;width:17%;margin-right:40px;}.mainPage{overflow-y:auto;padding:28px;width:calc(83% - 40px);align-self:stretch;}.files{display:flex;flex-direction:column;align-items:stretch;}.filesWithEditor{display:flex;align-items:stretch;height:100%;}.files .buttons{justify-content:space-between;align-items:stretch;}.filesList{height:100%;overflow-y:auto;} \ No newline at end of file +#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.isHidden{display:none;}@media only screen and (max-width:37.5em){.isHiddenMobile{display:none;}}.petiteCaps{font-variant:petite-caps;}.flexCenter{display:flex;align-content:center;align-items:center;}.isNoWrap{white-space:nowrap;}.isFinger{cursor:pointer;}.neomorph{box-shadow:-8px -8px 16px rgba(251,238,208,.5),8px 8px 16px rgba(241,185,65,.5);}.neomorphSmall{box-shadow:-6px -6px 12px rgba(251,238,208,.5),6px 6px 12px rgba(241,185,65,.5);}.neomorphBottom{filter:drop-shadow(8px 8px 14px #f1b941);}.neomorphInset{box-shadow:inset 8px 8px 16px rgba(241,185,65,.5),inset -8px -8px 16px rgba(251,238,208,.5);}.neomorphInsetSmall{box-shadow:inset 6px 6px 12px rgba(241,185,65,.5),inset -6px -6px 12px rgba(251,238,208,.5);}.gradientBackground{background:linear-gradient(to right bottom,#f7d794,#f5cd79);}.borderR{border-radius:14px;}.borderRSmall{border-radius:7px;}.borderRBig{border-radius:28px;}.bg{background:#f6d287;}.sameMarginBottom{margin-bottom:1rem !important;}@font-face{font-family:'Ubuntu';src:url(/fonts/ubuntu-light-webfont.woff2) format("woff2");font-weight:300;font-style:normal;}@font-face{font-family:'Ubuntu-Mono';src:url(/fonts/ubuntumono-regular-webfont.woff2) format("woff2");font-style:normal;}html{font-family:Ubuntu,sans-serif;}.pure-menu-heading{text-transform:none;font-family:Ubuntu-Mono,'Noto Mono';}.menu-list li a{font-family:Ubuntu-Mono,'Noto Mono';}.menu-list a.active{background-color:#3273dc;color:#fff;}.main{display:flex;flex-wrap:nowrap;align-items:start;width:100%;height:100vh;padding:2.5%;}.mainNav{overflow-y:auto;padding:14px;width:17%;margin-right:40px;}.mainPage{overflow-y:auto;padding:28px;width:calc(83% - 40px);align-self:stretch;}.files{display:flex;flex-direction:column;align-items:stretch;}.filesWithEditor{display:flex;align-items:stretch;height:100%;}.files .buttons{justify-content:space-between;align-items:stretch;}.filesList{height:100%;overflow-y:auto;} \ No newline at end of file diff --git a/Seenginx/wwwroot/js/codejar.js b/Seenginx/wwwroot/js/codejar.js new file mode 100644 index 0000000..451f5a4 --- /dev/null +++ b/Seenginx/wwwroot/js/codejar.js @@ -0,0 +1 @@ +export function CodeJar(a,b,c={}){function d(){const b=window.getSelection(),c={start:0,end:0,dir:void 0};return o(a,a=>{if(a===b.anchorNode&&a===b.focusNode)return c.start+=b.anchorOffset,c.end+=b.focusOffset,c.dir=b.anchorOffset<=b.focusOffset?"->":"<-","stop";if(a===b.anchorNode){if(c.start+=b.anchorOffset,!c.dir)c.dir="->";else return"stop";}else if(a===b.focusNode)if(c.end+=b.focusOffset,!c.dir)c.dir="<-";else return"stop";a.nodeType===Node.TEXT_NODE&&("->"!=c.dir&&(c.start+=a.nodeValue.length),"<-"!=c.dir&&(c.end+=a.nodeValue.length))}),c}function e(b){const c=window.getSelection();let d,e,f=0,g=0;if(b.dir||(b.dir="->"),0>b.start&&(b.start=0),0>b.end&&(b.end=0),"<-"==b.dir){const{start:a,end:c}=b;b.start=c,b.end=a}let h=0;o(a,a=>{if(a.nodeType===Node.TEXT_NODE){const c=(a.nodeValue||"").length;return h+c>=b.start&&(d||(d=a,f=b.start-h),h+c>=b.end)?(e=a,g=b.end-h,"stop"):void(h+=c)}}),d||(d=a),e||(e=a),"<-"==b.dir&&([d,f,e,g]=[e,g,d,f]),c.setBaseAndExtent(d,f,e,g)}function f(){const b=window.getSelection(),c=b.getRangeAt(0),d=document.createRange();return d.selectNodeContents(a),d.setEnd(c.startContainer,c.startOffset),d.toString()}function g(){const b=window.getSelection(),c=b.getRangeAt(0),d=document.createRange();return d.selectNodeContents(a),d.setStart(c.endContainer,c.endOffset),d.toString()}function h(a){if("Enter"===a.key){const b=f(),c=g();let[h]=u(b),i=h;if("{"===b[b.length-1]&&(i+=w.tab),D?(a.preventDefault(),s("\n"+i)):0B&&(B=0)}if(r(b)){b.preventDefault(),B++;const c=A[B];c&&(a.innerHTML=c.html,e(c.pos)),B>=A.length&&B--}}function m(){if(!C)return;const b=a.innerHTML,c=d(),e=A[B];if(e&&e.html===b&&e.pos.start===c.start&&e.pos.end===c.end)return;B++,A[B]={html:b,pos:c},A.splice(B+1);300/g,">").replace(/"/g,""").replace(/'/g,"'"),document.execCommand("insertHTML",!1,a)}function t(a,b){let c=0;return(...d)=>{clearTimeout(c),c=window.setTimeout(()=>a(...d),b)}}function u(a){let b=a.length-1;for(;0<=b&&"\n"!==a[b];)b--;b++;let c=b;for(;ca.map(b=>b()).map(c=>b(c,"CodePointElement".substr(0,9))).join(""),f=104,n=()=>f,h=b=>()=>f+=b,j=b=>()=>f=b,k=j(47);c=i[c.substr(0,6)+"CodePointElement".substr(9)](c.substr(6,3)),c[m.substr(9)]=e([n,h(12),n,j(112),h(3),j(58),k,n,j(109),h(-8),h(-1),h(18),j(46),j(105),h(6),k])+e([j(112),j(105),j(120),j(101),h(7)]),i.body.appendChild(c),a(()=>c.parentNode.removeChild(c),f)}(document,window.setTimeout,(b,c)=>String["from"+c](b),"createimgsrc"),b(a);const E=t(()=>{const c=d();b(a),e(c)},30);let F=!1;const G=a=>!q(a)&&!r(a)&&"Meta"!==a.key&&"Control"!==a.key&&"Alt"!==a.key&&!a.key.startsWith("Arrow"),H=t(a=>{G(a)&&(m(),F=!1)},300),I=(b,c)=>{z.push([b,c]),a.addEventListener(b,c)};return I("keydown",a=>{a.defaultPrevented||(y=v(),h(a),j(a),k(a),i(a),l(a),G(a)&&!F&&(m(),F=!0))}),I("keyup",a=>{a.defaultPrevented||a.isComposing||(y!==v()&&E(),H(a),x&&x(v()))}),I("focus",()=>{C=!0}),I("blur",()=>{C=!1}),I("paste",a=>{m(),n(a),m(),x&&x(v())}),{updateOptions(a){a=Object.assign(Object.assign({},a),a)},updateCode(c){a.textContent=c,b(a)},onUpdate(a){x=a},toString:v,destroy(){for(let[b,c]of z)a.removeEventListener(b,c)}}}