create-react-starter-kit 1.0.2 → 1.0.4
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/dist/generator/dependencies.d.ts.map +1 -1
- package/dist/generator/dependencies.js +20 -2
- package/dist/generator/dependencies.js.map +1 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +10 -2
- package/dist/generator/index.js.map +1 -1
- package/dist/templates/README.md.ejs +23 -29
- package/dist/templates/__when_e2eTesting_playwright__/playwright.config.ts.ejs +17 -1
- package/dist/templates/__when_e2eTesting_playwright__/tests/e2e/counter.spec.ts.ejs +25 -0
- package/dist/templates/__when_e2eTesting_playwright__/tests/e2e/feedback.spec.ts.ejs +20 -0
- package/dist/templates/__when_e2eTesting_playwright__/tests/e2e/home.spec.ts.ejs +30 -3
- package/dist/templates/__when_e2eTesting_playwright__/tests/e2e/posts.spec.ts.ejs +17 -0
- package/dist/templates/__when_formatting_prettier__/.prettierignore +28 -0
- package/dist/templates/__when_linting_biome__/biome.json +12 -0
- package/dist/templates/__when_unitTesting_jest__/tests/App.test.tsx.ejs +10 -1
- package/dist/templates/__when_unitTesting_rtl__/tests/App.test.tsx.ejs +10 -1
- package/dist/templates/__when_unitTesting_vitest__/tests/counter.test.tsx.ejs +36 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/feedback.test.tsx.ejs +49 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/pages.test.tsx.ejs +26 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/posts.test.tsx.ejs +58 -0
- package/dist/templates/__when_unitTesting_vitest__/tests/test-utils.tsx.ejs +50 -0
- package/dist/templates/__when_visualTesting_storybook__/.storybook/main.js.ejs +32 -1
- package/dist/templates/__when_visualTesting_storybook__/.storybook/preview.tsx.ejs +42 -0
- package/dist/templates/__when_visualTesting_storybook__/src/components/StackBadge.stories.tsx.ejs +35 -0
- package/dist/templates/__when_visualTesting_storybook__/src/components/ui/UiButton.stories.tsx.ejs +24 -1
- package/dist/templates/__when_visualTesting_storybook__/src/features/counter/CounterPanel.stories.tsx.ejs +25 -0
- package/dist/templates/__when_visualTesting_storybook__/src/features/feedback/FeedbackForm.stories.tsx.ejs +25 -0
- package/dist/templates/__when_visualTesting_storybook__/src/features/posts/PostsPanel.stories.tsx.ejs +25 -0
- package/dist/templates/__when_visualTesting_storybook__/src/routes/Pages.stories.tsx.ejs +42 -0
- package/dist/templates/docs/architecture.md.ejs +32 -34
- package/dist/templates/docs/getting-started.md.ejs +1 -1
- package/{templates/src/app → dist/templates/src}/App.tsx.ejs +34 -1
- package/dist/templates/src/components/layout/AppLayout.tsx.ejs +35 -12
- package/dist/templates/src/features/counter/CounterPanel.tsx.ejs +12 -6
- package/dist/templates/src/features/feedback/FeedbackForm.tsx.ejs +26 -7
- package/dist/templates/src/main.tsx.ejs +2 -2
- package/{templates/src/app → dist/templates/src}/providers.tsx.ejs +1 -2
- package/dist/templates/src/routes/AboutPage.tsx.ejs +11 -10
- package/dist/templates/src/routes/CounterPage.tsx.ejs +17 -0
- package/dist/templates/src/routes/FeedbackPage.tsx.ejs +21 -0
- package/dist/templates/src/routes/HomePage.tsx.ejs +43 -21
- package/dist/templates/src/routes/PostsPage.tsx.ejs +17 -0
- package/dist/templates/src/styles/global.css.ejs +14 -33
- package/package.json +1 -1
- package/templates/README.md.ejs +23 -29
- package/templates/__when_e2eTesting_playwright__/playwright.config.ts.ejs +17 -1
- package/templates/__when_e2eTesting_playwright__/tests/e2e/counter.spec.ts.ejs +25 -0
- package/templates/__when_e2eTesting_playwright__/tests/e2e/feedback.spec.ts.ejs +20 -0
- package/templates/__when_e2eTesting_playwright__/tests/e2e/home.spec.ts.ejs +30 -3
- package/templates/__when_e2eTesting_playwright__/tests/e2e/posts.spec.ts.ejs +17 -0
- package/templates/__when_formatting_prettier__/.prettierignore +28 -0
- package/templates/__when_linting_biome__/biome.json +12 -0
- package/templates/__when_unitTesting_jest__/tests/App.test.tsx.ejs +10 -1
- package/templates/__when_unitTesting_rtl__/tests/App.test.tsx.ejs +10 -1
- package/templates/__when_unitTesting_vitest__/tests/counter.test.tsx.ejs +36 -0
- package/templates/__when_unitTesting_vitest__/tests/feedback.test.tsx.ejs +49 -0
- package/templates/__when_unitTesting_vitest__/tests/pages.test.tsx.ejs +26 -0
- package/templates/__when_unitTesting_vitest__/tests/posts.test.tsx.ejs +58 -0
- package/templates/__when_unitTesting_vitest__/tests/test-utils.tsx.ejs +50 -0
- package/templates/__when_visualTesting_storybook__/.storybook/main.js.ejs +32 -1
- package/templates/__when_visualTesting_storybook__/.storybook/preview.tsx.ejs +42 -0
- package/templates/__when_visualTesting_storybook__/src/components/StackBadge.stories.tsx.ejs +35 -0
- package/templates/__when_visualTesting_storybook__/src/components/ui/UiButton.stories.tsx.ejs +24 -1
- package/templates/__when_visualTesting_storybook__/src/features/counter/CounterPanel.stories.tsx.ejs +25 -0
- package/templates/__when_visualTesting_storybook__/src/features/feedback/FeedbackForm.stories.tsx.ejs +25 -0
- package/templates/__when_visualTesting_storybook__/src/features/posts/PostsPanel.stories.tsx.ejs +25 -0
- package/templates/__when_visualTesting_storybook__/src/routes/Pages.stories.tsx.ejs +42 -0
- package/templates/docs/architecture.md.ejs +32 -34
- package/templates/docs/getting-started.md.ejs +1 -1
- package/{dist/templates/src/app → templates/src}/App.tsx.ejs +34 -1
- package/templates/src/components/layout/AppLayout.tsx.ejs +35 -12
- package/templates/src/features/counter/CounterPanel.tsx.ejs +12 -6
- package/templates/src/features/feedback/FeedbackForm.tsx.ejs +26 -7
- package/templates/src/main.tsx.ejs +2 -2
- package/{dist/templates/src/app → templates/src}/providers.tsx.ejs +1 -2
- package/templates/src/routes/AboutPage.tsx.ejs +11 -10
- package/templates/src/routes/CounterPage.tsx.ejs +17 -0
- package/templates/src/routes/FeedbackPage.tsx.ejs +21 -0
- package/templates/src/routes/HomePage.tsx.ejs +43 -21
- package/templates/src/routes/PostsPage.tsx.ejs +17 -0
- package/templates/src/styles/global.css.ejs +14 -33
- package/dist/templates/__when_unitTesting_vitest__/tests/App.test.tsx.ejs +0 -16
- package/dist/templates/__when_visualTesting_storybook__/.storybook/preview.js +0 -8
- package/dist/templates/src/components/ui/Toast.tsx.ejs +0 -61
- package/templates/__when_unitTesting_vitest__/tests/App.test.tsx.ejs +0 -16
- package/templates/__when_visualTesting_storybook__/.storybook/preview.js +0 -8
- package/templates/src/components/ui/Toast.tsx.ejs +0 -61
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
<% if (isTypeScript) { -%>
|
|
8
|
-
type ReactNode,
|
|
9
|
-
<% } -%>
|
|
10
|
-
} from 'react';
|
|
11
|
-
|
|
12
|
-
<% if (isTypeScript) { -%>
|
|
13
|
-
type ToastTone = 'info' | 'success' | 'error';
|
|
14
|
-
|
|
15
|
-
interface ToastItem {
|
|
16
|
-
id: string;
|
|
17
|
-
message: string;
|
|
18
|
-
tone: ToastTone;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ToastContextValue {
|
|
22
|
-
push: (message: string, tone?: ToastTone) => void;
|
|
23
|
-
}
|
|
24
|
-
<% } -%>
|
|
25
|
-
|
|
26
|
-
const ToastContext = createContext<% if (isTypeScript) { %><ToastContextValue | null><% } %>(null);
|
|
27
|
-
|
|
28
|
-
export function ToastProvider({ children }<% if (isTypeScript) { %>: { children: ReactNode }<% } %>) {
|
|
29
|
-
const [items, setItems] = useState<% if (isTypeScript) { %><ToastItem[]><% } %>([]);
|
|
30
|
-
|
|
31
|
-
const push = useCallback((message<% if (isTypeScript) { %>: string<% } %>, tone<% if (isTypeScript) { %>: ToastTone<% } %> = 'info') => {
|
|
32
|
-
const id = crypto.randomUUID();
|
|
33
|
-
setItems((prev) => [...prev, { id, message, tone }]);
|
|
34
|
-
window.setTimeout(() => {
|
|
35
|
-
setItems((prev) => prev.filter((item) => item.id !== id));
|
|
36
|
-
}, 3200);
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
const value = useMemo(() => ({ push }), [push]);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<ToastContext.Provider value={value}>
|
|
43
|
-
{children}
|
|
44
|
-
<div className="toast-viewport" aria-live="polite">
|
|
45
|
-
{items.map((item) => (
|
|
46
|
-
<div key={item.id} className={`toast toast-${item.tone}`}>
|
|
47
|
-
{item.message}
|
|
48
|
-
</div>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
</ToastContext.Provider>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function useToast() {
|
|
56
|
-
const ctx = useContext(ToastContext);
|
|
57
|
-
if (!ctx) {
|
|
58
|
-
throw new Error('useToast must be used within ToastProvider');
|
|
59
|
-
}
|
|
60
|
-
return ctx;
|
|
61
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { AppProviders } from '@/app/providers';
|
|
4
|
-
import { HomePage } from '@/routes/HomePage';
|
|
5
|
-
|
|
6
|
-
describe('HomePage', () => {
|
|
7
|
-
it('renders the project hero', () => {
|
|
8
|
-
render(
|
|
9
|
-
<AppProviders>
|
|
10
|
-
<HomePage />
|
|
11
|
-
</AppProviders>,
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(screen.getByRole('heading', { name: /<%= projectName %>/i })).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
<% if (isTypeScript) { -%>
|
|
8
|
-
type ReactNode,
|
|
9
|
-
<% } -%>
|
|
10
|
-
} from 'react';
|
|
11
|
-
|
|
12
|
-
<% if (isTypeScript) { -%>
|
|
13
|
-
type ToastTone = 'info' | 'success' | 'error';
|
|
14
|
-
|
|
15
|
-
interface ToastItem {
|
|
16
|
-
id: string;
|
|
17
|
-
message: string;
|
|
18
|
-
tone: ToastTone;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ToastContextValue {
|
|
22
|
-
push: (message: string, tone?: ToastTone) => void;
|
|
23
|
-
}
|
|
24
|
-
<% } -%>
|
|
25
|
-
|
|
26
|
-
const ToastContext = createContext<% if (isTypeScript) { %><ToastContextValue | null><% } %>(null);
|
|
27
|
-
|
|
28
|
-
export function ToastProvider({ children }<% if (isTypeScript) { %>: { children: ReactNode }<% } %>) {
|
|
29
|
-
const [items, setItems] = useState<% if (isTypeScript) { %><ToastItem[]><% } %>([]);
|
|
30
|
-
|
|
31
|
-
const push = useCallback((message<% if (isTypeScript) { %>: string<% } %>, tone<% if (isTypeScript) { %>: ToastTone<% } %> = 'info') => {
|
|
32
|
-
const id = crypto.randomUUID();
|
|
33
|
-
setItems((prev) => [...prev, { id, message, tone }]);
|
|
34
|
-
window.setTimeout(() => {
|
|
35
|
-
setItems((prev) => prev.filter((item) => item.id !== id));
|
|
36
|
-
}, 3200);
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
const value = useMemo(() => ({ push }), [push]);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<ToastContext.Provider value={value}>
|
|
43
|
-
{children}
|
|
44
|
-
<div className="toast-viewport" aria-live="polite">
|
|
45
|
-
{items.map((item) => (
|
|
46
|
-
<div key={item.id} className={`toast toast-${item.tone}`}>
|
|
47
|
-
{item.message}
|
|
48
|
-
</div>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
</ToastContext.Provider>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function useToast() {
|
|
56
|
-
const ctx = useContext(ToastContext);
|
|
57
|
-
if (!ctx) {
|
|
58
|
-
throw new Error('useToast must be used within ToastProvider');
|
|
59
|
-
}
|
|
60
|
-
return ctx;
|
|
61
|
-
}
|