This document describes the file structure and design patterns used in the project.
The project uses an MVC (Model-View-Controller) architecture adapted for Vanilla JavaScript with ES Modules:
- Model (
js/model/): Defines the application state (shadow properties) and business logic (CSS and Dart code generation). - View (
js/view/): Manipulates the DOM, updates the visual interface and captures user events. Delegates specific tasks to smaller components. - Controller (
js/main.js): The entry point. Instantiates the Model and View, and orchestrates communication between them.
Semantic page structure. Loads js/main.js as a module (type="module").
CSS has been modularized for easier maintenance and scalability.
styles.css: Main file that imports all modules.variables.css: Defines global variables (Colors, Fonts, Spacing) for the Design System.modules/:base.css: Reset and global styles (body, fonts).layout.css: Main grid, header and responsive structure.glassmorphism.css: Glass effects (frosted glass), background and animated blobs.controls.css: General styles for controls (sliders, containers).inputs.css: Specific input styling (range, color, text).buttons.css: Buttons (reset, copy).tabs.css: Tab system (CSS vs Dart).animations.css: Keyframes for background animations.
main.js: Initializes the application, listens for View events (viabindEvents) and updates Model and View in response.
model/ShadowModel.js:state: Stores horizontal, vertical, blur, spread, color, opacity, inset, borderRadius, padding.getCSS(): Returns thebox-shadowstring.getDart(): Returns FlutterBoxShadowcode (includinginsetandBorderRadiussupport).
view/ShadowView.js:- Selects DOM elements.
updatePreview(): Applies styles to the preview box.updateInputs(): Syncs inputs with current state.bindEvents(): Associates listeners to inputs and buttons.- Delegates functions to
TabManagerandNotificationManager.
TabManager.js: Manages tab switching logic (CSS/Dart) and content visibility.NotificationManager.js: Manages copy button visual feedback.LayerManager.js: Manages shadow layer list rendering.BackgroundManager.js: Manages background gradient controls.GradientManager.js: Manages gradient stop controls.ControlFactory.js: Factory for creating UI controls.
- User interacts with an input (e.g., blur slider).
ShadowViewcaptures the event and notifiesShadowController.ShadowControllercallsShadowModel.update()to change state.ShadowControllerrequests new state and generated strings from Model.ShadowControllercallsShadowView.updatePreview()andupdateInputs()to reflect changes on screen.