2 files added
4 files modified
128 ■■■■■ changed files
09 - deeper into components/cmp-adv-01-starting-setup/src/App.vue 11 ●●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/components/BadgeList.vue 33 ●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue 35 ●●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/components/CourseGoals.vue 17 ●●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/components/UserInfo.vue 30 ●●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/main.js 2 ●●●●● patch | view | raw | blame | history
09 - deeper into components/cmp-adv-01-starting-setup/src/App.vue
@@ -7,6 +7,13 @@
      :info-text="activeUser.description"
      :role="activeUser.role"
    ></user-info>
    <course-goals>
      <template #default="slotProps">
        <h2>{{ slotProps.item }}</h2>
        <p>{{ slotProps['anotherProp'] }}</p>
        <p>{{ slotProps.ciccio }}</p>
      </template>
    </course-goals>
  </div>
</template>
@@ -14,6 +21,7 @@
import TheHeader from './components/TheHeader.vue';
import BadgeList from './components/BadgeList.vue';
import UserInfo from './components/UserInfo.vue';
import CourseGoals from './components/CourseGoals.vue';
export default {
  components: {
@@ -21,7 +29,8 @@
    // TheHeader: TheHeader,
    TheHeader,
    BadgeList,
    UserInfo
    UserInfo,
    CourseGoals,
  },
  data() {
    return {
09 - deeper into components/cmp-adv-01-starting-setup/src/components/BadgeList.vue
@@ -1,30 +1,29 @@
<template>
  <section>
    <h2>Available Badges</h2>
    <ul>
      <li>
        <base-badge type="admin" caption="ADMIN"></base-badge>
      </li>
      <li>
        <base-badge type="author" caption="AUTHOR"></base-badge>
      </li>
    </ul>
    <base-card>
      <template #header>
        <h2>Available Badges</h2>
      </template>
      <template #default>
        <ul>
          <li>
            <base-badge type="admin" caption="ADMIN"></base-badge>
          </li>
          <li>
            <base-badge type="author" caption="AUTHOR"></base-badge>
          </li>
        </ul>
      </template>
    </base-card>
  </section>
</template>
<style scoped>
section {
  margin: 2rem auto;
  max-width: 30rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
  padding: 1rem;
}
section h2 {
  margin: 0.5rem 0;
  color: #3a3a3a;
}
ul {
  list-style: none;
  margin: 0;
09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue
New file
@@ -0,0 +1,35 @@
<template>
    <div>
        <header v-if="$slots.header">
            <slot name="header">
                <!-- <h2>Default Title </h2> -->
            </slot>
        </header>
        <slot></slot>
    </div>
</template>
<script>
export default {
    mounted() {
        console.log(this.$slots);
    }
}
</script>
<style scoped>
div {
    margin: 2rem auto;
    max-width: 30rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
    padding: 1rem;
}
section header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
</style>
09 - deeper into components/cmp-adv-01-starting-setup/src/components/CourseGoals.vue
New file
@@ -0,0 +1,17 @@
<template>
    <ul>
        <li v-for="goal in goals" :key="goal">
           <slot :item="goal" another-prop="qualcosa" ciccio="ciccio"></slot>
        </li>
    </ul>
</template>
<script>
export default {
    data() {
        return {
            goals: ['Finish the course', 'Learn Vue'],
        }
    }
}
</script>
09 - deeper into components/cmp-adv-01-starting-setup/src/components/UserInfo.vue
@@ -1,10 +1,14 @@
<template>
  <section>
    <header>
      <h3>{{ fullName }}</h3>
      <base-badge :type="role" :caption="role.toUpperCase()"></base-badge>
    </header>
    <p>{{ infoText }}</p>
    <base-card>
      <template #header>
        <h3>{{ fullName }}</h3>
        <base-badge :type="role" :caption="role.toUpperCase()"></base-badge>
      </template>
      <template #default>
        <p>{{ infoText }}</p>
      </template>
    </base-card>
  </section>
</template>
@@ -13,19 +17,3 @@
  props: ['fullName', 'infoText', 'role'],
};
</script>
<style scoped>
section {
  margin: 2rem auto;
  max-width: 30rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
  padding: 1rem;
}
section header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
09 - deeper into components/cmp-adv-01-starting-setup/src/main.js
@@ -2,10 +2,12 @@
import App from './App.vue';
import BaseBadge from './components/BaseBadge.vue';
import BaseCard from './components/BaseCard.vue';
const app = createApp(App);
app.component('base-badge', BaseBadge);
app.component('base-card', BaseCard);
app.mount('#app');