cartStore.ts — astro Source File
Architecture documentation for cartStore.ts, a typescript file in the astro codebase. 1 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR edd8f249_c500_21a1_e709_e13be23ae578["cartStore.ts"] 0cd22d54_77c8_593a_5643_86634e82d948["nanostores"] edd8f249_c500_21a1_e709_e13be23ae578 --> 0cd22d54_77c8_593a_5643_86634e82d948 9bd09477_d318_1e25_4e51_a3d91bcf1ef7["AddToCartForm.tsx"] 9bd09477_d318_1e25_4e51_a3d91bcf1ef7 --> edd8f249_c500_21a1_e709_e13be23ae578 82a2ad24_ec13_dffb_971f_f9297a68f94a["CartFlyout.tsx"] 82a2ad24_ec13_dffb_971f_f9297a68f94a --> edd8f249_c500_21a1_e709_e13be23ae578 2506c8d8_e1f6_b420_5388_f20e9293ff57["CartFlyoutToggle.tsx"] 2506c8d8_e1f6_b420_5388_f20e9293ff57 --> edd8f249_c500_21a1_e709_e13be23ae578 style edd8f249_c500_21a1_e709_e13be23ae578 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { atom, map } from 'nanostores';
export const isCartOpen = atom(false);
export type CartItem = {
id: string;
name: string;
imageSrc: string;
quantity: number;
};
export type CartItemDisplayInfo = Pick<CartItem, 'id' | 'name' | 'imageSrc'>;
export const cartItems = map<Record<string, CartItem>>({});
export function addCartItem({ id, name, imageSrc }: CartItemDisplayInfo) {
const existingEntry = cartItems.get()[id];
if (existingEntry) {
cartItems.setKey(id, {
...existingEntry,
quantity: existingEntry.quantity + 1,
});
} else {
cartItems.setKey(id, {
id,
name,
imageSrc,
quantity: 1,
});
}
}
Domain
Subdomains
Functions
Dependencies
- nanostores
Imported By
Source
Frequently Asked Questions
What does cartStore.ts do?
cartStore.ts is a source file in the astro codebase, written in typescript. It belongs to the StateStores domain, NanostoresImplementation subdomain.
What functions are defined in cartStore.ts?
cartStore.ts defines 1 function(s): addCartItem.
What does cartStore.ts depend on?
cartStore.ts imports 1 module(s): nanostores.
What files import cartStore.ts?
cartStore.ts is imported by 3 file(s): AddToCartForm.tsx, CartFlyout.tsx, CartFlyoutToggle.tsx.
Where is cartStore.ts in the architecture?
cartStore.ts is located at examples/with-nanostores/src/cartStore.ts (domain: StateStores, subdomain: NanostoresImplementation, directory: examples/with-nanostores/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free