Yulya-S 1 年間 前
コミット
d1952e87fb
3 ファイル変更156 行追加0 行削除
  1. 40 0
      css/css.css
  2. 66 0
      index.html
  3. 50 0
      scripts/script.vue

+ 40 - 0
css/css.css

@@ -0,0 +1,40 @@
+body { padding: 3%; }
+
+form {
+  width: 93%;
+  border-radius: 10px;
+  box-shadow: 10px 10px 20px 10px #a9b0b8;
+  padding: 3%;
+  display: flex; flex-direction: column;
+  gap: 3%;
+}
+.form_cont { font-size: 14pt; margin-left: 4%; display: grid; gap: 2%; }
+.tex { grid-template-columns: 20% 70%; }
+.tex > div > input { margin-right: 4%; }
+.check { grid-template-columns: 20% 50px; }
+form > div > label { text-align: right; }
+button {
+  width: 50%;
+  margin-left: 25%; margin-top: 2%; padding: 10px;
+  border-radius: 10px;
+}
+button:hover { background-color: #a9b0b8; }
+
+.notes {
+  width: 93%;
+  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2%;
+  margin-top: 5%; margin-left: 2%;
+}
+
+.note {
+  border-radius: 10px; border-top-left-radius: 0; border: 3px solid white;
+  box-shadow: 10px 10px 20px 5px #a9b0b8;
+  text-align: center;
+  padding: 20px;
+}
+.topic_box {
+  width: 100%;
+  display: grid; grid-template-columns: 10% 90%;
+}
+.topic_box > div { padding-top: 15px; font-size: 10pt; }
+.topic_box > button { width: 70%; }

+ 66 - 0
index.html

@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html lang="ru">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Заметки</title>
+    <link href="./css/css.css" rel="stylesheet" />
+  </head>
+  <body>
+    <div id="app">
+      <form @submit.prevent="add">
+        <h2>Добавление заметки:</h2>
+        <div class="form_cont tex" style="margin-bottom: 2%">
+          <label>Текст заметки:</label>
+          <input v-model="note.text" type="text" required/>
+        </div>
+        <div class="form_cont tex"  style="margin-bottom: 2%">
+          <label class="form-label">Тема заметки:</label>
+          <div>
+            <label>Домашнее</label>
+            <input v-model="note.topic" type="radio" value="Домашнее" />
+            <label>Встреча</label>
+            <input v-model="note.topic" type="radio" value="Встреча" />
+            <label>Работа</label>
+            <input v-model="note.topic" type="radio" value="Работа" />
+            <label>Учеба</label>
+            <input v-model="note.topic" type="radio" value="Учеба" />
+            <label>Покупки</label>
+            <input v-model="note.topic" type="radio" value="Покупки" />
+            <label>Развлечение</label>
+            <input v-model="note.topic" type="radio" value="Развлечение" />
+          </div>
+        </div>
+        <div class="form_cont check" style="margin-bottom: 2%">
+          <label>Важная:</label>
+          <input v-model="note.important" type="checkbox"/>
+        </div>
+        <div class="form_cont tex" style="margin-bottom: 2%">
+          <label>Цвет заметки:</label>
+          <select v-model="note.color">
+            <option value="white">Белая</option>
+            <option value="yellow">Желтая</option>
+            <option value="blue">Голубая</option>
+            <option value="pink">Розовая</option>
+            <option value="purple">фиолетовая</option>
+            <option value="green">зеленая</option>
+          </select>
+        </div>
+
+        <button type="submit" class="">Добавить заметку</button>
+      </form>
+
+      <div class="notes">
+        <div v-for="(note, index) in getNotes" class="note" v-bind:style="{ backgroundColor: note.color, borderColor: note.important ? 'red' : note.color }">
+          <h3>{{ note.text }}</h3>
+          <div class="topic_box">
+            <div>{{ note.topic }}</div>
+            <button @click="remove(index)" name="button">удалить заметку</button>
+          </div>
+        </div>
+      </div>
+    </div>
+    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
+    <script src="./scripts/script.vue"></script>
+  </body>
+</html>

+ 50 - 0
scripts/script.vue

@@ -0,0 +1,50 @@
+new Vue({
+        el: '#app',
+        data: {
+          note: {
+            text: '',
+            topic: "Домашнее",
+            color: "white",
+            important: false
+          },
+          notes: []
+        },
+        mounted() {
+          if (localStorage.getItem('notes')) {
+            try {
+              this.notes = JSON.parse(localStorage.getItem('notes'));
+            } catch(e) {
+              localStorage.removeItem('notes');
+            }
+          }
+        },
+         computed: {
+          getNotes() {
+            return this.notes.slice()
+          }
+        },
+        methods: {
+          add() {
+            if (this.note.topic.length == 0 ) this.note.topic = "Домашнее";
+            if (this.note.color == "yellow") this.note.color = "#f7f7c1";
+            else if (this.note.color == "blue") this.note.color = "#e3f3ff";
+            else if (this.note.color == "pink") this.note.color = "#f2d0ea";
+            else if (this.note.color == "purple") this.note.color = "#d8bfd8";
+            else if (this.note.color == "green") this.note.color = "#c2ff99";
+            this.notes.push({ ...this.note });
+            this.saveData();
+            this.note.text = '';
+            this.note.color = "white";
+            this.note.important = false;
+            this.note.topic = "Домашнее";
+          },
+          remove(index) {
+            this.notes.splice(index, 1);
+            this.saveData();
+          },
+          saveData() {
+            const parsed = JSON.stringify(this.notes);
+            localStorage.setItem('notes', parsed);
+          }
+        }
+      });