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

решение задач из блока components #9

Merged
merged 9 commits into from
Feb 6, 2025

Conversation

KiraIsmailova
Copy link
Contributor

No description provided.

@jsru-1
Copy link
Contributor

jsru-1 commented Jan 25, 2025

Проверьте, пожалуйста, ваше решение, не все тесты прошли (PR не будет принят до тех пор, пока все добавленные задачи не будут решены).

@jsru-1
Copy link
Contributor

jsru-1 commented Jan 25, 2025

Добавляю преподавателя (@ShGKme) для код-ревью.

@jsru-1 jsru-1 requested a review from ShGKme January 25, 2025 20:07
@jsru-1
Copy link
Contributor

jsru-1 commented Jan 27, 2025

Решение было обновлено, посмотрим что скажет @ShGKme

@jsru-1
Copy link
Contributor

jsru-1 commented Jan 28, 2025

Решение было обновлено, посмотрим что скажет @ShGKme

Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

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

Требуется поправить передачу слота в 04-sfc/10-MeetupView-script-setup, остальные задачи приняты

import { defineComponent } from 'vue'

export default defineComponent({
name: 'UiTitle.js',
Copy link
Contributor

Choose a reason for hiding this comment

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

Расширения файла не должно быть в имени. Имя - просто UiTitle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

передача слота исправлена, + добавилась 1 задача - UiStretch

Comment on lines +5 to +17
export default defineComponent({
name: 'WeatherCardList',

components: {
WeatherCard,
},

template: `
<ul class="weather-list unstyled-list">
<WeatherCard />
</ul>
`,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Это компонент называется WeatherCardList (список карточек). Но выводит всего одну карточку.

Comment on lines +4 to +31
export default defineComponent({
name: 'WeatherCard',

setup() {
const weatherData = getWeatherData();
console.log(weatherData);
console.log(WeatherConditionIcons);

function checkWeatherCondition(key, obj) {
let result;
if (obj.hasOwnProperty(key)) {
result = obj[key];
} else {
result = '';
}
return result;
}

return {
weatherData,
WeatherConditionIcons,
checkWeatherCondition,
}
},

template: `
<li v-for="(weather, index) in weatherData" :key="index" class="weather-card"
:class="{'weather-card--night' : weather.current.dt < '07:00' }">
Copy link
Contributor

Choose a reason for hiding this comment

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

А этот компонент напротив - называется "карточка", но выводит список карточек по конкретным данным из сервиса.

Comment on lines +6 to +14
props: {
text: {
type: String,
},
},

template: `
<slot>{{ text }}</slot>
`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Этот компонент ничего не делает. Он просто рендерит своё содержимое, как есть, либо переданный текст.

То есть

<UiTitle>
  <any />
  <thing />
</UiTitle>
<UiTitle :text="someText" />

не отличается от

<any />
<thing />
{{ someText }}

Comment on lines 41 to 44
<UiAlert
v-if="!meetup.agenda || !meetup.agenda.length">
<slot>Программа пока пуста...</slot>
</UiAlert>
Copy link
Contributor

Choose a reason for hiding this comment

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

<slot> здесь использован некорректно.

Специальный тег <slot> используется для создания слота в текущем компоненте - места, содержимое которого будет определять родительский компонент.

В компонент <meetupView> не передают содержимое. И если бы передавали - странно если единственное передаваемое содержимое - это контент алерта об отсутствии программы.

Для передачи содержимого В <UiAlert> специальные теги не нужны, так как это содержимое слота по умолчанию.

В полной форме для передачи слота используется элемент <template> с директивой v-slot:slotName

<UiAlert 
  v-if="!meetup.agenda || !meetup.agenda.length">
  <template #default>Программа пока пуста...</template>
</UiAlert>

@@ -26,7 +24,8 @@ const bgStyle = computed(() => (props.image ? { '--bg-url': `url('${props.image}
background-position: center;
/* Если изображение присутствует - берём его из CSS переменной, установленной на элемент в шаблоне */
/* Иначе выводим изображение по умолчанию - var(--default-cover) */
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), var(--bg-url, var(--default-cover));
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
v-bind('props.image ? `var(--bg-url, url(' ${props.image}')` : `var(--default-cover)`');
Copy link
Contributor

Choose a reason for hiding this comment

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

Такое решение работает, но сгенерируется очень длинное и сложное имя CSS переменной, содержащее всё это выражение с экранированием спец символов.

Лучше такие выражения выносить в computed

@jsru-1
Copy link
Contributor

jsru-1 commented Feb 5, 2025

Проверьте, пожалуйста, ваше решение, не все тесты прошли (PR не будет принят до тех пор, пока все добавленные задачи не будут решены).

@jsru-1
Copy link
Contributor

jsru-1 commented Feb 5, 2025

Добавляю преподавателя (@ShGKme) для код-ревью.

@jsru-1 jsru-1 requested a review from ShGKme February 5, 2025 09:15
Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

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

Принято

Comment on lines +41 to +44
<UiAlert
v-if="!meetup.agenda || !meetup.agenda.length">
<template #default>Программа пока пуста...</template>
</UiAlert>
Copy link
Contributor

Choose a reason for hiding this comment

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

Напомню, что слот по умолчанию (default) можно передавать просто между тегами компонента

<UiAlert 
  v-if="!meetup.agenda || !meetup.agenda.length">
  <template #default>Программа пока пуста...</template>
</UiAlert>

@jsru-1 jsru-1 merged commit e3a1836 into js-tasks-ru:master Feb 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants