heroshot 0.0.2-alpha.1 → 0.0.2-alpha.2

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.
package/src/types.ts DELETED
@@ -1,24 +0,0 @@
1
- export interface BeautifyOptions {
2
- shadow?: boolean;
3
- radius?: number;
4
- background?: string;
5
- padding?: number;
6
- }
7
-
8
- export interface ScreenshotDefinition {
9
- id: string;
10
- url?: string;
11
- file?: string;
12
- lines?: [number, number];
13
- selector?: string;
14
- output: string;
15
- viewport?: { width: number; height: number };
16
- waitFor?: string;
17
- delay?: number;
18
- beautify?: BeautifyOptions;
19
- theme?: string;
20
- }
21
-
22
- export interface HeroshotConfig {
23
- screenshots: ScreenshotDefinition[];
24
- }
@@ -1,44 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import type { HeroshotConfig, ScreenshotDefinition } from '../src/types.js';
3
-
4
- describe('types', () => {
5
- it('should allow valid screenshot definition', () => {
6
- const definition: ScreenshotDefinition = {
7
- id: 'test',
8
- url: 'http://localhost:3000',
9
- output: 'test.png',
10
- selector: '.main',
11
- };
12
-
13
- expect(definition.id).toBe('test');
14
- expect(definition.url).toBe('http://localhost:3000');
15
- });
16
-
17
- it('should allow config with multiple screenshots', () => {
18
- const config: HeroshotConfig = {
19
- screenshots: [
20
- { id: 'one', url: 'http://localhost:3000', output: 'one.png' },
21
- { id: 'two', file: 'src/index.ts', lines: [1, 10], output: 'two.png' },
22
- ],
23
- };
24
-
25
- expect(config.screenshots).toHaveLength(2);
26
- });
27
-
28
- it('should allow beautify options', () => {
29
- const definition: ScreenshotDefinition = {
30
- id: 'styled',
31
- url: 'http://localhost:3000',
32
- output: 'styled.png',
33
- beautify: {
34
- shadow: true,
35
- radius: 12,
36
- background: '#1a1a2e',
37
- padding: 16,
38
- },
39
- };
40
-
41
- expect(definition.beautify?.shadow).toBe(true);
42
- expect(definition.beautify?.radius).toBe(12);
43
- });
44
- });
@@ -1,230 +0,0 @@
1
- <script lang="ts">
2
- import type { ScreenshotItem } from '../types';
3
-
4
- interface Props {
5
- screenshots: ScreenshotItem[];
6
- onSelect: (screenshot: ScreenshotItem) => void;
7
- onRemove: (id: string) => void;
8
- onClose: () => void;
9
- }
10
-
11
- let { screenshots, onSelect, onRemove, onClose }: Props = $props();
12
-
13
- /**
14
- * Stop all keyboard events from reaching the page underneath.
15
- */
16
- function stopKeyboardEvent(event: KeyboardEvent): void {
17
- event.stopPropagation();
18
- if (event.key === 'Escape') {
19
- onClose();
20
- }
21
- }
22
- </script>
23
-
24
- <div
25
- class="backdrop"
26
- onclick={onClose}
27
- onkeydown={stopKeyboardEvent}
28
- onkeyup={(event) => event.stopPropagation()}
29
- onkeypress={(event) => event.stopPropagation()}
30
- role="presentation"
31
- >
32
- <div
33
- class="dialog"
34
- onclick={(event) => event.stopPropagation()}
35
- onkeydown={stopKeyboardEvent}
36
- onkeyup={(event) => event.stopPropagation()}
37
- onkeypress={(event) => event.stopPropagation()}
38
- role="dialog"
39
- aria-modal="true"
40
- aria-labelledby="dialog-title"
41
- tabindex="0"
42
- >
43
- <div class="header">
44
- <h3 id="dialog-title">Screenshots ({screenshots.length})</h3>
45
- <button class="close-btn" onclick={onClose} title="Close">
46
- <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
47
- <line x1="18" y1="6" x2="6" y2="18"/>
48
- <line x1="6" y1="6" x2="18" y2="18"/>
49
- </svg>
50
- </button>
51
- </div>
52
-
53
- <div class="content">
54
- {#if screenshots.length === 0}
55
- <p class="empty">No screenshots added yet. Click the crosshair to pick an element.</p>
56
- {:else}
57
- <ul class="list">
58
- {#each screenshots as screenshot (screenshot.id)}
59
- <li class="list-item">
60
- <button
61
- class="item-info"
62
- onclick={() => onSelect(screenshot)}
63
- title="Navigate to this element"
64
- >
65
- <span class="item-name">{screenshot.name}</span>
66
- <span class="item-selector">{screenshot.selector}</span>
67
- </button>
68
- <button
69
- class="remove-btn"
70
- onclick={() => onRemove(screenshot.id)}
71
- title="Remove screenshot"
72
- >
73
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
74
- <polyline points="3 6 5 6 21 6"/>
75
- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
76
- </svg>
77
- </button>
78
- </li>
79
- {/each}
80
- </ul>
81
- {/if}
82
- </div>
83
- </div>
84
- </div>
85
-
86
- <style>
87
- .backdrop {
88
- position: fixed;
89
- inset: 0;
90
- background: rgba(0, 0, 0, 0.6);
91
- display: flex;
92
- align-items: center;
93
- justify-content: center;
94
- z-index: 2147483647;
95
- }
96
-
97
- .dialog {
98
- background: #1a1a2e;
99
- border-radius: 12px;
100
- min-width: 500px;
101
- max-width: 90vw;
102
- max-height: 80vh;
103
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
104
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
105
- color: #fff;
106
- display: flex;
107
- flex-direction: column;
108
- }
109
-
110
- .header {
111
- display: flex;
112
- align-items: center;
113
- justify-content: space-between;
114
- padding: 20px 24px;
115
- border-bottom: 1px solid #2d2d44;
116
- }
117
-
118
- h3 {
119
- margin: 0;
120
- font-size: 18px;
121
- font-weight: 600;
122
- }
123
-
124
- .close-btn {
125
- width: 32px;
126
- height: 32px;
127
- border: none;
128
- border-radius: 6px;
129
- background: transparent;
130
- color: #aaa;
131
- cursor: pointer;
132
- display: flex;
133
- align-items: center;
134
- justify-content: center;
135
- transition: all 0.2s;
136
- }
137
-
138
- .close-btn:hover {
139
- background: #2d2d44;
140
- color: #fff;
141
- }
142
-
143
- .content {
144
- padding: 16px 24px 24px;
145
- overflow-y: auto;
146
- flex: 1;
147
- }
148
-
149
- .empty {
150
- color: #666;
151
- text-align: center;
152
- padding: 32px 0;
153
- margin: 0;
154
- }
155
-
156
- .list {
157
- list-style: none;
158
- margin: 0;
159
- padding: 0;
160
- display: flex;
161
- flex-direction: column;
162
- gap: 8px;
163
- }
164
-
165
- .list-item {
166
- display: flex;
167
- align-items: center;
168
- gap: 12px;
169
- padding: 12px 16px;
170
- background: #2d2d44;
171
- border-radius: 8px;
172
- transition: background 0.2s;
173
- }
174
-
175
- .list-item:hover {
176
- background: #3d3d5c;
177
- }
178
-
179
- .item-info {
180
- flex: 1;
181
- min-width: 0;
182
- display: flex;
183
- flex-direction: column;
184
- align-items: flex-start;
185
- gap: 4px;
186
- background: transparent;
187
- border: none;
188
- padding: 0;
189
- cursor: pointer;
190
- text-align: left;
191
- }
192
-
193
- .item-info:hover .item-name {
194
- color: #3b82f6;
195
- }
196
-
197
- .item-name {
198
- font-weight: 600;
199
- color: #fff;
200
- }
201
-
202
- .item-selector {
203
- font-family: monospace;
204
- font-size: 12px;
205
- color: #888;
206
- overflow: hidden;
207
- text-overflow: ellipsis;
208
- white-space: nowrap;
209
- }
210
-
211
- .remove-btn {
212
- width: 32px;
213
- height: 32px;
214
- border: none;
215
- border-radius: 6px;
216
- background: transparent;
217
- color: #666;
218
- cursor: pointer;
219
- display: flex;
220
- align-items: center;
221
- justify-content: center;
222
- transition: all 0.2s;
223
- flex-shrink: 0;
224
- }
225
-
226
- .remove-btn:hover {
227
- background: #ef4444;
228
- color: #fff;
229
- }
230
- </style>
@@ -1,186 +0,0 @@
1
- <script lang="ts">
2
- interface Props {
3
- selector: string;
4
- onSave: (name: string) => void;
5
- onCancel: () => void;
6
- }
7
-
8
- let { selector, onSave, onCancel }: Props = $props();
9
-
10
- let name = $state('');
11
- let inputElement = $state<HTMLInputElement | null>(null);
12
-
13
- // Focus input on mount
14
- $effect(() => {
15
- if (inputElement) {
16
- inputElement.focus();
17
- }
18
- });
19
-
20
- function handleSubmit(event: Event): void {
21
- event.preventDefault();
22
- const trimmedName = name.trim();
23
- if (trimmedName) {
24
- onSave(trimmedName);
25
- }
26
- }
27
-
28
- /**
29
- * Stop all keyboard events from reaching the page underneath.
30
- * This prevents the host page's keyboard shortcuts from interfering.
31
- */
32
- function stopKeyboardEvent(event: KeyboardEvent): void {
33
- event.stopPropagation();
34
- if (event.key === 'Escape') {
35
- onCancel();
36
- }
37
- }
38
- </script>
39
-
40
- <div
41
- class="backdrop"
42
- onclick={onCancel}
43
- onkeydown={stopKeyboardEvent}
44
- onkeyup={(event) => event.stopPropagation()}
45
- onkeypress={(event) => event.stopPropagation()}
46
- role="presentation"
47
- >
48
- <div
49
- class="modal"
50
- onclick={(event) => event.stopPropagation()}
51
- onkeydown={stopKeyboardEvent}
52
- onkeyup={(event) => event.stopPropagation()}
53
- onkeypress={(event) => event.stopPropagation()}
54
- role="dialog"
55
- aria-modal="true"
56
- aria-labelledby="modal-title"
57
- tabindex="0"
58
- >
59
- <h3 id="modal-title">Name this screenshot</h3>
60
- <p class="selector-preview">{selector}</p>
61
-
62
- <form onsubmit={handleSubmit}>
63
- <input
64
- bind:this={inputElement}
65
- bind:value={name}
66
- type="text"
67
- placeholder="e.g., hero-section, login-button"
68
- class="input"
69
- />
70
-
71
- <div class="actions">
72
- <button type="button" class="btn-secondary" onclick={onCancel}>
73
- Cancel
74
- </button>
75
- <button type="submit" class="btn-primary" disabled={!name.trim()}>
76
- Save
77
- </button>
78
- </div>
79
- </form>
80
- </div>
81
- </div>
82
-
83
- <style>
84
- .backdrop {
85
- position: fixed;
86
- inset: 0;
87
- background: rgba(0, 0, 0, 0.6);
88
- display: flex;
89
- align-items: center;
90
- justify-content: center;
91
- z-index: 2147483647;
92
- }
93
-
94
- .modal {
95
- background: #1a1a2e;
96
- border-radius: 12px;
97
- padding: 24px;
98
- min-width: 400px;
99
- max-width: 90vw;
100
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
101
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
102
- color: #fff;
103
- }
104
-
105
- h3 {
106
- margin: 0 0 12px;
107
- font-size: 18px;
108
- font-weight: 600;
109
- }
110
-
111
- .selector-preview {
112
- margin: 0 0 20px;
113
- padding: 8px 12px;
114
- background: #2d2d44;
115
- border-radius: 6px;
116
- font-family: monospace;
117
- font-size: 12px;
118
- color: #aaa;
119
- overflow: hidden;
120
- text-overflow: ellipsis;
121
- white-space: nowrap;
122
- }
123
-
124
- .input {
125
- width: 100%;
126
- padding: 12px;
127
- border: 2px solid #3d3d5c;
128
- border-radius: 6px;
129
- background: #2d2d44;
130
- color: #fff;
131
- font-size: 14px;
132
- outline: none;
133
- box-sizing: border-box;
134
- transition: border-color 0.2s;
135
- }
136
-
137
- .input:focus {
138
- border-color: #3b82f6;
139
- }
140
-
141
- .input::placeholder {
142
- color: #666;
143
- }
144
-
145
- .actions {
146
- display: flex;
147
- gap: 12px;
148
- justify-content: flex-end;
149
- margin-top: 20px;
150
- }
151
-
152
- .btn-primary,
153
- .btn-secondary {
154
- padding: 10px 20px;
155
- border: none;
156
- border-radius: 6px;
157
- font-size: 14px;
158
- font-weight: 600;
159
- cursor: pointer;
160
- transition: all 0.2s;
161
- }
162
-
163
- .btn-primary {
164
- background: #22c55e;
165
- color: #fff;
166
- }
167
-
168
- .btn-primary:hover:not(:disabled) {
169
- background: #16a34a;
170
- }
171
-
172
- .btn-primary:disabled {
173
- background: #3d3d5c;
174
- color: #666;
175
- cursor: not-allowed;
176
- }
177
-
178
- .btn-secondary {
179
- background: #3d3d5c;
180
- color: #fff;
181
- }
182
-
183
- .btn-secondary:hover {
184
- background: #4d4d6c;
185
- }
186
- </style>