Compare commits
17 Commits
from-WP2-t
...
a2ca4ec35e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2ca4ec35e | ||
|
|
316d305cba | ||
|
|
b4bb0f9036 | ||
|
|
e2e031b7c5 | ||
|
|
e5d0c2464d | ||
|
|
9e6eb9f8b2 | ||
|
|
c0fa763ce8 | ||
|
|
b78155bb6a | ||
|
|
eb1941c16a | ||
|
|
b0138067b2 | ||
|
|
28f8b038c1 | ||
|
|
2d96a0d9e7 | ||
|
|
bce683c0eb | ||
|
|
cd32863494 | ||
|
|
c5603e6789 | ||
|
|
7baf2fbf0c | ||
|
|
0905a4662e |
@@ -10,8 +10,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: LS
|
||||||
|
run: cd / && cat .dockerenv
|
||||||
|
- name: Test SSH access
|
||||||
|
run: ssh -Tv git@koptilnya.xyz
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ssh-key: '${{ secrets.SSH_PRIVATE_KEY }}'
|
||||||
|
ssh-strict: false
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
74
README.md
74
README.md
@@ -1,75 +1,7 @@
|
|||||||
# Nuxt Minimal Starter
|
node.js 20.19.0
|
||||||
|
|
||||||
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
yarn
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
Make sure to install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm install
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm install
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development Server
|
|
||||||
|
|
||||||
Start the development server on `http://localhost:3000`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm dev
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn dev
|
yarn dev
|
||||||
|
|
||||||
# bun
|
https://wp.koptilnya.xyz/wp-admin/edit.php?post_type=product
|
||||||
bun run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Production
|
|
||||||
|
|
||||||
Build the application for production:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm build
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun run build
|
|
||||||
```
|
|
||||||
|
|
||||||
Locally preview production build:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run preview
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm preview
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn preview
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun run preview
|
|
||||||
```
|
|
||||||
|
|
||||||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
|
||||||
12724
api/Api.ts
12724
api/Api.ts
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
import api from '~/api/instance'
|
import api from '~/api/instance'
|
||||||
|
|
||||||
export const getProductsDetail = async (productId: number) =>
|
export const getProductsDetail = async (productId: number) =>
|
||||||
await api.wc.v1ProductsDetail(productId)
|
await api.wc.v3ProductsDetail(productId)
|
||||||
|
|||||||
4
api/endpoints/getProductsVariationsList.ts
Normal file
4
api/endpoints/getProductsVariationsList.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import api from '~/api/instance'
|
||||||
|
|
||||||
|
export const getProductsVariationsList = async (productId: number) =>
|
||||||
|
await api.wc.v3ProductsVariationsList(productId)
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './getProductsDetail'
|
export * from './getProductsDetail'
|
||||||
|
export * from './getProductsVariationsList'
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export * from './useGetProductsDetail'
|
export * from './useGetProductsDetail'
|
||||||
|
export * from './useGetProductsVariationsList'
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { useQuery } from '@tanstack/vue-query'
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
import { unref, watch } from 'vue'
|
import { unref } from 'vue'
|
||||||
import { getProductsDetail } from '~/api/endpoints'
|
import { getProductsDetail } from '~/api/endpoints'
|
||||||
|
|
||||||
export const useGetProductsDetail = (productId: MaybeRef<number>) => {
|
export const useGetProductsDetail = (productId: MaybeRef<number>) => {
|
||||||
const q = useQuery({
|
return useQuery({
|
||||||
queryKey: ['get-products-detail', unref(productId)],
|
queryKey: ['get-products-detail', productId],
|
||||||
queryFn: () => getProductsDetail(unref(productId)),
|
queryFn: () => getProductsDetail(unref(productId)),
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => productId, () => q.refetch())
|
|
||||||
|
|
||||||
return q
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
api/queries/useGetProductsVariationsList.ts
Normal file
10
api/queries/useGetProductsVariationsList.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { useQuery } from '@tanstack/vue-query'
|
||||||
|
import { unref } from 'vue'
|
||||||
|
import { getProductsVariationsList } from '~/api/endpoints'
|
||||||
|
|
||||||
|
export const useGetProductsVariationsList = (productId: MaybeRef<number>) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['get-products-variations-list', productId],
|
||||||
|
queryFn: () => getProductsVariationsList(unref(productId)),
|
||||||
|
})
|
||||||
|
}
|
||||||
8
app.vue
8
app.vue
@@ -1,11 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<UApp>
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</div>
|
</UApp>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
@use '@/assets/scss/main' as *;
|
|
||||||
</style>
|
|
||||||
|
|||||||
2
assets/css/main.css
Normal file
2
assets/css/main.css
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
@import "@nuxt/ui";
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
// Breakpoints
|
|
||||||
$breakpoint-sm: 576px;
|
|
||||||
$breakpoint-md: 768px;
|
|
||||||
$breakpoint-lg: 992px;
|
|
||||||
$breakpoint-xl: 1200px;
|
|
||||||
$breakpoint-xxl: 1400px;
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
/* Modern CSS Reset */
|
|
||||||
*,
|
|
||||||
*::before,
|
|
||||||
*::after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove default margin and padding */
|
|
||||||
body,
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6,
|
|
||||||
p,
|
|
||||||
figure,
|
|
||||||
blockquote,
|
|
||||||
dl,
|
|
||||||
dd {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set core body defaults */
|
|
||||||
body {
|
|
||||||
min-height: 100vh;
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
text-rendering: optimizeSpeed;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove list styles on ul, ol elements */
|
|
||||||
ul,
|
|
||||||
ol {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A elements that don't have a class get default styles */
|
|
||||||
a:not([class]) {
|
|
||||||
text-decoration-skip-ink: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make images easier to work with */
|
|
||||||
img,
|
|
||||||
picture {
|
|
||||||
max-width: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inherit fonts for inputs and buttons */
|
|
||||||
input,
|
|
||||||
button,
|
|
||||||
textarea,
|
|
||||||
select {
|
|
||||||
font: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove all animations and transitions for people that prefer not to see them */
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
*,
|
|
||||||
*::before,
|
|
||||||
*::after {
|
|
||||||
animation-duration: 0.01ms !important;
|
|
||||||
animation-iteration-count: 1 !important;
|
|
||||||
transition-duration: 0.01ms !important;
|
|
||||||
scroll-behavior: auto !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
// Brand Colors
|
|
||||||
$brand-primary: #4f46e5; // Основной цвет бренда
|
|
||||||
$brand-secondary: #10b981; // Вторичный цвет бренда
|
|
||||||
|
|
||||||
// Neutral Colors
|
|
||||||
$neutral-50: #f9fafb; // Самый светлый оттенок
|
|
||||||
$neutral-100: #f3f4f6; // Светлый фон
|
|
||||||
$neutral-200: #e5e7eb; // Светлая граница
|
|
||||||
$neutral-300: #d1d5db; // Светлый текст
|
|
||||||
$neutral-400: #9ca3af; // Неактивный текст
|
|
||||||
$neutral-500: #6b7280; // Средний текст
|
|
||||||
$neutral-600: #4b5563; // Основной текст
|
|
||||||
$neutral-700: #374151; // Темный текст
|
|
||||||
$neutral-800: #1f2937; // Очень темный текст
|
|
||||||
$neutral-900: #111827; // Самый темный оттенок
|
|
||||||
|
|
||||||
// Semantic Colors
|
|
||||||
$text-primary: $neutral-900; // Основной текст
|
|
||||||
$text-secondary: $neutral-600; // Вторичный текст
|
|
||||||
$text-muted: $neutral-400; // Неактивный текст
|
|
||||||
$background-primary: $neutral-50; // Основной фон
|
|
||||||
$background-secondary: $neutral-100; // Вторичный фон
|
|
||||||
$border-color: $neutral-200; // Цвет границ
|
|
||||||
|
|
||||||
// Status Colors
|
|
||||||
$success: #10b981; // Успех
|
|
||||||
$warning: #f59e0b; // Предупреждение
|
|
||||||
$error: #ef4444; // Ошибка
|
|
||||||
$info: #3b82f6; // Информация
|
|
||||||
|
|
||||||
// Basic Colors
|
|
||||||
$black: #000000;
|
|
||||||
$dark-background: #13141c;
|
|
||||||
$dark-grey: #171821;
|
|
||||||
$grey-selector: #1b1b24;
|
|
||||||
$grey-blocks: #1e1f2b;
|
|
||||||
$grey-text-highlight: #23242c;
|
|
||||||
$grey-blocks-hover: #262736;
|
|
||||||
$grey-menu: #292a32;
|
|
||||||
$grey-stroke: #323442;
|
|
||||||
$grey-paginator: #323442;
|
|
||||||
$grey-icons: #5b5e6d;
|
|
||||||
$grey-text: #7f808b;
|
|
||||||
$grey-text2: #9A9BAB;
|
|
||||||
$white: #ffffff;
|
|
||||||
$greeen: #9fff00;
|
|
||||||
$greeen-dark: #43611b;
|
|
||||||
$red: #ff4141;
|
|
||||||
$red-dark: #3e232c;
|
|
||||||
$green: #20b26c;
|
|
||||||
$green-dark: #133324;
|
|
||||||
$gold: #ffc35c;
|
|
||||||
|
|
||||||
// Form Elements
|
|
||||||
$grey-form: #1c1d26;
|
|
||||||
$grey-form-stroke: #323442;
|
|
||||||
$grey-button: #21222d;
|
|
||||||
$grey-button-2: #32323c;
|
|
||||||
$grey-button-stroke: #5b5e6d;
|
|
||||||
|
|
||||||
// Export colors for JavaScript
|
|
||||||
:export {
|
|
||||||
black: $black;
|
|
||||||
darkBackground: $dark-background;
|
|
||||||
darkGrey: $dark-grey;
|
|
||||||
greySelector: $grey-selector;
|
|
||||||
greyBlocks: $grey-blocks;
|
|
||||||
greyTextHighlight: $grey-text-highlight;
|
|
||||||
greyBlocksHover: $grey-blocks-hover;
|
|
||||||
greyMenu: $grey-menu;
|
|
||||||
greyStroke: $grey-stroke;
|
|
||||||
greyPaginator: $grey-paginator;
|
|
||||||
greyIcons: $grey-icons;
|
|
||||||
greyText: $grey-text;
|
|
||||||
white: $white;
|
|
||||||
greeen: $greeen;
|
|
||||||
greeenDark: $greeen-dark;
|
|
||||||
red: $red;
|
|
||||||
redDark: $red-dark;
|
|
||||||
green: $green;
|
|
||||||
greenDark: $green-dark;
|
|
||||||
greyForm: $grey-form;
|
|
||||||
greyFormStroke: $grey-form-stroke;
|
|
||||||
greyButton: $grey-button;
|
|
||||||
greyButton2: $grey-button-2;
|
|
||||||
greyButtonStroke: $grey-button-stroke;
|
|
||||||
gold: $gold;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
@use 'main' as *;
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Inter', sans-serif;
|
|
||||||
color: $text-color;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
@include container;
|
|
||||||
}
|
|
||||||
@@ -1,23 +1,6 @@
|
|||||||
@use 'reset';
|
|
||||||
@use 'colors' as *;
|
|
||||||
@use 'typography' as *;
|
@use 'typography' as *;
|
||||||
@use 'utils' as *;
|
@use 'utils' as *;
|
||||||
|
|
||||||
// Base styles
|
|
||||||
html {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 1.5;
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: $font-family-base;
|
|
||||||
color: white;
|
|
||||||
background-color: black;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Typography
|
// Typography
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
@@ -25,7 +8,6 @@ h3,
|
|||||||
h4,
|
h4,
|
||||||
h5,
|
h5,
|
||||||
h6 {
|
h6 {
|
||||||
font-weight: $font-weight-semibold;
|
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
@@ -42,37 +24,7 @@ h3 {
|
|||||||
@include h3('h3');
|
@include h3('h3');
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
button {
|
button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-family: inherit;
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Forms
|
|
||||||
input,
|
|
||||||
textarea,
|
|
||||||
select {
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
color: inherit;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: $brand-primary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,7 @@
|
|||||||
@use 'sass:color';
|
@use 'sass:color';
|
||||||
@use 'sass:math';
|
|
||||||
@use 'breakpoints' as *;
|
|
||||||
|
|
||||||
// Mixins
|
|
||||||
@mixin responsive($breakpoint) {
|
|
||||||
@media (min-width: $breakpoint) {
|
|
||||||
@content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin mobile {
|
@mixin mobile {
|
||||||
@media (max-width: $breakpoint-md) {
|
@media (max-width: 768px) {
|
||||||
@content;
|
@content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
132
components/ProductDescription.vue
Normal file
132
components/ProductDescription.vue
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<template>
|
||||||
|
<div class="product-description">
|
||||||
|
<h1>{{ productsData?.name }}</h1>
|
||||||
|
|
||||||
|
<h2>{{ currentVariant?.price }} <Icon name="ph:currency-rub" /></h2>
|
||||||
|
|
||||||
|
<div class="product-description__variations">
|
||||||
|
<div
|
||||||
|
v-for="variation in productsVariationsData"
|
||||||
|
:key="variation?.id"
|
||||||
|
@click="() => currentVariantId = variation?.id"
|
||||||
|
>
|
||||||
|
<div class="product-description__variation">
|
||||||
|
<img width="80" :src="variation?.image?.src" :alt="variation?.image?.src">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{{ `Цвет: ${t(`colors.${currentColor}`)}` }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{{ `Материал: ${t(`materials.${currentMaterial}`)}` }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
Размер
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="product-description__sizes">
|
||||||
|
<div
|
||||||
|
v-for="size in sizes"
|
||||||
|
:key="size"
|
||||||
|
class="product-description__size"
|
||||||
|
@click="() => currentSize = size"
|
||||||
|
>
|
||||||
|
<UButton block :label="size" :variant="currentSize === size ? undefined : 'outline'" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UButton class="justify-content-center" label="Добавить в корзину" size="xl" />
|
||||||
|
|
||||||
|
<UAccordion :items="items" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { AccordionItem } from '@nuxt/ui'
|
||||||
|
import { useCurrentProduct, useProduct } from '~/composables'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const { productsData, productsVariationsData, sizes } = useProduct()
|
||||||
|
const { currentVariant, currentVariantId, currentColor, currentMaterial } = useCurrentProduct()
|
||||||
|
|
||||||
|
const currentSize = ref(0)
|
||||||
|
|
||||||
|
const items = ref<AccordionItem[]>([
|
||||||
|
{
|
||||||
|
label: 'Описание товара',
|
||||||
|
icon: 'i-heroicons-document-text',
|
||||||
|
content: productsData?.value?.description,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Состав и параметры',
|
||||||
|
icon: 'i-heroicons-beaker',
|
||||||
|
content: 'хлопок 100%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Рекомендации по уходу',
|
||||||
|
icon: 'i-heroicons-sparkles',
|
||||||
|
content: 'Бережная стирка при максимальной температуре 30ºС\nНе отбеливать\nМашинная сушка запрещена\nГлажение при 110ºС\nПрофессиональная сухая чистка',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Доставка и оплата',
|
||||||
|
icon: 'i-heroicons-truck',
|
||||||
|
content: 'Доставка в пункт выдачи',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Возврат и обмен',
|
||||||
|
icon: 'i-heroicons-arrow-path',
|
||||||
|
content: 'Возврат в течение 14 дней\nОбмен размера в течение 7 дней',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.product-description {
|
||||||
|
padding-top: 50px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
width: 400px;
|
||||||
|
padding-inline: 30px;
|
||||||
|
|
||||||
|
&__variations {
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: white;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__sizes {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__size {
|
||||||
|
width: 65px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__variation {
|
||||||
|
img {
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
25
components/ProductImages.vue
Normal file
25
components/ProductImages.vue
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<div class="product-images">
|
||||||
|
<div
|
||||||
|
v-for="image in currentVariantImages?.slice(0, 5)"
|
||||||
|
:key="image?.id"
|
||||||
|
>
|
||||||
|
<img width="100%" :src="image?.src" :alt="image?.src">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useCurrentProduct } from '~/composables'
|
||||||
|
|
||||||
|
const { currentVariantImages } = useCurrentProduct()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.product-images {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
2
composables/index.ts
Normal file
2
composables/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './useCurrentProduct'
|
||||||
|
export * from './useProduct'
|
||||||
31
composables/useCurrentProduct.ts
Normal file
31
composables/useCurrentProduct.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { createSharedComposable } from '@vueuse/core'
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
export const useCurrentProduct = createSharedComposable(() => {
|
||||||
|
const { defaultVariant, productsData, productsVariationsData, getAttribute } = useProduct()
|
||||||
|
|
||||||
|
const currentVariantId = ref(defaultVariant?.value?.id)
|
||||||
|
|
||||||
|
const currentVariant = computed(() =>
|
||||||
|
productsVariationsData?.value?.find(variation => variation?.id === currentVariantId?.value))
|
||||||
|
|
||||||
|
const currentColor = computed(() => getAttribute(currentVariant?.value?.attributes, 'color')?.option)
|
||||||
|
const currentMaterial = computed(() => getAttribute(currentVariant?.value?.attributes, 'material')?.option)
|
||||||
|
|
||||||
|
const currentVariantImages = computed(() =>
|
||||||
|
productsData?.value?.images?.filter(img => img?.src?.includes(`${currentColor.value}_${currentMaterial.value}_`)))
|
||||||
|
|
||||||
|
watch(() => defaultVariant.value, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
currentVariantId.value = newValue.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentVariantId,
|
||||||
|
currentVariant,
|
||||||
|
currentColor,
|
||||||
|
currentMaterial,
|
||||||
|
currentVariantImages,
|
||||||
|
}
|
||||||
|
})
|
||||||
39
composables/useProduct.ts
Normal file
39
composables/useProduct.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { useGetProductsDetail, useGetProductsVariationsList } from '~/api/queries'
|
||||||
|
|
||||||
|
export const useProduct = () => {
|
||||||
|
const { data: productsData } = useGetProductsDetail(79)
|
||||||
|
const { data: productsVariationsData } = useGetProductsVariationsList(79)
|
||||||
|
|
||||||
|
function getAttribute(attributes: string[], name: string) {
|
||||||
|
return attributes?.find(attribute => attribute?.name === name)
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultColor = computed(() => getAttribute(productsData?.value?.default_attributes, 'color')?.option)
|
||||||
|
const defaultMaterial = computed(() => getAttribute(productsData?.value?.default_attributes, 'material')?.option)
|
||||||
|
const defaultSize = computed(() => getAttribute(productsData?.value?.default_attributes, 'size')?.option)
|
||||||
|
|
||||||
|
const defaultVariant = computed(() => {
|
||||||
|
return productsVariationsData?.value?.find(variation => getAttribute(variation?.attributes, 'color')?.option === defaultColor?.value)
|
||||||
|
&& productsVariationsData?.value?.find(variation => getAttribute(variation?.attributes, 'material')?.option === defaultMaterial?.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const colors = computed(() => getAttribute(productsData?.value?.attributes, 'color')?.options)
|
||||||
|
const materials = computed(() => getAttribute(productsData?.value?.attributes, 'material')?.options)
|
||||||
|
const sizes = computed(() => getAttribute(productsData?.value?.attributes, 'size')?.options)
|
||||||
|
|
||||||
|
return {
|
||||||
|
productsData,
|
||||||
|
productsVariationsData,
|
||||||
|
|
||||||
|
defaultColor,
|
||||||
|
defaultMaterial,
|
||||||
|
defaultSize,
|
||||||
|
defaultVariant,
|
||||||
|
|
||||||
|
colors,
|
||||||
|
materials,
|
||||||
|
sizes,
|
||||||
|
|
||||||
|
getAttribute,
|
||||||
|
}
|
||||||
|
}
|
||||||
5
i18n/locales/en.json
Normal file
5
i18n/locales/en.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"colors": {
|
||||||
|
"black": "black"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
i18n/locales/ru.json
Normal file
11
i18n/locales/ru.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"colors": {
|
||||||
|
"black": "черный",
|
||||||
|
"beige": "бежевый",
|
||||||
|
"grey": "серый"
|
||||||
|
},
|
||||||
|
"materials": {
|
||||||
|
"cotton": "хлопок",
|
||||||
|
"cotton-polyester": "хлопок-полиэстер"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<header class="header">
|
<header class="header">
|
||||||
Header
|
<div class="header__container">
|
||||||
|
<h1 class="header__headline">
|
||||||
|
PAXTON
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="main">
|
<main class="main">
|
||||||
<div class="container">
|
<UContainer class="container">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</UContainer>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
@@ -17,25 +21,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@use '@/assets/scss/colors.scss' as colors;
|
|
||||||
@use '@/assets/scss/main.scss' as main;
|
|
||||||
@use '@/assets/scss/utils.scss' as utils;
|
|
||||||
|
|
||||||
.layout {
|
.layout {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: colors.$dark-grey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 1000px;
|
--ui-container: 100%;
|
||||||
margin: 48px auto 100px;
|
max-width: 100%;
|
||||||
|
|
||||||
@media (max-width: 1280px) {
|
margin: 0;
|
||||||
margin: 24px auto 52px;
|
padding: 0;
|
||||||
padding: 0 24px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@@ -45,11 +42,27 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
height: 54px;
|
||||||
|
background: white;
|
||||||
|
|
||||||
|
&__container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__headline {
|
||||||
|
height: 100%;
|
||||||
|
font-size: 32px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin-top: 64px;
|
margin-top: 54px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
|
|||||||
@@ -2,5 +2,15 @@
|
|||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: '2025-05-15',
|
compatibilityDate: '2025-05-15',
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
modules: ['@nuxt/ui', '@nuxt/image', '@nuxt/icon', '@nuxt/fonts'],
|
modules: ['@nuxt/ui', '@nuxt/image', '@nuxt/icon', '@nuxt/fonts', '@nuxtjs/i18n'],
|
||||||
|
css: ['~/assets/css/main.css', '~/assets/scss/main.scss'],
|
||||||
|
i18n: {
|
||||||
|
locales: [
|
||||||
|
{ code: 'en', name: 'English', file: 'en.json' },
|
||||||
|
{ code: 'ru', name: 'Русский', file: 'ru.json' },
|
||||||
|
],
|
||||||
|
defaultLocale: 'ru',
|
||||||
|
strategy: 'prefix_except_default',
|
||||||
|
detectBrowserLanguage: false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"@nuxt/icon": "1.15.0",
|
"@nuxt/icon": "1.15.0",
|
||||||
"@nuxt/image": "1.10.0",
|
"@nuxt/image": "1.10.0",
|
||||||
"@nuxt/ui": "3.2.0",
|
"@nuxt/ui": "3.2.0",
|
||||||
|
"@nuxtjs/i18n": "^10.0.4",
|
||||||
"@tanstack/vue-query": "^5.75.5",
|
"@tanstack/vue-query": "^5.75.5",
|
||||||
"@vueuse/core": "^13.1.0",
|
"@vueuse/core": "^13.1.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="card">
|
||||||
<pre>
|
<ProductImages />
|
||||||
{{ productsData?.images?.filter(img => img?.src?.includes(colorVariants.blackCottonPolyester)) }}
|
<ProductDescription />
|
||||||
</pre>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useGetProductsDetail } from '~/api/queries'
|
|
||||||
|
|
||||||
const { data: productsData } = useGetProductsDetail(79)
|
|
||||||
|
|
||||||
const colorVariants = {
|
|
||||||
beigeCottonPolyester: 'beige_cotton-polyester_',
|
|
||||||
blackCotton: 'black_cotton_',
|
|
||||||
greyCottonPolyester: 'grey_cotton-polyester_',
|
|
||||||
blackCottonPolyester: 'black_cotton-polyester_',
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.card {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
boroda
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
16
tailwind.config.ts
Normal file
16
tailwind.config.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// tailwind.config.ts
|
||||||
|
import type { Config } from 'tailwindcss'
|
||||||
|
|
||||||
|
const config: Config = {
|
||||||
|
content: [], // Nuxt сам заполняет content автоматически
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
fontFamily: {
|
||||||
|
sans: ['Inter', 'sans-serif'], // если используешь @nuxt/fonts или свою кастомную типографику
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
||||||
Reference in New Issue
Block a user