From cea4b9225847383eaecb09dd8b8e6ac19449f081 Mon Sep 17 00:00:00 2001 From: Vombat Date: Tue, 24 Dec 2024 00:22:24 +0300 Subject: [PATCH 1/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=201=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/10-counter/CounterApp.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/02-basics-2/10-counter/CounterApp.js b/02-basics-2/10-counter/CounterApp.js index e0d3101..73a9276 100644 --- a/02-basics-2/10-counter/CounterApp.js +++ b/02-basics-2/10-counter/CounterApp.js @@ -1,9 +1,13 @@ -import { defineComponent } from 'vue' +import { defineComponent, ref } from 'vue' export default defineComponent({ name: 'CounterApp', - setup() {}, + setup() { + const counter = ref(0); + + return {counter} + }, template: `
@@ -11,15 +15,18 @@ export default defineComponent({ class="button button--secondary" type="button" aria-label="Decrement" - disabled + :disabled="counter <= 0" + @click="counter--" >➖ - 0 + {{ counter }}
`, From fcc9b38dc1bcd84b2c7e1951018c1a705195c81c Mon Sep 17 00:00:00 2001 From: Vombat Date: Tue, 24 Dec 2024 00:43:38 +0300 Subject: [PATCH 2/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=202=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/20-broken-map/MapApp.js | 58 +++++++++++++---------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/02-basics-2/20-broken-map/MapApp.js b/02-basics-2/20-broken-map/MapApp.js index 5aa14fc..1f51a84 100644 --- a/02-basics-2/20-broken-map/MapApp.js +++ b/02-basics-2/20-broken-map/MapApp.js @@ -1,39 +1,33 @@ -import { defineComponent, ref, watch } from 'vue' +import { defineComponent, ref } from 'vue' export default defineComponent({ - name: 'MapApp', + name: 'MapApp', - setup() { - // Реактивные переменные для хранения координат метки - let x = ref(0) - let y = ref(0) + setup() { + // Реактивные переменные для хранения координат метки + let x = ref(0) + let y = ref(0) - /** - * Обработчик клика по карте для установки координат метки - * @param {MouseEvent} event - */ - function handleClick(event) { - x = event.offsetX - y = event.offsetY - } + /** + * Обработчик клика по карте для установки координат метки + * @param {MouseEvent} event + */ + function handleClick(event) { + x.value = event.offsetX + y.value = event.offsetY + } - // Следим за X и Y для установки нового положения - watch([x, y], () => { - // Находим метку и изменяем её положение - const map = document.querySelector('.pin') - map.style.left = `${x}px` - map.style.top = `${y}px` - }) + return { + x, + y, + handleClick, + } + }, - return { - handleClick, - } - }, - - template: ` -
- Map - 📍 -
- `, + template: ` +
+ Map + 📍 +
+ `, }) From 9eb5a14e2af58579142314546fc7a2f549accb37 Mon Sep 17 00:00:00 2001 From: Vombat Date: Tue, 24 Dec 2024 01:01:02 +0300 Subject: [PATCH 3/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=203=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/30-calculator/CalculatorApp.js | 61 ++++++++++++++++------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/02-basics-2/30-calculator/CalculatorApp.js b/02-basics-2/30-calculator/CalculatorApp.js index 381b03f..56fbd8e 100644 --- a/02-basics-2/30-calculator/CalculatorApp.js +++ b/02-basics-2/30-calculator/CalculatorApp.js @@ -1,26 +1,53 @@ -import { defineComponent } from 'vue' +import {defineComponent, ref, computed} from 'vue' export default defineComponent({ - name: 'CalculatorApp', + name: 'CalculatorApp', - setup() {}, + setup() { + const value1 = ref(0); + const value2 = ref(0); + const operator = ref('sum'); - template: ` -
- + const result = computed(() => { + switch (operator.value) { + case 'sum': + return value1.value + value2.value + case 'subtract': + return value1.value - value2.value + case 'multiply': + return value1.value * value2.value + case 'divide': + return value1.value / value2.value + default: + return value1.value + value2.value; + } + }) -
- - - - -
+ return { + value1, + value2, + operator, + result + } - + }, -
=
+ template: ` +
+ - 0 -
- `, +
+ + + + +
+ + + +
=
+ + {{ result }} +
+ `, }) From 8fdcca9c2c46423e73a2c82d76f2f2995bbdfcd4 Mon Sep 17 00:00:00 2001 From: Vombat Date: Tue, 24 Dec 2024 01:17:15 +0300 Subject: [PATCH 4/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=204=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../40-marked-emails/MarkedEmailsApp.js | 100 ++++++++++-------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/02-basics-2/40-marked-emails/MarkedEmailsApp.js b/02-basics-2/40-marked-emails/MarkedEmailsApp.js index 8de9625..b750228 100644 --- a/02-basics-2/40-marked-emails/MarkedEmailsApp.js +++ b/02-basics-2/40-marked-emails/MarkedEmailsApp.js @@ -1,52 +1,66 @@ -import { computed, defineComponent, ref } from 'vue' +import {computed, defineComponent, ref} from 'vue' // Значения взяты из https://jsonplaceholder.typicode.com/comments export const emails = [ - 'Eliseo@gardner.biz', - 'Jayne_Kuhic@sydney.com', - 'Nikita@garfield.biz', - 'Lew@alysha.tv', - 'Hayden@althea.biz', - 'Presley.Mueller@myrl.com', - 'Dallas@ole.me', - 'Mallory_Kunze@marie.org', - 'Meghan_Littel@rene.us', - 'Carmen_Keeling@caroline.name', - 'Veronica_Goodwin@timmothy.net', - 'Oswald.Vandervort@leanne.org', - 'Kariane@jadyn.tv', - 'Nathan@solon.io', - 'Maynard.Hodkiewicz@roberta.com', - 'Christine@ayana.info', - 'Preston_Hudson@blaise.tv', - 'Vincenza_Klocko@albertha.name', - 'Madelynn.Gorczany@darion.biz', - 'Mariana_Orn@preston.org', - 'Noemie@marques.me', - 'Khalil@emile.co.uk', - 'Sophia@arianna.co.uk', - 'Jeffery@juwan.us', - 'Isaias_Kuhic@jarrett.net', + 'Eliseo@gardner.biz', + 'Jayne_Kuhic@sydney.com', + 'Nikita@garfield.biz', + 'Lew@alysha.tv', + 'Hayden@althea.biz', + 'Presley.Mueller@myrl.com', + 'Dallas@ole.me', + 'Mallory_Kunze@marie.org', + 'Meghan_Littel@rene.us', + 'Carmen_Keeling@caroline.name', + 'Veronica_Goodwin@timmothy.net', + 'Oswald.Vandervort@leanne.org', + 'Kariane@jadyn.tv', + 'Nathan@solon.io', + 'Maynard.Hodkiewicz@roberta.com', + 'Christine@ayana.info', + 'Preston_Hudson@blaise.tv', + 'Vincenza_Klocko@albertha.name', + 'Madelynn.Gorczany@darion.biz', + 'Mariana_Orn@preston.org', + 'Noemie@marques.me', + 'Khalil@emile.co.uk', + 'Sophia@arianna.co.uk', + 'Jeffery@juwan.us', + 'Isaias_Kuhic@jarrett.net', ] export default defineComponent({ - name: 'MarkedEmailsApp', + name: 'MarkedEmailsApp', - setup() {}, + setup() { + const search = ref(''); - template: ` -
-
- -
-
    -
  • - Eliseo@gardner.biz -
  • -
  • - Jayne_Kuhic@sydney.com -
  • -
-
- `, + const filteredEmails = computed(() => { + if (!search.value) return [] + return emails.filter(item => item.toLowerCase().includes(search.value.toLowerCase())) + }) + + return { + search, + emails, + filteredEmails + } + }, + + template: ` +
+
+ +
+
    +
  • + {{ email }} +
  • +
+
+ `, }) From 7c162c6ac43b09d2e97cde3031432eed82e867f3 Mon Sep 17 00:00:00 2001 From: Vombat Date: Tue, 24 Dec 2024 02:24:13 +0300 Subject: [PATCH 5/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=205=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../50-selected-meetup/SelectedMeetupApp.js | 176 +++++++++++------- 1 file changed, 107 insertions(+), 69 deletions(-) diff --git a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js index dad23b8..5dc62cf 100644 --- a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js +++ b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js @@ -1,78 +1,116 @@ -import { defineComponent } from 'vue' -// import { getMeetup } from './meetupsService.ts' +import { defineComponent, ref, onMounted, watch } from 'vue' +import { getMeetup } from './meetupsService.ts' export default defineComponent({ - name: 'SelectedMeetupApp', + name: 'SelectedMeetupApp', - setup() {}, + setup() { + const meetupId = ref(1); + const currentMeetup = ref(null); + async function getMeetupInfo(id) { + return await getMeetup(id) + } - template: ` -
-
- + onMounted(async () => { + currentMeetup.value = await getMeetupInfo(meetupId.value); -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
+ }) - -
+ watch(meetupId, async () => { + currentMeetup.value = await getMeetupInfo(meetupId.value); + }) -
-
-

Some Meetup Title

-
-
-
- `, + return { + getMeetupInfo, + meetupId, + currentMeetup + } + }, + + template: ` +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+

{{ currentMeetup.title }}

+

Загрузка

+
+
+ {{ currentMeetup }} +
+ `, }) From 64c33a6bfe0ede5b9b6c8730d5d9881675bfcbc6 Mon Sep 17 00:00:00 2001 From: Vombat Date: Wed, 25 Dec 2024 00:11:44 +0300 Subject: [PATCH 6/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=204=D0=B9=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/40-marked-emails/MarkedEmailsApp.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/02-basics-2/40-marked-emails/MarkedEmailsApp.js b/02-basics-2/40-marked-emails/MarkedEmailsApp.js index b750228..b87f639 100644 --- a/02-basics-2/40-marked-emails/MarkedEmailsApp.js +++ b/02-basics-2/40-marked-emails/MarkedEmailsApp.js @@ -36,13 +36,13 @@ export default defineComponent({ const search = ref(''); const filteredEmails = computed(() => { - if (!search.value) return [] - return emails.filter(item => item.toLowerCase().includes(search.value.toLowerCase())) + const arr = []; + emails.forEach(email => arr.push({emailValue: email, isFlagged: search.value && email.toLowerCase().includes(search.value.toLowerCase())})); + return arr; }) return { search, - emails, filteredEmails } }, @@ -54,11 +54,11 @@ export default defineComponent({
  • - {{ email }} + {{ email.emailValue }}
From 369f0cf041820b9143bb7b47bb709261fdf8d778 Mon Sep 17 00:00:00 2001 From: Vombat Date: Wed, 25 Dec 2024 00:15:05 +0300 Subject: [PATCH 7/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=205=D0=B9=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/50-selected-meetup/SelectedMeetupApp.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js index 5dc62cf..091a998 100644 --- a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js +++ b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js @@ -7,22 +7,19 @@ export default defineComponent({ setup() { const meetupId = ref(1); const currentMeetup = ref(null); - async function getMeetupInfo(id) { - return await getMeetup(id) - } onMounted(async () => { - currentMeetup.value = await getMeetupInfo(meetupId.value); + currentMeetup.value = await getMeetup(meetupId.value); }) watch(meetupId, async () => { - currentMeetup.value = await getMeetupInfo(meetupId.value); + currentMeetup.value = await getMeetup(meetupId.value); }) return { - getMeetupInfo, + getMeetup, meetupId, currentMeetup } From 20b606770d9e51e735d088eeadd1575e3ccdc91c Mon Sep 17 00:00:00 2001 From: Vombat Date: Wed, 25 Dec 2024 00:15:25 +0300 Subject: [PATCH 8/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=205=D0=B9=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/50-selected-meetup/SelectedMeetupApp.js | 1 - 1 file changed, 1 deletion(-) diff --git a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js index 091a998..d96dc66 100644 --- a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js +++ b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js @@ -107,7 +107,6 @@ export default defineComponent({

Загрузка

- {{ currentMeetup }} `, }) From af3474c87033318a14fda291d82e9835d0e0168b Mon Sep 17 00:00:00 2001 From: Vombat Date: Wed, 25 Dec 2024 00:20:21 +0300 Subject: [PATCH 9/9] =?UTF-8?q?3=D0=B5=20=D0=B7=D0=B0=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20-=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=205=D0=B9=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../50-selected-meetup/SelectedMeetupApp.js | 56 +++---------------- 1 file changed, 8 insertions(+), 48 deletions(-) diff --git a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js index d96dc66..2db5ea3 100644 --- a/02-basics-2/50-selected-meetup/SelectedMeetupApp.js +++ b/02-basics-2/50-selected-meetup/SelectedMeetupApp.js @@ -36,60 +36,20 @@ export default defineComponent({ >Предыдущий
-
+
- -
-
- - -
-
- - -
-
- - -
-
- - +