Ver Fonte

modified ui in editor

huaisianhuang há 4 anos atrás
pai
commit
197d5cfcba

+ 60 - 4
backstage/static/js/blockElements.js

@@ -1,16 +1,47 @@
 function getBlockElements(contentDiv) {
+  let moreFlag = true;
   const blockDiv = document.createElement("div");
+  blockDiv.classList.add('blockDiv');
+  const editOpen = document.createElement('button');
+  editOpen.classList.add('btn__editOpen');
+  const editIcon = document.createElement('i');
+  editIcon.classList.add('fas', 'fa-edit');
+  editOpen.append(editIcon);
   const descButton = document.createElement('button');
+  descButton.classList.add('btn', 'btn__titledesc');
   descButton.textContent = 'Add Description';
   const imgButton = document.createElement('button');
-  imgButton.textContent = 'Add Image';
+  imgButton.classList.add('btn__addimg');
+  const icon = document.createElement('i');
+  icon.classList.add('fas', 'fa-images');
+  imgButton.appendChild(icon);
   const h = document.createElement("H2");
+  h.classList.add('blockDiv__h2' ,'mb-2');
   const input = document.createElement("INPUT");
+  input.classList.add('input');
   input.setAttribute("type", "text");
   const inputButton = document.createElement('button');
+  inputButton.classList.add('btn', 'btn__titleInput');
   inputButton.textContent = 'Title新增/修改';
   contentDiv.appendChild(blockDiv);
-  blockDiv.append(h, input, inputButton, descButton, imgButton);
+  blockDiv.append(editOpen, h, input, inputButton, descButton, imgButton);
+  blockDiv.classList.add('mb-4');
+  console.log(editOpen);
+  editOpen.addEventListener('click', function(e) {
+    if(e.target.nodeName !== 'I'){ return };
+    console.log(e.target.parentNode.parentNode.parentNode.children);
+    if(moreFlag) {
+      e.target.classList.remove('fas', 'fa-edit');
+      e.target.classList.add('fas', 'fa-minus');
+      blockDiv.style.height = 'auto';
+      moreFlag = false;
+    } else {
+      e.target.classList.remove('fas', 'fa-minus');
+      e.target.classList.add('fas', 'fa-edit');
+      blockDiv.style.height = '30vh';
+      moreFlag = true;
+    }
+  });
   return {
     blockDiv: blockDiv,
     h: h,
@@ -24,11 +55,18 @@ function getBlockElements(contentDiv) {
 function getdescElements(blockDiv) {
   const descDiv = document.createElement("div");
   const descTextArea = document.createElement("TEXTAREA");
+  descDiv.classList.add('descBlock');
+  descTextArea.classList.add('textarea');
   descTextArea.setAttribute("type", "text");
   const descInputButton = document.createElement('button');
+  descInputButton.classList.add('btn', 'btn__descInput');
   const removeButton = document.createElement('button');
+  removeButton.textContent = '刪除 ';
+  const icon = document.createElement('i');
+  icon.classList.add('fas', 'fa-trash-alt');
+  removeButton.append(icon);
+  removeButton.classList.add('btn', 'btn__remove');
   descInputButton.textContent = 'Description新增/修改';
-  removeButton.textContent = 'Description刪除';
   blockDiv.appendChild(descDiv);
   descDiv.append(descTextArea, descInputButton, removeButton);
   return {
@@ -40,13 +78,30 @@ function getdescElements(blockDiv) {
 
 function getImgElements(blockDiv) {
   const div = document.createElement("div");
+  const label = document.createElement('label');
   const img = document.createElement("img");
   const input = document.createElement("INPUT");
   const widthInput = document.createElement("INPUT");
   const heightInput = document.createElement("INPUT");
+  const imgContainer = document.createElement('div');
+  imgContainer.classList.add('img__container');
+  imgContainer.append(img);
+  label.setAttribute('for', 'file');
+  label.setAttribute('alt', '上傳照片');
+  label.textContent = "開啟檔案";
+  const icon = document.createElement('i');
+  icon.classList.add('fas', 'fa-cloud-upload-alt');
+  label.append(icon);
+  widthInput.setAttribute('placeholder', 'Width(ex: 600)');
+  widthInput.classList.add('input');
+  heightInput.setAttribute('placeholder', 'Height(ex: 600)');
+  heightInput.classList.add('input');
   const inputButton = document.createElement('button');
   const removeButton = document.createElement('button');
+  inputButton.classList.add('btn__imgEdit');
+  removeButton.classList.add('btn__imgEdit');
   input.setAttribute("type", "file");
+  input.setAttribute('id', 'file');
   input.addEventListener('change', function(event) {
     if (event.target.files[0]) {
       let formData = new FormData();
@@ -61,8 +116,9 @@ function getImgElements(blockDiv) {
   });
   inputButton.textContent = 'Image新增/修改';
   removeButton.textContent = 'Image刪除';
+
   blockDiv.appendChild(div);
-  div.append(img, input, widthInput, heightInput, inputButton, removeButton);
+  div.append(imgContainer, label, input, widthInput, heightInput, inputButton, removeButton);
   return {
     img: img,
     imgInput: input,

+ 19 - 1
backstage/static/js/sidebar.js

@@ -8,6 +8,8 @@ $('[data-toggle=sidebar-colapse]').click(function() {
   SidebarCollapse();
 });
 
+const toTopButton = document.querySelector('.toTop');
+
 function SidebarCollapse () {
   $('.menu-collapsed').toggleClass('d-none');
   $('.sidebar-submenu').toggleClass('d-none');
@@ -24,4 +26,20 @@ function SidebarCollapse () {
   
   // Collapse/Expand icon
   $('#collapse-icon').toggleClass('fa-angle-double-left fa-angle-double-right');
-}
+}
+
+window.addEventListener('scroll', autoFade);
+toTopButton.addEventListener('click', scrollTop);
+function scrollTop() {
+  document.body.scrollTop = 0;
+  document.documentElement.scrollTop = 0;
+}
+
+function autoFade() {
+  if(document.body.scrollTop >= 300 || document.documentElement.scrollTop >= 300) {
+    toTopButton.style.opacity = 1;
+  } else {
+    toTopButton.style.opacity = 0;
+  }
+}
+

+ 211 - 3
backstage/static/styles/main.css

@@ -1,15 +1,220 @@
 @import url('https://fonts.googleapis.com/css?family=Montserrat');
 
 /*-------------------------------- END ----*/
+
+
+/* blocks in editors */
+.blockDiv {
+  box-shadow: 0px 0px 8px rgb(211, 211, 211);
+  padding: 1rem;
+  border-radius: 5px;
+  height: 30vh;
+  overflow: hidden;
+  position: relative;
+}
+.blockDiv::before {
+  position: absolute;
+  width: 100%;
+  height: 30px;
+  content: '';
+  bottom: 0px;
+  left: 0;
+  z-index: 3;
+  background: -moz-linear-gradient(top, rgba(255,255,255,0.397) 0%, rgba(255,255,255,1) 90%, rgba(255,255,255,1) 100%);
+  background: -webkit-linear-gradient(top,  rgba(255,255,255,0.397) 0%,rgba(255,255,255,1) 90%,rgba(255,255,255,1) 100%);
+  background: linear-gradient(to bottom,  rgba(255, 255, 255, 0.397) 0%,rgba(255,255,255,1) 90%,rgba(255,255,255,1) 100%);
+}
+.descBlock {
+  margin: 1.5rem 0;
+}
+.blockDiv__h2 {
+  font-size: 1.3rem;
+}
+
+/* btn in blocks editor */
+.btn__editOpen {
+  width: 2.5rem;
+  height: 2.5rem;
+  position: absolute;
+  right: 1rem;
+  top: 1rem;
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 50%;
+  box-shadow: 0 0 6px rgb(179, 179, 179);
+}
+
+[class='btn__^'] {
+  cursor: pointer;
+}
+.btn__arTitle {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+}
+.btn__addimg {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 50%;
+}
+.btn__descInput {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+  margin-right: 0.5rem;
+}
+.btn__remove {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+}
+.btn__titledesc {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+  margin-right: 0.5em;
+}
+.btn__titleInput {
+  margin-right: 0.5rem;
+}
+.btn__imgEdit {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+  display: inline-block;
+}
+
+[class^="btn__"] {
+  margin-right: 0.5rem;
+}
+
+.btn__submit {
+  padding: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+}
+
+/* img in blocks editor */
+.img__container {
+  width: 100%;
+  height: 15rem;
+  margin-bottom: 0.5rem;
+}
+.img__container img {
+  object-fit: cover;
+  width:100%;
+  height: 100%;
+}
+
+/* input in blocks editor */
+.input {
+  outline: none;
+  border: 1.5px solid rgb(240, 240, 240);
+  padding: 0.5rem;
+  min-width: 20%;
+  margin-right: 6px;
+  margin-bottom: 6px;
+}
+
+.textarea {
+  width: 100%;
+  height: 8rem;
+  border: 2px solid rgb(240, 240, 240);
+  border-radius: 5px;
+  outline: none;
+}
+.textarea:focus {
+  border: 2px solid grey;
+}
+
+#file {
+  display: none;
+}
+label[for="file"] {
+  display: block;
+  width: 6.5rem;
+  padding: 0.5rem;
+  margin-bottom: 0.5rem;
+  outline: none;
+  border: none;
+  border-radius: 10px;
+  background-color: rgb(224, 222, 222);
+  cursor: pointer;
+}
+
+/* btn in collections */
+.btn:active, .btn:focus {
+  transform: translateY(2px);
+}
+.btn__edit:active, .btn__edit:focus {
+  background-color: #b9bcbe !important;
+}
+.btn__delete:active, .btn__delete:focus {
+  background-color: #fc919c !important;
+}
+
+/* table in collections */
+.table__tdata {
+  display: flex;
+  justify-content: center;
+}
+
+/* toTop */
+.toTop {
+  position: fixed ;
+	right: 1%;
+  bottom: 2%;
+  width: 40px;
+  height: 40px;
+  border-radius: 50%;
+  box-shadow: 0 0 6px rgb(179, 179, 179);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.toTop:hover {
+  transform: translateY(-2px);
+  box-shadow: 0 0 3px rgb(179, 179, 179);
+}
+
+.toTop:active {
+  transform: translateY(2px);
+}
+
+.toTop i {
+  font-size: 1.6rem;
+  cursor: pointer;
+  color: hsl(209, 11%, 57%);
+  opacity: 0.8;
+  transition: all 0.4s;
+}
+
+/* functional class */
+.inline_block {
+  display: inline-block;
+}
+
 #body-row {
-  margin-left: 0;
-  margin-right: 0;
+  margin-right: 5%;
 }
 
 #sidebar-container {
   min-height: 100vh;
   background-color: #132644;
   padding: 0;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  z-index: 100;
   /* flex: unset; */
 }
 
@@ -22,7 +227,10 @@
   width: 100px;
 }
 
-/* ----------| Menu item*/    
+/* ----------| Menu item*/  
+#sidebar-container {
+  position: fixed;
+}
 #sidebar-container .list-group a {
   height: 50px;
   color: white;

+ 48 - 0
backstage/static/styles/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

+ 18 - 18
backstage/templates/collections.html

@@ -1,6 +1,6 @@
 {% extends "layout.html" %}
 {% block main %}
-<h1>{{ title }}</h1>
+<h1 class="h3">{{ title }}</h1>
 <table id="example" class="table table-striped table-bordered" cellspacing="0" width="60%">
   <thead>
     <tr>
@@ -8,28 +8,28 @@
       <th>標題</th>
       <th>順序</th>
       <th>顯示</th>
-      <th style="text-align:center;width:100px;">新增 <button type="button" data-func="dt-add" class="btn btn-success btn-xs dt-add">
+      <th style="text-align:center;width:80px;">新增 <button type="button" data-func="dt-add" class="btn btn-success btn-xs dt-add">
           <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
         </button></th>
     </tr>
   </thead>
   {% for idx in range(0, length) %}
-    <tbody>
-      <tr>
-        <td>{{ idx }}</td>
-        <td>{{ collections[idx].title }}</td>
-        <td>1</td>
-        <td>on</td>
-        <td>
-          <div>
-            <a class="btn btn-secondary btn-sm m-1" href="{{ url_for('editor.editor', url=collections[idx].url) }}">編輯</a>
-            <form action="{{ url_for('editor.remove', url=collections[idx].url) }}" method="POST">
-              <input class="btn btn-danger" type="submit" value="Delete">
-            </form>
-          </div>
-        </td>
-      </tr>
-    </tbody>
+  <tbody>
+    <tr>
+      <td>{{ idx }}</td>
+      <td>{{ collections[idx].title }}</td>
+      <td>1</td>
+      <td>on</td>
+      <td>
+        <div class="d-flex justify-content-center">
+          <a class="btn btn-outline-secondary m-1 btn__edit" href="{{ url_for('editor.editor', url=collections[idx].url) }}">編輯</a>
+          <form action="{{ url_for('editor.remove', url=collections[idx].url) }}" method="POST" class="m-1 inline_block">
+            <input class="btn btn-danger btn__delete" type="submit" value="刪除">
+          </form>
+        </div>
+      </td>
+    </tr>
+  </tbody>
   {% endfor %}
 </table>
 {% endblock main %}

+ 4 - 4
backstage/templates/editor.html

@@ -3,11 +3,11 @@
   <div class="ui segment">
     <div class="ui two column very relaxed grid">
       <div class="column">
-        <div>
-          <button id="title_button">Title</button>
+        <div class="mb-2">
+          <button class="btn__arTitle" id="title_button">新增標題</button>
         </div>
-          <div id= "editor_block" class="ui segment"></div>
-        <button id='submit_button'>Submit</button>
+          <div id= "editor_block"></div>
+        <button id='submit_button' class="btn__submit">Submit</button>
         <script type="text/json" id="url">{"url": "{{ url }}"}</script>
         <script type="text/javascript" src="{{url_for('static', filename='config.js')}}"></script>
         <script type="text/javascript" src="{{url_for('static', filename='js/utils.js')}}"></script>

+ 10 - 7
backstage/templates/layout.html

@@ -9,6 +9,10 @@
   <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'>
   <link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css">
+  <link rel="stylesheet"
+    href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt"
+    crossorigin="anonymous">
+  <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles/reset.css') }}">
   <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles/main.css') }}">
   
   <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>
@@ -28,7 +32,7 @@
 <body>
   <div class="row" id="body-row">
     <!-- Sidebar -->
-    <div id="sidebar-container" class="sidebar-expanded d-none d-md-block"><!-- d-* hiddens the Sidebar in smaller devices. Its itens can be kept on the Navbar 'Menu' -->
+    <div id="sidebar-container" class="sidebar-expanded col-3"><!-- d-* hiddens the Sidebar in smaller devices. Its itens can be kept on the Navbar 'Menu' -->
       <!-- Bootstrap List Group -->
       <ul class="list-group">
         <!-- Separator with title -->
@@ -133,18 +137,17 @@
             <span id="collapse-icon" class="fa fa-2x mr-3"></span>
             <span id="collapse-text" class="menu-collapsed">Collapse</span>
           </div>
-        </a>
-        <!-- Logo -->
-        <li class="list-group-item logo-separator d-flex justify-content-center">
-          <img src='https://v4-alpha.getbootstrap.com/assets/brand/bootstrap-solid.svg' width="30" height="30" />    
-        </li>   
+        </a> 
       </ul><!-- List Group END-->
     </div><!-- sidebar-container END -->
 
     <!-- MAIN -->
-    <div class="col">
+    <div class="col-9 my-4 col ml-auto w-100">
       {% block main %}{% endblock %}
     </div><!-- Main Col END -->
+    <div class='toTop'>
+      <i class='fas fa-arrow-up'></i>
+    </div>
   </div><!-- body-row END -->
   </div><!-- container -->
   <!-- partial -->