Skip to content
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

Задачи по 4му занятию #4

Merged
merged 21 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6c219bb
4е занятие - 1я задача
Dec 25, 2024
acddaea
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Dec 25, 2024
cb98718
4е занятие - 2я задача
Dec 25, 2024
770e937
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Dec 25, 2024
2ef4a68
4е занятие - 3я задача
Dec 25, 2024
6ca61dd
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Dec 26, 2024
a164aa6
4е занятие - 4я задача
Dec 26, 2024
5f587b8
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Dec 26, 2024
b4e47a4
4е занятие - 5я задача
Dec 26, 2024
2a11b27
4е занятие - 5я задача - поправил имена
Dec 26, 2024
22f8d7e
4е занятие - правки по ревью
Jan 14, 2025
2f7ee6c
4е занятие - правки по ревью 2
Jan 14, 2025
0c3e31e
4е занятие - правки по ревью 3
Jan 14, 2025
8962cab
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Jan 14, 2025
5ce3e4c
5е занятие - задача 1 SFC
Jan 15, 2025
31a4ae5
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Jan 15, 2025
45ed243
5е занятие - задача 2 MeetupCover с v-bind в CSS
Jan 15, 2025
5899a8b
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Jan 15, 2025
beee19a
4е занятие SFC - задача 3UiStretch
Jan 15, 2025
9808c51
Merge branch 'master' of https://github.com/js-tasks-ru/vue-20241213_…
Jan 15, 2025
f147d14
4е занятие SFC - правки
Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 48 additions & 37 deletions 03-components/10-MeetupView/MeetupView.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,57 @@
import { defineComponent } from 'vue'
import { UiAlert, UiContainer } from '@shgk/vue-course-ui'
import {defineComponent} from 'vue'
import {UiAlert, UiContainer} from '@shgk/vue-course-ui'
import MeetupAgenda from './MeetupAgenda.js'
import MeetupDescription from './MeetupDescription.js'
import MeetupCover from './MeetupCover.js'
import MeetupInfo from './MeetupInfo.js'
import './MeetupView.css'

export default defineComponent({
name: 'MeetupView',

components: {
UiAlert,
UiContainer,
},

template: `
<div>

<!-- Обложка митапа -->

<UiContainer>
<div class="meetup">
<div class="meetup__content">
<h2>Описание</h2>

<!-- Описание митапа -->

<h2>Программа</h2>

<!-- Программа митапа -->
<!-- Или при пустой программе - сообщение "Программа пока пуста..." в UiAlert -->
<UiAlert></UiAlert>

</div>
<div class="meetup__aside">

<!-- Краткая информация о митапе -->

<div class="meetup__aside-buttons"></div>
</div>
name: 'MeetupView',

components: {
UiAlert,
UiContainer,
MeetupCover,
MeetupDescription,
MeetupInfo,
MeetupAgenda
},

props: {
meetup: {
type: Object,
require: true
},
},

template: `
<div>
<MeetupCover :title="meetup.title" :image="meetup.image" />

<UiContainer>
<div class="meetup">
<div class="meetup__content">
<h2>Описание</h2>

<MeetupDescription :description="meetup.description" />

<h2>Программа</h2>

<!-- Программа митапа -->
<!-- Или при пустой программе - сообщение "Программа пока пуста..." в UiAlert -->
<MeetupAgenda v-if="meetup?.agenda?.length" :agenda="meetup.agenda" />
<UiAlert v-else>Программа пока пуста...</UiAlert>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meetup описан, как обязательный параметр, поэтому его не нужно проверять на null через ?.


</div>
<div class="meetup__aside">

<MeetupInfo :date="meetup.date" :organizer="meetup.organizer" :place="meetup.place" />

<div class="meetup__aside-buttons"></div>
</div>
</div>
</UiContainer>
</div>
</UiContainer>
</div>
`,
`,
})
30 changes: 26 additions & 4 deletions 03-components/20-UiClock/UiClock.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import { defineComponent } from 'vue'
import {defineComponent, onMounted, onUnmounted, ref} from 'vue'

const INTERVAL = 1000;
export default defineComponent({
name: 'UiClock',
name: 'UiClock',

setup() {},
setup() {
const currentTime = ref(null);
let timer = 0;

template: `<div class="clock">10:12:02</div>`,
function setCurrentTime() {
currentTime.value = new Date().toLocaleTimeString(navigator.language, {timeStyle: 'medium'});
}

onMounted(() => {
timer = setInterval(() => setCurrentTime(), INTERVAL)
setCurrentTime()
})

onUnmounted (() => {
clearInterval(timer)
})

return {
currentTime
}
},

template: `
<div class="clock">{{ currentTime }}</div>`,
})
41 changes: 22 additions & 19 deletions 03-components/30-removable-emails/EmailList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ import { defineComponent } from 'vue'
import EmailListItem from './EmailListItem.js'

export default defineComponent({
name: 'EmailList',
name: 'EmailList',

components: {
EmailListItem,
},
components: {
EmailListItem,
},

props: {
emails: {
type: Array,
required: true,
props: {
emails: {
type: Array,
required: true,
},
},
},

template: `
<ul class="emails-list unstyled-list" aria-label="Emails">
<EmailListItem
v-for="({ email, isMarked }, index) in emails"
:key="email"
:email="email"
:marked="isMarked"
/>
</ul>
`,
emits: ['remove'],

template: `
<ul class="emails-list unstyled-list" aria-label="Emails">
<EmailListItem
v-for="({ email, isMarked }, index) in emails"
:key="email"
:email="email"
:marked="isMarked"
@click-del="$emit('remove', index)"
/>
</ul>
`,
})
36 changes: 19 additions & 17 deletions 03-components/30-removable-emails/EmailListItem.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { defineComponent } from 'vue'
import {defineComponent} from 'vue'

export default defineComponent({
name: 'EmailListItem',
name: 'EmailListItem',

props: {
email: {
type: String,
required: true,
},
props: {
email: {
type: String,
required: true,
},

marked: {
type: Boolean,
default: false,
marked: {
type: Boolean,
default: false,
},
},
},

template: `
<li :class="{ marked }">
{{ email }}
<button type="button" aria-label="Удалить" @click.stop>❌</button>
</li>
`,
emits: ['click-del'],

template: `
<li :class="{ marked }">
{{ email }}
<button type="button" aria-label="Удалить" @click.stop="$emit('click-del')">❌</button>
</li>
`,
})
122 changes: 61 additions & 61 deletions 03-components/30-removable-emails/MarkedEmailsApp.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
import { computed, defineComponent, ref } from 'vue'
import { UiFormGroup, UiInput } from '@shgk/vue-course-ui'
import {computed, defineComponent, ref} from 'vue'
import {UiFormGroup, UiInput} from '@shgk/vue-course-ui'
import EmailList from './EmailList.js'

// Значения взяты из https://jsonplaceholder.typicode.com/comments
export function getEmails() {
return [
'[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]',
]
return [
'[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',

components: {
UiFormGroup,
UiInput,
EmailList,
},
components: {
UiFormGroup,
UiInput,
EmailList,
},

setup() {
const emails = ref(getEmails())
const query = ref('')
setup() {
const emails = ref(getEmails())
const query = ref('')

const markedEmails = computed(() => {
return emails.value.map(email => ({
email,
isMarked: !!(query.value && email.toLowerCase().includes(query.value.toLowerCase())),
}))
})
const markedEmails = computed(() => {
return emails.value.map(email => ({
email,
isMarked: !!(query.value && email.toLowerCase().includes(query.value.toLowerCase())),
}))
})

function removeEmailByIndex(index) {
emails.value.splice(index, 1)
}
function removeEmailByIndex(index) {
emails.value.splice(index, 1)
}

return {
query,
markedEmails,
removeEmailByIndex,
}
},
return {
query,
markedEmails,
removeEmailByIndex,
}
},

template: `
<div>
<UiFormGroup>
<UiInput v-model.trim="query" type="search" placeholder="Поиск" aria-label="Поиск" small />
</UiFormGroup>
<EmailList :emails="markedEmails" />
</div>
`,
template: `
<div>
<UiFormGroup>
<UiInput v-model.trim="query" type="search" placeholder="Поиск" aria-label="Поиск" small/>
</UiFormGroup>
<EmailList :emails="markedEmails" @remove="removeEmailByIndex"/>
</div>
`,
})
Loading
Loading