@spree/docs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +54 -0
  2. package/dist/api-reference/platform/authentication.md +38 -0
  3. package/dist/api-reference/store-api/authentication.md +188 -0
  4. package/dist/api-reference/store-api/errors.md +277 -0
  5. package/dist/api-reference/store-api/idempotency.md +129 -0
  6. package/dist/api-reference/store-api/introduction.md +34 -0
  7. package/dist/api-reference/store-api/localization.md +279 -0
  8. package/dist/api-reference/store-api/metadata.md +160 -0
  9. package/dist/api-reference/store-api/monetary-amounts.md +65 -0
  10. package/dist/api-reference/store-api/querying.md +399 -0
  11. package/dist/api-reference/store-api/rate-limitting.md +103 -0
  12. package/dist/api-reference/store-api/relations.md +185 -0
  13. package/dist/api-reference/storefront/authentication.md +88 -0
  14. package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
  15. package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
  16. package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
  17. package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
  18. package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
  19. package/dist/api-reference/v2/introduction.md +22 -0
  20. package/dist/api-reference/v2/pagination.md +37 -0
  21. package/dist/api-reference/webhooks-events.md +883 -0
  22. package/dist/developer/admin/admin.md +205 -0
  23. package/dist/developer/admin/authentication.md +59 -0
  24. package/dist/developer/admin/components.md +711 -0
  25. package/dist/developer/admin/custom-css.md +243 -0
  26. package/dist/developer/admin/custom-javascript.md +116 -0
  27. package/dist/developer/admin/extending-ui.md +1964 -0
  28. package/dist/developer/admin/form-builder.md +444 -0
  29. package/dist/developer/admin/helper-methods.md +531 -0
  30. package/dist/developer/admin/navigation.md +805 -0
  31. package/dist/developer/admin/tables.md +491 -0
  32. package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
  33. package/dist/developer/cli/quickstart.md +137 -0
  34. package/dist/developer/contributing/creating-an-extension.md +258 -0
  35. package/dist/developer/contributing/developing-spree.md +339 -0
  36. package/dist/developer/contributing/quickstart.md +32 -0
  37. package/dist/developer/contributing/updating-extensions.md +67 -0
  38. package/dist/developer/core-concepts/addresses.md +265 -0
  39. package/dist/developer/core-concepts/adjustments.md +107 -0
  40. package/dist/developer/core-concepts/architecture.md +177 -0
  41. package/dist/developer/core-concepts/calculators.md +323 -0
  42. package/dist/developer/core-concepts/customers.md +230 -0
  43. package/dist/developer/core-concepts/events.md +624 -0
  44. package/dist/developer/core-concepts/imports-exports.md +698 -0
  45. package/dist/developer/core-concepts/inventory.md +191 -0
  46. package/dist/developer/core-concepts/markets.md +250 -0
  47. package/dist/developer/core-concepts/media.md +167 -0
  48. package/dist/developer/core-concepts/metafields.md +187 -0
  49. package/dist/developer/core-concepts/orders.md +328 -0
  50. package/dist/developer/core-concepts/payments.md +710 -0
  51. package/dist/developer/core-concepts/pricing.md +163 -0
  52. package/dist/developer/core-concepts/products.md +360 -0
  53. package/dist/developer/core-concepts/promotions.md +322 -0
  54. package/dist/developer/core-concepts/reports.md +206 -0
  55. package/dist/developer/core-concepts/search-filtering.md +237 -0
  56. package/dist/developer/core-concepts/shipments.md +212 -0
  57. package/dist/developer/core-concepts/slugs.md +111 -0
  58. package/dist/developer/core-concepts/staff-roles.md +123 -0
  59. package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
  60. package/dist/developer/core-concepts/stores.md +117 -0
  61. package/dist/developer/core-concepts/taxes.md +135 -0
  62. package/dist/developer/core-concepts/translations.md +120 -0
  63. package/dist/developer/core-concepts/users.md +299 -0
  64. package/dist/developer/core-concepts/webhooks.md +378 -0
  65. package/dist/developer/create-spree-app/quickstart.md +158 -0
  66. package/dist/developer/customization/api.md +93 -0
  67. package/dist/developer/customization/authentication.md +88 -0
  68. package/dist/developer/customization/checkout.md +204 -0
  69. package/dist/developer/customization/configuration.md +55 -0
  70. package/dist/developer/customization/decorators.md +523 -0
  71. package/dist/developer/customization/dependencies.md +232 -0
  72. package/dist/developer/customization/emails.md +21 -0
  73. package/dist/developer/customization/extensions.md +92 -0
  74. package/dist/developer/customization/metadata.md +236 -0
  75. package/dist/developer/customization/model-preferences.md +130 -0
  76. package/dist/developer/customization/permissions.md +265 -0
  77. package/dist/developer/customization/quickstart.md +229 -0
  78. package/dist/developer/customization/routes.md +24 -0
  79. package/dist/developer/customization/v4/admin-panel.md +78 -0
  80. package/dist/developer/customization/v4/authentication.md +210 -0
  81. package/dist/developer/customization/v4/checkout.md +212 -0
  82. package/dist/developer/customization/v4/deface.md +251 -0
  83. package/dist/developer/customization/v4/images.md +86 -0
  84. package/dist/developer/customization/v4/storefront.md +450 -0
  85. package/dist/developer/deployment/assets.md +87 -0
  86. package/dist/developer/deployment/aws.md +335 -0
  87. package/dist/developer/deployment/caching.md +27 -0
  88. package/dist/developer/deployment/cdn.md +39 -0
  89. package/dist/developer/deployment/database.md +155 -0
  90. package/dist/developer/deployment/docker.md +128 -0
  91. package/dist/developer/deployment/emails.md +77 -0
  92. package/dist/developer/deployment/environment_variables.md +111 -0
  93. package/dist/developer/deployment/heroku.md +51 -0
  94. package/dist/developer/deployment/render.md +95 -0
  95. package/dist/developer/getting-started/quickstart.md +82 -0
  96. package/dist/developer/how-to/custom-payment-method.md +374 -0
  97. package/dist/developer/how-to/custom-promotion.md +373 -0
  98. package/dist/developer/how-to/custom-report.md +387 -0
  99. package/dist/developer/how-to/custom-search-provider.md +230 -0
  100. package/dist/developer/multi-store/quickstart.md +71 -0
  101. package/dist/developer/multi-store/setup.md +38 -0
  102. package/dist/developer/multi-tenant/configuration.md +41 -0
  103. package/dist/developer/multi-tenant/core-concepts.md +75 -0
  104. package/dist/developer/multi-tenant/installation.md +96 -0
  105. package/dist/developer/multi-tenant/quickstart.md +20 -0
  106. package/dist/developer/multi-vendor/installation.md +45 -0
  107. package/dist/developer/multi-vendor/quickstart.md +17 -0
  108. package/dist/developer/sdk/admin/quickstart.md +22 -0
  109. package/dist/developer/sdk/authentication.md +89 -0
  110. package/dist/developer/sdk/configuration.md +225 -0
  111. package/dist/developer/sdk/quickstart.md +82 -0
  112. package/dist/developer/sdk/store/account.md +67 -0
  113. package/dist/developer/sdk/store/cart-checkout.md +140 -0
  114. package/dist/developer/sdk/store/markets.md +151 -0
  115. package/dist/developer/sdk/store/payments.md +96 -0
  116. package/dist/developer/sdk/store/products.md +149 -0
  117. package/dist/developer/sdk/store/wishlists.md +52 -0
  118. package/dist/developer/security/pci_compliance.md +15 -0
  119. package/dist/developer/security/security_policy.md +68 -0
  120. package/dist/developer/storefront/blocks.md +285 -0
  121. package/dist/developer/storefront/custom-css.md +260 -0
  122. package/dist/developer/storefront/custom-javascript.md +166 -0
  123. package/dist/developer/storefront/helper-methods.md +1288 -0
  124. package/dist/developer/storefront/links.md +298 -0
  125. package/dist/developer/storefront/nextjs/architecture.md +150 -0
  126. package/dist/developer/storefront/nextjs/customization.md +141 -0
  127. package/dist/developer/storefront/nextjs/deployment.md +180 -0
  128. package/dist/developer/storefront/nextjs/quickstart.md +92 -0
  129. package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
  130. package/dist/developer/storefront/pages.md +163 -0
  131. package/dist/developer/storefront/sections.md +569 -0
  132. package/dist/developer/storefront/storefront.md +56 -0
  133. package/dist/developer/storefront/themes.md +161 -0
  134. package/dist/developer/tutorial/admin.md +134 -0
  135. package/dist/developer/tutorial/extending-models.md +380 -0
  136. package/dist/developer/tutorial/file-uploads.md +121 -0
  137. package/dist/developer/tutorial/introduction.md +33 -0
  138. package/dist/developer/tutorial/model.md +41 -0
  139. package/dist/developer/tutorial/page-builder.md +487 -0
  140. package/dist/developer/tutorial/rich-text.md +73 -0
  141. package/dist/developer/tutorial/seo.md +332 -0
  142. package/dist/developer/tutorial/storefront.md +352 -0
  143. package/dist/developer/tutorial/testing.md +558 -0
  144. package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
  145. package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
  146. package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
  147. package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
  148. package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
  149. package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
  150. package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
  151. package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
  152. package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
  153. package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
  154. package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
  155. package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
  156. package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
  157. package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
  158. package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
  159. package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
  160. package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
  161. package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
  162. package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
  163. package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
  164. package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
  165. package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
  166. package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
  167. package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
  168. package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
  169. package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
  170. package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
  171. package/dist/developer/upgrades/quickstart.md +36 -0
  172. package/dist/integrations/analytics/google-analytics.md +64 -0
  173. package/dist/integrations/analytics/google-tag-manager.md +78 -0
  174. package/dist/integrations/integrations.md +39 -0
  175. package/dist/integrations/marketing/klaviyo.md +99 -0
  176. package/dist/integrations/payments/adyen.md +90 -0
  177. package/dist/integrations/payments/paypal.md +41 -0
  178. package/dist/integrations/payments/razorpay.md +45 -0
  179. package/dist/integrations/payments/stripe.md +109 -0
  180. package/dist/integrations/search/meilisearch.md +236 -0
  181. package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
  182. package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
  183. package/package.json +27 -0
@@ -0,0 +1,243 @@
1
+ ---
2
+ title: Admin Dashboard Custom CSS
3
+ sidebarTitle: Custom CSS
4
+ ---
5
+
6
+ Spree Admin Dashboard uses [Tailwind CSS v4](https://tailwindcss.com/) for styling. The stylesheet system is designed to be easily customizable while maintaining consistency with the Spree design system.
7
+
8
+ ## How It Works
9
+
10
+ When you install Spree Admin, the installer creates a file at `app/assets/tailwind/spree_admin.css` in your application. This file:
11
+
12
+ 1. Imports the base Spree Admin styles from the gem
13
+ 2. Scans your custom admin views, helpers, and JavaScript for Tailwind classes
14
+ 3. Allows you to add custom styles and override theme variables
15
+
16
+ ## Using Tailwind Utility Classes
17
+
18
+ You can use any Tailwind CSS utility class in your custom admin views, helpers, or JavaScript files. The build process automatically scans these locations:
19
+
20
+ - `app/views/spree/admin/**/*.erb`
21
+ - `app/helpers/spree/admin/**/*.rb`
22
+ - `app/javascript/spree/admin/**/*.js`
23
+
24
+ Example usage in a view:
25
+
26
+ ```erb
27
+ <div class="bg-zinc-100 p-4 rounded-lg shadow-sm">
28
+ <h2 class="text-lg font-bold text-zinc-900">Custom Section</h2>
29
+ <p class="text-sm text-zinc-600 mt-2">Your content here</p>
30
+ </div>
31
+ ```
32
+
33
+ ## Customizing the Theme
34
+
35
+ ### Overriding Theme Colors
36
+
37
+ To override Tailwind theme values, add a `@theme` block in your `app/assets/tailwind/spree_admin.css` file after the import:
38
+
39
+ ```css app/assets/tailwind/spree_admin.css
40
+ /* Import Spree Admin base styles from the gem */
41
+ @import "$SPREE_ADMIN_PATH/app/assets/tailwind/spree/admin/index.css";
42
+
43
+ /* Override theme colors */
44
+ @theme {
45
+ --color-primary: #4F46E5; /* Change primary color to indigo */
46
+ --color-success: #059669; /* Custom success color */
47
+ --color-danger: #DC2626; /* Custom danger color */
48
+ }
49
+ ```
50
+
51
+ ### Available Theme Variables
52
+
53
+ The Spree Admin theme defines these customizable variables:
54
+
55
+ | Variable | Default | Description |
56
+ |----------|---------|-------------|
57
+ | `--color-primary` | `var(--color-zinc-950)` | Primary brand color |
58
+ | `--color-success` | `var(--color-green-900)` | Success state color |
59
+ | `--color-danger` | `var(--color-red-600)` | Error/danger state color |
60
+ | `--color-warning` | `var(--color-yellow-900)` | Warning state color |
61
+ | `--color-info` | `var(--color-blue-900)` | Info state color |
62
+
63
+ ### Overriding Layout Variables
64
+
65
+ You can also customize layout-related CSS variables:
66
+
67
+ ```css app/assets/tailwind/spree_admin.css
68
+ :root {
69
+ --spacing-sidebar-width: 280px; /* Default: 220px */
70
+ --spacing-sidebar-collapsed: 70px; /* Default: 59px */
71
+ --spacing-header-height: 64px; /* Default: 58px */
72
+ }
73
+ ```
74
+
75
+ ## Adding Custom Components
76
+
77
+ Use Tailwind's `@layer` directive to add custom component styles that work seamlessly with the existing design:
78
+
79
+ ```css app/assets/tailwind/spree_admin.css
80
+ @layer components {
81
+ /* Custom card style */
82
+ .my-custom-card {
83
+ @apply bg-white rounded-lg shadow-sm border border-zinc-200 p-4;
84
+ }
85
+
86
+ /* Custom button variant */
87
+ .btn-custom {
88
+ @apply inline-flex items-center px-4 py-2 rounded-md;
89
+ @apply bg-indigo-600 text-white font-medium;
90
+ @apply hover:bg-indigo-700 transition-colors;
91
+ }
92
+
93
+ /* Custom status badge */
94
+ .status-badge {
95
+ @apply inline-flex items-center px-2 py-1 rounded-full text-xs font-medium;
96
+ }
97
+
98
+ .status-badge-active {
99
+ @apply status-badge bg-green-100 text-green-800;
100
+ }
101
+
102
+ .status-badge-inactive {
103
+ @apply status-badge bg-zinc-100 text-zinc-600;
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Adding Custom Utilities
109
+
110
+ For reusable utility classes, use the utilities layer:
111
+
112
+ ```css app/assets/tailwind/spree_admin.css
113
+ @layer utilities {
114
+ .text-gradient {
115
+ @apply bg-clip-text text-transparent bg-gradient-to-r from-indigo-500 to-purple-500;
116
+ }
117
+
118
+ .scrollbar-hidden {
119
+ -ms-overflow-style: none;
120
+ scrollbar-width: none;
121
+ }
122
+
123
+ .scrollbar-hidden::-webkit-scrollbar {
124
+ display: none;
125
+ }
126
+ }
127
+ ```
128
+
129
+ ## Scanning Additional Paths
130
+
131
+ If you have admin-related code in non-standard locations, add additional `@source` directives:
132
+
133
+ ```css app/assets/tailwind/spree_admin.css
134
+ /* Scan host app's custom admin code for Tailwind classes */
135
+ @source "../../views/spree/admin/**/*.erb";
136
+ @source "../../helpers/spree/admin/**/*.rb";
137
+ @source "../../javascript/spree/admin/**/*.js";
138
+
139
+ /* Add your custom paths */
140
+ @source "../../components/admin/**/*.erb";
141
+ @source "../../views/admin/**/*.erb";
142
+ ```
143
+
144
+ ## Development Workflow
145
+
146
+ ### Starting the CSS Watcher
147
+
148
+ During development, run the Tailwind CSS watcher to automatically rebuild styles when you make changes:
149
+
150
+ ```bash
151
+ bin/rails spree:admin:tailwindcss:watch
152
+ ```
153
+
154
+ Or if you're using `Procfile.dev` with foreman:
155
+
156
+ ```bash
157
+ bin/dev
158
+ ```
159
+
160
+ The watcher monitors:
161
+ - Your host app's CSS files in `app/assets/tailwind/`
162
+ - The Spree Admin engine's CSS files
163
+ - All files matching your `@source` patterns
164
+
165
+ ### Building for Production
166
+
167
+ CSS is automatically compiled during asset precompilation:
168
+
169
+ ```bash
170
+ bin/rails assets:precompile
171
+ ```
172
+
173
+ ## Common Customization Examples
174
+
175
+ ### Custom Primary Color Scheme
176
+
177
+ ```css app/assets/tailwind/spree_admin.css
178
+ @theme {
179
+ /* Use blue as the primary color */
180
+ --color-primary: #2563EB;
181
+ }
182
+
183
+ @layer components {
184
+ /* Ensure buttons use the new primary color */
185
+ .btn-primary {
186
+ @apply bg-blue-600 hover:bg-blue-700;
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### Dark Mode Adjustments
192
+
193
+ ```css app/assets/tailwind/spree_admin.css
194
+ @layer base {
195
+ /* Custom dark mode overrides */
196
+ .dark {
197
+ --color-primary: #60A5FA;
198
+ }
199
+ }
200
+ ```
201
+
202
+ ### Custom Form Styling
203
+
204
+ ```css app/assets/tailwind/spree_admin.css
205
+ @layer components {
206
+ /* Custom input style */
207
+ .input-custom {
208
+ @apply block w-full rounded-md border-zinc-300 shadow-sm;
209
+ @apply focus:border-indigo-500 focus:ring-indigo-500;
210
+ }
211
+
212
+ /* Custom select style */
213
+ .select-custom {
214
+ @apply block w-full rounded-md border-zinc-300 py-2 pl-3 pr-10;
215
+ @apply focus:border-indigo-500 focus:outline-none focus:ring-indigo-500;
216
+ }
217
+ }
218
+ ```
219
+
220
+ ## Troubleshooting
221
+
222
+ ### Changes Not Appearing
223
+
224
+ 1. Ensure the watcher is running: `bin/rails spree:admin:tailwindcss:watch`
225
+ 2. Check that your files are in paths covered by `@source` directives
226
+ 3. Hard refresh the browser (Cmd+Shift+R or Ctrl+Shift+R)
227
+
228
+ ### Missing Utility Classes
229
+
230
+ If a Tailwind class isn't working, ensure:
231
+ 1. The class is used in a file that's scanned by `@source`
232
+ 2. The class name is complete (not dynamically constructed)
233
+ 3. Run a fresh build: `bin/rails spree:admin:tailwindcss:build`
234
+
235
+ ### Listen Gem Required
236
+
237
+ The watch task requires the `listen` gem. Add it to your Gemfile:
238
+
239
+ ```ruby Gemfile
240
+ group :development do
241
+ gem 'listen', '>= 3.0'
242
+ end
243
+ ```
@@ -0,0 +1,116 @@
1
+ ---
2
+ title: Custom JavaScript for Admin Dashboard
3
+ sidebarTitle: Custom JavaScript
4
+ description: Learn how to add custom JavaScript to your Spree Admin Dashboard
5
+ ---
6
+
7
+ ## Extending Admin Dashboard with JavaScript
8
+
9
+ Spree Admin Dashboard can be easily extended with custom JavaScript. Most of the JavaScript in the Admin Dashboard is powered by a framework called [Stimulus.js](https://stimulus.hotwired.dev/) which is the Ruby on Rails default. It's a very simple and minimalistic framework only enhancing our server-side rendered HTML with a bit of interactivity.
10
+
11
+ ### 3rd party JavaScript libraries
12
+
13
+ Spree Admin Dashboard comes with a few 3rd party JavaScript libraries already included.
14
+
15
+ Main libraries we're using:
16
+
17
+ * [Stimulus.js](https://stimulus.hotwired.dev/)
18
+ * [Turbo](https://turbo.hotwired.dev/)
19
+ * [EasyPick](https://easepick.com/) (date picker)
20
+ * [TomSelect](https://tom-select.js.org/) (autocomplete/dropdowns)
21
+ * [Sortable.js](https://github.com/SortableJS/Sortable) - sortable drag and drop lists
22
+ * [Uppy](https://uppy.io/) - file uploader
23
+
24
+ You can find them in the [app/assets/javascripts/vendor](https://github.com/spree/spree/blob/main/admin/vendor/javascript) directory.
25
+
26
+ ### Managing JavaScript dependencies
27
+
28
+ You're probably wondering why these libraries are in the `vendor` directory, and not in `node_modules`.
29
+
30
+ That's because we're not using Node.js at all. So no Yarn or npm. We're using a different approach to manage dependencies.
31
+
32
+ We're using a tool called [Importmaps](https://github.com/rails/importmap-rails) to manage dependencies which is the Ruby on Rails default.
33
+
34
+ > **INFO:** If you want to use a different JavaScript package manager you can do so by using [jsbundling-rails](https://github.com/rails/jsbundling-rails) gem.
35
+
36
+ #### Install dependencies
37
+
38
+ To install dependencies you need to run the following command:
39
+
40
+ ```bash
41
+ bin/importmap pin react
42
+ ```
43
+
44
+ This will install the dependencies, download the files to your `vendor/javascript` directory and add them to your `config/importmap.rb` file, eg.
45
+
46
+ ```ruby
47
+ pin "react" # @19.1.0
48
+ ```
49
+
50
+ Now you can just import the library in your application entry point, eg. `application.js`:
51
+
52
+ ```js
53
+ import "react";
54
+ ```
55
+
56
+ ### Application entry point
57
+
58
+ Mentioned above, the application entry point is the `application.js` file. It's located in the `app/javascript` directory.
59
+
60
+ If you want to add custom JavaScript to your Spree Admin Dashboard, you can do so by adding a new file to the `app/javascript` directory.
61
+
62
+ ### Stimulus Controllers
63
+
64
+ Stimulus controllers are a way to add interactivity to your Spree Admin Dashboard. Admin Dashboard controllers can be found in the Spree repository in the [Admin Dashboard/app/javascript/spree/admin/controllers](https://github.com/spree/spree/tree/main/admin/app/javascript/spree/admin/controllers) directory.
65
+
66
+ You can find more information about Stimulus controllers in the [Stimulus.js documentation](https://stimulus.hotwired.dev/handbook/controllers).
67
+
68
+ To add a new controller you need to create a new file in the `app/javascript/controllers` directory. It will be automatically picked up by the application.
69
+
70
+ ```js
71
+ // app/javascript/controllers/hello_controller.js
72
+ import { Controller } from '@hotwired/stimulus'
73
+
74
+ export default class extends Controller {
75
+ connect() {
76
+ console.log("Hello Spree Commerce Stimulus!", this.element);
77
+ }
78
+ }
79
+ ```
80
+
81
+ To use the controller in your HTML you need to add the `data-controller` attribute to your element, eg.
82
+
83
+ ```html
84
+ <div data-controller="hello">
85
+ Hello Spree Commerce Stimulus!
86
+ </div>
87
+ ```
88
+
89
+ ## JavaScript snippets
90
+
91
+ If you need to add a small piece of JavaScript code (eg. tracking, marketing, analytics, customer service etc.) you can do this by:
92
+
93
+ 1. Declaring a new head partial in the `config/initializers/spree.rb` file, eg.
94
+
95
+ **Spree 5.2+:**
96
+
97
+ ```ruby config/initializers/spree.rb
98
+ Rails.application.config.after_initialize do
99
+ Spree.admin.partials.head << 'spree/admin/shared/my_tracking_code'
100
+ end
101
+ ```
102
+
103
+ **Spree 5.1 and below:**
104
+
105
+ ```ruby config/initializers/spree.rb
106
+ Rails.application.config.spree_admin.head_partials << 'spree/admin/shared/my_tracking_code'
107
+ ```
108
+
109
+
110
+ 2. Creating a new file in the `app/views/spree/admin/shared/my_tracking_code.html.erb`, where you can add your tracking code, eg.
111
+
112
+ ```erb
113
+ <script>
114
+ console.log("I'm a spy!");
115
+ </script>
116
+ ```