-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3е занятие все задачи #3
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cea4b92
3е занятие - 1я задача
f0de114
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
fcc9b38
3е занятие - 2я задача
1f99271
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
9eb5a14
3е занятие - 3я задача
4b4925b
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
8fdcca9
3е занятие - 4я задача
cb5dcad
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
7c162c6
3е занятие - 5я задача
64c33a6
3е занятие - правки по 4й задаче
369f0cf
3е занятие - правки по 5й задаче
20b6067
3е занятие - правки по 5й задаче2
af3474c
3е занятие - правки по 5й задаче 3
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ` | ||
<div class="map" @click="handleClick"> | ||
<img class="map-image" src="./map.png" alt="Map" draggable="false" /> | ||
<span class="pin">📍</span> | ||
</div> | ||
`, | ||
template: ` | ||
<div class="map" @click="handleClick"> | ||
<img class="map-image" src="./map.png" alt="Map" draggable="false"/> | ||
<span class="pin" :style="{left: x+'px', top: y+'px'}">📍</span> | ||
</div> | ||
`, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ` | ||
<div class="calculator"> | ||
<input type="number" aria-label="First operand" /> | ||
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; | ||
} | ||
}) | ||
|
||
<div class="calculator__operators"> | ||
<label><input type="radio" name="operator" value="sum"/>➕</label> | ||
<label><input type="radio" name="operator" value="subtract"/>➖</label> | ||
<label><input type="radio" name="operator" value="multiply"/>✖</label> | ||
<label><input type="radio" name="operator" value="divide"/>➗</label> | ||
</div> | ||
return { | ||
value1, | ||
value2, | ||
operator, | ||
result | ||
} | ||
|
||
<input type="number" aria-label="Second operand" /> | ||
}, | ||
|
||
<div>=</div> | ||
template: ` | ||
<div class="calculator"> | ||
<input v-model="value1" type="number" aria-label="First operand"/> | ||
|
||
<output>0</output> | ||
</div> | ||
`, | ||
<div class="calculator__operators"> | ||
<label><input v-model="operator" type="radio" name="operator" value="sum"/>➕</label> | ||
<label><input v-model="operator" type="radio" name="operator" value="subtract"/>➖</label> | ||
<label><input v-model="operator" type="radio" name="operator" value="multiply"/>✖</label> | ||
<label><input v-model="operator" type="radio" name="operator" value="divide"/>➗</label> | ||
</div> | ||
|
||
<input v-model="value2" type="number" aria-label="Second operand"/> | ||
|
||
<div>=</div> | ||
|
||
<output>{{ result }}</output> | ||
</div> | ||
`, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,66 @@ | ||
import { computed, defineComponent, ref } from 'vue' | ||
import {computed, defineComponent, ref} from 'vue' | ||
|
||
// Значения взяты из https://jsonplaceholder.typicode.com/comments | ||
export const emails = [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
] | ||
|
||
export default defineComponent({ | ||
name: 'MarkedEmailsApp', | ||
name: 'MarkedEmailsApp', | ||
|
||
setup() {}, | ||
setup() { | ||
const search = ref(''); | ||
|
||
template: ` | ||
<div> | ||
<div class="form-group"> | ||
<input type="search" aria-label="Search" /> | ||
</div> | ||
<ul aria-label="Emails"> | ||
<li> | ||
[email protected] | ||
</li> | ||
<li class="marked"> | ||
[email protected] | ||
</li> | ||
</ul> | ||
</div> | ||
`, | ||
const filteredEmails = computed(() => { | ||
const arr = []; | ||
emails.forEach(email => arr.push({emailValue: email, isFlagged: search.value && email.toLowerCase().includes(search.value.toLowerCase())})); | ||
return arr; | ||
}) | ||
|
||
return { | ||
search, | ||
filteredEmails | ||
} | ||
}, | ||
|
||
template: ` | ||
<div> | ||
<div class="form-group"> | ||
<input v-model="search" type="search" aria-label="Search"/> | ||
</div> | ||
<ul aria-label="Emails"> | ||
<li | ||
v-for="(email, index) in filteredEmails" | ||
:key="index" | ||
:class="{'marked': email.isFlagged}" | ||
> | ||
{{ email.emailValue }} | ||
</li> | ||
</ul> | ||
</div> | ||
`, | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь хорошо подойдёт метод массива
map