<script>
import { translateMenuTitle } from '@/utils/i18n'

export default {
  name: 'MenuItem',
  functional: true,
  props: {
    icon: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    }
  },
  render(h, context) {
    const { icon, title } = context.props
    const vnodes = []
    const vm = context.parent

    if (icon) {
      vnodes.push(<svg-icon icon-class={icon}/>)
    }

    if (title) {
      vnodes.push(<span slot='title'>{translateMenuTitle(title, vm && vm.$i18n && vm.$i18n.locale)}</span>)
    }
    return vnodes
  }
}
</script>
