@trishchuk/coolors-mcp 1.0.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 (197) hide show
  1. package/.claude/settings.local.json +39 -0
  2. package/.env +2 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +73 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +71 -0
  5. package/.github/pull_request_template.md +97 -0
  6. package/.github/workflows/ci.yml +127 -0
  7. package/.github/workflows/deploy-docs.yml +56 -0
  8. package/.github/workflows/release.yml +99 -0
  9. package/.mcp.json +12 -0
  10. package/.prettierignore +1 -0
  11. package/CLAUDE.md +201 -0
  12. package/DOCUMENTATION.md +274 -0
  13. package/GEMINI.md +54 -0
  14. package/LICENSE +21 -0
  15. package/README.md +401 -0
  16. package/demo/content_based_color.png +0 -0
  17. package/demo/music-player.html +621 -0
  18. package/demo/podcast-player.html +903 -0
  19. package/dist/bin/coolors-mcp.d.ts +1 -0
  20. package/dist/bin/coolors-mcp.js +154 -0
  21. package/dist/bin/coolors-mcp.js.map +1 -0
  22. package/dist/bin/server.d.ts +1 -0
  23. package/dist/bin/server.js +3292 -0
  24. package/dist/bin/server.js.map +1 -0
  25. package/dist/chunk-IQ7NN26V.js +114 -0
  26. package/dist/chunk-IQ7NN26V.js.map +1 -0
  27. package/dist/chunk-P3ARRKLS.js +1214 -0
  28. package/dist/chunk-P3ARRKLS.js.map +1 -0
  29. package/dist/color/index.d.ts +716 -0
  30. package/dist/color/index.js +153 -0
  31. package/dist/color/index.js.map +1 -0
  32. package/dist/coolors-mcp.d.ts +136 -0
  33. package/dist/coolors-mcp.js +7 -0
  34. package/dist/coolors-mcp.js.map +1 -0
  35. package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js +93 -0
  36. package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js.map +7 -0
  37. package/docs/.vitepress/cache/deps/_metadata.json +127 -0
  38. package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js +9 -0
  39. package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js.map +7 -0
  40. package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js +12683 -0
  41. package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js.map +7 -0
  42. package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js +9719 -0
  43. package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js.map +7 -0
  44. package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js +4710 -0
  45. package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js.map +7 -0
  46. package/docs/.vitepress/cache/deps/cytoscape.js +30278 -0
  47. package/docs/.vitepress/cache/deps/cytoscape.js.map +7 -0
  48. package/docs/.vitepress/cache/deps/dayjs.js +285 -0
  49. package/docs/.vitepress/cache/deps/dayjs.js.map +7 -0
  50. package/docs/.vitepress/cache/deps/debug.js +468 -0
  51. package/docs/.vitepress/cache/deps/debug.js.map +7 -0
  52. package/docs/.vitepress/cache/deps/package.json +3 -0
  53. package/docs/.vitepress/cache/deps/prismjs.js +1466 -0
  54. package/docs/.vitepress/cache/deps/prismjs.js.map +7 -0
  55. package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js +228 -0
  56. package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js.map +7 -0
  57. package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js +142 -0
  58. package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js.map +7 -0
  59. package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js +27 -0
  60. package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js.map +7 -0
  61. package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js +65 -0
  62. package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js.map +7 -0
  63. package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js +53 -0
  64. package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js.map +7 -0
  65. package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js +73 -0
  66. package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js.map +7 -0
  67. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4507 -0
  68. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  69. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +584 -0
  70. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  71. package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1146 -0
  72. package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
  73. package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1667 -0
  74. package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
  75. package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1814 -0
  76. package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
  77. package/docs/.vitepress/cache/deps/vue.js +344 -0
  78. package/docs/.vitepress/cache/deps/vue.js.map +7 -0
  79. package/docs/.vitepress/components/ClientGrid.vue +125 -0
  80. package/docs/.vitepress/components/CodeBlock.vue +231 -0
  81. package/docs/.vitepress/components/ConfigModal.vue +477 -0
  82. package/docs/.vitepress/components/DiagramModal.vue +528 -0
  83. package/docs/.vitepress/components/TroubleshootingModal.vue +472 -0
  84. package/docs/.vitepress/config.js +162 -0
  85. package/docs/.vitepress/theme/FundingLayout.vue +251 -0
  86. package/docs/.vitepress/theme/Layout.vue +134 -0
  87. package/docs/.vitepress/theme/components/AdBanner.vue +317 -0
  88. package/docs/.vitepress/theme/components/AdPlaceholder.vue +78 -0
  89. package/docs/.vitepress/theme/components/FundingEffects.vue +322 -0
  90. package/docs/.vitepress/theme/components/FundingHero.vue +345 -0
  91. package/docs/.vitepress/theme/components/SupportSection.vue +511 -0
  92. package/docs/.vitepress/theme/custom-app.css +339 -0
  93. package/docs/.vitepress/theme/custom.css +699 -0
  94. package/docs/.vitepress/theme/index.js +25 -0
  95. package/docs/README.md +198 -0
  96. package/docs/concepts/accessibility.md +473 -0
  97. package/docs/concepts/color-spaces.md +222 -0
  98. package/docs/concepts/distance-metrics.md +384 -0
  99. package/docs/concepts/hct.md +261 -0
  100. package/docs/concepts/image-analysis.md +396 -0
  101. package/docs/concepts/material-design.md +306 -0
  102. package/docs/concepts/theme-matching.md +399 -0
  103. package/docs/examples/basic-colors.md +490 -0
  104. package/docs/examples/creating-themes.md +898 -0
  105. package/docs/examples/css-refactoring.md +824 -0
  106. package/docs/examples/image-extraction.md +882 -0
  107. package/docs/getting-started.md +366 -0
  108. package/docs/index.md +190 -0
  109. package/docs/installation.md +157 -0
  110. package/docs/tools/README.md +234 -0
  111. package/docs/tools/accessibility.md +614 -0
  112. package/docs/tools/color-operations.md +374 -0
  113. package/docs/tools/image-extraction.md +624 -0
  114. package/docs/tools/material-design.md +347 -0
  115. package/docs/tools/theme-matching.md +552 -0
  116. package/eslint.config.ts +14 -0
  117. package/examples/theme-matching.md +113 -0
  118. package/jsr.json +7 -0
  119. package/mcp-config.json +8 -0
  120. package/note.md +35 -0
  121. package/package.json +122 -0
  122. package/research_results.md +53 -0
  123. package/src/bin/coolors-mcp.ts +194 -0
  124. package/src/bin/server.ts +61 -0
  125. package/src/color/__tests__/conversions-argb.test.ts +198 -0
  126. package/src/color/__tests__/extract-colors.test.ts +360 -0
  127. package/src/color/__tests__/image-utils.test.ts +242 -0
  128. package/src/color/__tests__/reference-colors.test.ts +278 -0
  129. package/src/color/__tests__/round-trip.test.ts +197 -0
  130. package/src/color/conversions.test.ts +402 -0
  131. package/src/color/conversions.ts +393 -0
  132. package/src/color/dislike/__tests__/dislike-analyzer.test.ts +248 -0
  133. package/src/color/dislike/dislike-analyzer.ts +114 -0
  134. package/src/color/extract-colors.ts +228 -0
  135. package/src/color/hct/__tests__/hct-class.test.ts +232 -0
  136. package/src/color/hct/harmonization.ts +204 -0
  137. package/src/color/hct/hct-class.ts +109 -0
  138. package/src/color/hct/hct-solver.ts +168 -0
  139. package/src/color/hct/index.ts +39 -0
  140. package/src/color/hct/tonal-palette.ts +211 -0
  141. package/src/color/hct/types.ts +88 -0
  142. package/src/color/image-utils.ts +79 -0
  143. package/src/color/index.ts +87 -0
  144. package/src/color/material-theme.ts +157 -0
  145. package/src/color/metrics.test.ts +276 -0
  146. package/src/color/metrics.ts +281 -0
  147. package/src/color/quantize/__tests__/quantizer_celebi.test.ts +195 -0
  148. package/src/color/quantize/lab_point_provider.ts +55 -0
  149. package/src/color/quantize/point_provider.ts +27 -0
  150. package/src/color/quantize/quantizer_celebi.ts +51 -0
  151. package/src/color/quantize/quantizer_celebi_test.ts +71 -0
  152. package/src/color/quantize/quantizer_map.ts +47 -0
  153. package/src/color/quantize/quantizer_wsmeans.ts +232 -0
  154. package/src/color/quantize/quantizer_wu.ts +472 -0
  155. package/src/color/score/__tests__/score.test.ts +224 -0
  156. package/src/color/score/score.ts +175 -0
  157. package/src/color/types.ts +151 -0
  158. package/src/color/utils/color_utils.ts +292 -0
  159. package/src/color/utils/math_utils.ts +145 -0
  160. package/src/color/utils.test.ts +403 -0
  161. package/src/color/utils.ts +315 -0
  162. package/src/constants.ts +5 -0
  163. package/src/coolors-mcp.ts +37 -0
  164. package/src/examples/addition.ts +333 -0
  165. package/src/examples/color-demo.ts +125 -0
  166. package/src/examples/custom-logger.ts +201 -0
  167. package/src/examples/oauth-server.ts +113 -0
  168. package/src/examples/session-context.ts +269 -0
  169. package/src/session.ts +116 -0
  170. package/src/theme/__tests__/matcher.test.ts +180 -0
  171. package/src/theme/__tests__/parser.test.ts +148 -0
  172. package/src/theme/__tests__/refactor.test.ts +224 -0
  173. package/src/theme/index.ts +34 -0
  174. package/src/theme/matcher.ts +395 -0
  175. package/src/theme/parser.ts +392 -0
  176. package/src/theme/refactor.ts +360 -0
  177. package/src/theme/types.ts +152 -0
  178. package/src/tools/__tests__/gradient-generator.test.ts +206 -0
  179. package/src/tools/__tests__/palette-with-locks.test.ts +109 -0
  180. package/src/tools/color-conversion.tool.ts +54 -0
  181. package/src/tools/color-distance.tool.ts +41 -0
  182. package/src/tools/colors.ts +31 -0
  183. package/src/tools/contrast-checker.tool.ts +37 -0
  184. package/src/tools/dislike-analyzer.tool.ts +247 -0
  185. package/src/tools/gradient-generator.tool.ts +250 -0
  186. package/src/tools/image-extraction.tools.ts +289 -0
  187. package/src/tools/index.ts +39 -0
  188. package/src/tools/material-theme.tools.ts +250 -0
  189. package/src/tools/palette-generator.tool.ts +135 -0
  190. package/src/tools/palette-with-locks.tool.ts +221 -0
  191. package/src/tools/registry.ts +142 -0
  192. package/src/tools/simple-tools.ts +37 -0
  193. package/src/tools/theme-matching.tools.ts +334 -0
  194. package/src/types.ts +182 -0
  195. package/src/utils.ts +22 -0
  196. package/tsconfig.json +8 -0
  197. package/vitest.config.js +15 -0
@@ -0,0 +1,251 @@
1
+ <template>
2
+ <div class="funding-layout">
3
+ <transition name="fade">
4
+ <button
5
+ v-if="showReturnButton"
6
+ @click="goBack"
7
+ class="return-button"
8
+ title="Return to previous page"
9
+ >
10
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
+ <path d="M19 12H5M5 12L12 19M5 12L12 5"/>
12
+ </svg>
13
+ <span>Return</span>
14
+ </button>
15
+ </transition>
16
+
17
+ <FundingHero />
18
+
19
+ <div
20
+ class="funding-content"
21
+ @mouseenter="handleMouseEnter"
22
+ @mousemove="handleMouseMove"
23
+ @mouseleave="handleMouseLeave"
24
+ ref="contentRef"
25
+ >
26
+ <Content />
27
+ </div>
28
+
29
+ <FundingEffects />
30
+ </div>
31
+ </template>
32
+
33
+ <script setup>
34
+ import { ref, onMounted, onUnmounted } from 'vue'
35
+ import { Content, useRouter } from 'vitepress'
36
+ import FundingHero from './components/FundingHero.vue'
37
+ import FundingEffects from './components/FundingEffects.vue'
38
+
39
+ const contentRef = ref(null)
40
+ const showReturnButton = ref(false)
41
+ const router = useRouter()
42
+
43
+ const goBack = () => {
44
+ if (window.history.length > 1) {
45
+ window.history.back()
46
+ } else {
47
+ router.go('/coolors-mcp/')
48
+ }
49
+ }
50
+
51
+ // Show return button after scroll
52
+ onMounted(() => {
53
+ const handleScroll = () => {
54
+ showReturnButton.value = window.scrollY > 100
55
+ }
56
+
57
+ window.addEventListener('scroll', handleScroll)
58
+
59
+ // Add page transition class
60
+ document.body.classList.add('page-transition-active')
61
+ setTimeout(() => {
62
+ document.body.classList.remove('page-transition-active')
63
+ }, 600)
64
+
65
+ onUnmounted(() => {
66
+ window.removeEventListener('scroll', handleScroll)
67
+ })
68
+ })
69
+
70
+ const handleMouseEnter = (e) => {
71
+ if (!contentRef.value) return
72
+
73
+ const rect = contentRef.value.getBoundingClientRect()
74
+ const x = e.clientX - rect.left
75
+ const y = e.clientY - rect.top
76
+
77
+ contentRef.value.style.setProperty('--content-mouse-x', `${x}px`)
78
+ contentRef.value.style.setProperty('--content-mouse-y', `${y}px`)
79
+ contentRef.value.classList.add('mouse-over')
80
+ }
81
+
82
+ const handleMouseMove = (e) => {
83
+ if (!contentRef.value) return
84
+
85
+ const rect = contentRef.value.getBoundingClientRect()
86
+ const x = e.clientX - rect.left
87
+ const y = e.clientY - rect.top
88
+
89
+ contentRef.value.style.setProperty('--content-mouse-x', `${x}px`)
90
+ contentRef.value.style.setProperty('--content-mouse-y', `${y}px`)
91
+ }
92
+
93
+ const handleMouseLeave = () => {
94
+ if (!contentRef.value) return
95
+ contentRef.value.classList.remove('mouse-over')
96
+ }
97
+ </script>
98
+
99
+ <style scoped>
100
+ .funding-layout {
101
+ min-height: 100vh;
102
+ background: var(--vp-c-bg);
103
+ animation: pageEnter 0.6s ease-out;
104
+ }
105
+
106
+ @keyframes pageEnter {
107
+ from {
108
+ opacity: 0;
109
+ transform: translateY(20px);
110
+ }
111
+ to {
112
+ opacity: 1;
113
+ transform: translateY(0);
114
+ }
115
+ }
116
+
117
+ .return-button {
118
+ position: fixed;
119
+ bottom: 32px;
120
+ right: 32px;
121
+ display: flex;
122
+ align-items: center;
123
+ gap: 8px;
124
+ padding: 10px 18px;
125
+ background: transparent;
126
+ color: var(--vp-c-text-1);
127
+ border: 1px solid var(--vp-c-divider);
128
+ border-radius: 8px;
129
+ font-weight: 500;
130
+ text-decoration: none;
131
+ cursor: pointer;
132
+ transition: all 0.2s ease;
133
+ font-size: 0.9rem;
134
+ z-index: 100;
135
+ }
136
+
137
+ .return-button:hover {
138
+ background: var(--vp-c-bg-mute);
139
+ border-color: var(--vp-c-brand);
140
+ transform: translateY(-2px);
141
+ }
142
+
143
+ .return-button svg {
144
+ transition: transform 0.3s ease;
145
+ }
146
+
147
+ .return-button:hover svg {
148
+ transform: translateX(-2px);
149
+ }
150
+
151
+ .fade-enter-active,
152
+ .fade-leave-active {
153
+ transition: all 0.3s ease;
154
+ }
155
+
156
+ .fade-enter-from,
157
+ .fade-leave-to {
158
+ opacity: 0;
159
+ transform: translateY(10px);
160
+ }
161
+
162
+ .funding-content {
163
+ --content-mouse-x: 50%;
164
+ --content-mouse-y: 50%;
165
+ max-width: 1200px;
166
+ margin: 0 auto;
167
+ padding: 48px 24px 96px;
168
+ position: relative;
169
+ }
170
+
171
+ .funding-content::before {
172
+ content: '';
173
+ position: absolute;
174
+ top: 0;
175
+ left: -100px;
176
+ right: -100px;
177
+ bottom: 0;
178
+ background: radial-gradient(
179
+ 1000px circle at var(--content-mouse-x) var(--content-mouse-y),
180
+ rgba(255, 140, 0, 0.03),
181
+ transparent 65%
182
+ );
183
+ pointer-events: none;
184
+ opacity: 0;
185
+ transition: opacity 0.6s ease;
186
+ }
187
+
188
+ .funding-content.mouse-over::before {
189
+ opacity: 1;
190
+ }
191
+
192
+ /* Light mode adjustments */
193
+ html:not(.dark) .funding-content::before {
194
+ background: radial-gradient(
195
+ 1000px circle at var(--content-mouse-x) var(--content-mouse-y),
196
+ rgba(66, 139, 202, 0.02),
197
+ transparent 65%
198
+ );
199
+ }
200
+
201
+ @media (max-width: 768px) {
202
+ .funding-content {
203
+ padding: 32px 20px 64px;
204
+ }
205
+ }
206
+ </style>
207
+
208
+ <style>
209
+ /* Global styles for funding content */
210
+ .funding-layout h1 {
211
+ display: none; /* Hide the markdown title since we have the hero */
212
+ }
213
+
214
+ .funding-layout h2 {
215
+ font-size: 36px;
216
+ font-weight: 700;
217
+ margin: 64px 0 32px;
218
+ padding: 0 24px;
219
+ text-align: center;
220
+ background: linear-gradient(135deg, var(--vp-c-text-1) 0%, var(--vp-c-brand) 100%);
221
+ -webkit-background-clip: text;
222
+ background-clip: text;
223
+ -webkit-text-fill-color: transparent;
224
+ line-height: 1.3;
225
+ }
226
+
227
+ .funding-layout h3 {
228
+ font-size: 24px;
229
+ font-weight: 600;
230
+ margin: 0 0 16px;
231
+ }
232
+
233
+ .funding-layout p {
234
+ line-height: 1.7;
235
+ color: var(--vp-c-text-2);
236
+ }
237
+
238
+ .funding-layout ul {
239
+ margin: 16px 0;
240
+ padding-left: 24px;
241
+ }
242
+
243
+ .funding-layout li {
244
+ margin: 8px 0;
245
+ color: var(--vp-c-text-2);
246
+ }
247
+
248
+ .funding-layout strong {
249
+ color: var(--vp-c-text-1);
250
+ }
251
+ </style>
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <FundingLayout v-if="frontmatter.layout === 'funding'" />
3
+ <Layout v-else>
4
+ <template #nav-bar-title-after>
5
+ <span v-if="!isHomePage" class="replacement-title">Documentation</span>
6
+ </template>
7
+ <template #nav-bar-content-before>
8
+ <div class="nav-warning">
9
+ 🏷️ <span>1.0.0</span>
10
+ </div>
11
+ </template>
12
+ <template #sidebar-nav-after>
13
+ <!-- Sidebar ad placement - most non-intrusive -->
14
+ <AdBanner
15
+ v-if="!isHomePage"
16
+ type="carbon"
17
+ position="sidebar"
18
+ :dismissible="true"
19
+ :hide-on-paths="['/', '/getting-started']"
20
+ />
21
+ </template>
22
+ <template #doc-footer-before>
23
+ <!-- Footer support section - shown after users find value -->
24
+ <SupportSection v-if="!isHomePage && !isFundingPage" />
25
+ </template>
26
+ </Layout>
27
+ </template>
28
+
29
+ <script setup>
30
+ import { computed } from 'vue'
31
+ import { useRoute, useData } from 'vitepress'
32
+ import DefaultTheme from 'vitepress/theme'
33
+ import AdBanner from './components/AdBanner.vue'
34
+ import SupportSection from './components/SupportSection.vue'
35
+ import FundingHero from './components/FundingHero.vue'
36
+ import FundingEffects from './components/FundingEffects.vue'
37
+ import FundingLayout from './FundingLayout.vue'
38
+
39
+ const { Layout } = DefaultTheme
40
+ const route = useRoute()
41
+ const { frontmatter } = useData()
42
+
43
+ const isHomePage = computed(() => route.path === '/' || route.path === '/coolors-mcp/')
44
+ const isFundingPage = computed(() => route.path.includes('/funding'))
45
+ </script>
46
+
47
+ <style>
48
+ /* Hide original title text when sidebar is present */
49
+ .VPNavBar.has-sidebar .VPNavBarTitle .title > span:not(.replacement-title) {
50
+ display: none;
51
+ }
52
+
53
+ /* Style the replacement title */
54
+ .replacement-title {
55
+ font-size: 16px;
56
+ font-weight: 600;
57
+ color: var(--vp-c-text-1);
58
+ }
59
+
60
+ /* Ensure version badge is visible in light mode */
61
+ .nav-warning {
62
+ color: var(--vp-c-text-2);
63
+ background: var(--vp-c-bg-soft);
64
+ padding: 2px 6px;
65
+ border-radius: 4px;
66
+ font-size: 12px;
67
+ font-weight: 500;
68
+ border: 1px solid var(--vp-c-border);
69
+ }
70
+
71
+ /* Ensure the nav bar title container accommodates our custom title */
72
+ .VPNavBar.has-sidebar .VPNavBarTitle {
73
+ position: relative;
74
+ }
75
+
76
+ /* Restore original title on home page (no sidebar) */
77
+ .VPNavBar:not(.has-sidebar) .VPNavBarTitle .title > span {
78
+ display: inline;
79
+ }
80
+
81
+ .nav-warning {
82
+ display: inline-flex;
83
+ align-items: center;
84
+ margin-right: auto;
85
+ margin-left: 28px;
86
+ padding: 4px 12px;
87
+ background-color: var(--vp-c-yellow-soft);
88
+ color: var(--vp-c-yellow-darker);
89
+ border-radius: 4px;
90
+ font-size: 13px;
91
+ font-weight: 500;
92
+ flex-shrink: 0;
93
+ border: 1px solid var(--vp-c-yellow);
94
+ }
95
+
96
+ /* Ensure proper contrast in both themes */
97
+ :root {
98
+ --vp-c-yellow-soft: #fef3c7;
99
+ --vp-c-yellow: #f59e0b;
100
+ --vp-c-yellow-darker: #92400e;
101
+ }
102
+
103
+ html.dark {
104
+ --vp-c-yellow-soft: rgba(245, 158, 11, 0.15);
105
+ --vp-c-yellow: #fbbf24;
106
+ --vp-c-yellow-darker: #fde047;
107
+ }
108
+
109
+ /* Add extra spacing on home page to prevent overlap */
110
+ .VPNavBar:not(.has-sidebar) .nav-warning {
111
+ margin-left: 32px;
112
+ }
113
+
114
+ /* Consistent spacing when sidebar is present */
115
+ .VPNavBar.has-sidebar .nav-warning {
116
+ margin-left: 28px;
117
+ }
118
+
119
+ .nav-warning span {
120
+ margin-left: 6px;
121
+ }
122
+
123
+ html.dark .nav-warning {
124
+ background-color: rgba(251, 191, 36, 0.1);
125
+ color: #fbbf24;
126
+ }
127
+
128
+ /* Hide on mobile to prevent navbar overflow */
129
+ @media (max-width: 768px) {
130
+ .nav-warning {
131
+ display: none;
132
+ }
133
+ }
134
+ </style>
@@ -0,0 +1,317 @@
1
+ <template>
2
+ <div v-if="shouldShowAd" class="ad-banner" :class="bannerClass">
3
+ <!-- GitHub Sponsors -->
4
+ <div v-if="type === 'github-sponsors'" class="sponsor-banner">
5
+ <div class="sponsor-content">
6
+ <span class="sponsor-icon">💖</span>
7
+ <span class="sponsor-text">Support this project on GitHub Sponsors</span>
8
+ <a :href="githubSponsorsUrl" target="_blank" rel="noopener" class="sponsor-button">
9
+ Sponsor
10
+ </a>
11
+ </div>
12
+ </div>
13
+
14
+ <!-- Carbon Ads -->
15
+ <div v-else-if="type === 'carbon'" class="carbon-ads">
16
+ <div id="carbonads">
17
+ <!-- Carbon will inject content here -->
18
+ </div>
19
+ </div>
20
+
21
+
22
+ <!-- Dismissible close button -->
23
+ <button v-if="dismissible" @click="dismissAd" class="ad-close" aria-label="Close ad">
24
+ ×
25
+ </button>
26
+ </div>
27
+ </template>
28
+
29
+ <script setup>
30
+ import { ref, computed, onMounted } from 'vue'
31
+
32
+ const props = defineProps({
33
+ type: {
34
+ type: String,
35
+ default: 'github-sponsors', // 'github-sponsors', 'carbon'
36
+ validator: (value) => ['github-sponsors', 'carbon'].includes(value)
37
+ },
38
+ position: {
39
+ type: String,
40
+ default: 'top', // 'top', 'bottom', 'sidebar', 'inline'
41
+ validator: (value) => ['top', 'bottom', 'sidebar', 'inline'].includes(value)
42
+ },
43
+ githubSponsorsUrl: {
44
+ type: String,
45
+ default: 'https://github.com/sponsors/jamubc'
46
+ },
47
+ dismissible: {
48
+ type: Boolean,
49
+ default: true
50
+ },
51
+ showOnPaths: {
52
+ type: Array,
53
+ default: () => [] // Empty array means show on all paths
54
+ },
55
+ hideOnPaths: {
56
+ type: Array,
57
+ default: () => ['/'] // Hide on home page by default
58
+ },
59
+ })
60
+
61
+ const isDismissed = ref(false)
62
+ const storageKey = `ad-dismissed-${props.type}-${props.position}`
63
+
64
+ const bannerClass = computed(() => `ad-banner--${props.position}`)
65
+
66
+ const shouldShowAd = computed(() => {
67
+ if (isDismissed.value) return false
68
+
69
+ // Check if we're in browser environment
70
+ if (typeof window === 'undefined') return false
71
+
72
+ const currentPath = window.location.pathname
73
+
74
+ // If showOnPaths is specified, only show on those paths
75
+ if (props.showOnPaths.length > 0) {
76
+ return props.showOnPaths.some(path => currentPath.includes(path))
77
+ }
78
+
79
+ // If hideOnPaths is specified, hide on those paths
80
+ if (props.hideOnPaths.length > 0) {
81
+ return !props.hideOnPaths.some(path => currentPath.includes(path))
82
+ }
83
+
84
+ return true
85
+ })
86
+
87
+ const dismissAd = () => {
88
+ isDismissed.value = true
89
+ if (typeof localStorage !== 'undefined') {
90
+ localStorage.setItem(storageKey, 'true')
91
+ }
92
+ }
93
+
94
+ onMounted(() => {
95
+ // Check if ad was previously dismissed
96
+ if (typeof localStorage !== 'undefined') {
97
+ const dismissed = localStorage.getItem(storageKey)
98
+ if (dismissed === 'true') {
99
+ isDismissed.value = true
100
+ }
101
+ }
102
+
103
+ // Load Carbon Ads script if needed
104
+ if (props.type === 'carbon' && !document.getElementById('carbon-script')) {
105
+ const script = document.createElement('script')
106
+ script.id = 'carbon-script'
107
+ script.async = true
108
+ script.type = 'text/javascript'
109
+ script.src = '//cdn.carbonads.com/carbon.js?serve=YOUR_CARBON_ID&placement=YOUR_PLACEMENT'
110
+ script.setAttribute('id', '_carbonads_js')
111
+ document.head.appendChild(script)
112
+ }
113
+ })
114
+ </script>
115
+
116
+ <style scoped>
117
+ .ad-banner {
118
+ position: relative;
119
+ margin: 16px 0;
120
+ border-radius: 8px;
121
+ background-color: var(--vp-c-bg-soft);
122
+ border: 1px solid var(--vp-c-divider);
123
+ overflow: hidden;
124
+ transition: all 0.3s ease;
125
+ }
126
+
127
+ .ad-banner:hover {
128
+ border-color: var(--vp-c-brand);
129
+ }
130
+
131
+ /* Position variants */
132
+ .ad-banner--top {
133
+ margin: 0 0 24px 0;
134
+ position: sticky;
135
+ top: 0;
136
+ z-index: 100;
137
+ backdrop-filter: blur(12px);
138
+ background-color: rgba(20, 20, 20, 0.95);
139
+ }
140
+
141
+ .ad-banner--bottom {
142
+ margin: 24px 0 0 0;
143
+ position: fixed;
144
+ bottom: 24px;
145
+ right: 24px;
146
+ max-width: 400px;
147
+ z-index: 100;
148
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
149
+ }
150
+
151
+ .ad-banner--sidebar {
152
+ margin: 16px 0;
153
+ max-width: 250px;
154
+ }
155
+
156
+ .ad-banner--inline {
157
+ margin: 24px auto;
158
+ max-width: 600px;
159
+ }
160
+
161
+ /* Sponsor Banner */
162
+ .sponsor-banner {
163
+ padding: 12px 16px;
164
+ display: flex;
165
+ align-items: center;
166
+ justify-content: space-between;
167
+ background: linear-gradient(135deg, rgba(66, 184, 131, 0.1) 0%, rgba(53, 73, 94, 0.1) 100%);
168
+ }
169
+
170
+ .sponsor-content {
171
+ display: flex;
172
+ align-items: center;
173
+ gap: 12px;
174
+ flex: 1;
175
+ }
176
+
177
+ .sponsor-icon {
178
+ font-size: 18px;
179
+ }
180
+
181
+ .sponsor-text {
182
+ font-size: 14px;
183
+ font-weight: 500;
184
+ color: var(--vp-c-text-1);
185
+ }
186
+
187
+ .sponsor-button {
188
+ padding: 6px 12px;
189
+ background-color: var(--vp-c-brand);
190
+ color: white;
191
+ text-decoration: none;
192
+ border-radius: 4px;
193
+ font-size: 13px;
194
+ font-weight: 500;
195
+ transition: all 0.2s ease;
196
+ white-space: nowrap;
197
+ }
198
+
199
+ .sponsor-button:hover {
200
+ background-color: var(--vp-c-brand-dark);
201
+ transform: translateY(-1px);
202
+ }
203
+
204
+ /* Carbon Ads */
205
+ .carbon-ads {
206
+ padding: 16px;
207
+ text-align: center;
208
+ }
209
+
210
+ #carbonads {
211
+ font-family: var(--vp-font-family-base);
212
+ line-height: 1.5;
213
+ max-width: 330px;
214
+ margin: 0 auto;
215
+ }
216
+
217
+ #carbonads span {
218
+ display: block;
219
+ padding: 0;
220
+ margin: 0;
221
+ }
222
+
223
+ #carbonads .carbon-wrap {
224
+ display: flex;
225
+ flex-direction: column;
226
+ align-items: center;
227
+ text-align: center;
228
+ }
229
+
230
+ #carbonads .carbon-img {
231
+ display: block;
232
+ margin: 0 0 8px;
233
+ line-height: 1;
234
+ }
235
+
236
+ #carbonads .carbon-img img {
237
+ border-radius: 4px;
238
+ max-width: 130px;
239
+ }
240
+
241
+ #carbonads .carbon-text {
242
+ display: block;
243
+ padding: 0;
244
+ color: var(--vp-c-text-1);
245
+ text-decoration: none;
246
+ font-size: 13px;
247
+ line-height: 1.4;
248
+ }
249
+
250
+ #carbonads .carbon-text:hover {
251
+ color: var(--vp-c-brand);
252
+ }
253
+
254
+ #carbonads .carbon-poweredby {
255
+ display: block;
256
+ margin-top: 8px;
257
+ color: var(--vp-c-text-3);
258
+ font-size: 11px;
259
+ text-decoration: none;
260
+ text-transform: uppercase;
261
+ letter-spacing: 0.5px;
262
+ }
263
+
264
+ /* Close button */
265
+ .ad-close {
266
+ position: absolute;
267
+ top: 8px;
268
+ right: 8px;
269
+ background: rgba(0, 0, 0, 0.5);
270
+ color: white;
271
+ border: none;
272
+ border-radius: 50%;
273
+ width: 24px;
274
+ height: 24px;
275
+ cursor: pointer;
276
+ font-size: 14px;
277
+ display: flex;
278
+ align-items: center;
279
+ justify-content: center;
280
+ opacity: 0.7;
281
+ transition: opacity 0.2s ease;
282
+ }
283
+
284
+ .ad-close:hover {
285
+ opacity: 1;
286
+ }
287
+
288
+ /* Mobile responsive */
289
+ @media (max-width: 768px) {
290
+ .ad-banner--bottom {
291
+ position: relative;
292
+ bottom: auto;
293
+ right: auto;
294
+ max-width: none;
295
+ margin: 16px;
296
+ }
297
+
298
+ .sponsor-content {
299
+ flex-direction: column;
300
+ gap: 8px;
301
+ text-align: center;
302
+ }
303
+
304
+ .sponsor-text {
305
+ font-size: 13px;
306
+ }
307
+ }
308
+
309
+ /* Dark theme specific adjustments */
310
+ html.dark .ad-banner--top {
311
+ background-color: rgba(10, 10, 10, 0.95);
312
+ }
313
+
314
+ html.dark .sponsor-banner {
315
+ background: linear-gradient(135deg, rgba(66, 184, 131, 0.15) 0%, rgba(53, 73, 94, 0.15) 100%);
316
+ }
317
+ </style>