0.2.306 • Published 9 days ago

dataiads-nuxt-layer v0.2.306

Weekly downloads
-
License
MIT
Repository
github
Last release
9 days ago

dataiads-nuxt-layer

Generic layer for building Dataïads landing pages

installation

First install package using yarn add dataiads-nuxt-layer.

Update your ts config to use the layer.

export default defineNuxtConfig({
  ssr: false,

  typescript: {
    strict: true,
  },

  extends: [
    "dataiads-nuxt-layer"
  ],

  runtimeConfig: {
    public: {
      mirroredDomain: "https://shop.dataiads.io",
    }
  }
})

Available composables

  • useLpoConfig in production: loads the config provided by the backend. In dev: loads the config found in runtimeConfig.public.devLpoConfig.
  • useProduct a shortcut to access the main product data stored inside a global state. data is automatically fetched on application startup.
  • useCollectorData a shortcut to access the global collector data stored inside a global state. data is automatically fetched on application startup.
  • getCustomAttr, getCustomAttrInt, getCustomAttrFloat, getCustomAttrJSON to access product custom attributes
  • salePriceDifference to get a products regular/sale price difference as a percentage
  • mask a utility function to extract parts of a string using a regular expression
  • itemPart a utility that splits a string and returns the requested part based on an index

Plugins

LPO Config

Handles loading the LPOConfig available for use in the composable useLpoConfig. This currently allows you to modify only the locale and variation for the time being, but will soon be open to any field, allowing you to make your app configurable via the backoffice.

Other plugins may rely on this for execution, it should therefore never be disabled.

Core

Handles page initialization, error handling configuration and initial page data load. Provides the following functions:

  • $fetchProductRecommendations to retrieve product recommendations from Dataïads api
  • $errorRedirect to fallback on mirrored domain product page when a critical error occurs
  • $reportError to report an error to Dataïads api

These plugins cannot be disabled.

Urls

Exposes URL related functions

  • oriUrl(link: string, query?: Record<string, string>): string forces mirrored domain from runtime configuration on a link, with optional extra query paramaeters.
  • isSafeLink(link: string): boolean a utility function to check that a links redirects to the mirrored domain
  • addToCartUrl(searchParams?: Record<string, string>): string

Google Fonts

Loads Google Fonts on the page. The requested fonts must be listed in the runtime configuration using googleFonts attribute.

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
        googleFonts: [
            { family: "Roboto", weights: ["600", "800"] }
        ]
    }
  }
})

I18n

Enable internationalization using vue-i18n package. Translation data must be available inside locales/ directory. When adding a new locale data file, dont forget to import it inside locales/index.ts. Set a locale value to enable this plugin, using the locale key in LPO Config

Provides $t() helper in templates

GTM

Inject GTM snippet in the page. Configure using gtm key in LPO config.

{ "id": "FOOBAR" }

Multiple GTM instances are supported by providing an array instead of a string.

{ "id": ["GTM-1", "GTM-2"] }

OneTrust

Inject Onetrust snippet in the page. Configure using onetyrust key in LPO config.

{"dataDomainScript": "123456-1234-1234-4321-654321"}

Axeptio

Inject Axeptio snippet in the page. clientId is mandatory. All other attributes are also injected in the configuration object.

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
        axeptio: { clientId: "123", otherSetting: "value" }
    }
  }
})

Components

Image

Display images from remote sources using Dataïads caching proxy servers and CDN.

<Image src="https://shop.dataiads.io/assets/product.png" height="300" width="400"/>

Can be disabled using runtimeConfig.public.optimizeImageLoad flag in nuxt options.

Product Image

Main product image display. Shows the product primary image and any other additional images on the side. Style can be customized using the two image slots or using class props

<ProductImage :product="product" :max-additional-images="4"
  class="flex flex-row"
  aside-class="hidden md:flex flex-col flex-nowrap overflow-y-scroll scrollbar-hide"
>
  <template #main-image="{ src, alt }">
    <Image class="mx-auto w-auto" height="400" width="400" :src="src" :alt="alt" ref="ref"/>
  </template>

  <template #aside-image="{ src, alt, active }">
    <Image height="80" width="80" class="border border-transparent mr-2 mb-2 cursor-pointer" :class="{ border: active, 'border-black': active }" :src="src"
      :alt="alt" />
  </template>

  <template #previous-btn>
    <div class="mx-1 p-8 cursor-pointer bg-green-100">&lt;</div>
  </template>

  <template #next-btn>
    <div class="mx-1 p-8 cursor-pointer bg-green-100">&gt;</div>
  </template>
</ProductImage>

Slider

Horizontal or vertical slider with next / previous buttons on large screens. Can be toggled to autoscroll. Buttons and items can be configured using slots and class props

<Slider :items="items" autoscroll>
    <template #item="{item}">{{ item.name }}</template>
    <template #previous-btn="scope"> prev </template>
    <template #next-btn="scope"> next </template>
</Slider>

Pagination

Display pagination for Filter system. Style can be customized using class props on top level element or props for buttons.

<FiltersPagination :filter="filter" :max-visible-buttons="3" class="flex items-center justify-center gap-2">
  <template #previous-button>
    <div class="flex items-center justify-center w-[39px] h-[39px] rounded-full border border-grey3 hover:bg-third hover:border-third hover:text-white">
      <img class="pr-0.5" src="~/assets/icons/chevron-l.svg" width="10" height="" loading="lazy" alt=""/>
    </div>
  </template>

  <template #page-button="{ active, number }">
    <div v-if="active" class="flex items-center justify-center w-[39px] h-[39px] rounded-full border border-transparent text-white bg-secondary hover:bg-secondary hover:cursor-default">{{ number }}</div>
    <div v-else class="flex items-center justify-center w-[39px] h-[39px] rounded-full border border-grey3 hover:bg-third hover:border-third hover:text-white">{{ number }}</div>
  </template>

  <template #next-button>
    <div class="flex items-center justify-center w-[39px] h-[39px] rounded-full border border-grey3 hover:bg-third hover:border-third hover:text-white">
      <img class="pr-0.5" src="~/assets/icons/chevron-r.svg" width="10" height="" loading="lazy" alt=""/>
    </div>
  </template>
</FiltersPagination>

Search

A search input that redirects to the mirrored website search page with the value as a parameter. A custom input can be provided as a slot

<Search redirect-url="https://shop.dataiads.io/search?lang=fr_FR" redirect-search-param="q" v-slot="{ value, input }">
  <input :value="value" @input="input" placeholder="rechercher...">
</Search>

Reviews star

Display a a product review as starts. Use slots to customize displayed stars

<StarsRating
  :value="getCustomAttrFloat(product, 'review-value')"
  :max-value="10"
  :count="getCustomAttr(product, 'review-count')"
  class="flex space-x-1 items-center mt-2 my-3 w-full"
>
  <template #star-full>
    <svg class="text-star w-[14px] h-[14px]" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
      <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"></path>
    </svg>
  </template>

  <template #star-empty>
    <svg class="text-star_empty w-[14px] h-[14px]" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
      <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"></path>
    </svg>
  </template>

  <template #count="{ value, count }">
    <span class="text-xs font-semibold ml-1 text-subtitle">
        {{ value }} <span class="hidden md:inline">{{ count }}</span>
    </span>
  </template>
</StarsRating>

Price display

Display product price. Handles sale prices and collected data.

<PriceDisplay :product="product">
  <template #price="{ price, priceIntegerPart, priceDecimalPart }">
    <div class="text-tint-price text-[22px]">{{ price }} €</div>
    <div class="text-secondary mr-6">
      <span class="mx-2">&#x2022;</span> Non remisable
    </div>
  </template>

  <template #sale-price="{ price, salePrice, currency, priceDifference, priceIntegerPart, priceDecimalPart, salePriceIntegerPart, salePriceDecimalPart }">
    <div class="text-tint-price text-[22px]">{{ salePrice }} €</div>
    <div class="line-through text-subtitle ml-2">{{ price }} €</div>
    <div class="badge"> -{{priceDifference}}% </div>
  </template>
</PriceDisplay>

Drawer filters

This enables the opening of filters or any other component in a drawer. When opened, the scroll on the document body is disabled.

<template #filters-drawer>
  <Drawer
    class="z-[1001]"
    outsideClass="z-[1000]"
    @clickOutside="() => (openFiltersDrawer = false)"
    :open="openFiltersDrawer"
  >
    <template #drawer-content>
      <div class="w-full">
        <!-- Your custom filters component -->
        <Filters
          :close-drawer="() => (openFiltersDrawer = false)"
          variant="drawer"
          :filter="filter"
        />
      </div>
    </template>
  </Drawer>
</template>

Accordion

This component is an accessible component to use accordion behavior it's highly inspired by nuxtui accordion component

<Accordion :columns="columns">
  <template #append="{ open }">
    Some icons ...
  </template>
</Accordion>
0.2.306

9 days ago

0.2.305

13 days ago

0.2.304

17 days ago

0.2.303

23 days ago

0.2.293

1 month ago

0.2.292

1 month ago

0.2.290

1 month ago

0.289.0-beta.1

1 month ago

0.289.0-beta.0

2 months ago

0.288.0-beta.0

2 months ago

0.2.289

2 months ago

0.2.288

2 months ago

0.2.287

2 months ago

0.287.0-beta.0

2 months ago

0.2.286

2 months ago

0.284.0-beta.2

2 months ago

0.2.285

2 months ago

0.2.284-beta-1

2 months ago

0.2.284-beta.0

2 months ago

0.2.284

3 months ago

0.2.283

3 months ago

0.2.282

3 months ago

0.2.281

3 months ago

0.2.279

3 months ago

0.2.278

3 months ago

0.2.277

4 months ago

0.2.276

4 months ago

0.2.275

4 months ago

0.2.274

4 months ago

0.2.273

4 months ago

0.2.272

4 months ago

0.2.271

4 months ago

0.2.270

4 months ago

0.2.269

4 months ago

0.2.268

4 months ago

0.2.267

4 months ago

0.2.266

4 months ago

0.2.265

4 months ago

0.2.263

4 months ago

0.2.262

4 months ago

0.2.261

4 months ago

0.2.260

4 months ago

0.2.259

4 months ago

0.2.258

4 months ago

0.2.257

4 months ago

0.2.256

4 months ago

0.2.255

4 months ago

0.2.254

4 months ago

0.2.253

4 months ago

0.2.252

4 months ago

0.2.251

4 months ago

0.2.250

4 months ago

0.2.249

4 months ago

0.2.246

4 months ago

0.2.245

5 months ago

0.2.244

5 months ago

0.2.243

5 months ago

0.2.242

5 months ago

0.2.241

5 months ago

0.2.240

5 months ago

0.2.239

5 months ago

0.2.238

5 months ago

0.2.237

5 months ago

0.2.236

5 months ago

0.2.235

5 months ago

0.2.234

5 months ago

0.2.232

5 months ago

0.2.231

5 months ago

0.2.230

5 months ago

0.2.228

5 months ago

0.2.227

5 months ago

0.2.225

5 months ago

0.2.149

9 months ago

0.2.148

9 months ago

0.2.147

9 months ago

0.2.146

9 months ago

0.2.145

9 months ago

0.2.144

9 months ago

0.2.143

9 months ago

0.2.142

10 months ago

0.2.141

10 months ago

0.2.140

10 months ago

0.2.139

10 months ago

0.2.138

10 months ago

0.2.137

10 months ago

0.2.136

10 months ago

0.2.135

10 months ago

0.2.134

10 months ago

0.2.133

10 months ago

0.2.132

10 months ago

0.2.187

8 months ago

0.2.185

8 months ago

0.2.184

8 months ago

0.2.183

8 months ago

0.2.182

8 months ago

0.2.181

8 months ago

0.2.180

8 months ago

0.2.179

8 months ago

0.2.178

8 months ago

0.2.177

8 months ago

0.2.176

8 months ago

0.2.175

8 months ago

0.2.174

8 months ago

0.2.173

8 months ago

0.2.172

8 months ago

0.2.171

9 months ago

0.2.170

9 months ago

0.2.169

9 months ago

0.2.168

9 months ago

0.2.167

9 months ago

0.2.166

9 months ago

0.2.165

9 months ago

0.2.164

9 months ago

0.2.163

9 months ago

0.2.162

9 months ago

0.2.161

9 months ago

0.2.160

9 months ago

0.2.159

9 months ago

0.2.158

9 months ago

0.2.157

9 months ago

0.2.156

9 months ago

0.2.155

9 months ago

0.2.154

9 months ago

0.2.153

9 months ago

0.2.152

9 months ago

0.2.151

9 months ago

0.2.150

9 months ago

0.2.199

7 months ago

0.2.198

7 months ago

0.2.197

7 months ago

0.2.196

7 months ago

0.2.195

7 months ago

0.2.194

7 months ago

0.2.193

7 months ago

0.2.192

8 months ago

0.2.191

8 months ago

0.2.224

6 months ago

0.2.223

6 months ago

0.2.222

6 months ago

0.2.221

6 months ago

0.2.220

6 months ago

0.2.219

6 months ago

0.2.218

6 months ago

0.2.217

6 months ago

0.2.216

6 months ago

0.2.215

6 months ago

0.2.214

6 months ago

0.2.213

6 months ago

0.2.212

6 months ago

0.2.211

6 months ago

0.2.210

6 months ago

0.2.209

6 months ago

0.2.208

6 months ago

0.2.207

7 months ago

0.2.206

7 months ago

0.2.205

7 months ago

0.2.203

7 months ago

0.2.202

7 months ago

0.2.201

7 months ago

0.2.200

7 months ago

0.2.131

10 months ago

0.2.130

10 months ago

0.2.129

10 months ago

0.2.128

10 months ago

0.2.127

10 months ago

0.2.125

11 months ago

0.2.124

11 months ago

0.2.123

11 months ago

0.2.122

11 months ago

0.2.121

11 months ago

0.2.120

11 months ago

0.2.119

11 months ago

0.2.118

11 months ago

0.2.117

11 months ago

0.2.116

11 months ago

0.2.115

11 months ago

0.2.114

11 months ago

0.2.96

12 months ago

0.2.95

12 months ago

0.2.94

12 months ago

0.2.93

12 months ago

0.2.92

12 months ago

0.2.91

12 months ago

0.2.90

12 months ago

0.2.99

12 months ago

0.2.98

12 months ago

0.2.89

12 months ago

0.2.88

12 months ago

0.2.113

11 months ago

0.2.112

11 months ago

0.2.111

11 months ago

0.2.110

12 months ago

0.2.109

12 months ago

0.2.108

12 months ago

0.2.106

12 months ago

0.2.105

12 months ago

0.2.104

12 months ago

0.2.103

12 months ago

0.2.102

12 months ago

0.2.101

12 months ago

0.2.100

12 months ago

0.2.69

1 year ago

0.2.68

1 year ago

0.2.67

1 year ago

0.2.66

1 year ago

0.2.65

1 year ago

0.2.85

1 year ago

0.2.84

1 year ago

0.2.83

1 year ago

0.2.82

1 year ago

0.2.81

1 year ago

0.2.80

1 year ago

0.2.87

1 year ago

0.2.86

1 year ago

0.2.74

1 year ago

0.2.73

1 year ago

0.2.72

1 year ago

0.2.71

1 year ago

0.2.79

1 year ago

0.2.78

1 year ago

0.2.77

1 year ago

0.2.76

1 year ago

0.2.75

1 year ago

0.2.63

1 year ago

0.2.62

1 year ago

0.2.60

1 year ago

0.2.64

1 year ago

0.2.59

1 year ago

0.2.58

1 year ago

0.2.56

1 year ago

0.2.50

1 year ago

0.2.55

1 year ago

0.2.54

1 year ago

0.2.53

1 year ago

0.2.41

1 year ago

0.2.40

1 year ago

0.2.49

1 year ago

0.2.48

1 year ago

0.2.47

1 year ago

0.2.46

1 year ago

0.2.45

1 year ago

0.2.44

1 year ago

0.2.43

1 year ago

0.2.42

1 year ago

0.2.30

1 year ago

0.2.37

1 year ago

0.2.36

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.23

1 year ago

0.2.22

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.0.20

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.1.0

1 year ago

0.1.1

1 year ago

0.2.7

1 year ago

0.0.9

1 year ago

0.2.6

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago