Skip to content

Commit

Permalink
Rename "shelf" into a more generic "object". (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-mathieu authored Jan 23, 2024
1 parent 82693a4 commit cd4dd7f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/lib/3dmap/scene.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script>
import { Gizmo, Text, HTML } from '@threlte/extras';
import { Text, HTML } from '@threlte/extras';
import { T } from '@threlte/core';
import CameraControls from './cameracontrols.svelte';
import { itemData, shelfData, currentItem } from '$lib/appstore.js';
import { itemData, objectsData, currentItem } from '$lib/appstore.js';
// App logic
import ProductCard from '$lib/productcard.svelte';
let shelves = $shelfData;
let objects = $objectsData;
let cameraControls;
function resetCameraPosition() {
Expand All @@ -22,7 +22,7 @@
resetCameraPosition();
return;
}
let shelf = shelves[item.shelf];
let shelf = objects[item.shelf];
if (!shelf) return;
let rot = shelf.rot || [0, 0, 0];
Expand All @@ -48,8 +48,8 @@
<T.AmbientLight intensity={10} />

<!-- App shelf logic -->
{#each Object.keys(shelves) as shelfKey (shelfKey)}
{@const shelf = shelves[shelfKey]}
{#each Object.keys(objects) as shelfKey (shelfKey)}
{@const shelf = objects[shelfKey]}
<T.Mesh position={shelf.pos} rotation={shelf.rot ? shelf.rot : [0, 0, 0]} castShadow>
{#if currentItemData && currentItemData.shelf == shelfKey}
<HTML zIndexRange={[0, 100]} position.y={2.5} scale={0.5} transform>
Expand Down
3 changes: 1 addition & 2 deletions src/lib/appstore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { writable } from 'svelte/store';

// Data stores
export const itemData = writable(null); // JSON of all the items (products + services)
export const shelfData = writable(null); // JSON of all the shelves
export const objectsData = writable(null); // JSON of all the objects
export const categoryData = writable(null); // JSON of all the shelves

// App window states
Expand Down
6 changes: 3 additions & 3 deletions src/lib/productcard.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { itemData, shelfData, productInfoModal } from '$lib/appstore.js';
import { itemData, objectsData, productInfoModal } from '$lib/appstore.js';
export let id;
export let selected = false;
export let enableInfoBtn = false;
Expand All @@ -19,9 +19,9 @@
<h2 class="font text-md title font-bold">{itemInfo.name}</h2>
<h3 class="-mt-1 text-sm font-light italic">{itemInfo.category}</h3>
<div class="flex flex-row">
{#if itemInfo.shelf != null && itemInfo.shelf in $shelfData}
{#if itemInfo.shelf != null && itemInfo.shelf in $objectsData}
<div class="h-4 w-4 rounded-full bg-success"></div>
<div class="-mt-[0.125rem] ml-1 text-sm">{$shelfData[itemInfo.shelf].name}</div>
<div class="-mt-[0.125rem] ml-1 text-sm">{$objectsData[itemInfo.shelf].name}</div>
{:else}
<div class="h-4 w-4 rounded-full bg-warning font-light"></div>
<div class="-mt-[0.125rem] ml-1 text-sm">Click & Collect</div>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/app/+page.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import itemsJson from './items.json';
import shelvesJson from './shelves.json';
import objectsJson from './objects.json';
import categoriesJson from './categories.json';
import { itemData, shelfData, categoryData } from '$lib/appstore.js';
import { itemData, objectsData, categoryData } from '$lib/appstore.js';

export function load({ url }) {
// Load data
itemData.set(itemsJson);
shelfData.set(shelvesJson);
objectsData.set(objectsJson);
categoryData.set(categoriesJson);
}
12 changes: 6 additions & 6 deletions src/routes/app/items.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"0": {
"categories": ["service"],
"shelf": 4,
"object": 4,
"name": "Complete Makeup",
"category": "45 minutes",
"price": 45,
Expand All @@ -10,23 +10,23 @@
},
"1": {
"categories": ["service"],
"shelf": 4,
"object": 4,
"name": "Glamour Makeup",
"category": "60 minutes",
"price": 60,
"picURL": "https://www.sephora.fr/dw/image/v2/BCVW_PRD/on/demandware.static/-/Library-Sites-SephoraV2/fr_FR/dw4a53c51b/60%20min%20540x370px_MU1.jpg"
},
"2": {
"categories": ["service", "trend"],
"shelf": 4,
"object": 4,
"name": "Skin Diagnosis",
"category": "10 minutes",
"price": 0,
"picURL": "https://www.sephora.fr/dw/image/v2/BCVW_PRD/on/demandware.static/-/Library-Sites-SephoraV2/default/dw85e371d5/LP/instore-experience-generique-master-studio/7.png"
},
"71388": {
"categories": ["product", "promo", "trend"],
"shelf": 0,
"object": 0,
"name": "J'adore",
"category": "Eau de Parfum",
"brand": "Dior",
Expand All @@ -37,7 +37,7 @@
},
"421404": {
"categories": ["product"],
"shelf": 2,
"object": 2,
"name": "Sauvage",
"category": "Parfum Homme",
"brand": "Dior",
Expand All @@ -47,7 +47,7 @@
},
"701980": {
"categories": ["product", "promo", "trend"],
"shelf": null,
"object": null,
"name": "Good Girl",
"category": "Coffret Eau de parfum",
"brand": "CAROLINA HERRERA",
Expand Down
File renamed without changes.

0 comments on commit cd4dd7f

Please sign in to comment.