<template>
  <view class="container">
    <ModuleTitle :title="recommendTheme.themeName" />

    <view class="container-scroll font-size-0 scroll-x whitescape-nowrap">
      <view
        class="card-item bg-white inline-block rounded-20 mr-8"
        v-for="(item, index) in recommendTheme.recommendPostsList"
        :key="index"
        @click="sendReply(item)"
      >
        <view class="m-4 relative">
          <image
            class="card-img rounded-16 relative z-10"
            :src="item.coverPhoto"
            mode="aspectFill"
          />

          <view class="shadow absolute rounded-16"></view>
        </view>

        <view
          class="card-text color-171717 font-size-14 line-height-20 border-box"
        >
          {{ item.topic }}
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { defineProps } from "vue";
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
import ModuleTitle from "@/components/ModuleTitle/index.vue";

const props = defineProps({
  recommendTheme: {
    type: Object,
    default: {},
  },
});

const sendReply = (item) => {
  const topic = item.userInputContent || item.topic.replace(/^#/, "");
  uni.$emit(RECOMMEND_POSTS_TITLE, topic);
};
</script>

<style lang="scss" scoped>
@import "./styles/index.scss";
</style>
